Search in sources :

Example 91 with SysSchemaAttributeDto

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

the class IdentityProvisioningTest method testAssignedRolesForSystem.

@Test
public void testAssignedRolesForSystem() {
    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_FOR_SYSTEM_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);
    IdmIdentityRoleDto identityRoleWithSystem = helper.createIdentityRole(identity, roleWithSystem, null, null);
    IdmIdentityRoleFilter identityRoleFilter = new IdmIdentityRoleFilter();
    identityRoleFilter.setIdentityId(identity.getId());
    TestResource resource = helper.findResource(identity.getUsername());
    assertNotNull(resource);
    String valueOnResource = resource.getDescrip();
    String result = "";
    IdmFormInstanceDto formInstanceDto = identityRoleService.getRoleAttributeValues(identityRoleWithSystem);
    identityRoleWithSystem.getEavs().clear();
    identityRoleWithSystem.getEavs().add(formInstanceDto);
    result = IdentityProvisioningExecutor.convertToAssignedRoleDto(identityRoleWithSystem).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 SysSchemaAttributeDto

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

the class ComplexHrProcessIntegrationTest method createHrIdentitySystem.

/**
 **********************************************************************************************************
 * ***************************************  SYSTEM INITIALIZATION  ******************************************
 */
/**
 ********** SOURCE HR Identity and Contract systems **************
 */
private void createHrIdentitySystem() {
    getBean().deleteAllResourceData(TestResource.TABLE_NAME);
    // create new system
    SysSystemDto system = accTestHelper.createSystem(TestResource.TABLE_NAME, identitySysName, null, "NAME");
    system.setReadonly(true);
    system.setDisabledProvisioning(true);
    system = systemService.save(system);
    List<IdmFormValueDto> values = new ArrayList<IdmFormValueDto>();
    IdmFormDefinitionDto savedFormDefinition = systemService.getConnectorFormDefinition(system);
    IdmFormValueDto changeLogColumnValue = new IdmFormValueDto(savedFormDefinition.getMappedAttributeByCode("changeLogColumn"));
    changeLogColumnValue.setValue("MODIFIED");
    values.add(changeLogColumnValue);
    formService.saveValues(system, savedFormDefinition, values);
    // generate schema for system
    List<SysSchemaObjectClassDto> objectClasses = systemService.generateSchema(system);
    // Create synchronization mapping
    SysSystemMappingDto syncSystemMapping = new SysSystemMappingDto();
    syncSystemMapping.setName(getHelper().createName());
    syncSystemMapping.setEntityType(SystemEntityType.IDENTITY);
    syncSystemMapping.setOperationType(SystemOperationType.SYNCHRONIZATION);
    syncSystemMapping.setObjectClass(objectClasses.get(0).getId());
    syncSystemMapping = systemMappingService.save(syncSystemMapping);
    SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
    schemaAttributeFilter.setSystemId(system.getId());
    List<SysSchemaAttributeDto> schemaAttributes = schemaAttributeService.find(schemaAttributeFilter, null).getContent();
    for (SysSchemaAttributeDto schemaAttr : schemaAttributes) {
        SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
        attributeMapping.setSchemaAttribute(schemaAttr.getId());
        attributeMapping.setSystemMapping(syncSystemMapping.getId());
        attributeMapping.setEntityAttribute(true);
        // just id, not mapped to attribute
        if (StringUtils.equalsIgnoreCase("__NAME__", schemaAttr.getName())) {
            attributeMapping.setUid(true);
            attributeMapping.setEntityAttribute(false);
            attributeMapping.setName(schemaAttr.getName());
        } else if (StringUtils.equalsIgnoreCase("FIRSTNAME", schemaAttr.getName())) {
            attributeMapping.setName(schemaAttr.getName().toLowerCase());
            attributeMapping.setIdmPropertyName("firstName");
        } else if (StringUtils.equalsIgnoreCase("lastname", schemaAttr.getName())) {
            attributeMapping.setName(schemaAttr.getName().toLowerCase());
            attributeMapping.setIdmPropertyName("lastName");
        } else if (StringUtils.equalsIgnoreCase("TITLE_BEFORE", schemaAttr.getName())) {
            attributeMapping.setName(schemaAttr.getName().toLowerCase());
            attributeMapping.setIdmPropertyName("titleBefore");
        } else if (StringUtils.equalsIgnoreCase("TITLE_AFTER", schemaAttr.getName())) {
            attributeMapping.setName(schemaAttr.getName().toLowerCase());
            attributeMapping.setIdmPropertyName("titleAfter");
        } else if (StringUtils.equalsIgnoreCase("PERSONAL_NUMBER", schemaAttr.getName())) {
            attributeMapping.setName(schemaAttr.getName().toLowerCase());
            attributeMapping.setIdmPropertyName("externalCode");
        } else {
            // skip those undefined
            continue;
        }
        attributeMapping = systemAttributeMappingService.save(attributeMapping);
    }
    // Create default synchronization config
    SysSystemAttributeMappingFilter mapAttrFilt = new SysSystemAttributeMappingFilter();
    mapAttrFilt.setSystemId(system.getId());
    mapAttrFilt.setName("__NAME__");
    SysSystemAttributeMappingDto correlationAttr = systemAttributeMappingService.find(mapAttrFilt, null).getContent().get(0);
    SysSyncIdentityConfigDto syncConfigCustom = new SysSyncIdentityConfigDto();
    syncConfigCustom.setReconciliation(false);
    syncConfigCustom.setCustomFilter(false);
    syncConfigCustom.setSystemMapping(syncSystemMapping.getId());
    syncConfigCustom.setCorrelationAttribute(correlationAttr.getId());
    syncConfigCustom.setName(identitySysName + "-SYNC");
    syncConfigCustom.setLinkedAction(SynchronizationLinkedActionType.UPDATE_ENTITY);
    syncConfigCustom.setUnlinkedAction(SynchronizationUnlinkedActionType.LINK);
    syncConfigCustom.setMissingEntityAction(SynchronizationMissingEntityActionType.CREATE_ENTITY);
    syncConfigCustom.setMissingAccountAction(ReconciliationMissingAccountActionType.IGNORE);
    syncConfigCustom.setStartAutoRoleRec(true);
    syncConfigCustom = (SysSyncIdentityConfigDto) sysSyncConfigService.save(syncConfigCustom);
}
Also used : SysSyncIdentityConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncIdentityConfigDto) SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) ArrayList(java.util.ArrayList) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)

Example 93 with SysSchemaAttributeDto

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

the class AccountManagementTest method createMapping.

private void createMapping(SysSystemDto system, final SysSystemMappingDto entityHandlingResult) {
    SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
    schemaAttributeFilter.setSystemId(system.getId());
    Page<SysSchemaAttributeDto> schemaAttributesPage = schemaAttributeService.find(schemaAttributeFilter, null);
    schemaAttributesPage.forEach(schemaAttr -> {
        if (ATTRIBUTE_NAME.equals(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
            attributeHandlingName.setUid(true);
            attributeHandlingName.setEntityAttribute(true);
            attributeHandlingName.setIdmPropertyName("name");
            attributeHandlingName.setName(schemaAttr.getName());
            attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
            // For provisioning .. we need create UID
            attributeHandlingName.setTransformToResourceScript("return entity.getName();");
            attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
            schemaAttributeMappingService.save(attributeHandlingName);
        } else if ("TYPE".equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
            attributeHandlingName.setIdmPropertyName("roleType");
            attributeHandlingName.setEntityAttribute(true);
            attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
            attributeHandlingName.setName(schemaAttr.getName());
            attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
            schemaAttributeMappingService.save(attributeHandlingName);
        } else if ("PRIORITY".equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
            attributeHandlingName.setIdmPropertyName("priority");
            attributeHandlingName.setEntityAttribute(true);
            attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
            attributeHandlingName.setName(schemaAttr.getName());
            attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
            schemaAttributeMappingService.save(attributeHandlingName);
        } else if ("APPROVE_REMOVE".equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
            attributeHandlingName.setIdmPropertyName("approveRemove");
            attributeHandlingName.setName(schemaAttr.getName());
            attributeHandlingName.setEntityAttribute(true);
            attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
            attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
            schemaAttributeMappingService.save(attributeHandlingName);
        } else if ("MODIFIED".equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
            attributeHandlingName.setIdmPropertyName("changed");
            attributeHandlingName.setName(schemaAttr.getName());
            attributeHandlingName.setEntityAttribute(false);
            attributeHandlingName.setExtendedAttribute(true);
            attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
            attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
            schemaAttributeMappingService.save(attributeHandlingName);
        } else if ("DESCRIPTION".equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
            attributeHandlingName.setIdmPropertyName("description");
            attributeHandlingName.setName(schemaAttr.getName());
            attributeHandlingName.setEntityAttribute(true);
            ;
            attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
            attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
            schemaAttributeMappingService.save(attributeHandlingName);
        }
    });
}
Also used : SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter)

Example 94 with SysSchemaAttributeDto

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

the class AccountManagementTest method createIdentityMapping.

private void createIdentityMapping(SysSystemDto system, final SysSystemMappingDto entityHandlingResult) {
    SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
    schemaAttributeFilter.setSystemId(system.getId());
    Page<SysSchemaAttributeDto> schemaAttributesPage = schemaAttributeService.find(schemaAttributeFilter, null);
    schemaAttributesPage.forEach(schemaAttr -> {
        if (ATTRIBUTE_NAME.equals(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
            attributeMapping.setUid(true);
            attributeMapping.setEntityAttribute(true);
            attributeMapping.setIdmPropertyName("username");
            attributeMapping.setName(schemaAttr.getName());
            attributeMapping.setSchemaAttribute(schemaAttr.getId());
            attributeMapping.setSystemMapping(entityHandlingResult.getId());
            schemaAttributeMappingService.save(attributeMapping);
        } else if ("firstname".equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
            attributeMapping.setIdmPropertyName("firstName");
            attributeMapping.setSchemaAttribute(schemaAttr.getId());
            attributeMapping.setName(schemaAttr.getName());
            attributeMapping.setSystemMapping(entityHandlingResult.getId());
            schemaAttributeMappingService.save(attributeMapping);
        } else if ("lastname".equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
            attributeMapping.setIdmPropertyName("lastName");
            attributeMapping.setName(schemaAttr.getName());
            attributeMapping.setSchemaAttribute(schemaAttr.getId());
            attributeMapping.setSystemMapping(entityHandlingResult.getId());
            schemaAttributeMappingService.save(attributeMapping);
        } else if (ATTRIBUTE_EMAIL.equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
            attributeMapping.setIdmPropertyName("email");
            attributeMapping.setName(schemaAttr.getName());
            attributeMapping.setSchemaAttribute(schemaAttr.getId());
            attributeMapping.setSystemMapping(entityHandlingResult.getId());
            schemaAttributeMappingService.save(attributeMapping);
        }
    });
}
Also used : SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter)

Example 95 with SysSchemaAttributeDto

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

the class ForwardAccountManagementTest method createIdentityMapping.

private void createIdentityMapping(SysSystemDto system, final SysSystemMappingDto entityHandlingResult) {
    SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
    schemaAttributeFilter.setSystemId(system.getId());
    Page<SysSchemaAttributeDto> schemaAttributesPage = schemaAttributeService.find(schemaAttributeFilter, null);
    schemaAttributesPage.forEach(schemaAttr -> {
        if (ATTRIBUTE_NAME.equals(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
            attributeMapping.setUid(true);
            attributeMapping.setEntityAttribute(true);
            attributeMapping.setIdmPropertyName("username");
            attributeMapping.setName(schemaAttr.getName());
            attributeMapping.setSchemaAttribute(schemaAttr.getId());
            attributeMapping.setSystemMapping(entityHandlingResult.getId());
            schemaAttributeMappingService.save(attributeMapping);
        } else if ("firstname".equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
            attributeMapping.setIdmPropertyName("firstName");
            attributeMapping.setSchemaAttribute(schemaAttr.getId());
            attributeMapping.setName(schemaAttr.getName());
            attributeMapping.setSystemMapping(entityHandlingResult.getId());
            schemaAttributeMappingService.save(attributeMapping);
        } else if ("lastname".equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
            attributeMapping.setIdmPropertyName("lastName");
            attributeMapping.setName(schemaAttr.getName());
            attributeMapping.setSchemaAttribute(schemaAttr.getId());
            attributeMapping.setSystemMapping(entityHandlingResult.getId());
            schemaAttributeMappingService.save(attributeMapping);
        } else if (ATTRIBUTE_EMAIL.equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
            attributeMapping.setIdmPropertyName("email");
            attributeMapping.setName(schemaAttr.getName());
            attributeMapping.setSchemaAttribute(schemaAttr.getId());
            attributeMapping.setSystemMapping(entityHandlingResult.getId());
            schemaAttributeMappingService.save(attributeMapping);
        }
    });
}
Also used : SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter)

Aggregations

SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)168 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)119 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)96 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)89 SysSchemaAttributeFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter)86 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)79 Test (org.junit.Test)73 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)52 UUID (java.util.UUID)40 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)39 SysRoleSystemDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto)36 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)35 SysRoleSystemAttributeDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto)34 AttributeMappingStrategyType (eu.bcvsolutions.idm.acc.domain.AttributeMappingStrategyType)28 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)27 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)27 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)26 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)26 Serializable (java.io.Serializable)26 List (java.util.List)25