@Override public AuthenticationTransactionManager handle(final AuthenticationTransaction authenticationTransaction, final AuthenticationContextBuilder authenticationContext) throws AuthenticationException { if (!authenticationTransaction.getCredentials().isEmpty()) { final Authentication authentication = this.authenticationManager.authenticate(authenticationTransaction); LOGGER.debug("Successful authentication; Collecting authentication result [{}]", authentication); authenticationContext.collect(authentication); } LOGGER.debug("Transaction ignored since there are no credentials to authenticate"); return this; }
@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(); }