Search in sources :

Example 1 with IdentityTypesRegistry

use of pl.edu.icm.unity.engine.api.identity.IdentityTypesRegistry in project unity by unity-idm.

the class TestInputMapActions method testMapIdentity.

@Test
public void testMapIdentity() throws EngineException {
    IdentityTypesRegistry idTypesReg = mock(IdentityTypesRegistry.class);
    when(idTypesReg.getByName("userName")).thenReturn(new UsernameIdentity());
    ExternalDataParser parser = mock(ExternalDataParser.class);
    IdentityParam id = new IdentityParam("userName", "a1-a2-idvalue");
    when(parser.parseAsIdentity(any(), eq(id.getValue()), any(), any())).thenReturn(id);
    MapIdentityActionFactory factory = new MapIdentityActionFactory(idTypesReg, parser);
    InputTranslationAction mapAction = factory.getInstance("userName", "attr['attribute:colon'] + '-' + attr['other'] + '-' + id", "CR", IdentityEffectMode.REQUIRE_MATCH.toString());
    RemotelyAuthenticatedInput input = new RemotelyAuthenticatedInput("test");
    input.addIdentity(new RemoteIdentity("idvalue", "idtype"));
    input.addAttribute(new RemoteAttribute("attribute:colon", "a1"));
    input.addAttribute(new RemoteAttribute("other", "a2"));
    MappingResult result = mapAction.invoke(input, InputTranslationContextFactory.createMvelContext(input), "testProf");
    MappedIdentity mi = result.getIdentities().get(0);
    assertEquals("CR", mi.getCredentialRequirement());
    assertEquals(IdentityEffectMode.REQUIRE_MATCH, mi.getMode());
    assertThat(mi.getIdentity()).isEqualTo(id);
}
Also used : MapIdentityActionFactory(pl.edu.icm.unity.engine.translation.in.action.MapIdentityActionFactory) IdentityTypesRegistry(pl.edu.icm.unity.engine.api.identity.IdentityTypesRegistry) MappingResult(pl.edu.icm.unity.engine.api.translation.in.MappingResult) IdentityParam(pl.edu.icm.unity.types.basic.IdentityParam) RemotelyAuthenticatedInput(pl.edu.icm.unity.engine.api.authn.remote.RemotelyAuthenticatedInput) RemoteIdentity(pl.edu.icm.unity.engine.api.authn.remote.RemoteIdentity) ExternalDataParser(pl.edu.icm.unity.engine.api.translation.ExternalDataParser) MappedIdentity(pl.edu.icm.unity.engine.api.translation.in.MappedIdentity) UsernameIdentity(pl.edu.icm.unity.stdext.identity.UsernameIdentity) InputTranslationAction(pl.edu.icm.unity.engine.api.translation.in.InputTranslationAction) RemoteAttribute(pl.edu.icm.unity.engine.api.authn.remote.RemoteAttribute) Test(org.junit.Test)

Example 2 with IdentityTypesRegistry

use of pl.edu.icm.unity.engine.api.identity.IdentityTypesRegistry in project unity by unity-idm.

the class BaseRequestPreprocessorTest method buildPreprocessor.

private BaseRequestPreprocessor buildPreprocessor(EntityResolver entityResolver) {
    IdentityTypesRegistry idTypesReg = mock(IdentityTypesRegistry.class);
    when(idTypesReg.getByName(eq(UsernameIdentity.ID))).thenReturn(new UsernameIdentity());
    return new BaseRequestPreprocessor(mock(CredentialRepository.class), mock(AttributeTypeDAO.class), mock(GroupDAO.class), mock(AttributesHelper.class), mock(AttributeTypeHelper.class), entityResolver, idTypesReg, mock(LocalCredentialsRegistry.class), mock(InvitationDB.class));
}
Also used : AttributeTypeHelper(pl.edu.icm.unity.engine.attribute.AttributeTypeHelper) AttributeTypeDAO(pl.edu.icm.unity.store.api.AttributeTypeDAO) IdentityTypesRegistry(pl.edu.icm.unity.engine.api.identity.IdentityTypesRegistry) LocalCredentialsRegistry(pl.edu.icm.unity.engine.api.authn.local.LocalCredentialsRegistry) UsernameIdentity(pl.edu.icm.unity.stdext.identity.UsernameIdentity) CredentialRepository(pl.edu.icm.unity.engine.credential.CredentialRepository) AttributesHelper(pl.edu.icm.unity.engine.attribute.AttributesHelper) GroupDAO(pl.edu.icm.unity.store.api.GroupDAO) InvitationDB(pl.edu.icm.unity.store.api.generic.InvitationDB)

Aggregations

IdentityTypesRegistry (pl.edu.icm.unity.engine.api.identity.IdentityTypesRegistry)2 UsernameIdentity (pl.edu.icm.unity.stdext.identity.UsernameIdentity)2 Test (org.junit.Test)1 LocalCredentialsRegistry (pl.edu.icm.unity.engine.api.authn.local.LocalCredentialsRegistry)1 RemoteAttribute (pl.edu.icm.unity.engine.api.authn.remote.RemoteAttribute)1 RemoteIdentity (pl.edu.icm.unity.engine.api.authn.remote.RemoteIdentity)1 RemotelyAuthenticatedInput (pl.edu.icm.unity.engine.api.authn.remote.RemotelyAuthenticatedInput)1 ExternalDataParser (pl.edu.icm.unity.engine.api.translation.ExternalDataParser)1 InputTranslationAction (pl.edu.icm.unity.engine.api.translation.in.InputTranslationAction)1 MappedIdentity (pl.edu.icm.unity.engine.api.translation.in.MappedIdentity)1 MappingResult (pl.edu.icm.unity.engine.api.translation.in.MappingResult)1 AttributeTypeHelper (pl.edu.icm.unity.engine.attribute.AttributeTypeHelper)1 AttributesHelper (pl.edu.icm.unity.engine.attribute.AttributesHelper)1 CredentialRepository (pl.edu.icm.unity.engine.credential.CredentialRepository)1 MapIdentityActionFactory (pl.edu.icm.unity.engine.translation.in.action.MapIdentityActionFactory)1 AttributeTypeDAO (pl.edu.icm.unity.store.api.AttributeTypeDAO)1 GroupDAO (pl.edu.icm.unity.store.api.GroupDAO)1 InvitationDB (pl.edu.icm.unity.store.api.generic.InvitationDB)1 IdentityParam (pl.edu.icm.unity.types.basic.IdentityParam)1