Search in sources :

Example 6 with IcConnectorObjectImpl

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

the class ConnIdIcConvertUtil method convertConnIdConnectorObject.

public static IcConnectorObject convertConnIdConnectorObject(ConnectorObject connObject) {
    if (connObject == null) {
        return null;
    }
    IcObjectClass icClass = ConnIdIcConvertUtil.convertConnIdObjectClass(connObject.getObjectClass());
    Set<Attribute> attributes = connObject.getAttributes();
    List<IcAttribute> icAttributes = new ArrayList<>();
    if (attributes != null) {
        for (Attribute a : attributes) {
            icAttributes.add(ConnIdIcConvertUtil.convertConnIdAttribute(a));
        }
    }
    return new IcConnectorObjectImpl(connObject.getUid().getUidValue(), icClass, icAttributes);
}
Also used : IcObjectClass(eu.bcvsolutions.idm.ic.api.IcObjectClass) IcEnabledAttribute(eu.bcvsolutions.idm.ic.api.IcEnabledAttribute) IcPasswordAttribute(eu.bcvsolutions.idm.ic.api.IcPasswordAttribute) Attribute(org.identityconnectors.framework.common.objects.Attribute) IcUidAttribute(eu.bcvsolutions.idm.ic.api.IcUidAttribute) IcLoginAttribute(eu.bcvsolutions.idm.ic.api.IcLoginAttribute) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) ArrayList(java.util.ArrayList) IcConnectorObjectImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl)

Example 7 with IcConnectorObjectImpl

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

the class BasicVirtualConnector method createRequest.

/**
 * Create new instance of request DTO. Method does not persist him.
 *
 * @param objectClass
 * @param attributes
 * @param uidString
 * @param operationType
 * @return
 */
private VsRequestDto createRequest(IcObjectClass objectClass, List<IcAttribute> attributes, String uidString, VsOperationType operationType) {
    VsRequestDto request = new VsRequestDto();
    request.setUid(uidString);
    request.setState(VsRequestState.CONCEPT);
    request.setSystem(this.systemId);
    request.setConfiguration(this.configuration);
    request.setConnectorKey(connectorKey);
    request.setConnectorObject(new IcConnectorObjectImpl(uidString, objectClass, attributes));
    request.setExecuteImmediately(!this.virtualConfiguration.isRequiredConfirmation());
    request.setOperationType(operationType);
    request.setImplementers(this.loadImplementers(this.virtualConfiguration.getImplementers()));
    return request;
}
Also used : VsRequestDto(eu.bcvsolutions.idm.vs.dto.VsRequestDto) IcConnectorObjectImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl)

Example 8 with IcConnectorObjectImpl

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

the class DefaultVsRequestService method getVsConnectorObject.

@Override
public IcConnectorObject getVsConnectorObject(VsRequestDto request) {
    LOG.info(MessageFormat.format("Start read vs connector object [{0}].", request));
    Assert.notNull(request, "VS request cannot be null!");
    Assert.notNull(request.getConnectorObject(), "Connector object in request cannot be null!");
    // Find account by UID and System ID
    VsAccountDto account = accountService.findByUidSystem(request.getUid(), request.getSystem());
    if (account == null) {
        return null;
    }
    BasicVirtualConfiguration configuration = getVirtualConnector(request).getVirtualConfiguration();
    List<IcAttribute> attributes = accountService.getIcAttributes(account);
    // result list
    if (!configuration.isDisableSupported()) {
        IcAttribute enableAttribute = attributes.stream().filter(attribute -> attribute.getName().equals(IcAttributeInfo.ENABLE)).findFirst().orElse(null);
        if (enableAttribute != null) {
            attributes.remove(enableAttribute);
        }
    }
    IcConnectorObjectImpl connectorObject = new IcConnectorObjectImpl();
    connectorObject.setUidValue(account.getUid());
    connectorObject.setObjectClass(request.getConnectorObject().getObjectClass());
    connectorObject.setAttributes(attributes);
    return connectorObject;
}
Also used : IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) VsAccountDto(eu.bcvsolutions.idm.vs.dto.VsAccountDto) IcConnectorObjectImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl) BasicVirtualConfiguration(eu.bcvsolutions.idm.vs.connector.basic.BasicVirtualConfiguration)

Example 9 with IcConnectorObjectImpl

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

the class DefaultVsRequestService method getWishConnectorObject.

@Override
public VsConnectorObjectDto getWishConnectorObject(VsRequestDto request) {
    LOG.info(MessageFormat.format("Start read wish connector object [{0}].", request));
    Assert.notNull(request, "VS request cannot be null!");
    List<VsAttributeDto> resultAttributes = new ArrayList<>();
    IcConnectorObject realConnectorObject = this.getVsConnectorObject(request);
    IcConnectorObject currentObject = realConnectorObject != null ? realConnectorObject : new IcConnectorObjectImpl();
    IcConnectorObject changeObject = request.getConnectorObject() != null ? request.getConnectorObject() : new IcConnectorObjectImpl();
    List<IcAttribute> currentAttributes = currentObject.getAttributes();
    List<IcAttribute> changedAttributes = request.getConnectorObject().getAttributes();
    // First add all new attributes
    changedAttributes.forEach(changedAttribute -> {
        if (currentObject.getAttributeByName(changedAttribute.getName()) == null) {
            VsAttributeDto vsAttribute = new VsAttributeDto(changedAttribute.getName(), changedAttribute.isMultiValue(), true);
            if (changedAttribute.isMultiValue()) {
                if (changedAttribute.getValues() != null) {
                    changedAttribute.getValues().forEach(value -> {
                        vsAttribute.getValues().add(new VsAttributeValueDto(value, null, VsValueChangeType.ADDED));
                    });
                }
            } else {
                vsAttribute.setValue(new VsAttributeValueDto(changedAttribute.getValue(), null, VsValueChangeType.ADDED));
            }
            resultAttributes.add(vsAttribute);
        }
    });
    // Second add all already exists attributes
    currentAttributes.forEach(currentAttribute -> {
        VsAttributeDto vsAttribute;
        // Attribute was changed
        if (changeObject.getAttributeByName(currentAttribute.getName()) != null) {
            vsAttribute = new VsAttributeDto(currentAttribute.getName(), currentAttribute.isMultiValue(), true);
            IcAttribute changedAttribute = changeObject.getAttributeByName(currentAttribute.getName());
            if (changedAttribute.isMultiValue()) {
                if (changedAttribute.getValues() != null) {
                    changedAttribute.getValues().forEach(value -> {
                        if (currentAttribute.getValues() != null && currentAttribute.getValues().contains(value)) {
                            vsAttribute.getValues().add(new VsAttributeValueDto(value, value, null));
                        } else {
                            vsAttribute.getValues().add(new VsAttributeValueDto(value, null, VsValueChangeType.ADDED));
                        }
                    });
                }
                if (currentAttribute.getValues() != null) {
                    currentAttribute.getValues().forEach(value -> {
                        if (changedAttribute.getValues() == null || !changedAttribute.getValues().contains(value)) {
                            vsAttribute.getValues().add(new VsAttributeValueDto(value, value, VsValueChangeType.REMOVED));
                        }
                    });
                }
            } else {
                Object changedValue = changedAttribute.getValue();
                Object currentValue = currentAttribute.getValue();
                if ((changedValue == null && currentValue == null) || (changedValue != null && changedValue.equals(currentObject)) || (currentValue != null && currentValue.equals(changedValue))) {
                    vsAttribute.setValue(new VsAttributeValueDto(changedValue, currentValue, null));
                } else {
                    vsAttribute.setValue(new VsAttributeValueDto(changedValue, currentValue, VsValueChangeType.UPDATED));
                }
            }
        } else {
            // Attribute was not changed
            vsAttribute = new VsAttributeDto(currentAttribute.getName(), currentAttribute.isMultiValue(), false);
            if (currentAttribute.isMultiValue()) {
                if (currentAttribute.getValues() != null) {
                    currentAttribute.getValues().forEach(value -> {
                        vsAttribute.getValues().add(new VsAttributeValueDto(value, value, null));
                    });
                }
            } else {
                vsAttribute.setValue(new VsAttributeValueDto(currentAttribute.getValue(), currentAttribute.getValue(), null));
            }
        }
        resultAttributes.add(vsAttribute);
    });
    BasicVirtualConfiguration configuration = getVirtualConnector(request).getVirtualConfiguration();
    // result list
    if (!configuration.isDisableSupported()) {
        VsAttributeDto enableAttribute = resultAttributes.stream().filter(attribute -> attribute.getName().equals(IcAttributeInfo.ENABLE)).findFirst().orElse(null);
        if (enableAttribute != null) {
            resultAttributes.remove(enableAttribute);
        }
    }
    VsConnectorObjectDto wishObject = new VsConnectorObjectDto();
    wishObject.setUid(request.getUid());
    wishObject.setAttributes(resultAttributes);
    return wishObject;
}
Also used : VsAttributeDto(eu.bcvsolutions.idm.vs.dto.VsAttributeDto) VsConnectorObjectDto(eu.bcvsolutions.idm.vs.dto.VsConnectorObjectDto) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) ArrayList(java.util.ArrayList) VsAttributeValueDto(eu.bcvsolutions.idm.vs.dto.VsAttributeValueDto) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) IcConnectorObjectImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl) BasicVirtualConfiguration(eu.bcvsolutions.idm.vs.connector.basic.BasicVirtualConfiguration)

Example 10 with IcConnectorObjectImpl

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

the class AbstractProvisioningExecutor method prepareProvisioningForAttribute.

private SysProvisioningOperationDto prepareProvisioningForAttribute(SysSystemEntityDto systemEntity, AttributeMapping attributeMapping, Object value, ProvisioningOperationType operationType, DTO dto) {
    Assert.notNull(systemEntity);
    Assert.notNull(systemEntity.getSystem());
    Assert.notNull(systemEntity.getEntityType());
    Assert.notNull(systemEntity.getUid());
    Assert.notNull(attributeMapping);
    SysSchemaAttributeDto schemaAttributeDto = getSchemaAttribute(attributeMapping);
    if (!schemaAttributeDto.isUpdateable()) {
        throw new ProvisioningException(AccResultCode.PROVISIONING_SCHEMA_ATTRIBUTE_IS_NOT_UPDATEABLE, ImmutableMap.of("property", attributeMapping.getIdmPropertyName(), "uid", systemEntity.getUid()));
    }
    SysSchemaObjectClassDto schemaObjectClassDto = schemaObjectClassService.get(schemaAttributeDto.getObjectClass());
    String objectClassName = schemaObjectClassDto.getObjectClassName();
    // We do transformation to system if is attribute only constant
    Object valueTransformed = value;
    if (!attributeMapping.isEntityAttribute() && !attributeMapping.isExtendedAttribute()) {
    // If is attribute handling resolve as constant, then we don't want
    // do transformation again (was did in getAttributeValue)
    } else {
        valueTransformed = attributeMappingService.transformValueToResource(systemEntity.getUid(), value, attributeMapping, dto);
    }
    IcAttribute icAttributeForCreate = attributeMappingService.createIcAttribute(schemaAttributeDto, valueTransformed);
    // 
    // Call ic modul for update single attribute
    IcConnectorObject connectorObject = new IcConnectorObjectImpl(systemEntity.getUid(), new IcObjectClassImpl(objectClassName), ImmutableList.of(icAttributeForCreate));
    SysProvisioningOperationDto.Builder operationBuilder = new SysProvisioningOperationDto.Builder().setOperationType(ProvisioningEventType.UPDATE).setSystemEntity(systemEntity).setEntityIdentifier(dto == null ? null : dto.getId()).setProvisioningContext(new ProvisioningContext(connectorObject));
    // 
    return operationBuilder.build();
}
Also used : IcObjectClassImpl(eu.bcvsolutions.idm.ic.impl.IcObjectClassImpl) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) 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) IcConnectorObjectImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)

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