Search in sources :

Example 1 with IcConnectorObjectImpl

use of eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl in project CzechIdMng by bcvsolutions.

the class DefaultSysProvisioningOperationServiceUnitTest method testReplaceGuardedStringsInConnectorObject.

@Test
public void testReplaceGuardedStringsInConnectorObject() {
    ProvisioningContext context = new ProvisioningContext();
    IcConnectorObjectImpl connectorObject = new IcConnectorObjectImpl();
    context.setConnectorObject(connectorObject);
    // 
    // fill properties
    String normalValue = "one";
    IcAttributeImpl normal = new IcAttributeImpl("normal", normalValue);
    connectorObject.getAttributes().add(normal);
    GuardedString guardedValue = new GuardedString("one");
    IcAttributeImpl guarded = new IcAttributeImpl("guarded", guardedValue);
    connectorObject.getAttributes().add(guarded);
    // 
    // run
    Map<String, Serializable> confidentiaValues = service.replaceGuardedStrings(context);
    // 
    // check
    assertEquals(1, confidentiaValues.size());
    assertEquals(guardedValue.asString(), confidentiaValues.get(service.createConnectorObjectPropertyKey(guarded, 0)));
    assertEquals(normalValue, connectorObject.getAttributes().get(0).getValue());
    assertNotEquals(guardedValue, connectorObject.getAttributes().get(1).getValue());
}
Also used : ProvisioningContext(eu.bcvsolutions.idm.acc.domain.ProvisioningContext) Serializable(java.io.Serializable) IcAttributeImpl(eu.bcvsolutions.idm.ic.impl.IcAttributeImpl) ConfidentialString(eu.bcvsolutions.idm.core.security.api.domain.ConfidentialString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IcConnectorObjectImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl) AbstractVerifiableUnitTest(eu.bcvsolutions.idm.test.api.AbstractVerifiableUnitTest) Test(org.junit.Test)

Example 2 with IcConnectorObjectImpl

use of eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl in project CzechIdMng by bcvsolutions.

the class PrepareConnectorObjectProcessor method processUpdate.

@SuppressWarnings("unchecked")
private void processUpdate(SysProvisioningOperationDto provisioningOperation, IcConnectorConfiguration connectorConfig, IcConnectorObject existsConnectorObject) {
    SysSystemDto system = systemService.get(provisioningOperation.getSystem());
    String systemEntityUid = provisioningOperationService.getByProvisioningOperation(provisioningOperation).getUid();
    ProvisioningContext provisioningContext = provisioningOperation.getProvisioningContext();
    IcConnectorObject connectorObject = provisioningContext.getConnectorObject();
    IcObjectClass objectClass = connectorObject.getObjectClass();
    // 
    IcConnectorObject updateConnectorObject;
    if (provisioningContext.getAccountObject() == null) {
        updateConnectorObject = connectorObject;
    } else {
        Map<ProvisioningAttributeDto, Object> fullAccountObject = provisioningOperationService.getFullAccountObject(provisioningOperation);
        updateConnectorObject = new IcConnectorObjectImpl(systemEntityUid, objectClass, null);
        SysSystemMappingDto mapping = getMapping(system, provisioningOperation.getEntityType());
        SysSchemaObjectClassDto schemaObjectClassDto = schemaObjectClassService.get(mapping.getObjectClass());
        List<SysSchemaAttributeDto> schemaAttributes = findSchemaAttributes(system, schemaObjectClassDto);
        SysProvisioningOperationFilter filter = new SysProvisioningOperationFilter();
        filter.setEntityIdentifier(provisioningOperation.getEntityIdentifier());
        filter.setEntityType(provisioningOperation.getEntityType());
        filter.setResultState(OperationState.EXECUTED);
        SysProvisioningArchiveDto lastSuccessEntity = null;
        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()));
            }
            SysSchemaAttributeDto schemaAttribute = schemaAttributeOptional.get();
            if (schemaAttribute.isUpdateable()) {
                if (schemaAttribute.isReturnedByDefault()) {
                    Object idmValue = fullAccountObject.get(provisioningAttribute);
                    IcAttribute attribute = existsConnectorObject.getAttributeByName(schemaAttribute.getName());
                    Object connectorValue = attribute != null ? (attribute.isMultiValue() ? attribute.getValues() : attribute.getValue()) : null;
                    Object resultValue = idmValue;
                    if (AttributeMappingStrategyType.CREATE == provisioningAttribute.getStrategyType()) {
                        // We do update, attributes with create strategy will be skipped
                        continue;
                    }
                    if (provisioningAttribute.isSendOnlyIfNotNull()) {
                        if (this.isValueEmpty(idmValue)) {
                            // Skip this attribute (marked with flag sendOnlyIfNotNull), because idm value is null
                            continue;
                        }
                    }
                    if (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 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.WRITE_IF_NULL == provisioningAttribute.getStrategyType()) {
                            List<IcAttribute> icAttributes = existsConnectorObject.getAttributes();
                            // 
                            Optional<IcAttribute> icAttributeOptional = icAttributes.stream().filter(ica -> {
                                return schemaAttribute.getName().equals(ica.getName());
                            }).findFirst();
                            IcAttribute icAttribute = null;
                            if (icAttributeOptional.isPresent()) {
                                icAttribute = icAttributeOptional.get();
                            }
                            // We need do transform from resource first
                            Object transformedConnectorValue = this.transformValueFromResource(provisioningAttribute.getTransformValueFromResourceScript(), schemaAttribute, icAttribute, icAttributes, system);
                            if (transformedConnectorValue != null || existSetAttribute || existAuthMergeAttribute || existMergeAttribute) {
                                // or exists same attribute with  SET/MERGE/AUTH_MERGE strategy (this strategies has higher priority)
                                continue;
                            }
                        }
                    }
                    if (AttributeMappingStrategyType.MERGE == provisioningAttribute.getStrategyType()) {
                        // Load last provisioning history
                        if (lastSuccessEntity == null) {
                            List<SysProvisioningArchiveDto> lastSuccessEntities = provisioningArchiveService.find(filter, new PageRequest(0, 1, new Sort(Direction.DESC, MODIFIED_FIELD_NAME))).getContent();
                            if (!lastSuccessEntities.isEmpty()) {
                                lastSuccessEntity = lastSuccessEntities.get(0);
                            }
                        }
                        // Merge IdM values with connector values
                        if (connectorValue instanceof List) {
                            List<Object> connectorValues = new ArrayList<>((List<Object>) connectorValue);
                            List<Object> idmValues = null;
                            if (idmValue instanceof List) {
                                idmValues = (List<Object>) idmValue;
                            }
                            if (idmValues != null) {
                                idmValues.stream().forEach(value -> {
                                    if (!connectorValues.contains(value)) {
                                        connectorValues.add(value);
                                    }
                                });
                            }
                            resultValue = connectorValues;
                        }
                        // Delete missing values by last provisioning history
                        if (lastSuccessEntity != null && lastSuccessEntity.getProvisioningContext() != null && lastSuccessEntity.getProvisioningContext().getAccountObject() != null && lastSuccessEntity.getProvisioningContext().getAccountObject().containsKey(provisioningAttribute)) {
                            Object oldValue = lastSuccessEntity.getProvisioningContext().getAccountObject().get(provisioningAttribute);
                            if (oldValue instanceof List) {
                                if (!oldValue.equals(idmValue)) {
                                    // Search all deleted values (managed by IdM) by founded last provisioning values
                                    List<?> deletedValues = ((List<?>) oldValue).stream().filter(value -> {
                                        List<?> idmValues = null;
                                        if (idmValue instanceof List) {
                                            idmValues = (List<?>) idmValue;
                                        }
                                        if (idmValues != null && idmValues.contains(value)) {
                                            return false;
                                        }
                                        return true;
                                    }).collect(Collectors.toList());
                                    if (resultValue instanceof List) {
                                        List<?> resultValues = new ArrayList<>((List<Object>) resultValue);
                                        // Remove all deleted values (managed by IdM)
                                        resultValues.removeAll(deletedValues);
                                        resultValue = resultValues;
                                    }
                                }
                            }
                        }
                    }
                    // Update attribute on resource by given mapping
                    // attribute and mapped value in entity
                    IcAttribute updatedAttribute = updateAttribute(systemEntityUid, resultValue, schemaAttribute, existsConnectorObject, system, provisioningAttribute);
                    if (updatedAttribute != null) {
                        updateConnectorObject.getAttributes().add(updatedAttribute);
                    }
                } else {
                    // filled values only
                    if (fullAccountObject.get(provisioningAttribute) != null) {
                        IcAttribute createdAttribute = createAttribute(schemaAttribute, fullAccountObject.get(provisioningAttribute));
                        if (createdAttribute != null) {
                            updateConnectorObject.getAttributes().add(createdAttribute);
                        }
                    }
                }
            }
        }
    }
    // 
    provisioningOperation.getProvisioningContext().setConnectorObject(updateConnectorObject);
    provisioningOperation.setOperationType(ProvisioningEventType.UPDATE);
}
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) SysProvisioningArchiveDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningArchiveDto) ArrayList(java.util.ArrayList) ProvisioningAttributeDto(eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto) PageRequest(org.springframework.data.domain.PageRequest) IcObjectClass(eu.bcvsolutions.idm.ic.api.IcObjectClass) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) Sort(org.springframework.data.domain.Sort) List(java.util.List) ArrayList(java.util.ArrayList) SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) ProvisioningContext(eu.bcvsolutions.idm.acc.domain.ProvisioningContext) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) IcConnectorObjectImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl)

Example 3 with IcConnectorObjectImpl

use of eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl in project CzechIdMng by bcvsolutions.

the class AbstractProvisioningExecutor method prepareProvisioning.

private SysProvisioningOperationDto prepareProvisioning(SysSystemEntityDto systemEntity, DTO dto, UUID entityId, ProvisioningOperationType operationType, List<? extends AttributeMapping> attributes) {
    Assert.notNull(systemEntity);
    Assert.notNull(systemEntity.getUid());
    Assert.notNull(systemEntity.getEntityType());
    SysSystemDto system = DtoUtils.getEmbedded(systemEntity, SysSystemEntity_.system, SysSystemDto.class);
    Assert.notNull(system);
    // If are input attributes null, then we load default mapped attributes
    if (attributes == null) {
        attributes = findAttributeMappings(system, systemEntity.getEntityType());
    }
    if (attributes == null || attributes.isEmpty()) {
        return null;
    }
    // Find connector identification persisted in system
    IcConnectorKey connectorKey = system.getConnectorKey();
    if (connectorKey == null) {
        throw new ProvisioningException(AccResultCode.CONNECTOR_KEY_FOR_SYSTEM_NOT_FOUND, ImmutableMap.of("system", system.getName()));
    }
    // Find connector configuration persisted in system
    IcConnectorConfiguration connectorConfig = systemService.getConnectorConfiguration(system);
    if (connectorConfig == null) {
        throw new ProvisioningException(AccResultCode.CONNECTOR_CONFIGURATION_FOR_SYSTEM_NOT_FOUND, ImmutableMap.of("system", system.getName()));
    }
    // One IDM object can be mapped to one connector object (= one connector
    // class).
    SysSystemMappingDto mapping = getMapping(system, systemEntity.getEntityType());
    if (mapping == null) {
        // TODO: delete operation?
        return null;
    }
    // 
    Map<ProvisioningAttributeDto, Object> accountAttributes = prepareMappedAttributesValues(dto, operationType, systemEntity, attributes);
    // public provisioning event
    SysSchemaObjectClassDto schemaObjectClassDto = schemaObjectClassService.get(mapping.getObjectClass());
    IcConnectorObject connectorObject = new IcConnectorObjectImpl(systemEntity.getUid(), new IcObjectClassImpl(schemaObjectClassDto.getObjectClassName()), null);
    SysProvisioningOperationDto.Builder operationBuilder = new SysProvisioningOperationDto.Builder().setOperationType(operationType).setSystemEntity(systemEntity).setEntityIdentifier(entityId).setProvisioningContext(new ProvisioningContext(accountAttributes, connectorObject));
    // 
    return operationBuilder.build();
}
Also used : IcConnectorConfiguration(eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration) IcObjectClassImpl(eu.bcvsolutions.idm.ic.impl.IcObjectClassImpl) IcConnectorKey(eu.bcvsolutions.idm.ic.api.IcConnectorKey) 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) 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) IcConnectorObjectImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)

Example 4 with IcConnectorObjectImpl

use of eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl in project CzechIdMng by bcvsolutions.

the class DefaultSynchronizationService method resolveMissingEntitySituation.

@Override
public SysSyncItemLogDto resolveMissingEntitySituation(String uid, SystemEntityType entityType, List<IcAttribute> icAttributes, UUID configId, String actionType) {
    Assert.notNull(uid);
    Assert.notNull(entityType);
    Assert.notNull(icAttributes);
    Assert.notNull(configId);
    Assert.notNull(actionType);
    AbstractSysSyncConfigDto config = synchronizationConfigService.get(configId);
    SysSystemMappingDto mapping = systemMappingService.get(config.getSystemMapping());
    SysSchemaObjectClassDto sysSchemaObjectClassDto = schemaObjectClassService.get(mapping.getObjectClass());
    SysSystemDto system = DtoUtils.getEmbedded(sysSchemaObjectClassDto, SysSchemaObjectClass_.system, SysSystemDto.class);
    SysSystemAttributeMappingFilter attributeHandlingFilter = new SysSystemAttributeMappingFilter();
    attributeHandlingFilter.setSystemMappingId(mapping.getId());
    List<SysSystemAttributeMappingDto> mappedAttributes = attributeHandlingService.find(attributeHandlingFilter, null).getContent();
    SysSyncItemLogDto itemLog = new SysSyncItemLogDto();
    // Little workaround, we have only IcAttributes ... we create IcObject manually
    IcConnectorObjectImpl icObject = new IcConnectorObjectImpl();
    icObject.setAttributes(icAttributes);
    icObject.setUidValue(uid);
    SynchronizationContext context = new SynchronizationContext();
    context.addUid(uid).addSystem(system).addConfig(config).addEntityType(entityType).addLogItem(itemLog).addMappedAttributes(mappedAttributes).addIcObject(icObject);
    getSyncExecutor(entityType).resolveMissingEntitySituation(SynchronizationMissingEntityActionType.valueOf(actionType), context);
    return itemLog;
}
Also used : AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) SynchronizationContext(eu.bcvsolutions.idm.acc.domain.SynchronizationContext) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSyncItemLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) IcConnectorObjectImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto)

Example 5 with IcConnectorObjectImpl

use of eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl in project CzechIdMng by bcvsolutions.

the class DefaultSysProvisioningOperationService method getFullConnectorObject.

/**
 * Returns fully loaded ConnectorObject with guarded strings.
 *
 * TODO: don't update connectorObject in provisioningOperation (needs attribute defensive clone)
 *
 * @param provisioningOperation
 * @return
 */
@Override
public IcConnectorObject getFullConnectorObject(SysProvisioningOperationDto provisioningOperation) {
    if (provisioningOperation == null || provisioningOperation.getProvisioningContext() == null || provisioningOperation.getProvisioningContext().getConnectorObject() == null) {
        return null;
    }
    List<IcAttribute> attributes = new ArrayList<>();
    // 
    IcConnectorObject connectorObject = provisioningOperation.getProvisioningContext().getConnectorObject();
    connectorObject.getAttributes().forEach(attribute -> {
        IcAttribute attributeCopy = null;
        if (attribute.isMultiValue()) {
            List<Object> values = (List<Object>) attribute.getValues();
            attributeCopy = new IcAttributeImpl(attribute.getName(), values, true);
        } else if (attribute instanceof IcPasswordAttribute && attribute.getValue() != null) {
            attributeCopy = new IcPasswordAttributeImpl(attribute.getName(), confidentialStorage.getGuardedString(provisioningOperation.getId(), SysProvisioningOperation.class, ((ConfidentialString) attribute.getValue()).getKey()));
        } else if (attribute instanceof IcPasswordAttribute && attribute.getValue() == null) {
            attributeCopy = new IcPasswordAttributeImpl(attribute.getName(), (GuardedString) null);
        } else {
            attributeCopy = new IcAttributeImpl(attribute.getName(), attribute.getValue());
        }
        attributes.add(attributeCopy);
    });
    IcConnectorObject newConnectorObject = new IcConnectorObjectImpl(connectorObject.getUidValue(), connectorObject.getObjectClass(), attributes);
    return newConnectorObject;
}
Also used : ArrayList(java.util.ArrayList) SysProvisioningOperation(eu.bcvsolutions.idm.acc.entity.SysProvisioningOperation) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) ConfidentialString(eu.bcvsolutions.idm.core.security.api.domain.ConfidentialString) IcPasswordAttributeImpl(eu.bcvsolutions.idm.ic.impl.IcPasswordAttributeImpl) IcAttributeImpl(eu.bcvsolutions.idm.ic.impl.IcAttributeImpl) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) List(java.util.List) ArrayList(java.util.ArrayList) IcPasswordAttribute(eu.bcvsolutions.idm.ic.api.IcPasswordAttribute) IcConnectorObjectImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl)

Aggregations

IcConnectorObjectImpl (eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl)14 IcAttribute (eu.bcvsolutions.idm.ic.api.IcAttribute)7 IcConnectorObject (eu.bcvsolutions.idm.ic.api.IcConnectorObject)7 ProvisioningContext (eu.bcvsolutions.idm.acc.domain.ProvisioningContext)6 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)6 SysProvisioningOperationDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)5 ArrayList (java.util.ArrayList)5 ProvisioningAttributeDto (eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto)4 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)4 IcObjectClass (eu.bcvsolutions.idm.ic.api.IcObjectClass)4 IcObjectClassImpl (eu.bcvsolutions.idm.ic.impl.IcObjectClassImpl)4 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)3 ProvisioningException (eu.bcvsolutions.idm.acc.exception.ProvisioningException)3 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)3 IcAttributeImpl (eu.bcvsolutions.idm.ic.impl.IcAttributeImpl)3 SynchronizationContext (eu.bcvsolutions.idm.acc.domain.SynchronizationContext)2 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)2 SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)2 SysSyncItemLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto)2 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)2