use of eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto 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.SysRoleSystemDto in project CzechIdMng by bcvsolutions.
the class CleanProvisioningQueueTaskExecutorIntegrationTest method testLrtWithFilterBatch.
@Test
public void testLrtWithFilterBatch() {
// create identity
IdmIdentityDto person = createIdentity("firstName" + System.currentTimeMillis(), "Surname" + System.currentTimeMillis(), "email" + System.currentTimeMillis() + "@gemail.eu", "000000009", false);
IdmIdentityDto personSecond = createIdentity("firstName" + System.currentTimeMillis(), "Surname" + System.currentTimeMillis(), "email" + System.currentTimeMillis() + "@gemail.eu", "000000009", false);
// create system read only
SysSystemDto system = helper.createTestResourceSystem(true);
system.setReadonly(true);
systemService.save(system);
// create role, "assign" role to system, "assign" role to identity
IdmRoleDto role = helper.createRole();
SysRoleSystemDto roleSystemDefault = helper.createRoleSystem(role, system);
roleSystemDefault.setSystemMapping(helper.getDefaultMapping(system).getId());
roleSystemService.save(roleSystemDefault);
IdmIdentityRoleDto identityRole = helper.createIdentityRole(person, role);
identityRole.setValidFrom(LocalDate.now().plusDays(1));
identityRoleService.save(identityRole);
// create system read only
SysSystemDto systemSecond = helper.createTestResourceSystem(true);
systemSecond.setReadonly(true);
systemService.save(systemSecond);
// create role, "assign" role to system, "assign" role to identity
IdmRoleDto roleSecond = helper.createRole();
SysRoleSystemDto roleSystemDefaultSecond = helper.createRoleSystem(roleSecond, systemSecond);
roleSystemDefaultSecond.setSystemMapping(helper.getDefaultMapping(systemSecond).getId());
roleSystemService.save(roleSystemDefaultSecond);
helper.createIdentityRole(personSecond, roleSecond);
// find items in provisioning queue// first system// 2 provisioning operations, but 1 batch
SysProvisioningOperationFilter filter = new SysProvisioningOperationFilter();
filter.setSystemId(system.getId());
Page<SysProvisioningOperationDto> page = sysProvisioningOperationService.find(filter, null);
Assert.assertEquals(2, page.getContent().size());
// find items in provisioning queue// second system
SysProvisioningOperationFilter filterSecond = new SysProvisioningOperationFilter();
filterSecond.setSystemId(systemSecond.getId());
Page<SysProvisioningOperationDto> pageSecond = sysProvisioningOperationService.find(filterSecond, null);
Assert.assertEquals(1, pageSecond.getContent().size());
UUID batchId = page.getContent().get(0).getBatch();
SysProvisioningBatchDto batch = sysProvisioningBatchService.get(batchId);
assertNotNull(batch);
// find items in provisioning queue
SysProvisioningOperationFilter filterBatch = new SysProvisioningOperationFilter();
filterBatch.setBatchId(batchId);
Page<SysProvisioningOperationDto> pageBatch = sysProvisioningOperationService.find(filterBatch, null);
Assert.assertEquals(2, pageBatch.getContent().size());
// create and start LRT to clean
CancelProvisioningQueueTaskExecutor lrt = new CancelProvisioningQueueTaskExecutor();
//
SysProvisioningOperationFilter filterLrt = new SysProvisioningOperationFilter();
filterLrt.setSystemId(system.getId());
filterLrt.setOperationType(ProvisioningEventType.CREATE);
//
// filter will find just 1 provisioning operation of same batch, but clean both
page = sysProvisioningOperationService.find(filterLrt, null);
Assert.assertEquals(1, page.getContent().size());
lrt.setFilter(filterLrt);
//
longRunningTaskManager.executeSync(lrt);
// items in queue are cleaned
filter = new SysProvisioningOperationFilter();
filter.setSystemId(system.getId());
page = sysProvisioningOperationService.find(filter, null);
Assert.assertEquals(0, page.getContent().size());
batch = sysProvisioningBatchService.get(batchId);
assertNull(batch);
// find items in provisioning queue// both systems
pageSecond = sysProvisioningOperationService.find(filterSecond, null);
Assert.assertEquals(1, pageSecond.getContent().size());
// archive
SysProvisioningOperationFilter filterArchive = new SysProvisioningOperationFilter();
filterArchive.setSystemId(system.getId());
Page<SysProvisioningArchiveDto> archivePage = archiveService.find(filterArchive, null);
// 2 provisioning operation
Assert.assertEquals(2, archivePage.getContent().size());
}
use of eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningServiceTest method compileAttributesOverrloadedSamePriorityTest.
@Test
@Transactional
public void compileAttributesOverrloadedSamePriorityTest() {
List<SysRoleSystemAttributeDto> overloadingAttributes = new ArrayList<>();
List<AttributeMapping> defaultAttributes = new ArrayList<>();
initDataSystem();
initOverloadedAttributes(overloadingAttributes, defaultAttributes);
List<AttributeMapping> compilledAttributes = provisioningService.compileAttributes(defaultAttributes, overloadingAttributes, SystemEntityType.IDENTITY);
Assert.assertEquals(2, compilledAttributes.size());
Assert.assertTrue(compilledAttributes.stream().filter(attribute -> {
return "defOneOverloadedRoleTwo".equals(attribute.getName());
}).findFirst().isPresent());
// set name role One to zroleOne
SysRoleSystemDto roleSystem = roleSystemService.get(overloadingAttributes.get(0).getRoleSystem());
IdmRoleDto roleDto = roleService.get(roleSystem.getRole());
roleDto.setName("zroleOne");
roleDto = roleService.save(roleDto);
roleSystem = roleSystemService.save(roleSystem);
compilledAttributes = provisioningService.compileAttributes(defaultAttributes, overloadingAttributes, SystemEntityType.IDENTITY);
Assert.assertEquals(2, compilledAttributes.size());
Assert.assertTrue(compilledAttributes.stream().filter(attribute -> {
return "defOneOverloaded".equals(attribute.getName());
}).findFirst().isPresent());
// We set role mapping attribute to disabled, then must have higher
// "priority", then role mapping one
// and must missing in result
SysRoleSystemAttributeDto attribute = overloadingAttributes.get(1);
attribute.setDisabledDefaultAttribute(true);
attribute = roleSystemAttributeService.save(attribute);
overloadingAttributes.set(1, attribute);
compilledAttributes = provisioningService.compileAttributes(defaultAttributes, overloadingAttributes, SystemEntityType.IDENTITY);
Assert.assertEquals(1, compilledAttributes.size());
}
use of eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningServiceTest method compileAttributesOverrloadedStrategyMergeAuthoTest.
@Test
@Transactional
public void compileAttributesOverrloadedStrategyMergeAuthoTest() {
List<SysRoleSystemAttributeDto> overloadingAttributes = new ArrayList<>();
List<AttributeMapping> defaultAttributes = new ArrayList<>();
initDataSystem();
initOverloadedAttributes(overloadingAttributes, defaultAttributes);
// roleOne
SysRoleSystemDto roleSystem1 = roleSystemService.get(overloadingAttributes.get(0).getRoleSystem());
IdmRoleDto roleDto = roleService.get(roleSystem1.getRole());
roleDto.setPriority(200);
roleDto = roleService.save(roleDto);
// roleTwo
SysRoleSystemDto roleSystem2 = roleSystemService.get(overloadingAttributes.get(1).getRoleSystem());
roleDto = roleService.get(roleSystem2.getRole());
roleDto.setPriority(100);
roleDto = roleService.save(roleDto);
// overloadedRoleOne
SysRoleSystemAttributeDto attribute1 = overloadingAttributes.get(0);
attribute1.setStrategyType(AttributeMappingStrategyType.AUTHORITATIVE_MERGE);
attribute1 = roleSystemAttributeService.save(attribute1);
overloadingAttributes.set(0, attribute1);
// overloadedRoleTwo
SysRoleSystemAttributeDto attribute2 = overloadingAttributes.get(1);
attribute2.setStrategyType(AttributeMappingStrategyType.AUTHORITATIVE_MERGE);
attribute2 = roleSystemAttributeService.save(attribute2);
overloadingAttributes.set(1, attribute2);
List<AttributeMapping> compilledAttributes = provisioningService.compileAttributes(defaultAttributes, overloadingAttributes, SystemEntityType.IDENTITY);
Assert.assertEquals(3, compilledAttributes.size());
Assert.assertTrue(compilledAttributes.stream().filter(attribute -> {
return "defOneOverloadedRoleTwo".equals(attribute.getName());
}).findFirst().isPresent());
}
use of eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningServiceTest method compileAttributesOverrloadedStrategyMergeTest.
@Test
@Transactional
public void compileAttributesOverrloadedStrategyMergeTest() {
List<SysRoleSystemAttributeDto> overloadingAttributes = new ArrayList<>();
List<AttributeMapping> defaultAttributes = new ArrayList<>();
initDataSystem();
initOverloadedAttributes(overloadingAttributes, defaultAttributes);
// roleOne
SysRoleSystemDto roleSystem1 = roleSystemService.get(overloadingAttributes.get(0).getRoleSystem());
IdmRoleDto roleDto = roleService.get(roleSystem1.getRole());
roleDto.setPriority(200);
roleDto = roleService.save(roleDto);
// roleTwo
SysRoleSystemDto roleSystem2 = roleSystemService.get(overloadingAttributes.get(1).getRoleSystem());
roleDto = roleService.get(roleSystem2.getRole());
roleDto.setPriority(200);
roleDto = roleService.save(roleDto);
// overloadedRoleOne
SysRoleSystemAttributeDto attribute1 = overloadingAttributes.get(0);
attribute1.setStrategyType(AttributeMappingStrategyType.MERGE);
attribute1 = roleSystemAttributeService.save(attribute1);
overloadingAttributes.set(0, attribute1);
// overloadedRoleTwo
SysRoleSystemAttributeDto attribute2 = overloadingAttributes.get(1);
attribute2.setStrategyType(AttributeMappingStrategyType.MERGE);
attribute2 = roleSystemAttributeService.save(attribute2);
overloadingAttributes.set(1, attribute2);
List<AttributeMapping> compilledAttributes = provisioningService.compileAttributes(defaultAttributes, overloadingAttributes, SystemEntityType.IDENTITY);
Assert.assertEquals(3, compilledAttributes.size());
Assert.assertTrue(compilledAttributes.stream().filter(attribute -> {
return "defOneOverloadedRoleTwo".equals(attribute.getName());
}).findFirst().isPresent());
}
Aggregations