public Authentication authenticate(Authentication authentication) throws AuthenticationException { throw new AuthenticationServiceException("Cannot authenticate " + authentication); } }
public Authentication authenticate(Authentication authentication) throws AuthenticationException { throw new AuthenticationServiceException("Cannot authenticate " + authentication); } }
@Override public ServerConfiguration getServerConfiguration(String issuer) { try { if (!whitelist.isEmpty() && !whitelist.contains(issuer)) { throw new AuthenticationServiceException("Whitelist was nonempty, issuer was not in whitelist: " + issuer); } if (blacklist.contains(issuer)) { throw new AuthenticationServiceException("Issuer was in blacklist: " + issuer); } return servers.get(issuer); } catch (UncheckedExecutionException | ExecutionException e) { logger.warn("Couldn't load configuration for " + issuer + ": " + e); return null; } }
public AuthenticationException resolveException(LoginException e) { return new AuthenticationServiceException(e.getMessage(), e); } }
public AuthenticationException resolveException(LoginException e) { return new AuthenticationServiceException(e.getMessage(), e); } }
@Override public RegisteredClient getClientConfiguration(ServerConfiguration issuer) { try { if (!whitelist.isEmpty() && !whitelist.contains(issuer.getIssuer())) { throw new AuthenticationServiceException("Whitelist was nonempty, issuer was not in whitelist: " + issuer); } if (blacklist.contains(issuer.getIssuer())) { throw new AuthenticationServiceException("Issuer was in blacklist: " + issuer); } return clients.get(issuer); } catch (UncheckedExecutionException | ExecutionException e) { logger.warn("Unable to get client configuration", e); return null; } }
@Override public IssuerServiceResponse getIssuer(HttpServletRequest request) { String identifier = request.getParameter(parameterName); if (!Strings.isNullOrEmpty(identifier)) { try { LoadingResult lr = issuers.get(identifier); if (!whitelist.isEmpty() && !whitelist.contains(lr.issuer)) { throw new AuthenticationServiceException("Whitelist was nonempty, issuer was not in whitelist: " + lr.issuer); } if (blacklist.contains(lr.issuer)) { throw new AuthenticationServiceException("Issuer was in blacklist: " + lr.issuer); } return new IssuerServiceResponse(lr.issuer, lr.loginHint, request.getParameter("target_link_uri")); } catch (UncheckedExecutionException | ExecutionException e) { logger.warn("Issue fetching issuer for user input: " + identifier + ": " + e.getMessage()); return null; } } else { logger.warn("No user input given, directing to login page: " + loginPageUrl); return new IssuerServiceResponse(loginPageUrl); } }
@Override public IssuerServiceResponse getIssuer(HttpServletRequest request) { // if the issuer is passed in, return that String iss = request.getParameter("iss"); if (!Strings.isNullOrEmpty(iss)) { if (!whitelist.isEmpty() && !whitelist.contains(iss)) { throw new AuthenticationServiceException("Whitelist was nonempty, issuer was not in whitelist: " + iss); } if (blacklist.contains(iss)) { throw new AuthenticationServiceException("Issuer was in blacklist: " + iss); } return new IssuerServiceResponse(iss, request.getParameter("login_hint"), request.getParameter("target_link_uri")); } else { try { // otherwise, need to forward to the account chooser String redirectUri = request.getRequestURL().toString(); URIBuilder builder = new URIBuilder(accountChooserUrl); builder.addParameter("redirect_uri", redirectUri); return new IssuerServiceResponse(builder.build().toString()); } catch (URISyntaxException e) { throw new AuthenticationServiceException("Account Chooser URL is not valid", e); } } }
public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException { if (postOnly && !request.getMethod().equals("POST")) { throw new AuthenticationServiceException( "Authentication method not supported: " + request.getMethod()); } String mobile = obtainMobile(request); if (mobile == null) { mobile = ""; } mobile = mobile.trim(); SmsAuthenticationToken authRequest = new SmsAuthenticationToken(mobile); setDetails(request, authRequest); return this.getAuthenticationManager().authenticate(authRequest); }
public Authentication authenticate(Authentication authentication) throws AuthenticationException { if (supports(authentication.getClass())) { return authentication; } else { throw new AuthenticationServiceException("Don't support this class"); } }
throw new AuthenticationServiceException( "Error message from server: " + response.getMessage()); throw new AuthenticationServiceException( "The server responded setup was needed, which shouldn't happen"); throw new AuthenticationServiceException( "Unrecognized return value " + status.toString());
throw new AuthenticationServiceException( "Unable to process claimed identity '" + claimedIdentity + "'"); throw new AuthenticationServiceException("Consumer error", oice);
} catch (SAMLException e) { LOGGER.debug("Incoming SAML message is invalid.", e); throw new AuthenticationServiceException("Incoming SAML message is invalid.", e); } catch (MetadataProviderException e) { LOGGER.debug("Error determining metadata contracts.", e); throw new AuthenticationServiceException("Error determining metadata contracts.", e); } catch (MessageEncodingException e) { LOGGER.debug("Error decoding incoming SAML message.", e); throw new AuthenticationServiceException("Error encoding outgoing SAML message.", e); } catch (MarshallingException | SecurityException | SignatureException e) { LOGGER.debug("Error signing SAML assertion.", e); throw new AuthenticationServiceException("Error signing SAML assertion.", e);
@Override public String buildAuthRequestUrl(ServerConfiguration serverConfig, RegisteredClient clientConfig, String redirectUri, String nonce, String state, Map<String, String> options, String loginHint) { try { URIBuilder uriBuilder = new URIBuilder(serverConfig.getAuthorizationEndpointUri()); uriBuilder.addParameter("response_type", "code"); uriBuilder.addParameter("client_id", clientConfig.getClientId()); uriBuilder.addParameter("scope", Joiner.on(" ").join(clientConfig.getScope())); uriBuilder.addParameter("redirect_uri", redirectUri); uriBuilder.addParameter("nonce", nonce); uriBuilder.addParameter("state", state); // Optional parameters: for (Entry<String, String> option : options.entrySet()) { uriBuilder.addParameter(option.getKey(), option.getValue()); } // if there's a login hint, send it if (!Strings.isNullOrEmpty(loginHint)) { uriBuilder.addParameter("login_hint", loginHint); } return uriBuilder.build().toString(); } catch (URISyntaxException e) { throw new AuthenticationServiceException("Malformed Authorization Endpoint Uri", e); } }
Throwable cause = exception.getCause(); if (cause != null) { AuthenticationException e = new AuthenticationServiceException(cause.getMessage(), cause.getCause()); logger.debug(cause); super.onAuthenticationFailure(request, response, e);
throw new AuthenticationServiceException("No issuer found."); throw new AuthenticationServiceException("No issuer found: " + issuer); if (serverConfig == null) { logger.error("No server configuration found for issuer: " + issuer); throw new AuthenticationServiceException("No server configuration found for issuer: " + issuer); if (clientConfig == null) { logger.error("No client configuration found for issuer: " + issuer); throw new AuthenticationServiceException("No client configuration found for issuer: " + issuer);
throw new AuthenticationServiceException("Malformed Authorization Endpoint Uri", e);
throw new AuthenticationServiceException("Malformed Authorization Endpoint Uri", e);
publisher.publishAuthenticationFailure(new LockedException(""), a); publisher.publishAuthenticationFailure(new LockedException("", cause), a); publisher.publishAuthenticationFailure(new AuthenticationServiceException(""), a); publisher.publishAuthenticationFailure(new AuthenticationServiceException("", cause), a); publisher.publishAuthenticationFailure(new CredentialsExpiredException(""), a);
.onErrorMap(UnknownHostException.class, t -> new AuthenticationServiceException("Unable to access the userInfoEndpoint " + userInfoUri, t)) .onErrorMap(t -> !(t instanceof AuthenticationServiceException), t -> { OAuth2Error oauth2Error = new OAuth2Error(INVALID_USER_INFO_RESPONSE_ERROR_CODE, "An error occurred reading the UserInfo Success response: " + t.getMessage(), null);