use of eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto in project CzechIdMng by bcvsolutions.
the class IdentityAccountManagementTest method initData.
private void initData() {
// create test system
SysSystemDto system = helper.createTestResourceSystem(true, SYSTEM_NAME);
//
// Create test identity for provisioning test
IdmIdentityDto identity = new IdmIdentityDto();
identity.setUsername(IDENTITY_USERNAME);
identity.setFirstName(IDENTITY_USERNAME);
identity.setLastName(IDENTITY_USERNAME);
identity.setEmail(IDENTITY_EMAIL);
identity = identityService.save(identity);
// Create mapped attributes to schema
SysSystemMappingDto systemMapping = helper.getDefaultMapping(system);
SysSystemAttributeMappingDto attributeHandlingLastName = schemaAttributeHandlingService.findBySystemMappingAndName(systemMapping.getId(), TestHelper.ATTRIBUTE_MAPPING_LASTNAME);
SysSystemAttributeMappingDto attributeHandlingPassword = schemaAttributeHandlingService.findBySystemMappingAndName(systemMapping.getId(), TestHelper.ATTRIBUTE_MAPPING_PASSWORD);
SysSystemAttributeMappingDto attributeHandlingFirstName = schemaAttributeHandlingService.findBySystemMappingAndName(systemMapping.getId(), TestHelper.ATTRIBUTE_MAPPING_FIRSTNAME);
SysSystemAttributeMappingDto attributeHandlingUserName = schemaAttributeHandlingService.findBySystemMappingAndName(systemMapping.getId(), TestHelper.ATTRIBUTE_MAPPING_NAME);
// username is transformed
attributeHandlingUserName.setTransformToResourceScript("return \"" + "x" + IDENTITY_USERNAME + "\";");
attributeHandlingUserName = schemaAttributeHandlingService.save(attributeHandlingUserName);
/*
* Create role with link on system (default)
*/
IdmRoleDto roleDefault = new IdmRoleDto();
roleDefault.setName(ROLE_DEFAULT);
roleDefault = roleService.save(roleDefault);
SysRoleSystemDto roleSystemDefault = new SysRoleSystemDto();
roleSystemDefault.setRole(roleDefault.getId());
roleSystemDefault.setSystem(system.getId());
roleSystemDefault.setSystemMapping(systemMapping.getId());
roleSystemDefault = roleSystemService.save(roleSystemDefault);
/*
* Create role with link on system (overloading last name attribute)
*/
IdmRoleDto roleOverloadingLastName = new IdmRoleDto();
roleOverloadingLastName.setName(ROLE_OVERLOADING_LAST_NAME);
roleOverloadingLastName = roleService.save(roleOverloadingLastName);
SysRoleSystemDto roleSystemLastName = new SysRoleSystemDto();
roleSystemLastName.setRole(roleOverloadingLastName.getId());
roleSystemLastName.setSystem(system.getId());
roleSystemLastName.setSystemMapping(systemMapping.getId());
roleSystemLastName = roleSystemService.save(roleSystemLastName);
// Attribute for overloading last name attribute
SysRoleSystemAttributeDto attributeLastName = new SysRoleSystemAttributeDto();
attributeLastName.setEntityAttribute(true);
attributeLastName.setIdmPropertyName("email");
attributeLastName.setName("Overloaded lastName with email");
attributeLastName.setRoleSystem(roleSystemLastName.getId());
attributeLastName.setSystemAttributeMapping(attributeHandlingLastName.getId());
attributeLastName = roleSystemAttributeService.save(attributeLastName);
/*
* Create role with link on system (overloading password attribute)
*/
IdmRoleDto roleOverloadingPassword = new IdmRoleDto();
roleOverloadingPassword.setName(ROLE_OVERLOADING_PASSWORD);
roleOverloadingPassword = roleService.save(roleOverloadingPassword);
SysRoleSystemDto roleSystemPassword = new SysRoleSystemDto();
roleSystemPassword.setRole(roleOverloadingPassword.getId());
roleSystemPassword.setSystem(system.getId());
roleSystemPassword.setSystemMapping(systemMapping.getId());
roleSystemPassword = roleSystemService.save(roleSystemPassword);
// Attribute for overloading last name attribute
SysRoleSystemAttributeDto attributePassword = new SysRoleSystemAttributeDto();
attributePassword.setEntityAttribute(true);
attributePassword.setIdmPropertyName("password");
attributePassword.setConfidentialAttribute(true);
attributePassword.setName("Overloaded password - add x");
attributePassword.setRoleSystem(roleSystemPassword.getId());
attributePassword.setSystemAttributeMapping(attributeHandlingPassword.getId());
attributePassword.setTransformScript("return new " + GuardedString.class.getName() + "(\"x\"+attributeValue.asString());");
attributePassword = roleSystemAttributeService.save(attributePassword);
/*
* Create role with link on system (overloading (disable) first name
* attribute)
*/
IdmRoleDto roleOverloadingFirstName = new IdmRoleDto();
roleOverloadingFirstName.setName(ROLE_OVERLOADING_FIRST_NAME);
roleOverloadingFirstName = roleService.save(roleOverloadingFirstName);
SysRoleSystemDto roleSystemFirstName = new SysRoleSystemDto();
roleSystemFirstName.setRole(roleOverloadingFirstName.getId());
roleSystemFirstName.setSystem(system.getId());
roleSystemFirstName.setSystemMapping(systemMapping.getId());
roleSystemFirstName = roleSystemService.save(roleSystemFirstName);
// Attribute for overloading first name attribute (disable him)
SysRoleSystemAttributeDto attributeFirstName = new SysRoleSystemAttributeDto();
attributeFirstName.setDisabledDefaultAttribute(true);
attributeFirstName.setName("Disable first name");
attributeFirstName.setRoleSystem(roleSystemFirstName.getId());
attributeFirstName.setSystemAttributeMapping(attributeHandlingFirstName.getId());
attributeFirstName = roleSystemAttributeService.save(attributeFirstName);
/*
* Create role with link on system (overloading name attribute ...
* create Y account)
*/
IdmRoleDto roleOverloadingName = new IdmRoleDto();
roleOverloadingName.setName(ROLE_OVERLOADING_Y_ACCOUNT);
roleOverloadingName = roleService.save(roleOverloadingName);
SysRoleSystemDto roleSystemName = new SysRoleSystemDto();
roleSystemName.setRole(roleOverloadingName.getId());
roleSystemName.setSystem(system.getId());
roleSystemName.setSystemMapping(systemMapping.getId());
roleSystemName = roleSystemService.save(roleSystemName);
// Attribute for overloading first name attribute (disable him)
SysRoleSystemAttributeDto attributeName = new SysRoleSystemAttributeDto();
attributeName.setUid(true);
attributeName.setEntityAttribute(true);
attributeName.setIdmPropertyName("username");
attributeName.setName("Account with Y-prefix name");
attributeName.setTransformScript("return \"y\" + attributeValue ;");
attributeName.setRoleSystem(roleSystemName.getId());
attributeName.setSystemAttributeMapping(attributeHandlingUserName.getId());
attributeName = roleSystemAttributeService.save(attributeName);
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto 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;
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto in project CzechIdMng by bcvsolutions.
the class DefaultRoleSynchronizationServiceTest 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);
}
});
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto in project CzechIdMng by bcvsolutions.
the class DefaultRoleSynchronizationServiceTest method doCreateSyncConfig.
@Test
@Transactional
public void doCreateSyncConfig() {
initData();
SysSystemMappingFilter mappingFilter = new SysSystemMappingFilter();
mappingFilter.setEntityType(SystemEntityType.ROLE);
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);
SysSystemAttributeMappingDto tokenAttribute = attributes.stream().filter(attribute -> {
return "changed".equals(attribute.getIdmPropertyName());
}).findFirst().orElse(null);
// Create default synchronization config
AbstractSysSyncConfigDto syncConfigCustom = new SysSyncConfigDto();
syncConfigCustom.setReconciliation(false);
syncConfigCustom.setCustomFilter(true);
syncConfigCustom.setSystemMapping(mapping.getId());
syncConfigCustom.setCorrelationAttribute(uidAttribute.getId());
syncConfigCustom.setTokenAttribute(tokenAttribute.getId());
syncConfigCustom.setName(SYNC_CONFIG_NAME);
syncConfigCustom.setLinkedAction(SynchronizationLinkedActionType.IGNORE);
syncConfigCustom.setUnlinkedAction(SynchronizationUnlinkedActionType.IGNORE);
syncConfigCustom.setMissingEntityAction(SynchronizationMissingEntityActionType.CREATE_ENTITY);
syncConfigCustom.setMissingAccountAction(ReconciliationMissingAccountActionType.IGNORE);
syncConfigService.save(syncConfigCustom);
SysSyncConfigFilter configFilter = new SysSyncConfigFilter();
configFilter.setSystemId(system.getId());
Assert.assertEquals(1, syncConfigService.find(configFilter, null).getTotalElements());
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto in project CzechIdMng by bcvsolutions.
the class DefaultSynchronizationServiceTest 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 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);
} else if (IcConnectorFacade.PASSWORD_ATTRIBUTE_NAME.equalsIgnoreCase(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
attributeMapping.setIdmPropertyName("password");
attributeMapping.setSchemaAttribute(schemaAttr.getId());
attributeMapping.setName(schemaAttr.getName());
attributeMapping.setSystemMapping(entityHandlingResult.getId());
schemaAttributeMappingService.save(attributeMapping);
} else if (SystemOperationType.SYNCHRONIZATION == entityHandlingResult.getOperationType() && ATTRIBUTE_MODIFIED.equalsIgnoreCase(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
attributeMapping.setEntityAttribute(false);
attributeMapping.setExtendedAttribute(true);
attributeMapping.setSchemaAttribute(schemaAttr.getId());
attributeMapping.setIdmPropertyName(ATTRIBUTE_MODIFIED);
attributeMapping.setName(ATTRIBUTE_MODIFIED);
attributeMapping.setSystemMapping(entityHandlingResult.getId());
schemaAttributeMappingService.save(attributeMapping);
} else if (schemaAttr.getName().equals(EAV_ATTRIBUTE)) {
SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
attributeMapping.setExtendedAttribute(true);
attributeMapping.setEntityAttribute(false);
attributeMapping.setSchemaAttribute(schemaAttr.getId());
attributeMapping.setIdmPropertyName(EAV_ATTRIBUTE);
attributeMapping.setName(EAV_ATTRIBUTE);
attributeMapping.setSystemMapping(entityHandlingResult.getId());
schemaAttributeMappingService.save(attributeMapping);
}
});
}
Aggregations