Search in sources :

Example 56 with SysRoleSystemDto

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

the class DefaultTestHelper method createRoleSystem.

@Override
public SysRoleSystemDto createRoleSystem(IdmRoleDto role, SysSystemDto system) {
    SysRoleSystemDto roleSystem = new SysRoleSystemDto();
    roleSystem.setRole(role.getId());
    roleSystem.setSystem(system.getId());
    // default mapping
    List<SysSystemMappingDto> mappings = systemMappingService.findBySystem(system, SystemOperationType.PROVISIONING, SystemEntityType.IDENTITY);
    // 
    roleSystem.setSystemMapping(mappings.get(0).getId());
    return roleSystemService.save(roleSystem);
}
Also used : SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)

Example 57 with SysRoleSystemDto

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

the class AccountManagementTest method identityAccountCanBeCreatedTest.

@Test
public /**
 * Script on the mapping "Can be account created?" returns true.
 */
void identityAccountCanBeCreatedTest() {
    SysSystemDto system = initIdentityData();
    Assert.assertNotNull(system);
    SysSystemMappingDto mapping = systemMappingService.findProvisioningMapping(system.getId(), SystemEntityType.IDENTITY);
    Assert.assertNotNull(mapping);
    mapping.setCanBeAccountCreatedScript("return Boolean.FALSE;");
    mapping = systemMappingService.save(mapping);
    IdmIdentityDto identity = helper.createIdentity();
    AccIdentityAccountFilter roleAccountFilter = new AccIdentityAccountFilter();
    roleAccountFilter.setEntityId(identity.getId());
    roleAccountFilter.setOwnership(Boolean.TRUE);
    roleAccountFilter.setSystemId(system.getId());
    List<AccIdentityAccountDto> identityAccounts = identityAccountService.find(roleAccountFilter, null).getContent();
    // None role assigned
    Assert.assertEquals(0, identityAccounts.size());
    IdmRoleDto roleDefault = helper.createRole();
    SysRoleSystemDto roleSystemDefault = new SysRoleSystemDto();
    roleSystemDefault.setRole(roleDefault.getId());
    roleSystemDefault.setSystem(system.getId());
    roleSystemDefault.setSystemMapping(mapping.getId());
    roleSystemDefault = roleSystemService.save(roleSystemDefault);
    IdmIdentityRoleDto identityRole = new IdmIdentityRoleDto();
    identityRole.setIdentityContract(identityContractService.getPrimeContract(identity.getId()).getId());
    identityRole.setRole(roleDefault.getId());
    identityRole = identityRoleService.save(identityRole);
    identityAccounts = identityAccountService.find(roleAccountFilter, null).getContent();
    // Role assigned, but script returns false
    Assert.assertEquals(0, identityAccounts.size());
    mapping.setCanBeAccountCreatedScript("return Boolean.TRUE;");
    mapping = systemMappingService.save(mapping);
    // Resave run the ACM
    identityRole = identityRoleService.save(identityRole);
    identityAccounts = identityAccountService.find(roleAccountFilter, null).getContent();
    Assert.assertEquals(1, identityAccounts.size());
    // Delete
    identityService.delete(identity);
    roleService.delete(roleDefault);
}
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) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 58 with SysRoleSystemDto

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());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) SysProvisioningArchiveDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningArchiveDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) CancelProvisioningQueueTaskExecutor(eu.bcvsolutions.idm.acc.scheduler.task.impl.CancelProvisioningQueueTaskExecutor) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) SysProvisioningBatchDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningBatchDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) UUID(java.util.UUID) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 59 with SysRoleSystemDto

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

the class DefaultTestHelper method createRoleSystem.

@Override
public SysRoleSystemDto createRoleSystem(IdmRoleDto role, SysSystemDto system) {
    SysRoleSystemDto roleSystem = new SysRoleSystemDto();
    roleSystem.setRole(role.getId());
    roleSystem.setSystem(system.getId());
    // default mapping
    List<SysSystemMappingDto> mappings = systemMappingService.findBySystem(system, SystemOperationType.PROVISIONING, SystemEntityType.IDENTITY);
    // 
    roleSystem.setSystemMapping(mappings.get(0).getId());
    return roleSystemService.save(roleSystem);
}
Also used : SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)

Example 60 with SysRoleSystemDto

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

the class VsSystemGeneratorTaskExecutor method assignRoleToSystem.

/**
 * Method assigns a role to an existing system
 * @param system
 * @param role
 */
void assignRoleToSystem(SysSystemDto system, IdmRoleDto role) {
    List<SysSystemMappingDto> mappings = systemMappingService.findBySystem(system, SystemOperationType.PROVISIONING, SystemEntityType.IDENTITY);
    SysRoleSystemDto roleSystem = new SysRoleSystemDto();
    roleSystem.setSystem(system.getId());
    roleSystem.setSystemMapping(mappings.get(0).getId());
    roleSystem.setRole(role.getId());
    roleSystemService.save(roleSystem);
}
Also used : SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto)

Aggregations

SysRoleSystemDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto)110 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)82 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)80 Test (org.junit.Test)69 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)65 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)64 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)61 SysRoleSystemAttributeDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto)59 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)50 SysRoleSystemFilter (eu.bcvsolutions.idm.acc.dto.filter.SysRoleSystemFilter)48 SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)43 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)40 UUID (java.util.UUID)35 AccIdentityAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter)34 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)33 AccIdentityAccountDto (eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)27 SysProvisioningOperationFilter (eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter)27 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)26 List (java.util.List)26 SysRoleSystemAttributeService (eu.bcvsolutions.idm.acc.service.api.SysRoleSystemAttributeService)25