Search in sources :

Example 1 with AbstractModuleFactory

use of com.evolveum.midpoint.authentication.impl.factory.module.AbstractModuleFactory in project midpoint by Evolveum.

the class AuthSequenceUtil method buildModuleFilters.

public static List<AuthModule> buildModuleFilters(AuthModuleRegistryImpl authRegistry, AuthenticationSequenceType sequence, HttpServletRequest request, AuthenticationModulesType authenticationModulesType, CredentialsPolicyType credentialPolicy, Map<Class<?>, Object> sharedObjects, AuthenticationChannel authenticationChannel) {
    Validate.notNull(authRegistry, "Registry for module factories is null");
    if (isSpecificSequence(request)) {
        return getSpecificModuleFilter(authRegistry, sequence.getChannel().getUrlSuffix(), request, sharedObjects, authenticationModulesType, credentialPolicy);
    }
    Validate.notEmpty(sequence.getModule(), "Sequence " + sequence.getName() + " don't contains authentication modules");
    List<AuthenticationSequenceModuleType> sequenceModules = SecurityPolicyUtil.getSortedModules(sequence);
    List<AuthModule> authModules = new ArrayList<>();
    sequenceModules.forEach(sequenceModule -> {
        try {
            AbstractAuthenticationModuleType module = getModuleByName(sequenceModule.getName(), authenticationModulesType);
            AbstractModuleFactory moduleFactory = authRegistry.findModelFactory(module, authenticationChannel);
            AuthModule authModule = moduleFactory.createModuleFilter(module, sequence.getChannel().getUrlSuffix(), request, sharedObjects, authenticationModulesType, credentialPolicy, authenticationChannel);
            authModules.add(authModule);
        } catch (Exception e) {
            LOGGER.error("Couldn't build filter for module moduleFactory", e);
        }
    });
    if (authModules.isEmpty()) {
        return null;
    }
    return authModules;
}
Also used : AuthModule(com.evolveum.midpoint.authentication.api.AuthModule) AbstractModuleFactory(com.evolveum.midpoint.authentication.impl.factory.module.AbstractModuleFactory) ServletException(javax.servlet.ServletException) AuthenticationException(org.springframework.security.core.AuthenticationException) AuthenticationServiceException(org.springframework.security.authentication.AuthenticationServiceException) IOException(java.io.IOException)

Aggregations

AuthModule (com.evolveum.midpoint.authentication.api.AuthModule)1 AbstractModuleFactory (com.evolveum.midpoint.authentication.impl.factory.module.AbstractModuleFactory)1 IOException (java.io.IOException)1 ServletException (javax.servlet.ServletException)1 AuthenticationServiceException (org.springframework.security.authentication.AuthenticationServiceException)1 AuthenticationException (org.springframework.security.core.AuthenticationException)1