use of org.apereo.cas.authentication.handler.DefaultAuthenticationHandlerResolver in project cas by apereo.
the class DefaultAuthenticationEventExecutionPlan method getAuthenticationHandlers.
@Override
@NonNull
public Set<AuthenticationHandler> getAuthenticationHandlers(final AuthenticationTransaction transaction) {
val handlers = getAuthenticationHandlers();
LOGGER.debug("Candidate/Registered authentication handlers for this transaction are [{}]", handlers);
val handlerResolvers = getAuthenticationHandlerResolvers(transaction);
LOGGER.debug("Authentication handler resolvers for this transaction are [{}]", handlerResolvers);
val resolvedHandlers = handlerResolvers.stream().filter(r -> r.supports(handlers, transaction)).map(r -> r.resolve(handlers, transaction)).flatMap(Set::stream).collect(Collectors.toCollection(LinkedHashSet::new));
if (resolvedHandlers.isEmpty()) {
LOGGER.debug("Authentication handler resolvers produced no candidate authentication handler. Using the default handler resolver instead...");
val defaultHandlerResolver = new DefaultAuthenticationHandlerResolver();
if (defaultHandlerResolver.supports(handlers, transaction)) {
resolvedHandlers.addAll(defaultHandlerResolver.resolve(handlers, transaction));
}
}
if (resolvedHandlers.isEmpty()) {
throw new AuthenticationException("No authentication handlers could be resolved to support the authentication transaction");
}
LOGGER.debug("Resolved and finalized authentication handlers to carry out this authentication transaction are [{}]", handlerResolvers);
return resolvedHandlers;
}
use of org.apereo.cas.authentication.handler.DefaultAuthenticationHandlerResolver in project cas by apereo.
the class DefaultAuthenticationManagerTests method getAuthenticationExecutionPlan.
private static AuthenticationEventExecutionPlan getAuthenticationExecutionPlan(final Map<AuthenticationHandler, PrincipalResolver> map) {
val plan = new DefaultAuthenticationEventExecutionPlan();
plan.registerAuthenticationHandlerWithPrincipalResolver(map);
plan.registerAuthenticationHandlerResolver(new RegisteredServiceAuthenticationHandlerResolver(mockServicesManager(), new DefaultAuthenticationServiceSelectionPlan(new DefaultAuthenticationServiceSelectionStrategy())));
plan.registerAuthenticationHandlerResolver(new DefaultAuthenticationHandlerResolver());
plan.registerAuthenticationPostProcessor((builder, transaction) -> LOGGER.trace("Running authentication post processor"));
return plan;
}
use of org.apereo.cas.authentication.handler.DefaultAuthenticationHandlerResolver in project cas by apereo.
the class RegisteredServiceAuthenticationHandlerResolverTests method checkAuthenticationHandlerResolution.
@Test
public void checkAuthenticationHandlerResolution() {
val resolver = new DefaultAuthenticationHandlerResolver();
val transaction = new DefaultAuthenticationTransactionFactory().newTransaction(RegisteredServiceTestUtils.getService("serviceid2"), RegisteredServiceTestUtils.getCredentialsWithSameUsernameAndPassword("casuser"));
val handlers = resolver.resolve(this.authenticationHandlers, transaction);
assertEquals(handlers.size(), this.authenticationHandlers.size());
}
use of org.apereo.cas.authentication.handler.DefaultAuthenticationHandlerResolver in project cas by apereo.
the class DefaultAuthenticationHandlerResolverTests method verifyOperation.
@Test
public void verifyOperation() {
val h1 = new SimpleTestUsernamePasswordAuthenticationHandler("h1");
val h2 = new SimpleTestUsernamePasswordAuthenticationHandler("h2");
h2.setState(AuthenticationHandlerStates.STANDBY);
val resolver = new DefaultAuthenticationHandlerResolver();
assertTrue(resolver.supports(of(h1, h2), mock(AuthenticationTransaction.class)));
val result = resolver.resolve(of(h1, h2), mock(AuthenticationTransaction.class));
assertTrue(result.contains(h1));
assertFalse(result.contains(h2));
assertEquals(Ordered.LOWEST_PRECEDENCE, resolver.getOrder());
}
Aggregations