@Override public final void populateAttributes(final AuthenticationBuilder builder, final Credential credential) { final String credentialsClass = credential.getClass().getName(); final String authenticationMethod = this.authenticationMethods.get(credentialsClass); builder.addAttribute(ATTRIBUTE_AUTHENTICATION_METHOD, authenticationMethod); }
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(); }
@Override public void populateAttributes(final AuthenticationBuilder builder, final Credential credential) { Set<String> successes = builder.getSuccesses().keySet(); if (successes != null) { successes = new HashSet(successes); } builder.addAttribute(SUCCESSFUL_AUTHENTICATION_HANDLERS, successes); }
/** * 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()); } }
builder.addCredential(new BasicCredentialMetaData(c)); try { authenticateAndResolvePrincipal(builder, credential, entry.getValue(), handler); if (this.authenticationPolicy.isSatisfiedBy(builder.build())) { return builder; logger.info("{} failed authenticating {}", handler.getName(), credential); logger.debug("{} exception details: {}", handler.getName(), e.getMessage()); builder.addFailure(handler.getName(), e.getClass()); } catch (final PreventedException e) { logger.error("{}: {} (Details: {})", handler.getName(), e.getMessage(), e.getCause().getMessage()); builder.addFailure(handler.getName(), e.getClass());
final Principal modifiedPrincipal = this.principalFactory.createPrincipal(principalId, attributesToRelease); final AuthenticationBuilder builder = DefaultAuthenticationBuilder.newInstance(authentication); builder.setPrincipal(modifiedPrincipal); builder.build(), serviceTicket.getGrantingTicket().getChainedAuthentications(), serviceTicket.getService(),
@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()); }
authenticationAttributes); authenticationBuilder.addSuccesses(authn.getSuccesses()) .addFailures(authn.getFailures()) .addCredentials(authn.getCredentials());
builder.addSuccess(handler.getName(), result); logger.info("{} successfully authenticated {}", handler.getName(), credential); if (resolver == null) { builder.setPrincipal(principal);
@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(); }
@Override public void populateAttributes(final AuthenticationBuilder builder, final Credential credential) { final RememberMeCredential r = (RememberMeCredential) credential; if (r.isRememberMe()) { LOGGER.debug("Credential is configured to be remembered. Captured this as {} attribute", RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME); builder.addAttribute(RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME, Boolean.TRUE); } }
/** * Add authentication method attribute. * * @param builder the builder * @param authentication the authentication */ private void addAuthenticationMethodAttribute(final AuthenticationBuilder builder, final Authentication authentication) { for (final HandlerResult result : authentication.getSuccesses().values()) { builder.addAttribute(AUTHENTICATION_METHOD_ATTRIBUTE, result.getHandlerName()); } }
@Override public void populateAttributes(final AuthenticationBuilder builder, final Credential credential) { logger.debug("Processing request to capture the credential for [{}]", credential.getId()); final UsernamePasswordCredential c = (UsernamePasswordCredential) credential; builder.addAttribute(UsernamePasswordCredential.AUTHENTICATION_ATTRIBUTE_PASSWORD, c.getPassword()); logger.debug("Encrypted credential is added as the authentication attribute [{}] to the authentication", UsernamePasswordCredential.AUTHENTICATION_ATTRIBUTE_PASSWORD); }
/** * {@InheritDoc} */ @Override public void populateAttributes(final AuthenticationBuilder builder, final Credential credential) { if (credential instanceof ClientCredential) { final ClientCredential clientCredential = (ClientCredential) credential; builder.addAttribute(CLIENT_NAME, clientCredential.getOpenIdCredentials().getClientName()); } }
@Override public void populateAttributes(final AuthenticationBuilder authenticationBuilder, final Credential credential) { final RequestContext context = RequestContextHolder.getRequestContext(); if (context != null) { final Service svc = WebUtils.getService(context); if (svc instanceof MultiFactorAuthenticationSupportingWebApplicationService) { final MultiFactorAuthenticationSupportingWebApplicationService mfaSvc = (MultiFactorAuthenticationSupportingWebApplicationService) svc; authenticationBuilder.addAttribute( MultiFactorAuthenticationSupportingWebApplicationService.CONST_PARAM_AUTHN_METHOD, mfaSvc.getAuthenticationMethod()); logger.debug("Captured authentication method [{}] into the authentication context", mfaSvc.getAuthenticationMethod()); } } }