Search in sources :

Example 76 with SysSystemMappingDto

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

the class DefaultTreeSynchronizationServiceTest method doCreateSyncConfig.

@Test
@Transactional
public void doCreateSyncConfig() {
    initData();
    SysSystemMappingFilter mappingFilter = new SysSystemMappingFilter();
    mappingFilter.setEntityType(SystemEntityType.TREE);
    mappingFilter.setSystemId(system.getId());
    mappingFilter.setOperationType(SystemOperationType.SYNCHRONIZATION);
    List<SysSystemMappingDto> mappings = systemMappingService.find(mappingFilter, null).getContent();
    Assert.assertEquals(1, mappings.size());
    SysSystemMappingDto mapping = mappings.get(0);
    SysSystemAttributeMappingFilter attributeMappingFilter = new SysSystemAttributeMappingFilter();
    attributeMappingFilter.setSystemMappingId(mapping.getId());
    List<SysSystemAttributeMappingDto> attributes = attributeMappingService.find(attributeMappingFilter, null).getContent();
    SysSystemAttributeMappingDto uidAttribute = attributes.stream().filter(attribute -> {
        return attribute.isUid();
    }).findFirst().get();
    // Create default synchronization config
    AbstractSysSyncConfigDto syncConfigCustom = new SysSyncTreeConfigDto();
    syncConfigCustom.setReconciliation(true);
    syncConfigCustom.setCustomFilter(true);
    syncConfigCustom.setSystemMapping(mapping.getId());
    syncConfigCustom.setCorrelationAttribute(uidAttribute.getId());
    syncConfigCustom.setReconciliation(true);
    syncConfigCustom.setName(SYNC_CONFIG_NAME);
    syncConfigCustom.setLinkedAction(SynchronizationLinkedActionType.IGNORE);
    syncConfigCustom.setUnlinkedAction(SynchronizationUnlinkedActionType.IGNORE);
    syncConfigCustom.setMissingEntityAction(SynchronizationMissingEntityActionType.CREATE_ENTITY);
    syncConfigCustom.setMissingAccountAction(ReconciliationMissingAccountActionType.IGNORE);
    syncConfigService.save(syncConfigCustom);
    SysSyncConfigFilter configFilter = new SysSyncConfigFilter();
    configFilter.setSystemId(system.getId());
    Assert.assertEquals(1, syncConfigService.find(configFilter, null).getTotalElements());
}
Also used : SysSyncTreeConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncTreeConfigDto) AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) SysSystemMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSyncConfigFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 77 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
 */
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);
        List<SysSystemAttributeMappingDto> passwordAttributes = attributeMappingService.getAllPasswordAttributes(system.getId(), mapping.getId());
        GuardedString generatedPassword = null;
        // If exists at least one password attribute generate password and try set echos for current system
        if (!passwordAttributes.isEmpty()) {
            // Check if exists a uniform password for this entity. If yes, then use it.
            if (provisioningOperation.getEntityIdentifier() != null && provisioningOperation.getEntityType() != null && provisioningOperation.getSystem() != null && provisioningOperation.getTransactionId() != null) {
                if (uniformPasswordManager.isSystemInUniformPasswordAgenda(provisioningOperation.getSystem())) {
                    generatedPassword = uniformPasswordManager.generateUniformPassword(provisioningOperation.getEntityIdentifier(), provisioningOperation.getEntityType().getEntityType(), provisioningOperation.getTransactionId());
                }
            }
            if (generatedPassword == null) {
                generatedPassword = generatePassword(system);
            }
        } else {
            generatedPassword = null;
        }
        // Found all given password from original provisioning context, these passwords will be skipped
        List<ProvisioningAttributeDto> givenPasswords = provisioningContext.getAccountObject().keySet().stream().filter(provisioningAtt -> provisioningAtt.isPasswordAttribute()).collect(Collectors.toList());
        // Iterate over all password attributes founded for system and mapping
        for (SysSystemAttributeMappingDto passwordAttribute : passwordAttributes) {
            // Password may be add by another process or execute existing provisioning operation, these password skip
            SysSchemaAttributeDto schemaByPasswordAttribute = DtoUtils.getEmbedded(passwordAttribute, SysSystemAttributeMapping_.schemaAttribute, SysSchemaAttributeDto.class);
            Optional<ProvisioningAttributeDto> findAnyPassword = // 
            givenPasswords.stream().filter(givenPassword -> givenPassword.getSchemaAttributeName().equals(// 
            schemaByPasswordAttribute.getName())).findAny();
            if (findAnyPassword.isPresent()) {
                continue;
            }
            // All non existing passwords in provisioning context will be added and
            // transformed. Then will be set as new attribute into fullAccountObject
            GuardedString transformPassword = transformPassword(provisioningOperation, system.getId(), passwordAttribute, generatedPassword);
            SysSchemaAttributeDto schemaAttribute = // 
            schemaAttributes.stream().filter(// 
            schemaAtt -> schemaAtt.getId().equals(passwordAttribute.getSchemaAttribute())).findFirst().orElse(null);
            ProvisioningAttributeDto passwordProvisiongAttributeDto = ProvisioningAttributeDto.createProvisioningAttributeKey(passwordAttribute, schemaAttribute.getName(), schemaAttribute.getClassType());
            fullAccountObject.put(passwordProvisiongAttributeDto, transformPassword);
            // Update previous account object (gui left side)
            Map<ProvisioningAttributeDto, Object> accountObject = provisioningOperation.getProvisioningContext().getAccountObject();
            // Is needed put password also into account object. Complete provisioning operation can be stored in
            // queue and while retry the provisioning operation is value get from confidential storage.
            // Confidential key is composed by account object.
            String confidentialStrorageKey = provisioningOperationService.createAccountObjectPropertyKey(passwordProvisiongAttributeDto.getKey(), 0);
            confidentialStorage.saveGuardedString(provisioningOperation, confidentialStrorageKey, transformPassword);
            accountObject.put(passwordProvisiongAttributeDto, new ConfidentialString(confidentialStrorageKey));
        }
        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)) {
                    // is null
                    continue;
                }
            }
            if (AttributeMappingStrategyType.CREATE == provisioningAttribute.getStrategyType() || AttributeMappingStrategyType.WRITE_IF_NULL == provisioningAttribute.getStrategyType()) {
                boolean existSetAttribute = // 
                fullAccountObject.keySet().stream().anyMatch(provisioningAttributeKey -> {
                    // 
                    return provisioningAttributeKey.getSchemaAttributeName().equals(schemaAttribute.getName()) && AttributeMappingStrategyType.SET == provisioningAttributeKey.getStrategyType();
                });
                boolean existIfResourceNulltAttribute = // 
                fullAccountObject.keySet().stream().anyMatch(provisioningAttributeKey -> {
                    // 
                    return provisioningAttributeKey.getSchemaAttributeName().equals(schemaAttribute.getName()) && AttributeMappingStrategyType.WRITE_IF_NULL == provisioningAttributeKey.getStrategyType();
                });
                boolean existMergeAttribute = // 
                fullAccountObject.keySet().stream().anyMatch(provisioningAttributeKey -> {
                    // 
                    return provisioningAttributeKey.getSchemaAttributeName().equals(schemaAttribute.getName()) && AttributeMappingStrategyType.MERGE == provisioningAttributeKey.getStrategyType();
                });
                boolean existAuthMergeAttribute = // 
                fullAccountObject.keySet().stream().anyMatch(provisioningAttributeKey -> {
                    return provisioningAttributeKey.getSchemaAttributeName().equals(schemaAttribute.getName()) && AttributeMappingStrategyType.AUTHORITATIVE_MERGE == provisioningAttributeKey.getStrategyType();
                });
                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 : IdmPasswordPolicyDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordPolicyDto) DtoUtils(eu.bcvsolutions.idm.core.api.utils.DtoUtils) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) Enabled(eu.bcvsolutions.idm.core.security.api.domain.Enabled) Autowired(org.springframework.beans.factory.annotation.Autowired) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) SysSystemAttributeMapping_(eu.bcvsolutions.idm.acc.entity.SysSystemAttributeMapping_) ConfidentialString(eu.bcvsolutions.idm.core.security.api.domain.ConfidentialString) SysSchemaAttribute(eu.bcvsolutions.idm.acc.entity.SysSchemaAttribute) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) Map(java.util.Map) ProvisioningConfiguration(eu.bcvsolutions.idm.acc.config.domain.ProvisioningConfiguration) SysProvisioningAttributeService(eu.bcvsolutions.idm.acc.service.api.SysProvisioningAttributeService) AbstractEntityEventProcessor(eu.bcvsolutions.idm.core.api.event.AbstractEntityEventProcessor) ImmutableMap(com.google.common.collect.ImmutableMap) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) UniformPasswordManager(eu.bcvsolutions.idm.acc.service.api.UniformPasswordManager) SysProvisioningOperationService(eu.bcvsolutions.idm.acc.service.api.SysProvisioningOperationService) Collection(java.util.Collection) SystemOperationType(eu.bcvsolutions.idm.acc.domain.SystemOperationType) ProvisioningAttributeDto(eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto) Set(java.util.Set) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) Serializable(java.io.Serializable) List(java.util.List) ConnectorManager(eu.bcvsolutions.idm.acc.service.api.ConnectorManager) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) CollectionUtils(org.springframework.util.CollectionUtils) Entry(java.util.Map.Entry) Optional(java.util.Optional) SysSchemaObjectClassService(eu.bcvsolutions.idm.acc.service.api.SysSchemaObjectClassService) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) AccResultCode(eu.bcvsolutions.idm.acc.domain.AccResultCode) 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) ConnectorType(eu.bcvsolutions.idm.acc.service.api.ConnectorType) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) MessageFormat(java.text.MessageFormat) Strings(com.google.common.base.Strings) SysSystemMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemMappingService) AbstractDto(eu.bcvsolutions.idm.core.api.dto.AbstractDto) ConfidentialStorage(eu.bcvsolutions.idm.core.api.service.ConfidentialStorage) Lists(com.google.common.collect.Lists) LookupService(eu.bcvsolutions.idm.core.api.service.LookupService) SystemEntityType(eu.bcvsolutions.idm.acc.domain.SystemEntityType) 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) EntityEvent(eu.bcvsolutions.idm.core.api.event.EntityEvent) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto) ProvisioningContext(eu.bcvsolutions.idm.acc.domain.ProvisioningContext) AccModuleDescriptor(eu.bcvsolutions.idm.acc.AccModuleDescriptor) Description(org.springframework.context.annotation.Description) SysProvisioningArchiveService(eu.bcvsolutions.idm.acc.service.api.SysProvisioningArchiveService) IdmPasswordPolicyType(eu.bcvsolutions.idm.core.api.domain.IdmPasswordPolicyType) SysSystemService(eu.bcvsolutions.idm.acc.service.api.SysSystemService) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) SysSchemaAttributeService(eu.bcvsolutions.idm.acc.service.api.SysSchemaAttributeService) Component(org.springframework.stereotype.Component) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) ProvisioningService(eu.bcvsolutions.idm.acc.service.api.ProvisioningService) BaseDto(eu.bcvsolutions.idm.core.api.dto.BaseDto) SysSystemAttributeMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemAttributeMappingService) IdmPasswordPolicyService(eu.bcvsolutions.idm.core.api.service.IdmPasswordPolicyService) Assert(org.springframework.util.Assert) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) ProvisioningAttributeDto(eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) ConfidentialString(eu.bcvsolutions.idm.core.security.api.domain.ConfidentialString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) ConfidentialString(eu.bcvsolutions.idm.core.security.api.domain.ConfidentialString) 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)

Example 78 with SysSystemMappingDto

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

the class SynchronizationMonitoringEvaluator method evaluate.

@Override
public IdmMonitoringResultDto evaluate(IdmMonitoringDto monitoring) {
    SysSyncConfigFilter context = new SysSyncConfigFilter();
    context.setIncludeLastLog(Boolean.TRUE);
    UUID synchronizationId = getParameterConverter().toUuid(monitoring.getEvaluatorProperties(), PARAMETER_SYNCHRONIZATION);
    AbstractSysSyncConfigDto sync = syncConfigService.get(synchronizationId, context);
    if (sync == null) {
        throw new EntityNotFoundException(SysSyncConfig.class, synchronizationId);
    }
    // 
    SysSystemMappingDto mapping = DtoUtils.getEmbedded(sync, SysSyncConfig_.systemMapping.getName(), SysSystemMappingDto.class);
    SysSchemaObjectClassDto schema = DtoUtils.getEmbedded(mapping, SysSystemMapping_.objectClass.getName(), SysSchemaObjectClassDto.class);
    SysSystemDto system = systemService.get(schema.getSystem());
    // 
    IdmMonitoringResultDto result = new IdmMonitoringResultDto();
    result.setOwnerId(getLookupService().getOwnerId(sync));
    result.setOwnerType(getLookupService().getOwnerType(SysSyncConfig.class));
    // 
    ResultModel resultModel;
    SysSyncLogDto lastSyncLog = sync.getLastSyncLog();
    if (!sync.isEnabled()) {
        resultModel = new DefaultResultModel(AccResultCode.MONITORING_SYNCHRONIZATION_DISABLED, ImmutableMap.of("synchronizationName", sync.getName(), "systemName", system.getName(), "systemId", system.getId().toString()));
    } else if (lastSyncLog != null) {
        result.setOwnerId(getLookupService().getOwnerId(lastSyncLog));
        result.setOwnerType(getLookupService().getOwnerType(lastSyncLog));
        // 
        // count error and other (~success) operations
        int errorCounter = 0;
        int otherCounter = 0;
        for (SysSyncActionLogDto action : lastSyncLog.getSyncActionLogs()) {
            if (action.getOperationResult() == OperationResultType.ERROR) {
                errorCounter += action.getOperationCount();
            } else {
                otherCounter += action.getOperationCount();
            }
        }
        // 
        if (sync.getLastSyncLog().isContainsError() || errorCounter > 0) {
            result.setValue(String.valueOf(errorCounter));
            resultModel = new DefaultResultModel(AccResultCode.MONITORING_SYNCHRONIZATION_CONTAINS_ERROR, ImmutableMap.of("synchronizationName", sync.getName(), "systemName", system.getName(), "systemId", system.getId().toString(), "count", errorCounter));
        } else {
            result.setValue(String.valueOf(otherCounter));
            resultModel = new DefaultResultModel(AccResultCode.MONITORING_SYNCHRONIZATION_OK, ImmutableMap.of("synchronizationName", sync.getName(), "systemName", system.getName(), "systemId", system.getId().toString(), "count", otherCounter));
        }
    } else {
        resultModel = new DefaultResultModel(AccResultCode.MONITORING_SYNCHRONIZATION_NOT_EXECUTED, ImmutableMap.of("synchronizationName", sync.getName(), "systemName", system.getName(), "systemId", system.getId().toString()));
    }
    // 
    result.setResult(new OperationResultDto.Builder(OperationState.EXECUTED).setModel(resultModel).build());
    // 
    return result;
}
Also used : DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) OperationResultDto(eu.bcvsolutions.idm.core.api.dto.OperationResultDto) DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) ResultModel(eu.bcvsolutions.idm.core.api.dto.ResultModel) EntityNotFoundException(eu.bcvsolutions.idm.core.api.exception.EntityNotFoundException) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SysSyncConfig(eu.bcvsolutions.idm.acc.entity.SysSyncConfig) SysSyncActionLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncActionLogDto) AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) SysSyncConfigFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter) UUID(java.util.UUID) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto) IdmMonitoringResultDto(eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringResultDto)

Example 79 with SysSystemMappingDto

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

the class SystemMappingIdentityAutoAttributesProcessor method process.

@Override
public EventResult<SysSystemMappingDto> process(EntityEvent<SysSystemMappingDto> event) {
    SysSystemMappingDto dto = event.getContent();
    UUID schemaId = dto.getObjectClass();
    if (schemaId == null) {
        return new DefaultEventResult<>(event, this);
    }
    List<SysSchemaAttributeDto> schemaAttributes = getSchemaAttributes(schemaId);
    // UID attribute
    SysSchemaAttributeDto primarySchemaAttribute = getSchemaAttributeByCatalogue(schemaAttributes, this.getPrimaryKeyCatalogue());
    if (primarySchemaAttribute != null) {
        createAttributeMappingBySchemaAttribute(dto, primarySchemaAttribute, IdmIdentity_.username.getName(), true);
    }
    // First name attribute
    SysSchemaAttributeDto schemaAttribute = getSchemaAttributeByCatalogue(schemaAttributes, this.getFirstNameCatalogue());
    if (schemaAttribute != null) {
        createAttributeMappingBySchemaAttribute(dto, schemaAttribute, IdmIdentity_.firstName.getName(), false);
    }
    // Last name attribute
    schemaAttribute = getSchemaAttributeByCatalogue(schemaAttributes, this.getLastNameCatalogue());
    if (schemaAttribute != null) {
        createAttributeMappingBySchemaAttribute(dto, schemaAttribute, IdmIdentity_.lastName.getName(), false);
    }
    // Email attribute
    schemaAttribute = getSchemaAttributeByCatalogue(schemaAttributes, this.getEmailCatalogue());
    if (schemaAttribute != null) {
        createAttributeMappingBySchemaAttribute(dto, schemaAttribute, IdmIdentity_.email.getName(), false);
    }
    // Title before attribute
    schemaAttribute = getSchemaAttributeByCatalogue(schemaAttributes, this.getTitleBeforeCatalogue());
    if (schemaAttribute != null) {
        createAttributeMappingBySchemaAttribute(dto, schemaAttribute, IdmIdentity_.titleBefore.getName(), false);
    }
    // Title after attribute
    schemaAttribute = getSchemaAttributeByCatalogue(schemaAttributes, this.getTitleAfterCatalogue());
    if (schemaAttribute != null) {
        createAttributeMappingBySchemaAttribute(dto, schemaAttribute, IdmIdentity_.titleAfter.getName(), false);
    }
    // Phone attribute
    schemaAttribute = getSchemaAttributeByCatalogue(schemaAttributes, this.getPhoneCatalogue());
    if (schemaAttribute != null) {
        createAttributeMappingBySchemaAttribute(dto, schemaAttribute, IdmIdentity_.phone.getName(), false);
    }
    // Password attribute
    createAttributeMappingForPassword(dto, schemaAttributes);
    return new DefaultEventResult<>(event, this);
}
Also used : SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) UUID(java.util.UUID)

Example 80 with SysSystemMappingDto

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

the class AdGroupConnectorTypeTest method testStepOneByMemberSystem.

@Test
public void testStepOneByMemberSystem() {
    // Create system with members.
    SysSystemDto memberSystemDto = createMemberSystem();
    SysSystemMappingFilter mappingFilter = new SysSystemMappingFilter();
    mappingFilter.setSystemId(memberSystemDto.getId());
    mappingFilter.setOperationType(SystemOperationType.PROVISIONING);
    mappingFilter.setEntityType(SystemEntityType.IDENTITY);
    SysSystemMappingDto mappingDto = mappingService.find(mappingFilter, null).getContent().stream().findFirst().orElse(null);
    assertNotNull(mappingDto);
    ConnectorType connectorType = connectorManager.getConnectorType(MockAdGroupConnectorType.NAME);
    ConnectorTypeDto connectorTypeDto = connectorManager.convertTypeToDto(connectorType);
    connectorTypeDto.setReopened(false);
    connectorManager.load(connectorTypeDto);
    assertNotNull(connectorTypeDto);
    connectorTypeDto.getMetadata().put(MockAdGroupConnectorType.SYSTEM_NAME, this.getHelper().createName());
    connectorTypeDto.getMetadata().put(MockAdGroupConnectorType.MEMBER_SYSTEM_MAPPING, mappingDto.getId().toString());
    connectorTypeDto.setWizardStepName(MockAdGroupConnectorType.STEP_ONE);
    // Execute the first step.
    ConnectorTypeDto stepExecutedResult = connectorManager.execute(connectorTypeDto);
    BaseDto systemDto = stepExecutedResult.getEmbedded().get(MockAdGroupConnectorType.SYSTEM_DTO_KEY);
    assertNotNull("System ID cannot be null!", systemDto);
    SysSystemDto system = systemService.get(systemDto.getId());
    assertNotNull(system);
    // Clean
    systemService.delete((SysSystemDto) systemDto);
    systemService.delete(memberSystemDto);
}
Also used : ConnectorTypeDto(eu.bcvsolutions.idm.acc.dto.ConnectorTypeDto) AdGroupConnectorType(eu.bcvsolutions.idm.acc.connector.AdGroupConnectorType) MockAdUserConnectorType(eu.bcvsolutions.idm.acc.service.impl.mock.MockAdUserConnectorType) ConnectorType(eu.bcvsolutions.idm.acc.service.api.ConnectorType) MockAdGroupConnectorType(eu.bcvsolutions.idm.acc.service.impl.mock.MockAdGroupConnectorType) SysSystemMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) BaseDto(eu.bcvsolutions.idm.core.api.dto.BaseDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)359 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)269 Test (org.junit.Test)208 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)180 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)172 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)134 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)106 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)95 SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)90 SysSystemMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter)89 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)80 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)70 UUID (java.util.UUID)60 SysSchemaAttributeFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter)58 SysRoleSystemDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto)56 SysSyncConfigFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter)42 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)38 TestResource (eu.bcvsolutions.idm.acc.entity.TestResource)38 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)36 SysRoleSystemAttributeDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto)36