Search in sources :

Example 16 with ProvisioningContext

use of eu.bcvsolutions.idm.acc.domain.ProvisioningContext in project CzechIdMng by bcvsolutions.

the class DefaultSysProvisioningOperationService method deleteConfidentialStrings.

/**
 * Deletes persisted confidential storage values
 *
 * @param provisioningOperation
 */
protected void deleteConfidentialStrings(SysProvisioningOperationDto provisioningOperation) {
    Assert.notNull(provisioningOperation);
    // 
    ProvisioningContext context = provisioningOperation.getProvisioningContext();
    if (context == null) {
        return;
    }
    Map<ProvisioningAttributeDto, Object> accountObject = context.getAccountObject();
    if (accountObject != null) {
        for (Entry<ProvisioningAttributeDto, Object> entry : accountObject.entrySet()) {
            Object idmValue = entry.getValue();
            if (idmValue == null) {
                continue;
            }
            // single value
            if (idmValue instanceof ConfidentialString) {
                confidentialStorage.delete(provisioningOperation.getId(), SysProvisioningOperation.class, ((ConfidentialString) entry.getValue()).getKey());
            } else // array
            if (idmValue.getClass().isArray()) {
                if (!idmValue.getClass().getComponentType().isPrimitive()) {
                    Object[] idmValues = (Object[]) idmValue;
                    for (int j = 0; j < idmValues.length; j++) {
                        Object singleValue = idmValues[j];
                        if (singleValue instanceof ConfidentialString) {
                            confidentialStorage.delete(provisioningOperation.getId(), SysProvisioningOperation.class, ((ConfidentialString) singleValue).getKey());
                        }
                    }
                }
            } else // collection
            if (idmValue instanceof Collection) {
                Collection<?> idmValues = (Collection<?>) idmValue;
                idmValues.forEach(singleValue -> {
                    if (singleValue instanceof ConfidentialString) {
                        confidentialStorage.delete(provisioningOperation.getId(), SysProvisioningOperation.class, ((ConfidentialString) singleValue).getKey());
                    }
                });
            }
        }
    }
    // 
    IcConnectorObject connectorObject = context.getConnectorObject();
    if (connectorObject != null) {
        connectorObject.getAttributes().forEach(attribute -> {
            if (attribute.getValues() != null) {
                attribute.getValues().forEach(attributeValue -> {
                    if (attributeValue instanceof ConfidentialString) {
                        confidentialStorage.delete(provisioningOperation.getId(), SysProvisioningOperation.class, ((ConfidentialString) attributeValue).getKey());
                    }
                });
            }
        });
    }
}
Also used : ProvisioningContext(eu.bcvsolutions.idm.acc.domain.ProvisioningContext) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) Collection(java.util.Collection) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) ProvisioningAttributeDto(eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto) SysProvisioningOperation(eu.bcvsolutions.idm.acc.entity.SysProvisioningOperation) ConfidentialString(eu.bcvsolutions.idm.core.security.api.domain.ConfidentialString)

Aggregations

ProvisioningContext (eu.bcvsolutions.idm.acc.domain.ProvisioningContext)16 ProvisioningAttributeDto (eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto)11 SysProvisioningOperationDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)8 IcConnectorObject (eu.bcvsolutions.idm.ic.api.IcConnectorObject)7 IcConnectorObjectImpl (eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl)7 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)6 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)5 SysSystemEntityDto (eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto)5 OperationResult (eu.bcvsolutions.idm.core.api.entity.OperationResult)5 ConfidentialString (eu.bcvsolutions.idm.core.security.api.domain.ConfidentialString)5 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)5 Test (org.junit.Test)5 SysProvisioningArchiveDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningArchiveDto)4 SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)4 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)4 ProvisioningException (eu.bcvsolutions.idm.acc.exception.ProvisioningException)4 AbstractVerifiableUnitTest (eu.bcvsolutions.idm.test.api.AbstractVerifiableUnitTest)4 Serializable (java.io.Serializable)4 HashMap (java.util.HashMap)4 SysProvisioningOperationFilter (eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter)3