use of org.apereo.cas.authentication.AuthenticationEventExecutionPlanConfigurer in project cas by apereo.
the class CasCoreAuthenticationPolicyConfiguration method authenticationPolicyExecutionPlanConfigurer.
@ConditionalOnMissingBean(name = "authenticationPolicyExecutionPlanConfigurer")
@Bean
public AuthenticationEventExecutionPlanConfigurer authenticationPolicyExecutionPlanConfigurer() {
return plan -> {
final AuthenticationPolicyProperties police = casProperties.getAuthn().getPolicy();
if (police.getReq().isEnabled()) {
LOGGER.debug("Activating authentication policy [{}]", RequiredHandlerAuthenticationPolicy.class.getSimpleName());
plan.registerAuthenticationPolicy(new RequiredHandlerAuthenticationPolicy(police.getReq().getHandlerName(), police.getReq().isTryAll()));
} else if (police.getAll().isEnabled()) {
LOGGER.debug("Activating authentication policy [{}]", AllAuthenticationPolicy.class.getSimpleName());
plan.registerAuthenticationPolicy(new AllAuthenticationPolicy());
} else if (police.getNotPrevented().isEnabled()) {
LOGGER.debug("Activating authentication policy [{}]", NotPreventedAuthenticationPolicy.class.getSimpleName());
plan.registerAuthenticationPolicy(notPreventedAuthenticationPolicy());
} else if (police.getUniquePrincipal().isEnabled()) {
LOGGER.debug("Activating authentication policy [{}]", UniquePrincipalAuthenticationPolicy.class.getSimpleName());
plan.registerAuthenticationPolicy(new UniquePrincipalAuthenticationPolicy(ticketRegistry.getIfAvailable()));
} else if (!police.getGroovy().isEmpty()) {
LOGGER.debug("Activating authentication policy [{}]", GroovyScriptAuthenticationPolicy.class.getSimpleName());
police.getGroovy().forEach(groovy -> plan.registerAuthenticationPolicy(new GroovyScriptAuthenticationPolicy(resourceLoader, groovy.getScript())));
} else if (!police.getRest().isEmpty()) {
LOGGER.debug("Activating authentication policy [{}]", RestfulAuthenticationPolicy.class.getSimpleName());
police.getRest().forEach(r -> plan.registerAuthenticationPolicy(new RestfulAuthenticationPolicy(new RestTemplate(), r.getEndpoint())));
} else if (police.getAny().isEnabled()) {
LOGGER.debug("Activating authentication policy [{}]", AnyAuthenticationPolicy.class.getSimpleName());
plan.registerAuthenticationPolicy(new AnyAuthenticationPolicy(police.getAny().isTryAll()));
}
};
}
use of org.apereo.cas.authentication.AuthenticationEventExecutionPlanConfigurer in project cas by apereo.
the class WsFedAuthenticationEventExecutionPlanConfiguration method wsfedAuthenticationEventExecutionPlanConfigurer.
@ConditionalOnMissingBean(name = "wsfedAuthenticationEventExecutionPlanConfigurer")
@Bean
public AuthenticationEventExecutionPlanConfigurer wsfedAuthenticationEventExecutionPlanConfigurer() {
return plan -> casProperties.getAuthn().getWsfed().stream().filter(wsfed -> StringUtils.isNotBlank(wsfed.getIdentityProviderUrl()) && StringUtils.isNotBlank(wsfed.getIdentityProviderIdentifier())).forEach(wsfed -> {
final AuthenticationHandler handler = new WsFederationAuthenticationHandler(wsfed.getName(), servicesManager, adfsPrincipalFactory());
if (!wsfed.isAttributeResolverEnabled()) {
plan.registerAuthenticationHandler(handler);
} else {
final WsFederationCredentialsToPrincipalResolver r = new WsFederationCredentialsToPrincipalResolver(attributeRepository, adfsPrincipalFactory(), wsfed.getPrincipal().isReturnNull(), wsfed.getPrincipal().getPrincipalAttribute(), getWsFederationConfiguration(wsfed));
plan.registerAuthenticationHandlerWithPrincipalResolver(handler, r);
}
});
}
Aggregations