Search in sources :

Example 1 with AuthenticationsPolicyType

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

the class TestAuthSequenceUtil method TestGetSequenceByEmptyNodeGroups.

@Test
public void TestGetSequenceByEmptyNodeGroups() {
    AuthenticationsPolicyType authenticationPolicy = new AuthenticationsPolicyType();
    authenticationPolicy.getSequence().addAll(getSequences());
    List<AuthenticationSequenceType> sequences = AuthSequenceUtil.getSequencesForNodeGroups(new ArrayList<>(), authenticationPolicy);
    assertEquals("Wrong sequences", 1, sequences.size());
}
Also used : AuthenticationSequenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.AuthenticationSequenceType) AuthenticationsPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.AuthenticationsPolicyType) AbstractHigherUnitTest(com.evolveum.midpoint.test.AbstractHigherUnitTest) Test(org.testng.annotations.Test)

Example 2 with AuthenticationsPolicyType

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

the class TestAuthSequenceUtil method TestGetSequenceByNodeGroups.

@Test
public void TestGetSequenceByNodeGroups() {
    AuthenticationsPolicyType authenticationPolicy = new AuthenticationsPolicyType();
    authenticationPolicy.getSequence().addAll(getSequences());
    List<ObjectReferenceType> nodeGroups = new ArrayList<>();
    nodeGroups.add(getReference("1"));
    nodeGroups.add(getReference("2"));
    List<AuthenticationSequenceType> sequences = AuthSequenceUtil.getSequencesForNodeGroups(nodeGroups, authenticationPolicy);
    assertEquals("Wrong sequences", 3, sequences.size());
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) AuthenticationSequenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.AuthenticationSequenceType) ArrayList(java.util.ArrayList) AuthenticationsPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.AuthenticationsPolicyType) AbstractHigherUnitTest(com.evolveum.midpoint.test.AbstractHigherUnitTest) Test(org.testng.annotations.Test)

Example 3 with AuthenticationsPolicyType

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

the class TestAuthSequenceUtil method TestGetSequenceByNodeGroup.

@Test
public void TestGetSequenceByNodeGroup() {
    AuthenticationsPolicyType authenticationPolicy = new AuthenticationsPolicyType();
    authenticationPolicy.getSequence().addAll(getSequences());
    List<ObjectReferenceType> nodeGroups = new ArrayList<>();
    nodeGroups.add(getReference("2"));
    List<AuthenticationSequenceType> sequences = AuthSequenceUtil.getSequencesForNodeGroups(nodeGroups, authenticationPolicy);
    assertEquals("Wrong sequences", 2, sequences.size());
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) AuthenticationSequenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.AuthenticationSequenceType) ArrayList(java.util.ArrayList) AuthenticationsPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.AuthenticationsPolicyType) AbstractHigherUnitTest(com.evolveum.midpoint.test.AbstractHigherUnitTest) Test(org.testng.annotations.Test)

Example 4 with AuthenticationsPolicyType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AuthenticationsPolicyType 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)4 AuthenticationsPolicyType (com.evolveum.midpoint.xml.ns._public.common.common_3.AuthenticationsPolicyType)4 AbstractHigherUnitTest (com.evolveum.midpoint.test.AbstractHigherUnitTest)3 Test (org.testng.annotations.Test)3 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)2 ArrayList (java.util.ArrayList)2 AuthModule (com.evolveum.midpoint.authentication.api.AuthModule)1 AuthenticationChannel (com.evolveum.midpoint.authentication.api.AuthenticationChannel)1 MidpointAuthentication (com.evolveum.midpoint.authentication.api.config.MidpointAuthentication)1 ModuleAuthenticationImpl (com.evolveum.midpoint.authentication.impl.module.authentication.ModuleAuthenticationImpl)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1 Authentication (org.springframework.security.core.Authentication)1