private Form readFormData(Message message) { try { return FormUtils.readForm(provider, message); } catch (Exception ex) { throw ExceptionUtils.toNotAuthorizedException(null, null); } }
private Form readFormData(Message message) { try { return FormUtils.readForm(provider, message); } catch (Exception ex) { throw ExceptionUtils.toNotAuthorizedException(null, null); } }
protected Element readToken(Message message, String assertion) { if (assertion == null) { throw ExceptionUtils.toNotAuthorizedException(null, null); } try { byte[] deflatedToken = Base64UrlUtility.decode(assertion); InputStream is = new ByteArrayInputStream(deflatedToken); return readToken(message, is); } catch (Base64Exception ex) { throw ExceptionUtils.toNotAuthorizedException(null, null); } }
private void validateSAMLVersion(SamlAssertionWrapper assertionW) { if (assertionW.getSaml2() == null) { throw ExceptionUtils.toNotAuthorizedException(null, null); } }
protected void checkRegistrationAccessToken(Client c, String accessToken) { String regAccessToken = c.getProperties().get(ClientRegistrationResponse.REG_ACCESS_TOKEN); if (regAccessToken == null || !regAccessToken.equals(accessToken)) { throw ExceptionUtils.toNotAuthorizedException(null, null); } }
protected void reportInvalidClient(OAuthError error) { ResponseBuilder rb = JAXRSUtils.toResponseBuilder(401); throw ExceptionUtils.toNotAuthorizedException(null, rb.type(MediaType.APPLICATION_JSON_TYPE).entity(error).build()); }
private void checkSecurityContext() { SecurityContext sc = mc.getSecurityContext(); if (!sc.isSecure() && blockUnsecureRequests) { LOG.warning("Unsecure HTTP, Transport Layer Security is recommended"); ExceptionUtils.toNotAuthorizedException(null, null); } if (sc.getUserPrincipal() == null && blockUnauthorizedRequests) { LOG.warning("Authenticated Principal is not available"); ExceptionUtils.toNotAuthorizedException(null, null); } }
protected void throwFault(String error, Exception ex) { // TODO: get bundle resource message once this filter is moved // to rt/rs/security String errorMsg = error; if (ex != null) { errorMsg += ": " + ExceptionUtils.getStackTrace(ex); } LOG.warning(errorMsg); Response response = JAXRSUtils.toResponseBuilder(401).entity(error).build(); throw ExceptionUtils.toNotAuthorizedException(null, response); }
private void checkSecurityContext() { SecurityContext sc = mc.getSecurityContext(); if (!sc.isSecure() && blockUnsecureRequests) { LOG.warning("Unsecure HTTP, Transport Layer Security is recommended"); ExceptionUtils.toNotAuthorizedException(null, null); } if (sc.getUserPrincipal() == null && blockUnauthorizedRequests) { LOG.warning("Authenticated Principal is not available"); ExceptionUtils.toNotAuthorizedException(null, null); } }
protected void checkInitialAuthentication() { if (initialAccessToken != null) { String accessToken = getRequestAccessToken(); if (!initialAccessToken.equals(accessToken)) { throw ExceptionUtils.toNotAuthorizedException(null, null); } } else { checkSecurityContext(); } }
@Override protected void checkSecurityContextStart(ContainerRequestContext rc) { SecurityContext sc = rc.getSecurityContext(); if (!(sc instanceof OidcSecurityContext) && sc.getUserPrincipal() != null) { throw ExceptionUtils.toNotAuthorizedException(null, null); } }
protected void checkSecurityContextStart(ContainerRequestContext rc) { SecurityContext sc = rc.getSecurityContext(); if (sc == null || sc.getUserPrincipal() == null) { throw ExceptionUtils.toNotAuthorizedException(null, null); } }
private byte[] getServiceTicket(String encodedServiceTicket) { try { return Base64Utility.decode(encodedServiceTicket); } catch (Base64Exception ex) { throw ExceptionUtils.toNotAuthorizedException(null, getFaultResponse()); } }
protected SecurityContext getAndValidateSecurityContext(MultivaluedMap<String, String> params) { SecurityContext securityContext = (SecurityContext)getMessageContext().get(SecurityContext.class.getName()); if (securityContext == null || securityContext.getUserPrincipal() == null) { throw ExceptionUtils.toNotAuthorizedException(null, null); } checkTransportSecurity(); return securityContext; } protected UserSubject createUserSubject(SecurityContext securityContext,
protected SecurityContext getAndValidateSecurityContext(MultivaluedMap<String, String> params) { SecurityContext securityContext = (SecurityContext)getMessageContext().get(SecurityContext.class.getName()); if (securityContext == null || securityContext.getUserPrincipal() == null) { throw ExceptionUtils.toNotAuthorizedException(null, null); } checkTransportSecurity(); return securityContext; }
protected SecurityContext getAndValidateSecurityContext(MultivaluedMap<String, String> params) { SecurityContext securityContext = (SecurityContext)getMessageContext().get(SecurityContext.class.getName()); if (securityContext == null || securityContext.getUserPrincipal() == null) { throw ExceptionUtils.toNotAuthorizedException(null, null); } checkTransportSecurity(); return securityContext; } protected UserSubject createUserSubject(SecurityContext securityContext,
protected Client readClient(String clientId) { String accessToken = getRequestAccessToken(); Client c = clientProvider.getClient(clientId); if (c == null) { throw ExceptionUtils.toNotAuthorizedException(null, null); } checkRegistrationAccessToken(c, accessToken); return c; }
protected SecurityContext getAndValidateSecurityContext(MultivaluedMap<String, String> params) { SecurityContext securityContext = (SecurityContext)getMessageContext().get(SecurityContext.class.getName()); if (securityContext == null || securityContext.getUserPrincipal() == null) { throw ExceptionUtils.toNotAuthorizedException(null, null); } checkTransportSecurity(); return securityContext; }
/** * @param mc the {@link MessageContext} * @return the {@link OAuthContext} of the given {@link MessageContext} * @throws WebApplicationException with Status 401 if not authenticated */ public static OAuthContext getContext(final MessageContext mc) { final OAuthContext oauth = mc.getContent(OAuthContext.class); if ((oauth == null) || (oauth.getSubject() == null) || (oauth.getSubject().getLogin() == null)) { throw ExceptionUtils.toNotAuthorizedException(null, null); } return oauth; }
protected void checkSecurityContext() { SecurityContext sc = mc.getSecurityContext(); if (sc.getUserPrincipal() == null) { throw ExceptionUtils.toNotAuthorizedException(null, null); } if (userRole != null && !sc.isUserInRole(userRole)) { throw ExceptionUtils.toForbiddenException(null, null); } }