use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter 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);
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class ComplexHrProcessIntegrationTest method createLdapProvisioningMapping.
private void createLdapProvisioningMapping(SysSystemDto system) {
List<SysSchemaObjectClassDto> objectClasses = systemService.generateSchema(system);
SysSchemaObjectClassDto objectClass = objectClasses.stream().filter(oc -> oc.getObjectClassName().equals("__ACCOUNT__")).findFirst().orElse(null);
SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
schemaAttributeFilter.setSystemId(system.getId());
List<SysSchemaAttributeDto> schemaAttributes = schemaAttributeService.find(schemaAttributeFilter, null).getContent();
// Provisioning mapping
SysSystemMappingDto mapping = new SysSystemMappingDto();
mapping.setName(getHelper().createName());
mapping.setEntityType(SystemEntityType.IDENTITY);
mapping.setOperationType(SystemOperationType.PROVISIONING);
mapping.setObjectClass(objectClass.getId());
mapping = systemMappingService.save(mapping);
ImmutableMap<String, String> mappingConfig = new ImmutableMap.Builder<String, String>().put("mail", IdmIdentity_.email.getName()).put("sn", IdmIdentity_.lastName.getName()).put("givenName", IdmIdentity_.firstName.getName()).put("cn", IdmIdentity_.username.getName()).put("__NAME__", IdmIdentity_.username.getName()).put("title ", IdmIdentity_.titleBefore.getName()).put("__PASSWORD__", "__PASSWORD__").put("initials", "multivalue").build();
for (SysSchemaAttributeDto schemaAttr : schemaAttributes) {
String schemaName = schemaAttr.getName();
if (!mappingConfig.containsKey(schemaName)) {
continue;
}
SysSystemAttributeMappingFilter attrFilt = new SysSystemAttributeMappingFilter();
attrFilt.setName(schemaName);
attrFilt.setSystemId(system.getId());
attrFilt.setOperationType(SystemOperationType.PROVISIONING);
if (systemAttributeMappingService.count(attrFilt) > 0) {
// some attributes are in the schema more than once, skip if already mapped
continue;
}
SysSystemAttributeMappingDto mappingAttr = new SysSystemAttributeMappingDto();
mappingAttr.setName(schemaName);
mappingAttr.setIdmPropertyName(mappingConfig.get(schemaName));
mappingAttr.setSystemMapping(mapping.getId());
mappingAttr.setSchemaAttribute(schemaAttr.getId());
mappingAttr.setEntityAttribute(true);
if ("__NAME__".equals(schemaName)) {
mappingAttr.setUid(true);
mappingAttr.setTransformToResourceScript("return \"uid=\"+attributeValue+\",ou=" + ldapUserOU + "," + ldapBaseOU + "\";");
} else if ("__PASSWORD__".equals(schemaName)) {
mappingAttr.setPasswordAttribute(true);
mappingAttr.setEntityAttribute(false);
mappingAttr.setIdmPropertyName(null);
mappingAttr.setSendAlways(true);
} else if ("initials".equals(schemaName)) {
// used as multivalue merged attr
mappingAttr.setEntityAttribute(false);
mappingAttr.setStrategyType(AttributeMappingStrategyType.MERGE);
mappingAttr = systemAttributeMappingService.save(mappingAttr);
createLdapGroupRoles(system, mappingAttr);
}
systemAttributeMappingService.save(mappingAttr);
}
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemServiceIntegrationTest method createSync.
private AbstractSysSyncConfigDto createSync(SysSystemDto system) {
SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
schemaAttributeFilter.setSystemId(system.getId());
SysSystemMappingDto mappingOrig = helper.getDefaultMapping(system);
SysSystemAttributeMappingFilter attributeMappingFilter = new SysSystemAttributeMappingFilter();
attributeMappingFilter.setSystemMappingId(mappingOrig.getId());
List<SysSystemAttributeMappingDto> attributes = schemaAttributeMappingService.find(attributeMappingFilter, null).getContent();
SysSystemAttributeMappingDto nameAttribute = attributes.stream().filter(attribute -> {
return attribute.getName().equalsIgnoreCase(TestHelper.ATTRIBUTE_MAPPING_NAME);
}).findFirst().get();
SysSystemAttributeMappingDto firstNameAttribute = attributes.stream().filter(attribute -> {
return attribute.getName().equalsIgnoreCase(TestHelper.ATTRIBUTE_MAPPING_FIRSTNAME);
}).findFirst().get();
SysSystemAttributeMappingDto emailAttribute = attributes.stream().filter(attribute -> {
return attribute.getName().equalsIgnoreCase(TestHelper.ATTRIBUTE_MAPPING_EMAIL);
}).findFirst().get();
// create synchronization config
AbstractSysSyncConfigDto syncConfig = new SysSyncIdentityConfigDto();
syncConfig.setCustomFilter(true);
syncConfig.setSystemMapping(mappingOrig.getId());
syncConfig.setCorrelationAttribute(nameAttribute.getId());
syncConfig.setTokenAttribute(firstNameAttribute.getId());
syncConfig.setFilterAttribute(emailAttribute.getId());
syncConfig.setReconciliation(true);
syncConfig.setName(system.getName());
syncConfig.setLinkedAction(SynchronizationLinkedActionType.IGNORE);
syncConfig.setUnlinkedAction(SynchronizationUnlinkedActionType.IGNORE);
syncConfig.setMissingEntityAction(SynchronizationMissingEntityActionType.CREATE_ENTITY);
syncConfig.setMissingAccountAction(ReconciliationMissingAccountActionType.IGNORE);
syncConfig = syncConfigService.save(syncConfig);
return syncConfig;
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemServiceIntegrationTest method duplicateSystemWithSynchronization.
@Test
public void duplicateSystemWithSynchronization() {
String syncName = "test-sync-config";
// create test system
SysSystemDto system = helper.createTestResourceSystem(true);
SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
schemaAttributeFilter.setSystemId(system.getId());
// Number of schema attributes on original system
int numberOfSchemaAttributesOrig = schemaAttributeService.find(schemaAttributeFilter, null).getContent().size();
SysSystemMappingDto mappingOrig = helper.getDefaultMapping(system);
// Number of mapping attributes on original system
int numberOfMappingAttributesOrig = systemAttributeMappingService.findBySystemMapping(mappingOrig).size();
SysSystemAttributeMappingFilter attributeMappingFilter = new SysSystemAttributeMappingFilter();
attributeMappingFilter.setSystemMappingId(mappingOrig.getId());
List<SysSystemAttributeMappingDto> attributes = schemaAttributeMappingService.find(attributeMappingFilter, null).getContent();
SysSystemAttributeMappingDto nameAttribute = attributes.stream().filter(attribute -> {
return attribute.getName().equalsIgnoreCase(TestHelper.ATTRIBUTE_MAPPING_NAME);
}).findFirst().get();
SysSystemAttributeMappingDto firstNameAttribute = attributes.stream().filter(attribute -> {
return attribute.getName().equalsIgnoreCase(TestHelper.ATTRIBUTE_MAPPING_FIRSTNAME);
}).findFirst().get();
SysSystemAttributeMappingDto emailAttribute = attributes.stream().filter(attribute -> {
return attribute.getName().equalsIgnoreCase(TestHelper.ATTRIBUTE_MAPPING_EMAIL);
}).findFirst().get();
// create synchronization config
AbstractSysSyncConfigDto syncConfigDuplicate = new SysSyncIdentityConfigDto();
syncConfigDuplicate.setCustomFilter(true);
syncConfigDuplicate.setSystemMapping(mappingOrig.getId());
syncConfigDuplicate.setCorrelationAttribute(nameAttribute.getId());
syncConfigDuplicate.setTokenAttribute(firstNameAttribute.getId());
syncConfigDuplicate.setFilterAttribute(emailAttribute.getId());
syncConfigDuplicate.setReconciliation(true);
syncConfigDuplicate.setName(syncName);
syncConfigDuplicate.setLinkedAction(SynchronizationLinkedActionType.IGNORE);
syncConfigDuplicate.setUnlinkedAction(SynchronizationUnlinkedActionType.IGNORE);
syncConfigDuplicate.setMissingEntityAction(SynchronizationMissingEntityActionType.CREATE_ENTITY);
syncConfigDuplicate.setMissingAccountAction(ReconciliationMissingAccountActionType.IGNORE);
syncConfigDuplicate = syncConfigService.save(syncConfigDuplicate);
EntityEvent<SysSystemDto> event = new SystemEvent(SystemEventType.DUPLICATE, system);
SysSystemDto duplicatedSystem = systemService.publish(event).getContent();
// check duplicate
systemService.checkSystem(duplicatedSystem);
Assert.assertNotEquals(system.getId(), duplicatedSystem.getId());
schemaAttributeFilter.setSystemId(duplicatedSystem.getId());
// Number of schema attributes on duplicated system
int numberOfSchemaAttributes = schemaAttributeService.find(schemaAttributeFilter, null).getContent().size();
Assert.assertEquals(numberOfSchemaAttributesOrig, numberOfSchemaAttributes);
SysSystemMappingDto mapping = helper.getDefaultMapping(duplicatedSystem);
// Number of mapping attributes on duplicated system
int numberOfMappingAttributes = systemAttributeMappingService.findBySystemMapping(mapping).size();
Assert.assertEquals(numberOfMappingAttributesOrig, numberOfMappingAttributes);
// check synchronization config
SysSyncConfigFilter syncFilter = new SysSyncConfigFilter();
syncFilter.setSystemId(duplicatedSystem.getId());
List<AbstractSysSyncConfigDto> configs = syncConfigService.find(syncFilter, null).getContent();
Assert.assertEquals(1, configs.size());
Assert.assertEquals(1, configs.size());
AbstractSysSyncConfigDto configNew = configs.get(0);
Assert.assertFalse(configNew.isEnabled());
Assert.assertTrue(configNew.isReconciliation());
Assert.assertEquals(syncName, configNew.getName());
Assert.assertTrue(configNew.isCustomFilter());
Assert.assertEquals(syncConfigDuplicate.getLinkedAction(), configNew.getLinkedAction());
Assert.assertEquals(syncConfigDuplicate.getUnlinkedAction(), configNew.getUnlinkedAction());
Assert.assertEquals(syncConfigDuplicate.getMissingEntityAction(), configNew.getMissingEntityAction());
Assert.assertEquals(syncConfigDuplicate.getMissingAccountAction(), configNew.getMissingAccountAction());
SysSystemAttributeMappingDto correlationAtt = schemaAttributeMappingService.get(configNew.getCorrelationAttribute());
SysSystemAttributeMappingDto tokenAtt = schemaAttributeMappingService.get(configNew.getTokenAttribute());
SysSystemAttributeMappingDto filterAtt = schemaAttributeMappingService.get(configNew.getFilterAttribute());
Assert.assertEquals(nameAttribute.getName(), correlationAtt.getName());
Assert.assertEquals(nameAttribute.getIdmPropertyName(), correlationAtt.getIdmPropertyName());
Assert.assertEquals(firstNameAttribute.getName(), tokenAtt.getName());
Assert.assertEquals(firstNameAttribute.getIdmPropertyName(), tokenAtt.getIdmPropertyName());
Assert.assertEquals(emailAttribute.getName(), filterAtt.getName());
Assert.assertEquals(emailAttribute.getIdmPropertyName(), filterAtt.getIdmPropertyName());
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class DefaultUniformPasswordManagerIntegrationTest method doCreateSyncConfig.
public AbstractSysSyncConfigDto doCreateSyncConfig(SysSystemDto system, IdmTreeTypeDto treeType) {
SysSystemMappingFilter mappingFilter = new SysSystemMappingFilter();
mappingFilter.setEntityType(SystemEntityType.CONTRACT);
mappingFilter.setSystemId(system.getId());
mappingFilter.setOperationType(SystemOperationType.SYNCHRONIZATION);
List<SysSystemMappingDto> mappings = systemMappingService.find(mappingFilter, null).getContent();
Assert.assertEquals(1, mappings.size());
SysSystemMappingDto mapping = mappings.get(0);
SysSystemAttributeMappingFilter attributeMappingFilter = new SysSystemAttributeMappingFilter();
attributeMappingFilter.setSystemMappingId(mapping.getId());
List<SysSystemAttributeMappingDto> attributes = schemaAttributeMappingService.find(attributeMappingFilter, null).getContent();
SysSystemAttributeMappingDto uidAttribute = attributes.stream().filter(attribute -> {
return attribute.isUid();
}).findFirst().orElse(null);
// Create default synchronization config
SysSyncContractConfigDto syncConfigCustom = new SysSyncContractConfigDto();
syncConfigCustom.setReconciliation(true);
syncConfigCustom.setCustomFilter(false);
syncConfigCustom.setSystemMapping(mapping.getId());
syncConfigCustom.setCorrelationAttribute(uidAttribute.getId());
syncConfigCustom.setName(this.getHelper().createName());
syncConfigCustom.setLinkedAction(SynchronizationLinkedActionType.UPDATE_ENTITY);
syncConfigCustom.setUnlinkedAction(SynchronizationUnlinkedActionType.LINK_AND_UPDATE_ENTITY);
syncConfigCustom.setMissingEntityAction(SynchronizationMissingEntityActionType.CREATE_ENTITY);
syncConfigCustom.setMissingAccountAction(ReconciliationMissingAccountActionType.IGNORE);
syncConfigCustom.setStartOfHrProcesses(true);
syncConfigCustom.setStartAutoRoleRec(true);
if (treeType != null) {
syncConfigCustom.setDefaultTreeType(treeType.getId());
}
syncConfigCustom = (SysSyncContractConfigDto) syncConfigService.save(syncConfigCustom);
SysSyncConfigFilter configFilter = new SysSyncConfigFilter();
configFilter.setSystemId(system.getId());
Assert.assertEquals(1, syncConfigService.find(configFilter, null).getTotalElements());
return syncConfigCustom;
}
Aggregations