@Override public void populateAttributes(final AuthenticationBuilder builder, final Credential credential) { final UsernamePasswordCredential c = (UsernamePasswordCredential) credential; final Authentication authentication = builder.build(); this.credentialCache.put(authentication.getPrincipal().getId(), c.getPassword()); }
private Authentication buildAuthentication() { if (isEmpty()) { LOGGER.warn("No authentication event has been recorded; CAS cannot finalize the authentication context"); return null; } final Map<String, Object> authenticationAttributes = new HashMap<>(); final Map<String, Object> principalAttributes = new HashMap<>(); final AuthenticationBuilder authenticationBuilder = DefaultAuthenticationBuilder.newInstance(); buildAuthenticationHistory(this.authentications, authenticationAttributes, principalAttributes, authenticationBuilder); final Principal primaryPrincipal = getPrimaryPrincipal(this.authentications, principalAttributes); authenticationBuilder.setPrincipal(primaryPrincipal); LOGGER.debug("Determined primary authentication principal to be [{}]", primaryPrincipal); authenticationBuilder.setAttributes(authenticationAttributes); LOGGER.debug("Collected authentication attributes for this context are [{}]", authenticationAttributes); final DateTime dt = DateTime.now(); authenticationBuilder.setAuthenticationDate(dt); LOGGER.debug("Authentication context commenced at [{}]", dt); return authenticationBuilder.build(); }
try { authenticateAndResolvePrincipal(builder, credential, entry.getValue(), handler); if (this.authenticationPolicy.isSatisfiedBy(builder.build())) { return builder;
/** * Evaluate produced authentication context. * * @param builder the builder * @throws AuthenticationException the authentication exception */ private void evaluateProducedAuthenticationContext(final AuthenticationBuilder builder) throws AuthenticationException { // We apply an implicit security policy of at least one successful authentication if (builder.getSuccesses().isEmpty()) { throw new AuthenticationException(builder.getFailures(), builder.getSuccesses()); } // Apply the configured security policy if (!this.authenticationPolicy.isSatisfiedBy(builder.build())) { throw new AuthenticationException(builder.getFailures(), builder.getSuccesses()); } }
@Override @Audit( action="AUTHENTICATION", actionResolverName="AUTHENTICATION_RESOLVER", resourceResolverName="AUTHENTICATION_RESOURCE_RESOLVER") @Timed(name="AUTHENTICATE_TIMED") @Metered(name="AUTHENTICATE_METER") @Counted(name="AUTHENTICATE_COUNT", monotonic=true) public Authentication authenticate(final AuthenticationTransaction transaction) throws AuthenticationException { final AuthenticationBuilder builder = authenticateInternal(transaction.getCredentials()); final Authentication authentication = builder.build(); final Principal principal = authentication.getPrincipal(); if (principal instanceof NullPrincipal) { throw new UnresolvedPrincipalException(authentication); } addAuthenticationMethodAttribute(builder, authentication); logger.info("Authenticated {} with credentials {}.", principal, transaction.getCredentials()); logger.debug("Attribute map for {}: {}", principal.getId(), principal.getAttributes()); populateAuthenticationMetadataAttributes(builder, transaction.getCredentials()); return builder.build(); }
builder.build(), serviceTicket.getGrantingTicket().getChainedAuthentications(), serviceTicket.getService(),