use of org.apereo.cas.authentication.exceptions.UnresolvedPrincipalException in project cas by apereo.
the class DefaultAuthenticationManager method authenticate.
@Override
@Audit(action = AuditableActions.AUTHENTICATION, actionResolverName = AuditActionResolvers.AUTHENTICATION_RESOLVER, resourceResolverName = AuditResourceResolvers.AUTHENTICATION_RESOURCE_RESOLVER)
public Authentication authenticate(final AuthenticationTransaction transaction) throws AuthenticationException {
val result = invokeAuthenticationPreProcessors(transaction);
if (!result) {
LOGGER.warn("An authentication pre-processor could not successfully process the authentication transaction");
throw new AuthenticationException("Authentication pre-processor has failed to process transaction");
}
AuthenticationCredentialsThreadLocalBinder.bindCurrent(transaction.getCredentials());
val builder = authenticateInternal(transaction);
AuthenticationCredentialsThreadLocalBinder.bindCurrent(builder);
val authentication = builder.build();
addAuthenticationMethodAttribute(builder, authentication);
populateAuthenticationMetadataAttributes(builder, transaction);
invokeAuthenticationPostProcessors(builder, transaction);
val auth = builder.build();
val principal = auth.getPrincipal();
if (principal instanceof NullPrincipal) {
throw new UnresolvedPrincipalException(auth);
}
LOGGER.info("Authenticated principal [{}] with attributes [{}] via credentials [{}].", principal.getId(), principal.getAttributes(), transaction.getCredentials());
AuthenticationCredentialsThreadLocalBinder.bindCurrent(auth);
return auth;
}
Aggregations