Search in sources :

Example 91 with IdmIdentityRoleFilter

use of eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter in project CzechIdMng by bcvsolutions.

the class PerformanceAccountManagementTest method testDeletePerformance100WithoutRequest.

@Ignore
@Test
@Transactional
public void testDeletePerformance100WithoutRequest() {
    SysSystemDto system = initIdentityData();
    Assert.assertNotNull(system);
    SysSystemMappingDto mapping = systemMappingService.findProvisioningMapping(system.getId(), SystemEntityType.IDENTITY);
    Assert.assertNotNull(mapping);
    mapping = systemMappingService.save(mapping);
    IdmIdentityDto identity = helper.createIdentity();
    AccIdentityAccountFilter roleAccountFilter = new AccIdentityAccountFilter();
    roleAccountFilter.setEntityId(identity.getId());
    roleAccountFilter.setOwnership(Boolean.TRUE);
    List<AccIdentityAccountDto> identityAccounts = identityAccountService.find(roleAccountFilter, null).getContent();
    List<IdmRoleDto> roles = this.createRolesWithSystem(system, 100);
    IdmIdentityContractDto primeContract = identityContractService.getPrimeContract(identity.getId());
    Date startAcm = new Date();
    IdmRoleRequestDto request = helper.createRoleRequest(primeContract, roles.toArray(new IdmRoleDto[0]));
    helper.executeRequest(request, false, true);
    Date endAcm = new Date();
    System.out.println("testDeletePerformance100WithoutRequest - ACM duration: " + (endAcm.getTime() - startAcm.getTime()));
    identityAccounts = identityAccountService.find(roleAccountFilter, null).getContent();
    Assert.assertEquals(100, identityAccounts.size());
    // Delete
    IdmIdentityRoleFilter identityRoleFilter = new IdmIdentityRoleFilter();
    identityRoleFilter.setIdentityContractId(primeContract.getId());
    List<IdmIdentityRoleDto> identityRoles = identityRoleService.find(identityRoleFilter, null).getContent();
    Date startAcmDelete = new Date();
    identityRoles.forEach(identityRole -> {
        identityRoleService.delete(identityRole);
        if (getHibernateSession().isOpen()) {
            getHibernateSession().flush();
            getHibernateSession().clear();
        }
    });
    Date endAcmDelete = new Date();
    System.out.println("testDeletePerformance100WithoutRequest - Delete duration: " + (endAcmDelete.getTime() - startAcmDelete.getTime()));
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) IdmIdentityRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) Date(java.util.Date) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto) Ignore(org.junit.Ignore) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 92 with IdmIdentityRoleFilter

use of eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter in project CzechIdMng by bcvsolutions.

the class PerformanceAccountManagementTest method testDeletePerformance200WithoutRequest.

@Ignore
@Test
@Transactional
public void testDeletePerformance200WithoutRequest() {
    SysSystemDto system = initIdentityData();
    Assert.assertNotNull(system);
    SysSystemMappingDto mapping = systemMappingService.findProvisioningMapping(system.getId(), SystemEntityType.IDENTITY);
    Assert.assertNotNull(mapping);
    mapping = systemMappingService.save(mapping);
    IdmIdentityDto identity = helper.createIdentity();
    AccIdentityAccountFilter roleAccountFilter = new AccIdentityAccountFilter();
    roleAccountFilter.setEntityId(identity.getId());
    roleAccountFilter.setOwnership(Boolean.TRUE);
    List<AccIdentityAccountDto> identityAccounts = identityAccountService.find(roleAccountFilter, null).getContent();
    List<IdmRoleDto> roles = this.createRolesWithSystem(system, 200);
    IdmIdentityContractDto primeContract = identityContractService.getPrimeContract(identity.getId());
    Date startAcm = new Date();
    IdmRoleRequestDto request = helper.createRoleRequest(primeContract, roles.toArray(new IdmRoleDto[0]));
    helper.executeRequest(request, false, true);
    Date endAcm = new Date();
    System.out.println("testDeletePerformance200WithoutRequest - ACM duration: " + (endAcm.getTime() - startAcm.getTime()));
    identityAccounts = identityAccountService.find(roleAccountFilter, null).getContent();
    Assert.assertEquals(200, identityAccounts.size());
    // Delete
    IdmIdentityRoleFilter identityRoleFilter = new IdmIdentityRoleFilter();
    identityRoleFilter.setIdentityContractId(primeContract.getId());
    List<IdmIdentityRoleDto> identityRoles = identityRoleService.find(identityRoleFilter, null).getContent();
    Date startAcmDelete = new Date();
    identityRoles.forEach(identityRole -> {
        identityRoleService.delete(identityRole);
        if (getHibernateSession().isOpen()) {
            getHibernateSession().flush();
            getHibernateSession().clear();
        }
    });
    Date endAcmDelete = new Date();
    System.out.println("testDeletePerformance200WithoutRequest - Delete duration: " + (endAcmDelete.getTime() - startAcmDelete.getTime()));
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) IdmIdentityRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) Date(java.util.Date) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto) Ignore(org.junit.Ignore) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 93 with IdmIdentityRoleFilter

use of eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter in project CzechIdMng by bcvsolutions.

the class PerformanceAccountManagementTest method testDeletePerformance100.

@Ignore
@Test
@Transactional
public void testDeletePerformance100() {
    SysSystemDto system = initIdentityData();
    Assert.assertNotNull(system);
    SysSystemMappingDto mapping = systemMappingService.findProvisioningMapping(system.getId(), SystemEntityType.IDENTITY);
    Assert.assertNotNull(mapping);
    mapping = systemMappingService.save(mapping);
    IdmIdentityDto identity = helper.createIdentity();
    AccIdentityAccountFilter roleAccountFilter = new AccIdentityAccountFilter();
    roleAccountFilter.setEntityId(identity.getId());
    roleAccountFilter.setOwnership(Boolean.TRUE);
    List<AccIdentityAccountDto> identityAccounts = identityAccountService.find(roleAccountFilter, null).getContent();
    List<IdmRoleDto> roles = this.createRolesWithSystem(system, 100);
    IdmIdentityContractDto primeContract = identityContractService.getPrimeContract(identity.getId());
    Date startAcm = new Date();
    IdmRoleRequestDto request = helper.createRoleRequest(primeContract, roles.toArray(new IdmRoleDto[0]));
    helper.executeRequest(request, false, true);
    Date endAcm = new Date();
    System.out.println("testDeletePerformance100 - ACM duration: " + (endAcm.getTime() - startAcm.getTime()));
    identityAccounts = identityAccountService.find(roleAccountFilter, null).getContent();
    Assert.assertEquals(100, identityAccounts.size());
    // Delete
    IdmIdentityRoleFilter identityRoleFilter = new IdmIdentityRoleFilter();
    identityRoleFilter.setIdentityContractId(primeContract.getId());
    List<IdmIdentityRoleDto> identityRoles = identityRoleService.find(identityRoleFilter, null).getContent();
    IdmRoleRequestDto requestDel = helper.createRoleRequest(identity);
    identityRoles.forEach(identityRole -> {
        IdmConceptRoleRequestDto conceptRoleRequest = new IdmConceptRoleRequestDto();
        conceptRoleRequest.setRoleRequest(requestDel.getId());
        conceptRoleRequest.setIdentityContract(primeContract.getId());
        conceptRoleRequest.setIdentityRole(identityRole.getId());
        conceptRoleRequest.setOperation(ConceptRoleRequestOperation.REMOVE);
        conceptRoleRequestService.save(conceptRoleRequest);
    });
    Date startAcmDelete = new Date();
    helper.executeRequest(requestDel, false, true);
    Date endAcmDelete = new Date();
    System.out.println("testDeletePerformance100 - Delete duration: " + (endAcmDelete.getTime() - startAcmDelete.getTime()));
    identityAccounts = identityAccountService.find(roleAccountFilter, null).getContent();
    Assert.assertEquals(0, identityAccounts.size());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) IdmIdentityRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) Date(java.util.Date) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) IdmConceptRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto) Ignore(org.junit.Ignore) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 94 with IdmIdentityRoleFilter

use of eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter in project CzechIdMng by bcvsolutions.

the class IdentityProvisioningTest method testAttachment.

@Test
public void testAttachment() {
    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 attributeByte = new SysSystemAttributeMappingDto();
    attributeByte.setUid(false);
    attributeByte.setEntityAttribute(false);
    attributeByte.setExtendedAttribute(true);
    attributeByte.setIdmPropertyName(getHelper().createName());
    attributeByte.setName(descriptionSchemaAttribute.getName());
    attributeByte.setSchemaAttribute(descriptionSchemaAttribute.getId());
    attributeByte.setSystemMapping(defaultMapping.getId());
    // Transformation data to string
    attributeByte.setTransformToResourceScript("if(attributeValue == null) " + System.lineSeparator() + "{return null;}" + System.lineSeparator() + " return new String(attributeValue.getData());");
    schemaAttributeMappingService.save(attributeByte);
    IdmRoleDto roleWithSystem = helper.createRole();
    helper.createRoleSystem(roleWithSystem, systemDto);
    // Set type of attribute to attachment
    IdmFormAttributeDto eavAttributeByte = formService.getAttribute(IdmIdentityDto.class, attributeByte.getIdmPropertyName());
    eavAttributeByte.setPersistentType(PersistentType.ATTACHMENT);
    eavAttributeByte = formService.saveAttribute(eavAttributeByte);
    // Create attachment with content
    String originalContent = getHelper().createName();
    IdmAttachmentDto attachment = new IdmAttachmentDto();
    attachment.setName("test.txt");
    attachment.setMimetype("text/plain");
    attachment.setInputData(IOUtils.toInputStream(originalContent));
    attachment.setOwnerType(AttachmentManager.TEMPORARY_ATTACHMENT_OWNER_TYPE);
    attachment = attachmentManager.saveAttachment(null, attachment);
    InputStream inputStream = attachmentManager.getAttachmentData(attachment.getId());
    try {
        String content = IOUtils.toString(inputStream);
        assertEquals(originalContent, content);
        // Create form value with attachment
        IdmIdentityDto identity = helper.createIdentity();
        formService.saveValues(identity, eavAttributeByte, Lists.newArrayList(attachment.getId()));
        // Assign the system
        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();
        InputStream is = attachmentManager.getAttachmentData(attachment.getId());
        try {
            String data = new String(IOUtils.toByteArray(is));
            assertEquals(data, valueOnResource);
        } finally {
            IOUtils.closeQuietly(is);
        }
    } catch (IOException e) {
        throw new CoreException(e);
    } finally {
        IOUtils.closeQuietly(inputStream);
    }
}
Also used : IdmAttachmentDto(eu.bcvsolutions.idm.core.ecm.api.dto.IdmAttachmentDto) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) InputStream(java.io.InputStream) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) IOException(java.io.IOException) IdmIdentityRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) CoreException(eu.bcvsolutions.idm.core.api.exception.CoreException) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 95 with IdmIdentityRoleFilter

use of eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter 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)

Aggregations

IdmIdentityRoleFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter)116 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)85 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)84 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)81 Test (org.junit.Test)72 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)67 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)46 UUID (java.util.UUID)41 IdmRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto)39 IdmIdentityRoleService (eu.bcvsolutions.idm.core.api.service.IdmIdentityRoleService)38 List (java.util.List)38 Autowired (org.springframework.beans.factory.annotation.Autowired)38 IdmConceptRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto)33 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)31 LocalDate (java.time.LocalDate)31 Assert (org.junit.Assert)28 IdmRoleService (eu.bcvsolutions.idm.core.api.service.IdmRoleService)27 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)25 IdmAutomaticRoleAttributeDto (eu.bcvsolutions.idm.core.api.dto.IdmAutomaticRoleAttributeDto)25 IdmFormAttributeDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto)25