Search in sources :

Example 36 with IcConnectorObject

use of eu.bcvsolutions.idm.ic.api.IcConnectorObject in project CzechIdMng by bcvsolutions.

the class DefaultSysProvisioningOperationService method replaceGuardedStrings.

/**
 * Replaces GuardedStrings as ConfidentialStrings in given {@link ProvisioningContext}.
 *
 * TODO: don't update accountObject in provisioningOperation (needs attribute defensive clone)
 *
 * @param context
 * @return Returns values (key / value) to store in confidential storage.
 */
protected Map<String, Serializable> replaceGuardedStrings(ProvisioningContext context) {
    try {
        Map<String, Serializable> confidentialValues = new HashMap<>();
        if (context == null) {
            return confidentialValues;
        }
        // 
        Map<ProvisioningAttributeDto, Object> accountObject = context.getAccountObject();
        if (accountObject != null) {
            for (Entry<ProvisioningAttributeDto, Object> entry : accountObject.entrySet()) {
                if (entry.getValue() == null) {
                    continue;
                }
                Object idmValue = entry.getValue();
                // single value
                if (idmValue instanceof GuardedString) {
                    GuardedString guardedString = (GuardedString) entry.getValue();
                    // save value into confidential storage
                    String confidentialStorageKey = createAccountObjectPropertyKey(entry.getKey().getKey(), 0);
                    confidentialValues.put(confidentialStorageKey, guardedString.asString());
                    accountObject.put(entry.getKey(), new ConfidentialString(confidentialStorageKey));
                } else // array
                if (idmValue.getClass().isArray()) {
                    if (!idmValue.getClass().getComponentType().isPrimitive()) {
                        // objects only, we dont want pto proces byte, boolean etc.
                        Object[] idmValues = (Object[]) idmValue;
                        List<ConfidentialString> processedValues = new ArrayList<>();
                        for (int j = 0; j < idmValues.length; j++) {
                            Object singleValue = idmValues[j];
                            if (singleValue instanceof GuardedString) {
                                GuardedString guardedString = (GuardedString) singleValue;
                                // save value into confidential storage
                                String confidentialStorageKey = createAccountObjectPropertyKey(entry.getKey().getKey(), j);
                                confidentialValues.put(confidentialStorageKey, guardedString.asString());
                                processedValues.add(new ConfidentialString(confidentialStorageKey));
                            }
                        }
                        if (!processedValues.isEmpty()) {
                            accountObject.put(entry.getKey(), processedValues.toArray(new ConfidentialString[processedValues.size()]));
                        }
                    }
                } else // collection
                if (idmValue instanceof Collection) {
                    Collection<?> idmValues = (Collection<?>) idmValue;
                    List<ConfidentialString> processedValues = new ArrayList<>();
                    idmValues.forEach(singleValue -> {
                        if (singleValue instanceof GuardedString) {
                            GuardedString guardedString = (GuardedString) singleValue;
                            // save value into confidential storage
                            String confidentialStorageKey = createAccountObjectPropertyKey(entry.getKey().getKey(), processedValues.size());
                            confidentialValues.put(confidentialStorageKey, guardedString.asString());
                            processedValues.add(new ConfidentialString(confidentialStorageKey));
                        }
                    });
                    if (!processedValues.isEmpty()) {
                        accountObject.put(entry.getKey(), processedValues);
                    }
                }
            }
        }
        // 
        IcConnectorObject connectorObject = context.getConnectorObject();
        if (connectorObject != null) {
            for (IcAttribute attribute : connectorObject.getAttributes()) {
                if (attribute.getValues() != null) {
                    for (int j = 0; j < attribute.getValues().size(); j++) {
                        Object attributeValue = attribute.getValues().get(j);
                        if (attributeValue instanceof GuardedString) {
                            GuardedString guardedString = (GuardedString) attributeValue;
                            String confidentialStorageKey = createConnectorObjectPropertyKey(attribute, j);
                            confidentialValues.put(confidentialStorageKey, guardedString.asString());
                            attribute.getValues().set(j, new ConfidentialString(confidentialStorageKey));
                        }
                    }
                }
            }
        }
        // 
        return confidentialValues;
    } catch (Exception ex) {
        throw new CoreException("Replace guarded strings for provisioning operation failed.", ex);
    }
}
Also used : Serializable(java.io.Serializable) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ConfidentialString(eu.bcvsolutions.idm.core.security.api.domain.ConfidentialString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) ProvisioningAttributeDto(eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) CoreException(eu.bcvsolutions.idm.core.api.exception.CoreException) ConfidentialString(eu.bcvsolutions.idm.core.security.api.domain.ConfidentialString) CoreException(eu.bcvsolutions.idm.core.api.exception.CoreException) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) Collection(java.util.Collection) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) List(java.util.List) ArrayList(java.util.ArrayList)

Example 37 with IcConnectorObject

use of eu.bcvsolutions.idm.ic.api.IcConnectorObject in project CzechIdMng by bcvsolutions.

the class ConnIdIcConvertUtil method convertConnIdSyncDelta.

public static IcSyncDelta convertConnIdSyncDelta(SyncDelta delta) {
    if (delta == null) {
        return null;
    }
    IcSyncToken token = ConnIdIcConvertUtil.convertConnIdSyncToken(delta.getToken());
    IcSyncDeltaTypeEnum deltaType = IcSyncDeltaTypeEnum.valueOf(delta.getDeltaType().name());
    IcUidAttribute previousUid = ConnIdIcConvertUtil.convertConnIdUid(delta.getPreviousUid());
    IcObjectClass objectClass = ConnIdIcConvertUtil.convertConnIdObjectClass(delta.getObjectClass());
    IcUidAttribute uid = ConnIdIcConvertUtil.convertConnIdUid(delta.getUid());
    IcConnectorObject object = ConnIdIcConvertUtil.convertConnIdConnectorObject(delta.getObject());
    return new IcSyncDeltaImpl(token, deltaType, previousUid, objectClass, uid, object);
}
Also used : IcSyncDeltaTypeEnum(eu.bcvsolutions.idm.ic.impl.IcSyncDeltaTypeEnum) IcObjectClass(eu.bcvsolutions.idm.ic.api.IcObjectClass) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) IcSyncDeltaImpl(eu.bcvsolutions.idm.ic.impl.IcSyncDeltaImpl) IcSyncToken(eu.bcvsolutions.idm.ic.api.IcSyncToken) IcUidAttribute(eu.bcvsolutions.idm.ic.api.IcUidAttribute)

Example 38 with IcConnectorObject

use of eu.bcvsolutions.idm.ic.api.IcConnectorObject in project CzechIdMng by bcvsolutions.

the class CzechIdMIcConnectorService method readObject.

@Override
public IcConnectorObject readObject(IcConnectorInstance connectorInstance, IcConnectorConfiguration connectorConfiguration, IcObjectClass objectClass, IcUidAttribute uid) {
    Assert.notNull(connectorInstance);
    Assert.notNull(connectorInstance.getConnectorKey());
    Assert.notNull(connectorConfiguration);
    Assert.notNull(uid);
    String key = connectorInstance.getConnectorKey().toString();
    LOG.debug("Read object - CzechIdM (Uid= {} {})", uid, key);
    if (objectClass == null) {
        objectClass = new IcObjectClassImpl(IcObjectClassInfo.ACCOUNT);
    }
    IcConnector connector = this.getConnectorInstance(connectorInstance, connectorConfiguration);
    if (!(connector instanceof IcCanRead)) {
        throw new IcException(MessageFormat.format("Connector [{0}] not supports read operation!", key));
    }
    IcConnectorObject object = ((IcCanRead) connector).read(uid, objectClass);
    LOG.debug("Readed object - CzechIdM ({}) Uid= {}", object, uid);
    return object;
}
Also used : IcObjectClassImpl(eu.bcvsolutions.idm.ic.impl.IcObjectClassImpl) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) IcCanRead(eu.bcvsolutions.idm.ic.api.operation.IcCanRead) IcConnector(eu.bcvsolutions.idm.ic.api.IcConnector) IcException(eu.bcvsolutions.idm.ic.exception.IcException) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString)

Example 39 with IcConnectorObject

use of eu.bcvsolutions.idm.ic.api.IcConnectorObject in project CzechIdMng by bcvsolutions.

the class IcAttributeFilter method isPresent.

/**
 * Determines if the attribute provided is present in the
 * {@link IcConnectorObject}.
 */
public boolean isPresent(IcConnectorObject obj) {
    Optional<IcAttribute> optionalAttr = obj.getAttributes().stream().filter(attribute -> {
        return getName().equals(this.attr.getName());
    }).findFirst();
    IcAttribute attr = optionalAttr.isPresent() ? optionalAttr.get() : null;
    return attr != null;
}
Also used : IcFilter(eu.bcvsolutions.idm.ic.filter.api.IcFilter) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) Optional(java.util.Optional) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute)

Aggregations

IcConnectorObject (eu.bcvsolutions.idm.ic.api.IcConnectorObject)39 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)21 IcObjectClass (eu.bcvsolutions.idm.ic.api.IcObjectClass)17 IcUidAttribute (eu.bcvsolutions.idm.ic.api.IcUidAttribute)13 SysProvisioningOperationDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)12 IcAttribute (eu.bcvsolutions.idm.ic.api.IcAttribute)12 ProvisioningAttributeDto (eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto)11 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)11 SysSystemEntityDto (eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto)10 ProvisioningException (eu.bcvsolutions.idm.acc.exception.ProvisioningException)10 IcConnectorObjectImpl (eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl)9 ArrayList (java.util.ArrayList)9 ProvisioningContext (eu.bcvsolutions.idm.acc.domain.ProvisioningContext)8 SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)8 IcConnectorConfiguration (eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration)8 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)8 Test (org.junit.Test)8 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)7 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)7 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)7