use of org.apereo.cas.support.events.authentication.CasAuthenticationTransactionFailureEvent in project cas by apereo.
the class PolicyBasedAuthenticationManager method evaluateProducedAuthenticationContext.
/**
* Evaluate produced authentication context.
* We apply an implicit security policy of at least one successful authentication.
* Then, we apply the configured security policy.
*
* @param builder the builder
* @param transaction the transaction
* @throws AuthenticationException the authentication exception
*/
protected void evaluateProducedAuthenticationContext(final AuthenticationBuilder builder, final AuthenticationTransaction transaction) throws AuthenticationException {
if (builder.getSuccesses().isEmpty()) {
publishEvent(new CasAuthenticationTransactionFailureEvent(this, builder.getFailures(), transaction.getCredentials()));
throw new AuthenticationException(builder.getFailures(), builder.getSuccesses());
}
LOGGER.debug("Executing authentication policy [{}]", this.authenticationPolicy);
final Authentication authentication = builder.build();
if (!this.authenticationPolicy.isSatisfiedBy(authentication)) {
publishEvent(new CasAuthenticationPolicyFailureEvent(this, builder.getFailures(), transaction, authentication));
throw new AuthenticationException(builder.getFailures(), builder.getSuccesses());
}
}
Aggregations