Search in sources :

Example 6 with AuthenticationSequenceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AuthenticationSequenceType in project midpoint by Evolveum.

the class MidpointAnonymousAuthenticationFilter method createAuthentication.

protected Authentication createAuthentication(HttpServletRequest request) {
    Authentication auth = createBasicAuthentication(request);
    MidpointAuthentication authentication = new MidpointAuthentication(SecurityPolicyUtil.createDefaultSequence());
    AuthenticationsPolicyType authenticationsPolicy;
    try {
        authenticationsPolicy = SecurityPolicyUtil.createDefaultAuthenticationPolicy(NO_CUSTOM_IGNORED_LOCAL_PATH, prismContext.getSchemaRegistry());
    } catch (SchemaException e) {
        LOGGER.error("Couldn't get default authentication policy");
        throw new IllegalArgumentException("Couldn't get default authentication policy", e);
    }
    AuthenticationSequenceType sequence = SecurityPolicyUtil.createDefaultSequence();
    AuthenticationChannel authenticationChannel = AuthSequenceUtil.buildAuthChannel(authChannelRegistry, sequence);
    List<AuthModule> authModules = AuthSequenceUtil.buildModuleFilters(authRegistry, sequence, request, authenticationsPolicy.getModules(), null, new HashMap<>(), authenticationChannel);
    authentication.setAuthModules(authModules);
    if (authModules != null) {
        ModuleAuthenticationImpl module = (ModuleAuthenticationImpl) authModules.get(0).getBaseModuleAuthentication();
        module.setAuthentication(auth);
        authentication.addAuthentications(module);
    }
    authentication.setPrincipal(auth.getPrincipal());
    return authentication;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ModuleAuthenticationImpl(com.evolveum.midpoint.authentication.impl.module.authentication.ModuleAuthenticationImpl) AuthenticationChannel(com.evolveum.midpoint.authentication.api.AuthenticationChannel) MidpointAuthentication(com.evolveum.midpoint.authentication.api.config.MidpointAuthentication) Authentication(org.springframework.security.core.Authentication) AuthenticationSequenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.AuthenticationSequenceType) AuthModule(com.evolveum.midpoint.authentication.api.AuthModule) AuthenticationsPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.AuthenticationsPolicyType) MidpointAuthentication(com.evolveum.midpoint.authentication.api.config.MidpointAuthentication)

Aggregations

AuthenticationSequenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.AuthenticationSequenceType)6 AuthenticationsPolicyType (com.evolveum.midpoint.xml.ns._public.common.common_3.AuthenticationsPolicyType)4 AbstractHigherUnitTest (com.evolveum.midpoint.test.AbstractHigherUnitTest)3 ArrayList (java.util.ArrayList)3 Test (org.testng.annotations.Test)3 MidpointAuthentication (com.evolveum.midpoint.authentication.api.config.MidpointAuthentication)2 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)2 Authentication (org.springframework.security.core.Authentication)2 AuthModule (com.evolveum.midpoint.authentication.api.AuthModule)1 AuthenticationChannel (com.evolveum.midpoint.authentication.api.AuthenticationChannel)1 ModuleAuthenticationImpl (com.evolveum.midpoint.authentication.impl.module.authentication.ModuleAuthenticationImpl)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1