Search in sources :

Example 16 with MultifactorAuthenticationProvider

use of org.apereo.cas.services.MultifactorAuthenticationProvider in project cas by apereo.

the class AbstractCasWebflowEventResolver method resolveEventViaAttribute.

private Set<Event> resolveEventViaAttribute(final Principal principal, final Map<String, Object> attributesToExamine, final Collection<String> attributeNames, final RegisteredService service, final RequestContext context, final Collection<MultifactorAuthenticationProvider> providers, final Predicate<String> predicate) {
    if (providers == null || providers.isEmpty()) {
        LOGGER.debug("No authentication provider is associated with this service");
        return null;
    }
    LOGGER.debug("Locating attribute value for attribute(s): [{}]", attributeNames);
    for (final String attributeName : attributeNames) {
        final Object attributeValue = attributesToExamine.get(attributeName);
        if (attributeValue == null) {
            LOGGER.debug("Attribute value for [{}] to determine event is not configured for [{}]", attributeName, principal.getId());
            continue;
        }
        LOGGER.debug("Selecting a multifactor authentication provider out of [{}] for [{}] and service [{}]", providers, principal.getId(), service);
        final MultifactorAuthenticationProvider provider = this.multifactorAuthenticationProviderSelector.resolve(providers, service, principal);
        LOGGER.debug("Located attribute value [{}] for [{}]", attributeValue, attributeNames);
        Set<Event> results = resolveEventViaSingleAttribute(principal, attributeValue, service, context, provider, predicate);
        if (results == null || results.isEmpty()) {
            results = resolveEventViaMultivaluedAttribute(principal, attributeValue, service, context, provider, predicate);
        }
        if (results != null && !results.isEmpty()) {
            LOGGER.debug("Resolved set of events based on the attribute [{}] are [{}]", attributeName, results);
            return results;
        }
    }
    LOGGER.debug("No set of events based on the attribute(s) [{}] could be matched", attributeNames);
    return null;
}
Also used : Event(org.springframework.webflow.execution.Event) MultifactorAuthenticationProvider(org.apereo.cas.services.MultifactorAuthenticationProvider)

Aggregations

MultifactorAuthenticationProvider (org.apereo.cas.services.MultifactorAuthenticationProvider)16 Authentication (org.apereo.cas.authentication.Authentication)11 Event (org.springframework.webflow.execution.Event)11 RegisteredService (org.apereo.cas.services.RegisteredService)10 AuthenticationException (org.apereo.cas.authentication.AuthenticationException)7 Map (java.util.Map)5 RequestContext (org.springframework.webflow.execution.RequestContext)5 Set (java.util.Set)4 CentralAuthenticationService (org.apereo.cas.CentralAuthenticationService)4 AuthenticationServiceSelectionPlan (org.apereo.cas.authentication.AuthenticationServiceSelectionPlan)4 AuthenticationSystemSupport (org.apereo.cas.authentication.AuthenticationSystemSupport)4 Principal (org.apereo.cas.authentication.principal.Principal)4 MultifactorAuthenticationProviderSelector (org.apereo.cas.services.MultifactorAuthenticationProviderSelector)4 ServicesManager (org.apereo.cas.services.ServicesManager)4 TicketRegistrySupport (org.apereo.cas.ticket.registry.TicketRegistrySupport)4 BaseMultifactorAuthenticationProviderEventResolver (org.apereo.cas.web.flow.authentication.BaseMultifactorAuthenticationProviderEventResolver)4 WebUtils (org.apereo.cas.web.support.WebUtils)4 Logger (org.slf4j.Logger)4 LoggerFactory (org.slf4j.LoggerFactory)4 CookieGenerator (org.springframework.web.util.CookieGenerator)4