Search in sources :

Example 1 with NotPreventedAuthenticationPolicy

use of org.apereo.cas.authentication.policy.NotPreventedAuthenticationPolicy 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()));
        }
    };
}
Also used : CasConfigurationProperties(org.apereo.cas.configuration.CasConfigurationProperties) AuthenticationPolicy(org.apereo.cas.authentication.AuthenticationPolicy) GeoLocationService(org.apereo.cas.authentication.adaptive.geo.GeoLocationService) Autowired(org.springframework.beans.factory.annotation.Autowired) ObjectProvider(org.springframework.beans.factory.ObjectProvider) TicketRegistry(org.apereo.cas.ticket.registry.TicketRegistry) NotPreventedAuthenticationPolicy(org.apereo.cas.authentication.policy.NotPreventedAuthenticationPolicy) EnableConfigurationProperties(org.springframework.boot.context.properties.EnableConfigurationProperties) Qualifier(org.springframework.beans.factory.annotation.Qualifier) DefaultAdaptiveAuthenticationPolicy(org.apereo.cas.authentication.adaptive.DefaultAdaptiveAuthenticationPolicy) RestTemplate(org.springframework.web.client.RestTemplate) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) UniquePrincipalAuthenticationPolicy(org.apereo.cas.authentication.policy.UniquePrincipalAuthenticationPolicy) ResourceLoader(org.springframework.core.io.ResourceLoader) RequiredHandlerAuthenticationPolicyFactory(org.apereo.cas.authentication.policy.RequiredHandlerAuthenticationPolicyFactory) AnyAuthenticationPolicy(org.apereo.cas.authentication.policy.AnyAuthenticationPolicy) GroovyScriptAuthenticationPolicy(org.apereo.cas.authentication.policy.GroovyScriptAuthenticationPolicy) AuthenticationPolicyProperties(org.apereo.cas.configuration.model.core.authentication.AuthenticationPolicyProperties) ApplicationContext(org.springframework.context.ApplicationContext) AllAuthenticationPolicy(org.apereo.cas.authentication.policy.AllAuthenticationPolicy) Configuration(org.springframework.context.annotation.Configuration) Slf4j(lombok.extern.slf4j.Slf4j) ContextualAuthenticationPolicyFactory(org.apereo.cas.authentication.ContextualAuthenticationPolicyFactory) RequiredHandlerAuthenticationPolicy(org.apereo.cas.authentication.policy.RequiredHandlerAuthenticationPolicy) Bean(org.springframework.context.annotation.Bean) AuthenticationEventExecutionPlanConfigurer(org.apereo.cas.authentication.AuthenticationEventExecutionPlanConfigurer) RestfulAuthenticationPolicy(org.apereo.cas.authentication.policy.RestfulAuthenticationPolicy) AdaptiveAuthenticationPolicy(org.apereo.cas.authentication.adaptive.AdaptiveAuthenticationPolicy) AnyAuthenticationPolicy(org.apereo.cas.authentication.policy.AnyAuthenticationPolicy) RequiredHandlerAuthenticationPolicy(org.apereo.cas.authentication.policy.RequiredHandlerAuthenticationPolicy) RestTemplate(org.springframework.web.client.RestTemplate) GroovyScriptAuthenticationPolicy(org.apereo.cas.authentication.policy.GroovyScriptAuthenticationPolicy) RestfulAuthenticationPolicy(org.apereo.cas.authentication.policy.RestfulAuthenticationPolicy) AuthenticationPolicyProperties(org.apereo.cas.configuration.model.core.authentication.AuthenticationPolicyProperties) UniquePrincipalAuthenticationPolicy(org.apereo.cas.authentication.policy.UniquePrincipalAuthenticationPolicy) AllAuthenticationPolicy(org.apereo.cas.authentication.policy.AllAuthenticationPolicy) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

Slf4j (lombok.extern.slf4j.Slf4j)1 AuthenticationEventExecutionPlanConfigurer (org.apereo.cas.authentication.AuthenticationEventExecutionPlanConfigurer)1 AuthenticationPolicy (org.apereo.cas.authentication.AuthenticationPolicy)1 ContextualAuthenticationPolicyFactory (org.apereo.cas.authentication.ContextualAuthenticationPolicyFactory)1 AdaptiveAuthenticationPolicy (org.apereo.cas.authentication.adaptive.AdaptiveAuthenticationPolicy)1 DefaultAdaptiveAuthenticationPolicy (org.apereo.cas.authentication.adaptive.DefaultAdaptiveAuthenticationPolicy)1 GeoLocationService (org.apereo.cas.authentication.adaptive.geo.GeoLocationService)1 AllAuthenticationPolicy (org.apereo.cas.authentication.policy.AllAuthenticationPolicy)1 AnyAuthenticationPolicy (org.apereo.cas.authentication.policy.AnyAuthenticationPolicy)1 GroovyScriptAuthenticationPolicy (org.apereo.cas.authentication.policy.GroovyScriptAuthenticationPolicy)1 NotPreventedAuthenticationPolicy (org.apereo.cas.authentication.policy.NotPreventedAuthenticationPolicy)1 RequiredHandlerAuthenticationPolicy (org.apereo.cas.authentication.policy.RequiredHandlerAuthenticationPolicy)1 RequiredHandlerAuthenticationPolicyFactory (org.apereo.cas.authentication.policy.RequiredHandlerAuthenticationPolicyFactory)1 RestfulAuthenticationPolicy (org.apereo.cas.authentication.policy.RestfulAuthenticationPolicy)1 UniquePrincipalAuthenticationPolicy (org.apereo.cas.authentication.policy.UniquePrincipalAuthenticationPolicy)1 CasConfigurationProperties (org.apereo.cas.configuration.CasConfigurationProperties)1 AuthenticationPolicyProperties (org.apereo.cas.configuration.model.core.authentication.AuthenticationPolicyProperties)1 TicketRegistry (org.apereo.cas.ticket.registry.TicketRegistry)1 ObjectProvider (org.springframework.beans.factory.ObjectProvider)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1