Search in sources :

Example 16 with SysSystemMappingDto

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

the class DefaultSysSystemMappingServiceTest method typeFilterTest.

@Test
public void typeFilterTest() {
    IdmBasePermission permission = IdmBasePermission.ADMIN;
    SysSystemDto system = createSystem();
    SysSchemaObjectClassDto objectClass = createObjectClass(system);
    SysSystemMappingDto mappingSystem1 = testHelper.createMappingSystem(SystemEntityType.CONTRACT, objectClass);
    SysSystemMappingDto mappingSystem2 = testHelper.createMappingSystem(SystemEntityType.CONTRACT, objectClass);
    SysSystemMappingDto mappingSystem3 = testHelper.createMappingSystem(SystemEntityType.TREE, objectClass);
    SysSystemMappingFilter filter = new SysSystemMappingFilter();
    filter.setSystemId(system.getId());
    filter.setEntityType(SystemEntityType.CONTRACT);
    Page<SysSystemMappingDto> result = mappingService.find(filter, null, permission);
    assertEquals(2, result.getTotalElements());
    assertTrue(result.getContent().contains(mappingSystem1));
    assertTrue(result.getContent().contains(mappingSystem2));
    assertFalse(result.getContent().contains(mappingSystem3));
}
Also used : SysSystemMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter) IdmBasePermission(eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 17 with SysSystemMappingDto

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

the class DefaultSysSystemMappingServiceTest method operationTypeFilterTest.

@Test
public void operationTypeFilterTest() {
    IdmBasePermission permission = IdmBasePermission.ADMIN;
    SystemEntityType entityType = SystemEntityType.IDENTITY;
    SysSystemDto system = createSystem();
    SysSchemaObjectClassDto objectClass = createObjectClass(system);
    SysSystemMappingDto mappingSystem1 = testHelper.createMappingSystem(entityType, objectClass);
    createProvisioningMappingSystem(SystemEntityType.TREE, objectClass);
    SysSystemMappingDto mappingSystem3 = createProvisioningMappingSystem(entityType, objectClass);
    SysSystemMappingFilter filter = new SysSystemMappingFilter();
    filter.setOperationType(SystemOperationType.PROVISIONING);
    filter.setSystemId(system.getId());
    Page<SysSystemMappingDto> result = mappingService.find(filter, null, permission);
    assertEquals(2, result.getTotalElements());
    assertTrue(result.getContent().contains(mappingSystem3));
    assertFalse(result.getContent().contains(mappingSystem1));
}
Also used : SysSystemMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter) IdmBasePermission(eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission) SystemEntityType(eu.bcvsolutions.idm.acc.domain.SystemEntityType) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 18 with SysSystemMappingDto

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

the class DefaultSysSystemMappingServiceTest method objectClassFilterTest.

@Test
public void objectClassFilterTest() {
    IdmBasePermission permission = IdmBasePermission.ADMIN;
    SystemEntityType entityType = SystemEntityType.IDENTITY;
    SysSystemDto system = createSystem();
    SysSystemDto system2 = createSystem();
    SysSchemaObjectClassDto objectClass = createObjectClass(system);
    SysSchemaObjectClassDto objectClass2 = createObjectClass(system2);
    SysSystemMappingDto mappingSystem1 = testHelper.createMappingSystem(entityType, objectClass);
    SysSystemMappingDto mappingSystem2 = testHelper.createMappingSystem(entityType, objectClass2);
    SysSystemMappingFilter filter = new SysSystemMappingFilter();
    filter.setObjectClassId(mappingSystem1.getObjectClass());
    Page<SysSystemMappingDto> result = mappingService.find(filter, null, permission);
    assertEquals(1, result.getTotalElements());
    assertTrue(result.getContent().contains(mappingSystem1));
    assertFalse(result.getContent().contains(mappingSystem2));
}
Also used : SysSystemMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter) IdmBasePermission(eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission) SystemEntityType(eu.bcvsolutions.idm.acc.domain.SystemEntityType) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 19 with SysSystemMappingDto

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

the class SystemMappingDeleteProcessor method process.

@Override
public EventResult<SysSystemMappingDto> process(EntityEvent<SysSystemMappingDto> event) {
    SysSystemMappingDto systemMapping = event.getContent();
    // 
    if (configService.countBySystemMapping(systemMapping) > 0) {
        throw new ResultCodeException(AccResultCode.SYSTEM_MAPPING_DELETE_FAILED_USED_IN_SYNC, ImmutableMap.of("mapping", systemMapping.getName()));
    }
    // 
    // remove all handled attributes
    SysSystemAttributeMappingFilter filter = new SysSystemAttributeMappingFilter();
    filter.setSystemMappingId(systemMapping.getId());
    systemAttributeMappingService.find(filter, null).forEach(systemAttributeMapping -> {
        systemAttributeMappingService.delete(systemAttributeMapping);
    });
    // 
    // delete mapped roles
    SysRoleSystemFilter roleSystemFilter = new SysRoleSystemFilter();
    roleSystemFilter.setSystemMappingId(systemMapping.getId());
    roleSystemService.find(roleSystemFilter, null).forEach(roleSystem -> {
        roleSystemService.delete(roleSystem);
    });
    // 
    systemMappingService.deleteInternal(systemMapping);
    // 
    return new DefaultEventResult<>(event, this);
}
Also used : SysRoleSystemFilter(eu.bcvsolutions.idm.acc.dto.filter.SysRoleSystemFilter) SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)

Example 20 with SysSystemMappingDto

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

the class PrepareConnectorObjectProcessor method processCreate.

/**
 * Create object on target system
 *
 * @param provisioningOperation
 * @param connectorConfig
 */
private void processCreate(SysProvisioningOperationDto provisioningOperation) {
    SysSystemDto system = systemService.get(provisioningOperation.getSystem());
    ProvisioningContext provisioningContext = provisioningOperation.getProvisioningContext();
    IcConnectorObject connectorObject = provisioningContext.getConnectorObject();
    // 
    // prepare provisioning attributes from account attributes
    Map<ProvisioningAttributeDto, Object> fullAccountObject = provisioningOperationService.getFullAccountObject(provisioningOperation);
    if (fullAccountObject != null) {
        connectorObject.getAttributes().clear();
        SysSystemMappingDto mapping = getMapping(system, provisioningOperation.getEntityType());
        SysSchemaObjectClassDto schemaObjectClassDto = schemaObjectClassService.get(mapping.getObjectClass());
        List<SysSchemaAttributeDto> schemaAttributes = findSchemaAttributes(system, schemaObjectClassDto);
        for (Entry<ProvisioningAttributeDto, Object> entry : fullAccountObject.entrySet()) {
            ProvisioningAttributeDto provisioningAttribute = entry.getKey();
            Optional<SysSchemaAttributeDto> schemaAttributeOptional = schemaAttributes.stream().filter(schemaAttribute -> {
                return provisioningAttribute.getSchemaAttributeName().equals(schemaAttribute.getName());
            }).findFirst();
            if (!schemaAttributeOptional.isPresent()) {
                throw new ProvisioningException(AccResultCode.PROVISIONING_SCHEMA_ATTRIBUTE_IS_FOUND, ImmutableMap.of("attribute", provisioningAttribute.getSchemaAttributeName()));
            }
            Object idmValue = fullAccountObject.get(provisioningAttribute);
            SysSchemaAttributeDto schemaAttribute = schemaAttributeOptional.get();
            if (provisioningAttribute.isSendOnlyIfNotNull()) {
                if (this.isValueEmpty(idmValue)) {
                    // Skip this attribute (marked with flag sendOnlyIfNotNull), because IdM value is null
                    continue;
                }
            }
            if (AttributeMappingStrategyType.CREATE == provisioningAttribute.getStrategyType() || AttributeMappingStrategyType.WRITE_IF_NULL == provisioningAttribute.getStrategyType()) {
                boolean existSetAttribute = fullAccountObject.keySet().stream().filter(provisioningAttributeKey -> {
                    return provisioningAttributeKey.getSchemaAttributeName().equals(schemaAttribute.getName()) && AttributeMappingStrategyType.SET == provisioningAttributeKey.getStrategyType();
                }).findFirst().isPresent();
                boolean existIfResourceNulltAttribute = fullAccountObject.keySet().stream().filter(provisioningAttributeKey -> {
                    return provisioningAttributeKey.getSchemaAttributeName().equals(schemaAttribute.getName()) && AttributeMappingStrategyType.WRITE_IF_NULL == provisioningAttributeKey.getStrategyType();
                }).findFirst().isPresent();
                boolean existMergeAttribute = fullAccountObject.keySet().stream().filter(provisioningAttributeKey -> {
                    return provisioningAttributeKey.getSchemaAttributeName().equals(schemaAttribute.getName()) && AttributeMappingStrategyType.MERGE == provisioningAttributeKey.getStrategyType();
                }).findFirst().isPresent();
                boolean existAuthMergeAttribute = fullAccountObject.keySet().stream().filter(provisioningAttributeKey -> {
                    return provisioningAttributeKey.getSchemaAttributeName().equals(schemaAttribute.getName()) && AttributeMappingStrategyType.AUTHORITATIVE_MERGE == provisioningAttributeKey.getStrategyType();
                }).findFirst().isPresent();
                if (AttributeMappingStrategyType.CREATE == provisioningAttribute.getStrategyType()) {
                    if (existIfResourceNulltAttribute || existSetAttribute || existAuthMergeAttribute || existMergeAttribute) {
                        // (this strategies has higher priority)
                        continue;
                    }
                }
                if (AttributeMappingStrategyType.WRITE_IF_NULL == provisioningAttribute.getStrategyType()) {
                    if (existSetAttribute || existAuthMergeAttribute || existMergeAttribute) {
                        // (this strategies has higher priority)
                        continue;
                    }
                }
            }
            IcAttribute createdAttribute = createAttribute(schemaAttribute, fullAccountObject.get(provisioningAttribute));
            if (createdAttribute != null) {
                connectorObject.getAttributes().add(createdAttribute);
            }
        }
        provisioningContext.setConnectorObject(connectorObject);
    }
    provisioningOperation.setOperationType(ProvisioningEventType.CREATE);
}
Also used : SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) NotificationManager(eu.bcvsolutions.idm.core.notification.api.service.NotificationManager) Autowired(org.springframework.beans.factory.annotation.Autowired) Enabled(eu.bcvsolutions.idm.core.security.api.domain.Enabled) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) SysSchemaAttribute(eu.bcvsolutions.idm.acc.entity.SysSchemaAttribute) SysProvisioningArchiveDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningArchiveDto) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) Map(java.util.Map) ProvisioningConfiguration(eu.bcvsolutions.idm.acc.config.domain.ProvisioningConfiguration) Sort(org.springframework.data.domain.Sort) AbstractEntityEventProcessor(eu.bcvsolutions.idm.core.api.event.AbstractEntityEventProcessor) ImmutableMap(com.google.common.collect.ImmutableMap) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) Collection(java.util.Collection) SysProvisioningOperationService(eu.bcvsolutions.idm.acc.service.api.SysProvisioningOperationService) SystemOperationType(eu.bcvsolutions.idm.acc.domain.SystemOperationType) PageRequest(org.springframework.data.domain.PageRequest) ProvisioningAttributeDto(eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) List(java.util.List) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) CollectionUtils(org.springframework.util.CollectionUtils) Entry(java.util.Map.Entry) Optional(java.util.Optional) IcUidAttribute(eu.bcvsolutions.idm.ic.api.IcUidAttribute) SysSchemaObjectClassService(eu.bcvsolutions.idm.acc.service.api.SysSchemaObjectClassService) DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) AccResultCode(eu.bcvsolutions.idm.acc.domain.AccResultCode) IcConnectorConfiguration(eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration) IcConnectorFacade(eu.bcvsolutions.idm.ic.service.api.IcConnectorFacade) AttributeMappingStrategyType(eu.bcvsolutions.idm.acc.domain.AttributeMappingStrategyType) ProvisioningEventType(eu.bcvsolutions.idm.acc.domain.ProvisioningEventType) SysSystemEntityService(eu.bcvsolutions.idm.acc.service.api.SysSystemEntityService) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) Strings(com.google.common.base.Strings) SysSystemMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemMappingService) SystemEntityType(eu.bcvsolutions.idm.acc.domain.SystemEntityType) IcUidAttributeImpl(eu.bcvsolutions.idm.ic.impl.IcUidAttributeImpl) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult) IcConnectorObjectImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl) IcObjectClass(eu.bcvsolutions.idm.ic.api.IcObjectClass) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) EventResult(eu.bcvsolutions.idm.core.api.event.EventResult) Direction(org.springframework.data.domain.Sort.Direction) EntityEvent(eu.bcvsolutions.idm.core.api.event.EntityEvent) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto) ProvisioningContext(eu.bcvsolutions.idm.acc.domain.ProvisioningContext) Description(org.springframework.context.annotation.Description) AccModuleDescriptor(eu.bcvsolutions.idm.acc.AccModuleDescriptor) SysProvisioningArchiveService(eu.bcvsolutions.idm.acc.service.api.SysProvisioningArchiveService) SysSystemService(eu.bcvsolutions.idm.acc.service.api.SysSystemService) OperationState(eu.bcvsolutions.idm.core.api.domain.OperationState) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) SysSchemaAttributeService(eu.bcvsolutions.idm.acc.service.api.SysSchemaAttributeService) Component(org.springframework.stereotype.Component) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) IdmMessageDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto) SysSystemAttributeMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemAttributeMappingService) ResultModel(eu.bcvsolutions.idm.core.api.dto.ResultModel) Assert(org.springframework.util.Assert) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) ProvisioningAttributeDto(eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) ProvisioningContext(eu.bcvsolutions.idm.acc.domain.ProvisioningContext) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)

Aggregations

SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)112 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)78 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)50 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)50 Test (org.junit.Test)50 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)44 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)28 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)28 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)27 SysSystemMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter)24 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)23 SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)23 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)22 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)21 SysSyncConfigFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter)15 SysRoleSystemDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto)14 SysSchemaAttributeFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter)14 TestResource (eu.bcvsolutions.idm.acc.entity.TestResource)13 IdmBasePermission (eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission)13 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)12