Search in sources :

Example 36 with SysSchemaAttributeDto

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

the class IdentityProvisioningTest method testIdentityState.

@Test
public void testIdentityState() {
    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 attributeMapping = new SysSystemAttributeMappingDto();
    attributeMapping.setUid(false);
    attributeMapping.setEntityAttribute(true);
    attributeMapping.setIdmPropertyName(IdentityProvisioningExecutor.IDENTITY_STATE_IDM_NAME);
    attributeMapping.setName(descriptionSchemaAttribute.getName());
    attributeMapping.setSchemaAttribute(descriptionSchemaAttribute.getId());
    attributeMapping.setSystemMapping(defaultMapping.getId());
    attributeMapping = schemaAttributeMappingService.save(attributeMapping);
    IdmRoleDto roleWithSystem = helper.createRole();
    helper.createRoleSystem(roleWithSystem, systemDto);
    IdmIdentityDto identity = helper.createIdentity();
    helper.createIdentityRole(identity, roleWithSystem, null, null);
    // the default state after identity creation
    TestResource resource = helper.findResource(identity.getUsername());
    assertNotNull(resource);
    String valueOnResource = resource.getDescrip();
    Assert.assertEquals(IdentityState.VALID.toString(), valueOnResource);
    // the identity state is changed manually
    identity.setState(IdentityState.DISABLED);
    identityService.save(identity);
    resource = helper.findResource(identity.getUsername());
    assertNotNull(resource);
    valueOnResource = resource.getDescrip();
    Assert.assertEquals(IdentityState.DISABLED.toString(), valueOnResource);
    // test transformation still works
    attributeMapping.setTransformToResourceScript("return \"DELIBERATE_NONSENSE\";");
    attributeMapping = schemaAttributeMappingService.save(attributeMapping);
    identity.setState(IdentityState.LEFT);
    identityService.save(identity);
    resource = helper.findResource(identity.getUsername());
    assertNotNull(resource);
    valueOnResource = resource.getDescrip();
    Assert.assertEquals("DELIBERATE_NONSENSE", valueOnResource);
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 37 with SysSchemaAttributeDto

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

the class IdentityProvisioningTest method testUserType.

@Test
public void testUserType() {
    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(IdmIdentity_.formProjection.getName());
    attributeAssignedRoles.setTransformToResourceScript("if(attributeValue != null) " + System.lineSeparator() + "{return attributeValue.getCode();}");
    attributeAssignedRoles.setName(descriptionSchemaAttribute.getName());
    attributeAssignedRoles.setSchemaAttribute(descriptionSchemaAttribute.getId());
    attributeAssignedRoles.setSystemMapping(defaultMapping.getId());
    schemaAttributeMappingService.save(attributeAssignedRoles);
    IdmRoleDto roleWithSystem = helper.createRole();
    helper.createRoleSystem(roleWithSystem, systemDto);
    IdmIdentityDto identity = helper.createIdentity();
    // Create projection
    IdmFormProjectionDto projection = new IdmFormProjectionDto();
    projection.setOwnerType(IdmIdentity.class.getCanonicalName());
    projection.setCode(getHelper().createName());
    projection.setDisabled(false);
    projection = formProjectionService.save(projection);
    // Set projection to the identity
    identity.setFormProjection(projection.getId());
    identity = identityService.save(identity);
    // Execute provisioning
    helper.createIdentityRole(identity, roleWithSystem, null, null);
    TestResource resource = helper.findResource(identity.getUsername());
    assertNotNull(resource);
    String valueOnResource = resource.getDescrip();
    // Code of the projection must be on target system.
    assertEquals(projection.getCode(), valueOnResource);
    // Delete projection.
    formProjectionService.delete(projection);
}
Also used : IdmFormProjectionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormProjectionDto) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 38 with SysSchemaAttributeDto

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

the class IdentityProvisioningTest method testAssignedRoles.

@Test
public void testAssignedRoles() {
    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_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);
    helper.createIdentityRole(identity, roleWithSystem, null, null);
    IdmIdentityRoleFilter identityRoleFilter = new IdmIdentityRoleFilter();
    identityRoleFilter.setIdentityId(identity.getId());
    List<IdmIdentityRoleDto> identityRoles = identityRoleService.find(identityRoleFilter, PageRequest.of(0, Integer.MAX_VALUE, Sort.by(IdmIdentityRole_.created.getName()))).getContent();
    TestResource resource = helper.findResource(identity.getUsername());
    assertNotNull(resource);
    String valueOnResource = resource.getDescrip();
    String result = "";
    for (IdmIdentityRoleDto identityRole : identityRoles) {
        IdmFormInstanceDto formInstanceDto = identityRoleService.getRoleAttributeValues(identityRole);
        identityRole.getEavs().clear();
        identityRole.getEavs().add(formInstanceDto);
        result = result + IdentityProvisioningExecutor.convertToAssignedRoleDto(identityRole).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)

Example 39 with SysSchemaAttributeDto

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

the class PerformanceAccountManagementTest method createIdentityMapping.

private void createIdentityMapping(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);
        }
    });
}
Also used : SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter)

Example 40 with SysSchemaAttributeDto

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

the class MappingContextTest method createDescriptionAttribute.

private void createDescriptionAttribute(SysSystemDto system, SysSystemMappingDto mapping) {
    SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
    schemaAttributeFilter.setSystemId(system.getId());
    schemaAttributeFilter.setName(TestHelper.ATTRIBUTE_MAPPING_DESCRIPTION);
    SysSchemaAttributeDto descriptionSchemaAttribute = schemaAttributeService.find(schemaAttributeFilter, null).getContent().get(0);
    Assert.assertNotNull(descriptionSchemaAttribute);
    SysSystemAttributeMappingDto descriptionAttribute = new SysSystemAttributeMappingDto();
    descriptionAttribute.setUid(false);
    descriptionAttribute.setEntityAttribute(false);
    descriptionAttribute.setName(descriptionSchemaAttribute.getName());
    descriptionAttribute.setSchemaAttribute(descriptionSchemaAttribute.getId());
    descriptionAttribute.setSystemMapping(mapping.getId());
    descriptionAttribute.setTransformToResourceScript("return context.toString();");
    descriptionAttribute = attributeMappingService.save(descriptionAttribute);
}
Also used : SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter)

Aggregations

SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)168 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)119 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)96 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)89 SysSchemaAttributeFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter)86 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)79 Test (org.junit.Test)73 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)52 UUID (java.util.UUID)40 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)39 SysRoleSystemDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto)36 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)35 SysRoleSystemAttributeDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto)34 AttributeMappingStrategyType (eu.bcvsolutions.idm.acc.domain.AttributeMappingStrategyType)28 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)27 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)27 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)26 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)26 Serializable (java.io.Serializable)26 List (java.util.List)25