Search in sources :

Example 11 with AttributeMapping

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

the class DefaultSysSystemAttributeMappingService method getAttributeValue.

/**
 * Find value for this mapped attribute by property name. Returned value can be list of objects. Returns transformed value.
 *
 * @param uid - Account identifier
 * @param entity
 * @param attributeHandling
 * @param idmValue
 * @return
 * @throws IntrospectionException
 * @throws IllegalAccessException
 * @throws InvocationTargetException
 */
@Override
public Object getAttributeValue(String uid, AbstractDto entity, AttributeMapping attributeHandling) {
    Object idmValue = null;
    // 
    SysSchemaAttributeDto schemaAttributeDto = getSchemaAttribute(attributeHandling);
    // 
    if (attributeHandling.isExtendedAttribute() && entity != null && formService.isFormable(entity.getClass())) {
        List<IdmFormValueDto> formValues = formService.getValues(entity, attributeHandling.getIdmPropertyName());
        if (formValues.isEmpty()) {
            idmValue = null;
        } else if (schemaAttributeDto.isMultivalued()) {
            // Multiple value extended attribute
            List<Object> values = new ArrayList<>();
            formValues.stream().forEachOrdered(formValue -> {
                values.add(formValue.getValue());
            });
            idmValue = values;
        } else {
            // Single value extended attribute
            IdmFormValueDto formValue = formValues.get(0);
            if (formValue.isConfidential()) {
                Object confidentialValue = formService.getConfidentialPersistentValue(formValue);
                // If is confidential value String and schema attribute is GuardedString type, then convert to GuardedString will be did.
                if (confidentialValue instanceof String && schemaAttributeDto.getClassType().equals(GuardedString.class.getName())) {
                    idmValue = new GuardedString((String) confidentialValue);
                } else {
                    idmValue = confidentialValue;
                }
            } else {
                idmValue = formValue.getValue();
            }
        }
    } else // Find value from entity
    if (attributeHandling.isEntityAttribute()) {
        if (attributeHandling.isConfidentialAttribute()) {
            // If is attribute isConfidential, then we will find value in
            // secured storage
            idmValue = confidentialStorage.getGuardedString(entity.getId(), entity.getClass(), attributeHandling.getIdmPropertyName());
        } else {
            try {
                // We will search value directly in entity by property name
                idmValue = EntityUtils.getEntityValue(entity, attributeHandling.getIdmPropertyName());
            } catch (IntrospectionException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | ProvisioningException o_O) {
                throw new ProvisioningException(AccResultCode.PROVISIONING_IDM_FIELD_NOT_FOUND, ImmutableMap.of("property", attributeHandling.getIdmPropertyName(), "entityType", entity.getClass()), o_O);
            }
        }
    } else {
    // If Attribute value is not in entity nor in extended attribute, then idmValue is null.
    // It means attribute is static ... we will call transformation to resource.
    }
    return this.transformValueToResource(uid, idmValue, attributeHandling, entity);
}
Also used : IdmScriptCategory(eu.bcvsolutions.idm.core.api.domain.IdmScriptCategory) DtoUtils(eu.bcvsolutions.idm.core.api.utils.DtoUtils) SysSystemAttributeMappingRepository(eu.bcvsolutions.idm.acc.repository.SysSystemAttributeMappingRepository) FormPropertyManager(eu.bcvsolutions.idm.acc.service.api.FormPropertyManager) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) PluginRegistry(org.springframework.plugin.core.PluginRegistry) Autowired(org.springframework.beans.factory.annotation.Autowired) FormService(eu.bcvsolutions.idm.core.eav.api.service.FormService) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) GroovyScriptService(eu.bcvsolutions.idm.core.api.service.GroovyScriptService) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) Map(java.util.Map) BasePermission(eu.bcvsolutions.idm.core.security.api.domain.BasePermission) Pageable(org.springframework.data.domain.Pageable) SysSystemAttributeMapping(eu.bcvsolutions.idm.acc.entity.SysSystemAttributeMapping) ImmutableMap(com.google.common.collect.ImmutableMap) SystemOperationType(eu.bcvsolutions.idm.acc.domain.SystemOperationType) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) UUID(java.util.UUID) Page(org.springframework.data.domain.Page) Collectors(java.util.stream.Collectors) IntrospectionException(java.beans.IntrospectionException) InvocationTargetException(java.lang.reflect.InvocationTargetException) AttributeMapping(eu.bcvsolutions.idm.acc.domain.AttributeMapping) SysSyncConfigRepository(eu.bcvsolutions.idm.acc.repository.SysSyncConfigRepository) List(java.util.List) SysRoleSystemAttributeRepository(eu.bcvsolutions.idm.acc.repository.SysRoleSystemAttributeRepository) Optional(java.util.Optional) Identifiable(eu.bcvsolutions.idm.core.api.domain.Identifiable) 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) OrderAwarePluginRegistry(org.springframework.plugin.core.OrderAwarePluginRegistry) IcPasswordAttributeImpl(eu.bcvsolutions.idm.ic.impl.IcPasswordAttributeImpl) HashMap(java.util.HashMap) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) SysSystemMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemMappingService) AbstractDto(eu.bcvsolutions.idm.core.api.dto.AbstractDto) ConfidentialStorage(eu.bcvsolutions.idm.core.api.service.ConfidentialStorage) SystemEntityType(eu.bcvsolutions.idm.acc.domain.SystemEntityType) Service(org.springframework.stereotype.Service) EntityUtils(eu.bcvsolutions.idm.core.api.utils.EntityUtils) AbstractReadWriteDtoService(eu.bcvsolutions.idm.core.api.service.AbstractReadWriteDtoService) IcAttributeImpl(eu.bcvsolutions.idm.ic.impl.IcAttributeImpl) SysSchemaObjectClass_(eu.bcvsolutions.idm.acc.entity.SysSchemaObjectClass_) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) SysRoleSystemAttributeDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto) AbstractScriptEvaluator(eu.bcvsolutions.idm.core.script.evaluator.AbstractScriptEvaluator) SysSchemaAttributeService(eu.bcvsolutions.idm.acc.service.api.SysSchemaAttributeService) SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSystemAttributeMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemAttributeMappingService) Transactional(org.springframework.transaction.annotation.Transactional) Assert(org.springframework.util.Assert) StringUtils(org.springframework.util.StringUtils) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) List(java.util.List) ArrayList(java.util.ArrayList) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString)

Example 12 with AttributeMapping

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

the class AbstractProvisioningExecutor method doInternalProvisioning.

@Override
public void doInternalProvisioning(AccAccountDto account, DTO dto) {
    Assert.notNull(account);
    Assert.notNull(dto);
    // 
    ProvisioningOperationType operationType;
    SysSystemDto system = DtoUtils.getEmbedded(account, AccAccount_.system, SysSystemDto.class);
    SysSystemEntityDto systemEntity = getSystemEntity(account);
    SystemEntityType entityType = SystemEntityType.getByClass(dto.getClass());
    String uid = account.getUid();
    // 
    if (systemEntity == null) {
        // prepare system entity - uid could be changed by provisioning, but
        // we need to link her with account
        // First we try find system entity with same uid.
        systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, entityType, uid);
        if (systemEntity == null) {
            systemEntity = new SysSystemEntityDto();
            systemEntity.setEntityType(entityType);
            systemEntity.setSystem(system.getId());
            systemEntity.setUid(uid);
            systemEntity.setWish(true);
            systemEntity = systemEntityService.save(systemEntity);
        }
        account.setSystemEntity(systemEntity.getId());
        account = accountService.save(account);
        // we wont create account, but after target system call can be
        // switched to UPDATE
        operationType = ProvisioningOperationType.CREATE;
    } else {
        // we wont update account, but after target system call can be
        // switched to CREATE
        operationType = ProvisioningOperationType.UPDATE;
    }
    List<AttributeMapping> finalAttributes = resolveMappedAttributes(account, dto, system, systemEntity.getEntityType());
    if (CollectionUtils.isEmpty(finalAttributes)) {
        // nothing to do - mapping is empty
        return;
    }
    doProvisioning(systemEntity, dto, dto.getId(), operationType, finalAttributes);
}
Also used : ProvisioningOperationType(eu.bcvsolutions.idm.acc.domain.ProvisioningOperationType) SysSystemAttributeMapping(eu.bcvsolutions.idm.acc.entity.SysSystemAttributeMapping) AttributeMapping(eu.bcvsolutions.idm.acc.domain.AttributeMapping) SystemEntityType(eu.bcvsolutions.idm.acc.domain.SystemEntityType) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto)

Example 13 with AttributeMapping

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

the class AbstractProvisioningExecutor method compileAtributeForStrategy.

/**
 * Compile given attribute for strategy
 *
 * @param strategy
 * @param defaultAttribute
 * @param overloadingAttributes
 * @return
 */
protected List<AttributeMapping> compileAtributeForStrategy(AttributeMappingStrategyType strategy, AttributeMapping defaultAttribute, List<SysRoleSystemAttributeDto> overloadingAttributes) {
    List<AttributeMapping> finalAttributes = new ArrayList<>();
    List<SysRoleSystemAttributeDto> attributesOrdered = overloadingAttributes.stream().filter(roleSystemAttribute -> {
        // Search attribute override same schema attribute
        SysSystemAttributeMappingDto attributeMapping = systemAttributeMappingService.get(roleSystemAttribute.getSystemAttributeMapping());
        return attributeMapping.equals(defaultAttribute);
    }).sorted((att1, att2) -> {
        // Sort attributes by role priority
        SysRoleSystemDto roleSystem2 = roleSystemService.get(att2.getRoleSystem());
        SysRoleSystemDto roleSystem1 = roleSystemService.get(att1.getRoleSystem());
        IdmRoleDto role1 = roleService.get(roleSystem1.getRole());
        IdmRoleDto role2 = roleService.get(roleSystem2.getRole());
        return Integer.valueOf(role2.getPriority()).compareTo(Integer.valueOf(role1.getPriority()));
    }).collect(Collectors.toList());
    // We have some overloaded attributes
    if (!attributesOrdered.isEmpty()) {
        List<SysRoleSystemAttributeDto> attributesOrderedGivenStrategy = attributesOrdered.stream().filter(attribute -> {
            return strategy == attribute.getStrategyType();
        }).collect(Collectors.toList());
        // We do not have overloaded attributes for given strategy
        if (attributesOrderedGivenStrategy.isEmpty()) {
            return finalAttributes;
        }
        // First element have role with max priority
        SysRoleSystemDto roleSystemForSetMaxPriority = roleSystemService.get(attributesOrderedGivenStrategy.get(0).getRoleSystem());
        IdmRoleDto roleForSetMaxPriority = roleService.get(roleSystemForSetMaxPriority.getRole());
        int maxPriority = roleForSetMaxPriority.getPriority();
        // We will search for attribute with highest priority (and role
        // name)
        Optional<SysRoleSystemAttributeDto> highestPriorityAttributeOptional = attributesOrderedGivenStrategy.stream().filter(attribute -> {
            SysRoleSystemDto roleSystem = roleSystemService.get(attribute.getRoleSystem());
            IdmRoleDto roleDto = roleService.get(roleSystem.getRole());
            // Filter attributes by max priority
            return maxPriority == roleDto.getPriority();
        }).sorted((att1, att2) -> {
            // Second filtering, if we have same priority, then
            // we will sort by role name
            SysRoleSystemDto roleSystem1 = roleSystemService.get(att1.getRoleSystem());
            SysRoleSystemDto roleSystem2 = roleSystemService.get(att2.getRoleSystem());
            // 
            IdmRoleDto roleDto1 = roleService.get(roleSystem1.getRole());
            IdmRoleDto roleDto2 = roleService.get(roleSystem2.getRole());
            // 
            return roleDto2.getName().compareTo(roleDto1.getName());
        }).findFirst();
        if (highestPriorityAttributeOptional.isPresent()) {
            SysRoleSystemAttributeDto highestPriorityAttribute = highestPriorityAttributeOptional.get();
            // overloaded attributes
            if (strategy == AttributeMappingStrategyType.AUTHORITATIVE_MERGE || strategy == AttributeMappingStrategyType.MERGE) {
                attributesOrderedGivenStrategy.forEach(attribute -> {
                    // Disabled attribute will be skipped
                    if (!attribute.isDisabledDefaultAttribute()) {
                        // Default values (values from schema attribute
                        // handling)
                        attribute.setSchemaAttribute(defaultAttribute.getSchemaAttribute());
                        attribute.setTransformFromResourceScript(defaultAttribute.getTransformFromResourceScript());
                        // Common properties (for MERGE strategy) will be
                        // set from MERGE attribute with highest priority
                        attribute.setSendAlways(highestPriorityAttribute.isSendAlways());
                        attribute.setSendOnlyIfNotNull(highestPriorityAttribute.isSendOnlyIfNotNull());
                        // Add modified attribute to final list
                        finalAttributes.add(attribute);
                    }
                });
                return finalAttributes;
            }
            // We will search for disabled overloaded attribute
            Optional<SysRoleSystemAttributeDto> disabledOverloadedAttOptional = attributesOrderedGivenStrategy.stream().filter(attribute -> {
                // Filter attributes by max priority
                SysRoleSystemDto roleSystem = roleSystemService.get(attribute.getRoleSystem());
                IdmRoleDto roleDto = roleService.get(roleSystem.getRole());
                return maxPriority == roleDto.getPriority();
            }).filter(attribute -> {
                // overloaded attribute
                return attribute.isDisabledDefaultAttribute();
            }).findFirst();
            if (disabledOverloadedAttOptional.isPresent()) {
                // priority
                return finalAttributes;
            }
            // Disabled attribute will be skipped
            if (!highestPriorityAttribute.isDisabledDefaultAttribute()) {
                // Default values (values from schema attribute handling)
                highestPriorityAttribute.setSchemaAttribute(defaultAttribute.getSchemaAttribute());
                highestPriorityAttribute.setCached(defaultAttribute.isCached());
                highestPriorityAttribute.setTransformFromResourceScript(defaultAttribute.getTransformFromResourceScript());
                // Add modified attribute to final list
                finalAttributes.add(highestPriorityAttribute);
                return finalAttributes;
            }
        }
    }
    if (!defaultAttribute.isDisabledAttribute() && strategy == defaultAttribute.getStrategyType()) {
        finalAttributes.add(defaultAttribute);
    }
    return finalAttributes;
}
Also used : ProvisioningExecutor(eu.bcvsolutions.idm.acc.service.api.ProvisioningExecutor) DtoUtils(eu.bcvsolutions.idm.core.api.utils.DtoUtils) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) Autowired(org.springframework.beans.factory.annotation.Autowired) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) EntityAccountDto(eu.bcvsolutions.idm.acc.dto.EntityAccountDto) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) SysRoleSystemService(eu.bcvsolutions.idm.acc.service.api.SysRoleSystemService) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) SysSystemEntity_(eu.bcvsolutions.idm.acc.entity.SysSystemEntity_) Map(java.util.Map) ProvisioningEntityExecutor(eu.bcvsolutions.idm.acc.service.api.ProvisioningEntityExecutor) SysSystemAttributeMapping(eu.bcvsolutions.idm.acc.entity.SysSystemAttributeMapping) ImmutableMap(com.google.common.collect.ImmutableMap) Collection(java.util.Collection) SystemOperationType(eu.bcvsolutions.idm.acc.domain.SystemOperationType) ReadWriteDtoService(eu.bcvsolutions.idm.core.api.service.ReadWriteDtoService) Set(java.util.Set) ProvisioningAttributeDto(eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) AttributeMapping(eu.bcvsolutions.idm.acc.domain.AttributeMapping) List(java.util.List) EntityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.EntityAccountFilter) AccAccountService(eu.bcvsolutions.idm.acc.service.api.AccAccountService) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) CollectionUtils(org.springframework.util.CollectionUtils) AccountType(eu.bcvsolutions.idm.acc.domain.AccountType) Optional(java.util.Optional) IcUidAttribute(eu.bcvsolutions.idm.ic.api.IcUidAttribute) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) AccAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter) SysSchemaObjectClassService(eu.bcvsolutions.idm.acc.service.api.SysSchemaObjectClassService) DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) AccResultCode(eu.bcvsolutions.idm.acc.domain.AccResultCode) IcConnectorConfiguration(eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration) IcConnectorFacade(eu.bcvsolutions.idm.ic.service.api.IcConnectorFacade) ProvisioningEvent(eu.bcvsolutions.idm.acc.event.ProvisioningEvent) AttributeMappingStrategyType(eu.bcvsolutions.idm.acc.domain.AttributeMappingStrategyType) ProvisioningEventType(eu.bcvsolutions.idm.acc.domain.ProvisioningEventType) SysSystemEntityService(eu.bcvsolutions.idm.acc.service.api.SysSystemEntityService) IdmAccountDto(eu.bcvsolutions.idm.core.api.dto.IdmAccountDto) HashMap(java.util.HashMap) IcObjectClassImpl(eu.bcvsolutions.idm.ic.impl.IcObjectClassImpl) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) SysSystemMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemMappingService) AbstractDto(eu.bcvsolutions.idm.core.api.dto.AbstractDto) ImmutableList(com.google.common.collect.ImmutableList) SystemEntityType(eu.bcvsolutions.idm.acc.domain.SystemEntityType) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult) IcConnectorObjectImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl) ProvisioningOperationType(eu.bcvsolutions.idm.acc.domain.ProvisioningOperationType) LinkedHashSet(java.util.LinkedHashSet) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto) ProvisioningContext(eu.bcvsolutions.idm.acc.domain.ProvisioningContext) Codeable(eu.bcvsolutions.idm.core.api.domain.Codeable) SysSystemMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter) SysRoleSystemAttributeService(eu.bcvsolutions.idm.acc.service.api.SysRoleSystemAttributeService) SysSchemaObjectClass_(eu.bcvsolutions.idm.acc.entity.SysSchemaObjectClass_) IcConnectorKey(eu.bcvsolutions.idm.ic.api.IcConnectorKey) SysSystemService(eu.bcvsolutions.idm.acc.service.api.SysSystemService) IdmRoleService(eu.bcvsolutions.idm.core.api.service.IdmRoleService) OperationState(eu.bcvsolutions.idm.core.api.domain.OperationState) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) SysRoleSystemAttributeDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto) SysSchemaAttributeService(eu.bcvsolutions.idm.acc.service.api.SysSchemaAttributeService) SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) AccAccount_(eu.bcvsolutions.idm.acc.entity.AccAccount_) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) CoreResultCode(eu.bcvsolutions.idm.core.api.domain.CoreResultCode) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) ProvisioningService(eu.bcvsolutions.idm.acc.service.api.ProvisioningService) Collections(java.util.Collections) SysSystemAttributeMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemAttributeMappingService) PasswordChangeDto(eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto) EntityEventManager(eu.bcvsolutions.idm.core.api.service.EntityEventManager) Assert(org.springframework.util.Assert) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemAttributeMapping(eu.bcvsolutions.idm.acc.entity.SysSystemAttributeMapping) AttributeMapping(eu.bcvsolutions.idm.acc.domain.AttributeMapping) ArrayList(java.util.ArrayList) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) SysRoleSystemAttributeDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto)

Example 14 with AttributeMapping

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

the class AbstractProvisioningExecutor method resolveAdditionalPasswordChangeAttributes.

private List<AttributeMapping> resolveAdditionalPasswordChangeAttributes(AccAccountDto account, DTO dto, SysSystemDto system, SystemEntityType entityType) {
    EntityAccountFilter filter = this.createEntityAccountFilter();
    filter.setEntityId(dto.getId());
    filter.setSystemId(system.getId());
    filter.setOwnership(Boolean.TRUE);
    filter.setAccountId(account.getId());
    List<? extends EntityAccountDto> entityAccoutnList = this.getEntityAccountService().find(filter, null).getContent();
    if (entityAccoutnList == null) {
        return Collections.<AttributeMapping>emptyList();
    }
    // 
    SysSystemMappingDto mapping = getMapping(system, entityType);
    if (mapping == null) {
        return Collections.<AttributeMapping>emptyList();
    }
    // 
    // All additional mapped attributes from system, witch has to be send on
    // password change
    SysSystemAttributeMappingFilter attributeFilter = new SysSystemAttributeMappingFilter();
    attributeFilter.setSystemMappingId(mapping.getId());
    attributeFilter.setSendOnPasswordChange(Boolean.TRUE);
    List<? extends AttributeMapping> additionalPasswordChangeAttributes = attributeMappingService.find(attributeFilter, null).getContent();
    // 
    // All role system attributes (overloading) for this uid and same system
    List<SysRoleSystemAttributeDto> roleSystemAttributesAll = findOverloadingAttributes(dto, system, entityAccoutnList, entityType);
    // 
    // Final list of attributes use for provisioning
    List<AttributeMapping> results = compileAttributes(additionalPasswordChangeAttributes, roleSystemAttributesAll, entityType);
    // 
    return results == null ? Collections.<AttributeMapping>emptyList() : results;
}
Also used : EntityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.EntityAccountFilter) SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) SysSystemAttributeMapping(eu.bcvsolutions.idm.acc.entity.SysSystemAttributeMapping) AttributeMapping(eu.bcvsolutions.idm.acc.domain.AttributeMapping) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysRoleSystemAttributeDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto)

Example 15 with AttributeMapping

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

the class AbstractProvisioningExecutor method compileAttributes.

/**
 * Create final list of attributes for provisioning.
 *
 * @param identityAccount
 * @param defaultAttributes
 * @param overloadingAttributes
 * @return
 */
@Override
public List<AttributeMapping> compileAttributes(List<? extends AttributeMapping> defaultAttributes, List<SysRoleSystemAttributeDto> overloadingAttributes, SystemEntityType entityType) {
    Assert.notNull(overloadingAttributes, "List of overloading attributes cannot be null!");
    List<AttributeMapping> finalAttributes = new ArrayList<>();
    if (defaultAttributes == null) {
        return null;
    }
    defaultAttributes.stream().forEach(defaultAttribute -> {
        for (AttributeMappingStrategyType strategy : AttributeMappingStrategyType.values()) {
            finalAttributes.addAll(compileAtributeForStrategy(strategy, defaultAttribute, overloadingAttributes));
        }
    });
    // Validate attributes on incompatible strategies
    validateAttributesStrategy(finalAttributes);
    return finalAttributes;
}
Also used : AttributeMappingStrategyType(eu.bcvsolutions.idm.acc.domain.AttributeMappingStrategyType) SysSystemAttributeMapping(eu.bcvsolutions.idm.acc.entity.SysSystemAttributeMapping) AttributeMapping(eu.bcvsolutions.idm.acc.domain.AttributeMapping) ArrayList(java.util.ArrayList)

Aggregations

AttributeMapping (eu.bcvsolutions.idm.acc.domain.AttributeMapping)21 ArrayList (java.util.ArrayList)17 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)16 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)15 SysRoleSystemAttributeDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto)15 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)15 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)14 ProvisioningException (eu.bcvsolutions.idm.acc.exception.ProvisioningException)14 SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)13 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)13 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)13 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)13 SystemOperationType (eu.bcvsolutions.idm.acc.domain.SystemOperationType)12 SysSchemaAttributeService (eu.bcvsolutions.idm.acc.service.api.SysSchemaAttributeService)12 SysSystemAttributeMappingService (eu.bcvsolutions.idm.acc.service.api.SysSystemAttributeMappingService)12 SysSystemMappingService (eu.bcvsolutions.idm.acc.service.api.SysSystemMappingService)12 DtoUtils (eu.bcvsolutions.idm.core.api.utils.DtoUtils)12 IcConnectorFacade (eu.bcvsolutions.idm.ic.service.api.IcConnectorFacade)12 List (java.util.List)12 UUID (java.util.UUID)12