@Test(expected = IllegalArgumentException.class) public void testInvalidAuthenticationObject() { Authentication auth = new UsernamePasswordAuthenticationToken("user", "pass"); provider.authenticate(auth); }
public Authentication authenticate(Authentication authentication) throws AuthenticationException { if (!supports(authentication.getClass())) { throw new IllegalArgumentException("Only SAMLAuthenticationToken is supported, " + authentication.getClass() + " was attempted"); } SAMLAuthenticationToken token = (SAMLAuthenticationToken) authentication; SAMLMessageStorage store = token.getMessageStore(); SAMLMessageContext context = token.getCredentials(); SAMLCredential credential; try { credential = consumer.processAuthenticationResponse(context, store); } catch (SAMLException e) { samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.FAILURE, context, e); throw new AuthenticationServiceException("Error validating SAML message", e); } catch (ValidationException e) { log.debug("Error validating signature", e); samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.FAILURE, context); throw new AuthenticationServiceException("Error validating SAML message signature", e); } catch (org.opensaml.xml.security.SecurityException e) { log.debug("Error validating signature", e); samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.FAILURE, context); throw new AuthenticationServiceException("Error validating SAML message signature", e); } catch (DecryptionException e) { log.debug("Error decrypting SAML message", e); samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.FAILURE, context); throw new AuthenticationServiceException("Error decrypting SAML message", e); } Object userDetails = getUserDetails(credential); Object principal = getPrincipal(credential, userDetails); Collection<GrantedAuthority> entitlements = getEntitlements(credential, userDetails); Date expiration = getExpirationDate(credential); ExpiringUsernameAuthenticationToken result = new ExpiringUsernameAuthenticationToken(expiration, principal, credential, entitlements); result.setDetails(userDetails); samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.SUCCESS, context, result, null); return result; }
SAMLAuthenticationProvider implements AuthenticationProvider, InitializingBean { public Authentication authenticate(Authentication authentication) throws AuthenticationException { if (!supports(authentication.getClass())) { throw new IllegalArgumentException("Only SAMLAuthenticationToken is supported, " + authentication.getClass() + " was attempted"); } SAMLAuthenticationToken token = (SAMLAuthenticationToken) authentication; SAMLMessageStorage store = token.getMessageStore(); SAMLMessageContext context = token.getCredentials(); SAMLCredential credential; try { credential = consumer.processAuthenticationResponse(context, store); } catch (SAMLException e) { samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.FAILURE, context, e); throw new AuthenticationServiceException("Error validating SAML message", e); } catch (ValidationException e) { log.debug("Error validating signature", e); samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.FAILURE, context); throw new AuthenticationServiceException("Error validating SAML message signature", e); } catch (org.opensaml.xml.security.SecurityException e) { log.debug("Error validating signature", e); samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.FAILURE, context); throw new AuthenticationServiceException("Error validating SAML message signature", e); } catch (DecryptionException e) { log.debug("Error decrypting SAML message", e); samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.FAILURE, context); throw new AuthenticationServiceException("Error decrypting SAML message", e); } Object userDetails = getUserDetails(credential); Object principal = getPrincipal(credential, userDetails); Collection<GrantedAuthority> entitlements = getEntitlements(credential, userDetails); Date expiration = getExpirationDate(credential); ExpiringUsernameAuthenticationToken result = new ExpiringUsernameAuthenticationToken(expiration, principal, credential, entitlements); result.setDetails(userDetails); samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.SUCCESS, context, result, null); return result; } }
SAMLAuthenticationProvider implements AuthenticationProvider, InitializingBean { public Authentication authenticate(Authentication authentication) throws AuthenticationException { if (!supports(authentication.getClass())) { throw new IllegalArgumentException("Only SAMLAuthenticationToken is supported, " + authentication.getClass() + " was attempted"); } SAMLAuthenticationToken token = (SAMLAuthenticationToken) authentication; SAMLMessageStorage store = token.getMessageStore(); SAMLMessageContext context = token.getCredentials(); SAMLCredential credential; try { credential = consumer.processAuthenticationResponse(context, store); } catch (SAMLException e) { samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.FAILURE, context, e); throw new AuthenticationServiceException("Error validating SAML message", e); } catch (ValidationException e) { log.debug("Error validating signature", e); samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.FAILURE, context); throw new AuthenticationServiceException("Error validating SAML message signature", e); } catch (org.opensaml.xml.security.SecurityException e) { log.debug("Error validating signature", e); samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.FAILURE, context); throw new AuthenticationServiceException("Error validating SAML message signature", e); } catch (DecryptionException e) { log.debug("Error decrypting SAML message", e); samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.FAILURE, context); throw new AuthenticationServiceException("Error decrypting SAML message", e); } Object userDetails = getUserDetails(credential); Object principal = getPrincipal(credential, userDetails); Collection<GrantedAuthority> entitlements = getEntitlements(credential, userDetails); Date expiration = getExpirationDate(credential); ExpiringUsernameAuthenticationToken result = new ExpiringUsernameAuthenticationToken(expiration, principal, credential, entitlements); result.setDetails(userDetails); samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.SUCCESS, context, result, null); return result; } SAMLAuthenticationProvider();  SAMLAuthenticationProvider(WebSSOProfileConsumer consumer); }
SAMLAuthenticationProvider implements AuthenticationProvider, InitializingBean { public Authentication authenticate(Authentication authentication) throws AuthenticationException { if (!supports(authentication.getClass())) { throw new IllegalArgumentException("Only SAMLAuthenticationToken is supported, " + authentication.getClass() + " was attempted"); } SAMLAuthenticationToken token = (SAMLAuthenticationToken) authentication; SAMLMessageStorage store = token.getMessageStore(); SAMLMessageContext context = token.getCredentials(); SAMLCredential credential; try { credential = consumer.processAuthenticationResponse(context, store); } catch (SAMLException e) { samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.FAILURE, context, e); throw new AuthenticationServiceException("Error validating SAML message", e); } catch (ValidationException e) { log.debug("Error validating signature", e); samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.FAILURE, context); throw new AuthenticationServiceException("Error validating SAML message signature", e); } catch (org.opensaml.xml.security.SecurityException e) { log.debug("Error validating signature", e); samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.FAILURE, context); throw new AuthenticationServiceException("Error validating SAML message signature", e); } catch (DecryptionException e) { log.debug("Error decrypting SAML message", e); samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.FAILURE, context); throw new AuthenticationServiceException("Error decrypting SAML message", e); } Object userDetails = getUserDetails(credential); Object principal = getPrincipal(credential, userDetails); Collection<GrantedAuthority> entitlements = getEntitlements(credential, userDetails); Date expiration = getExpirationDate(credential); ExpiringUsernameAuthenticationToken result = new ExpiringUsernameAuthenticationToken(expiration, principal, credential, entitlements); result.setDetails(userDetails); samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.SUCCESS, context, result, null); return result; } SAMLAuthenticationProvider();  SAMLAuthenticationProvider(WebSSOProfileConsumer consumer); Authentication authenticate(Authentication authentication); SAMLUserDetailsService getUserDetails(); boolean supports(Class aClass); @Autowired(required = false) void setUserDetails(SAMLUserDetailsService userDetails); @Autowired void setSamlLogger(SAMLLogger samlLogger); @Autowired void setConsumer(WebSSOProfileConsumer consumer); void afterPropertiesSet(); }
SAMLAuthenticationProvider implements AuthenticationProvider, InitializingBean { public Authentication authenticate(Authentication authentication) throws AuthenticationException { if (!supports(authentication.getClass())) { throw new IllegalArgumentException("Only SAMLAuthenticationToken is supported, " + authentication.getClass() + " was attempted"); } SAMLAuthenticationToken token = (SAMLAuthenticationToken) authentication; SAMLMessageStorage store = token.getMessageStore(); SAMLMessageContext context = token.getCredentials(); SAMLCredential credential; try { credential = consumer.processAuthenticationResponse(context, store); } catch (SAMLException e) { samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.FAILURE, context, e); throw new AuthenticationServiceException("Error validating SAML message", e); } catch (ValidationException e) { log.debug("Error validating signature", e); samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.FAILURE, context); throw new AuthenticationServiceException("Error validating SAML message signature", e); } catch (org.opensaml.xml.security.SecurityException e) { log.debug("Error validating signature", e); samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.FAILURE, context); throw new AuthenticationServiceException("Error validating SAML message signature", e); } catch (DecryptionException e) { log.debug("Error decrypting SAML message", e); samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.FAILURE, context); throw new AuthenticationServiceException("Error decrypting SAML message", e); } Object userDetails = getUserDetails(credential); Object principal = getPrincipal(credential, userDetails); Collection<GrantedAuthority> entitlements = getEntitlements(credential, userDetails); Date expiration = getExpirationDate(credential); ExpiringUsernameAuthenticationToken result = new ExpiringUsernameAuthenticationToken(expiration, principal, credential, entitlements); result.setDetails(userDetails); samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.SUCCESS, context, result, null); return result; } SAMLAuthenticationProvider();  SAMLAuthenticationProvider(WebSSOProfileConsumer consumer); Authentication authenticate(Authentication authentication); SAMLUserDetailsService getUserDetails(); boolean supports(Class aClass); @Autowired(required = false) void setUserDetails(SAMLUserDetailsService userDetails); @Autowired void setSamlLogger(SAMLLogger samlLogger); @Autowired void setConsumer(WebSSOProfileConsumer consumer); void afterPropertiesSet();  }