Search in sources :

Example 91 with SysSystemMappingDto

use of eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto in project CzechIdMng by bcvsolutions.

the class IdentityProvisioningTest method testAssignedRoles.

@Test
public void testAssignedRoles() {
    SysSystemDto systemDto = helper.createTestResourceSystem(true);
    SysSystemMappingDto defaultMapping = helper.getDefaultMapping(systemDto);
    SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
    schemaAttributeFilter.setSystemId(systemDto.getId());
    List<SysSchemaAttributeDto> schemaAttributes = schemaAttributeService.find(schemaAttributeFilter, null).getContent();
    SysSchemaAttributeDto descriptionSchemaAttribute = schemaAttributes.stream().filter(attribute -> TestHelper.ATTRIBUTE_MAPPING_DESCRIPTION.equalsIgnoreCase(attribute.getName())).findFirst().get();
    SysSystemAttributeMappingDto attributeAssignedRoles = new SysSystemAttributeMappingDto();
    attributeAssignedRoles.setUid(false);
    attributeAssignedRoles.setEntityAttribute(true);
    attributeAssignedRoles.setIdmPropertyName(IdentityProvisioningExecutor.ASSIGNED_ROLES_FIELD);
    attributeAssignedRoles.setTransformToResourceScript("if(attributeValue == null) " + System.lineSeparator() + "{return null;}" + System.lineSeparator() + " String result = '';" + System.lineSeparator() + " for(Object assignedRole : attributeValue)" + System.lineSeparator() + " {result = result + (assignedRole.toString())};" + System.lineSeparator() + " return result;");
    attributeAssignedRoles.setName(descriptionSchemaAttribute.getName());
    attributeAssignedRoles.setSchemaAttribute(descriptionSchemaAttribute.getId());
    attributeAssignedRoles.setSystemMapping(defaultMapping.getId());
    schemaAttributeMappingService.save(attributeAssignedRoles);
    IdmRoleDto roleWithSystem = helper.createRole();
    IdmRoleDto roleWithOutSystem = helper.createRole();
    helper.createRoleSystem(roleWithSystem, systemDto);
    IdmIdentityDto identity = helper.createIdentity();
    helper.createIdentityRole(identity, roleWithOutSystem, null, null);
    helper.createIdentityRole(identity, roleWithSystem, null, null);
    IdmIdentityRoleFilter identityRoleFilter = new IdmIdentityRoleFilter();
    identityRoleFilter.setIdentityId(identity.getId());
    List<IdmIdentityRoleDto> identityRoles = identityRoleService.find(identityRoleFilter, PageRequest.of(0, Integer.MAX_VALUE, Sort.by(IdmIdentityRole_.created.getName()))).getContent();
    TestResource resource = helper.findResource(identity.getUsername());
    assertNotNull(resource);
    String valueOnResource = resource.getDescrip();
    String result = "";
    for (IdmIdentityRoleDto identityRole : identityRoles) {
        IdmFormInstanceDto formInstanceDto = identityRoleService.getRoleAttributeValues(identityRole);
        identityRole.getEavs().clear();
        identityRole.getEavs().add(formInstanceDto);
        result = result + IdentityProvisioningExecutor.convertToAssignedRoleDto(identityRole).toString();
    }
    assertEquals(result, valueOnResource);
}
Also used : IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) IdmIdentityRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 92 with SysSystemMappingDto

use of eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto in project CzechIdMng by bcvsolutions.

the class PerformanceAccountManagementTest method testAcmPerformanceAdd200One.

@Ignore
@Test
public void testAcmPerformanceAdd200One() {
    SysSystemDto system = initIdentityData();
    Assert.assertNotNull(system);
    SysSystemMappingDto mapping = systemMappingService.findProvisioningMapping(system.getId(), SystemEntityType.IDENTITY);
    Assert.assertNotNull(mapping);
    mapping = systemMappingService.save(mapping);
    IdmIdentityDto identity = identityService.getByUsername(IDENTITY_PERFORMANCE);
    boolean first = false;
    if (identity == null) {
        identity = helper.createIdentity(IDENTITY_PERFORMANCE);
        first = true;
    }
    AccIdentityAccountFilter roleAccountFilter = new AccIdentityAccountFilter();
    roleAccountFilter.setEntityId(identity.getId());
    roleAccountFilter.setOwnership(Boolean.TRUE);
    List<AccIdentityAccountDto> identityAccounts = identityAccountService.find(roleAccountFilter, null).getContent();
    List<IdmRoleDto> roles = this.createRolesWithSystem(system, 200);
    IdmIdentityContractDto primeContract = identityContractService.getPrimeContract(identity.getId());
    Date startAcm = new Date();
    IdmRoleRequestDto request = helper.createRoleRequest(primeContract, roles.toArray(new IdmRoleDto[0]));
    helper.executeRequest(request, false, true);
    Date endAcm = new Date();
    System.out.println("testAcmPerformance200One - ACM duration: " + (endAcm.getTime() - startAcm.getTime()));
    identityAccounts = identityAccountService.find(roleAccountFilter, null).getContent();
    if (first) {
        Assert.assertEquals(200, identityAccounts.size());
    } else {
        Assert.assertEquals(400, identityAccounts.size());
    }
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) Date(java.util.Date) Ignore(org.junit.Ignore) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 93 with SysSystemMappingDto

use of eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto in project CzechIdMng by bcvsolutions.

the class MappingContextTest method testMappingContextIdentityRolesForSystem.

@Test
public void testMappingContextIdentityRolesForSystem() {
    SysSystemDto system = helper.createTestResourceSystem(true);
    Assert.assertNotNull(system);
    SysSystemMappingDto mapping = systemMappingService.findProvisioningMapping(system.getId(), SystemEntityType.IDENTITY);
    Assert.assertNotNull(mapping);
    // Create the description attribute (print context as string).
    createDescriptionAttribute(system, mapping);
    // Set context transformation to the mapping.
    // Add identity roles for this system to the context.
    mapping.setAddContextIdentityRolesForSystem(true);
    mapping = initContextForMapping(mapping);
    IdmRoleDto roleWithSystem = helper.createRole();
    IdmRoleDto roleWithoutSystem = helper.createRole();
    helper.createRoleSystem(roleWithSystem, system);
    IdmIdentityDto identity = helper.createIdentity();
    helper.createIdentityRole(identity, roleWithoutSystem, null, null);
    IdmIdentityRoleDto identityRoleWithSystem = helper.createIdentityRole(identity, roleWithSystem, null, null);
    IdmIdentityRoleFilter identityRoleFilter = new IdmIdentityRoleFilter();
    identityRoleFilter.setIdentityId(identity.getId());
    List<IdmIdentityRoleDto> identityRoles = identityRoleService.find(identityRoleFilter, PageRequest.of(0, Integer.MAX_VALUE, Sort.by(IdmIdentityRole_.created.getName()))).getContent();
    Assert.assertEquals(2, identityRoles.size());
    TestResource resource = helper.findResource(identity.getUsername());
    assertNotNull(resource);
    assertEquals(identity.getFirstName(), resource.getFirstname());
    MappingContext context = new MappingContext();
    context.put("test", "TestValueOne");
    context.setIdentityRolesForSystem(Lists.newArrayList(identityRoleWithSystem));
    assertEquals(context.toString(), resource.getDescrip());
    // Delete role mapping
    systemMappingService.delete(mapping);
}
Also used : MappingContext(eu.bcvsolutions.idm.acc.domain.MappingContext) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmIdentityRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 94 with SysSystemMappingDto

use of eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto in project CzechIdMng by bcvsolutions.

the class IdentityRoleValidRequestSchedulerTest method createAndSaveSystemWithMapping.

private SysSystemDto createAndSaveSystemWithMapping() {
    system = null;
    systemMapping = null;
    SysSystemAttributeMappingDto nameAttributeMapping = null;
    SysSystemAttributeMappingDto firstNameAttributeMapping = null;
    SysSystemAttributeMappingDto lastNameAttributeMapping = null;
    SysSystemAttributeMappingDto passwordAttributeMapping = null;
    // prepare test system
    system = helper.createSystem(TestResource.TABLE_NAME);
    // generate schema
    List<SysSchemaObjectClassDto> objectClasses = systemService.generateSchema(system);
    // create test mapping
    systemMapping = new SysSystemMappingDto();
    systemMapping.setName("default_" + System.currentTimeMillis());
    systemMapping.setEntityType(SystemEntityType.IDENTITY);
    systemMapping.setOperationType(SystemOperationType.PROVISIONING);
    systemMapping.setObjectClass(objectClasses.get(0).getId());
    systemMapping = mappingService.save(systemMapping);
    SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
    schemaAttributeFilter.setSystemId(system.getId());
    Page<SysSchemaAttributeDto> schemaAttributesPage = schemaAttributeService.find(schemaAttributeFilter, null);
    for (SysSchemaAttributeDto schemaAttr : schemaAttributesPage) {
        if ("__NAME__".equals(schemaAttr.getName())) {
            nameAttributeMapping = new SysSystemAttributeMappingDto();
            nameAttributeMapping.setUid(true);
            nameAttributeMapping.setEntityAttribute(true);
            nameAttributeMapping.setIdmPropertyName("username");
            nameAttributeMapping.setName(schemaAttr.getName());
            nameAttributeMapping.setSchemaAttribute(schemaAttr.getId());
            nameAttributeMapping.setSystemMapping(systemMapping.getId());
            nameAttributeMapping = attributeMappingService.save(nameAttributeMapping);
        } else if ("firstname".equalsIgnoreCase(schemaAttr.getName())) {
            firstNameAttributeMapping = new SysSystemAttributeMappingDto();
            firstNameAttributeMapping.setIdmPropertyName("firstName");
            firstNameAttributeMapping.setSchemaAttribute(schemaAttr.getId());
            firstNameAttributeMapping.setName(schemaAttr.getName());
            firstNameAttributeMapping.setSystemMapping(systemMapping.getId());
            firstNameAttributeMapping = attributeMappingService.save(firstNameAttributeMapping);
        } else if ("lastname".equalsIgnoreCase(schemaAttr.getName())) {
            lastNameAttributeMapping = new SysSystemAttributeMappingDto();
            lastNameAttributeMapping.setIdmPropertyName("lastName");
            lastNameAttributeMapping.setName(schemaAttr.getName());
            lastNameAttributeMapping.setSchemaAttribute(schemaAttr.getId());
            lastNameAttributeMapping.setSystemMapping(systemMapping.getId());
            lastNameAttributeMapping = attributeMappingService.save(lastNameAttributeMapping);
        } else if (IcConnectorFacade.PASSWORD_ATTRIBUTE_NAME.equalsIgnoreCase(schemaAttr.getName())) {
            passwordAttributeMapping = new SysSystemAttributeMappingDto();
            passwordAttributeMapping.setIdmPropertyName("password");
            passwordAttributeMapping.setSchemaAttribute(schemaAttr.getId());
            passwordAttributeMapping.setName(schemaAttr.getName());
            passwordAttributeMapping.setSystemMapping(systemMapping.getId());
            passwordAttributeMapping = attributeMappingService.save(passwordAttributeMapping);
        }
    }
    assertNotNull(system);
    assertNotNull(nameAttributeMapping);
    assertNotNull(firstNameAttributeMapping);
    assertNotNull(lastNameAttributeMapping);
    assertNotNull(passwordAttributeMapping);
    return system;
}
Also used : SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)

Example 95 with SysSystemMappingDto

use of eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto in project CzechIdMng by bcvsolutions.

the class DefaultAccAuthenticatorTest method initData.

private void initData() {
    SysSystemDto system = createTestSystem();
    List<SysSchemaObjectClassDto> objectClasses = sysSystemService.generateSchema(system);
    IdmIdentityDto identity = new IdmIdentityDto();
    identity.setUsername(USERNAME);
    identity.setLastName(USERNAME);
    identity.setPassword(new GuardedString(PASSWORD));
    identity = identityService.save(identity);
    // Create mapped attributes to schema
    SysSystemMappingDto systemMapping = new SysSystemMappingDto();
    systemMapping.setName("default_" + System.currentTimeMillis());
    systemMapping.setEntityType(SystemEntityType.IDENTITY);
    systemMapping.setOperationType(SystemOperationType.PROVISIONING);
    systemMapping.setObjectClass(objectClasses.get(0).getId());
    final SysSystemMappingDto entityHandlingResult = systemEntityHandlingService.save(systemMapping);
    SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
    schemaAttributeFilter.setSystemId(system.getId());
    SysSystemAttributeMappingDto attributeHandlingLastName = new SysSystemAttributeMappingDto();
    SysSystemAttributeMappingDto attributeHandlingPassword = new SysSystemAttributeMappingDto();
    SysSystemAttributeMappingDto attributeHandlingUsername = new SysSystemAttributeMappingDto();
    Page<SysSchemaAttributeDto> schemaAttributesPage = schemaAttributeService.find(schemaAttributeFilter, null);
    for (SysSchemaAttributeDto schemaAttr : schemaAttributesPage) {
        if ("__NAME__".equals(schemaAttr.getName())) {
            attributeHandlingUsername.setUid(true);
            attributeHandlingUsername.setEntityAttribute(true);
            attributeHandlingUsername.setAuthenticationAttribute(true);
            attributeHandlingUsername.setIdmPropertyName("username");
            attributeHandlingUsername.setTransformToResourceScript("if(attributeValue){return \"x\"+ attributeValue;}");
            attributeHandlingUsername.setName(schemaAttr.getName());
            attributeHandlingUsername.setSchemaAttribute(schemaAttr.getId());
            attributeHandlingUsername.setSystemMapping(entityHandlingResult.getId());
            attributeHandlingUsername = schemaAttributeHandlingService.save(attributeHandlingUsername);
        } else if ("lastname".equalsIgnoreCase(schemaAttr.getName())) {
            attributeHandlingLastName.setIdmPropertyName("lastName");
            attributeHandlingLastName.setName(schemaAttr.getName());
            attributeHandlingLastName.setSchemaAttribute(schemaAttr.getId());
            attributeHandlingLastName.setSystemMapping(entityHandlingResult.getId());
            attributeHandlingLastName = schemaAttributeHandlingService.save(attributeHandlingLastName);
        } else if (IcConnectorFacade.PASSWORD_ATTRIBUTE_NAME.equalsIgnoreCase(schemaAttr.getName())) {
            attributeHandlingPassword.setIdmPropertyName("password");
            attributeHandlingPassword.setSchemaAttribute(schemaAttr.getId());
            attributeHandlingPassword.setName(schemaAttr.getName());
            attributeHandlingPassword.setSystemMapping(entityHandlingResult.getId());
            attributeHandlingPassword = schemaAttributeHandlingService.save(attributeHandlingPassword);
        }
    }
    // create two roles with same system and different override username
    IdmRoleDto role1 = getHelper().createRole(ROLE_NAME);
    SysRoleSystemDto role1System = new SysRoleSystemDto();
    role1System.setRole(role1.getId());
    role1System.setSystem(system.getId());
    role1System.setSystemMapping(entityHandlingResult.getId());
    role1System = roleSystemService.save(role1System);
    IdmRoleDto role2 = getHelper().createRole(ROLE_NAME + "2");
    role2 = roleService.save(role2);
    SysRoleSystemDto roleSystem2 = new SysRoleSystemDto();
    roleSystem2.setSystem(system.getId());
    roleSystem2.setSystemMapping(entityHandlingResult.getId());
    roleSystem2.setRole(role2.getId());
    roleSystem2 = roleSystemService.save(roleSystem2);
    SysRoleSystemAttributeDto overloadedRole2 = new SysRoleSystemAttributeDto();
    overloadedRole2.setSystemAttributeMapping(attributeHandlingUsername.getId());
    overloadedRole2.setUid(true);
    overloadedRole2.setEntityAttribute(true);
    overloadedRole2.setTransformScript("return \"z" + USERNAME + "\";");
    overloadedRole2.setIdmPropertyName("username");
    overloadedRole2.setName("username");
    overloadedRole2.setRoleSystem(roleSystem2.getId());
    overloadedRole2 = roleSystemAttributeService.save(overloadedRole2);
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SysRoleSystemAttributeDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)

Aggregations

SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)359 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)269 Test (org.junit.Test)208 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)180 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)172 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)134 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)106 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)95 SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)90 SysSystemMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter)89 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)80 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)70 UUID (java.util.UUID)60 SysSchemaAttributeFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter)58 SysRoleSystemDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto)56 SysSyncConfigFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter)42 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)38 TestResource (eu.bcvsolutions.idm.acc.entity.TestResource)38 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)36 SysRoleSystemAttributeDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto)36