Search in sources :

Example 51 with SysRoleSystemAttributeDto

use of eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto 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 = DtoUtils.getEmbedded(roleSystemAttribute, SysRoleSystemAttribute_.systemAttributeMapping.getName(), SysSystemAttributeMappingDto.class);
        return attributeMapping.equals(defaultAttribute);
    }).sorted((att1, att2) -> {
        // Sort attributes by role priority
        IdmRoleDto role1 = this.getRole(att1);
        IdmRoleDto role2 = this.getRole(att2);
        return Integer.compare(role2.getPriority(), 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
        IdmRoleDto roleForSetMaxPriority = this.getRole((AttributeMapping) attributesOrderedGivenStrategy.get(0));
        int maxPriority = roleForSetMaxPriority.getPriority();
        // We will search for attribute with highest priority (and role
        // name)
        Optional<SysRoleSystemAttributeDto> highestPriorityAttributeOptional = attributesOrderedGivenStrategy.stream().filter(attribute -> {
            IdmRoleDto roleDto = this.getRole(attribute);
            // 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
            IdmRoleDto roleDto1 = this.getRole(att1);
            IdmRoleDto roleDto2 = this.getRole(att2);
            // 
            return roleDto2.getCode().compareTo(roleDto1.getCode());
        }).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
                IdmRoleDto roleDto = this.getRole(attribute);
                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) AccIdentityAccount_(eu.bcvsolutions.idm.acc.entity.AccIdentityAccount_) EntityAccountDto(eu.bcvsolutions.idm.acc.dto.EntityAccountDto) StringUtils(org.apache.commons.lang3.StringUtils) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) SysSystemAttributeMapping_(eu.bcvsolutions.idm.acc.entity.SysSystemAttributeMapping_) IdmRoleRequestService(eu.bcvsolutions.idm.core.api.service.IdmRoleRequestService) SysRoleSystemService(eu.bcvsolutions.idm.acc.service.api.SysRoleSystemService) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) SysSystemEntity_(eu.bcvsolutions.idm.acc.entity.SysSystemEntity_) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) 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) PageRequest(org.springframework.data.domain.PageRequest) ProvisioningAttributeDto(eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) Serializable(java.io.Serializable) 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) MappingContext(eu.bcvsolutions.idm.acc.domain.MappingContext) IcConnectorFacade(eu.bcvsolutions.idm.ic.service.api.IcConnectorFacade) ProvisioningEvent(eu.bcvsolutions.idm.acc.event.ProvisioningEvent) AttributeMappingStrategyType(eu.bcvsolutions.idm.acc.domain.AttributeMappingStrategyType) SysRoleSystem_(eu.bcvsolutions.idm.acc.entity.SysRoleSystem_) 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) SysRoleSystemAttribute_(eu.bcvsolutions.idm.acc.entity.SysRoleSystemAttribute_) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) SystemEntityNotFoundException(eu.bcvsolutions.idm.acc.exception.SystemEntityNotFoundException) 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_) 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) EventContext(eu.bcvsolutions.idm.core.api.event.EventContext) SysRoleSystemAttributeDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto) SysSchemaAttributeService(eu.bcvsolutions.idm.acc.service.api.SysSchemaAttributeService) SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) Contextable(eu.bcvsolutions.idm.core.api.domain.Contextable) 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) SysRoleSystemAttributeDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto)

Example 52 with SysRoleSystemAttributeDto

use of eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto in project CzechIdMng by bcvsolutions.

the class AbstractProvisioningExecutor method resolveAdditionalPasswordChangeAttributes.

private List<AttributeMapping> resolveAdditionalPasswordChangeAttributes(AccAccountDto account, DTO dto, SysSystemDto system, SystemEntityType entityType) {
    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);
    // we want only active attributes
    attributeFilter.setDisabledAttribute(Boolean.FALSE);
    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, account, entityType);
    // 
    // Final list of attributes use for provisioning
    List<AttributeMapping> results = compileAttributes(additionalPasswordChangeAttributes, roleSystemAttributesAll, entityType);
    // 
    return results == null ? Collections.<AttributeMapping>emptyList() : results;
}
Also used : 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 53 with SysRoleSystemAttributeDto

use of eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto in project CzechIdMng by bcvsolutions.

the class CrossDomainAdUserConnectorTypeTest method createOverriddenLdapGroupAttribute.

private void createOverriddenLdapGroupAttribute(SysSystemAttributeMappingDto ldapGroupsAttribute, SysRoleSystemDto roleSystem, String script) {
    // Creates overridden ldapGroup merge attribute.
    SysRoleSystemAttributeDto ldapGroupsRoleSystemAttribute = new SysRoleSystemAttributeDto();
    ldapGroupsRoleSystemAttribute.setSystemAttributeMapping(ldapGroupsAttribute.getId());
    ldapGroupsRoleSystemAttribute.setRoleSystem(roleSystem.getId());
    ldapGroupsRoleSystemAttribute.setEntityAttribute(ldapGroupsAttribute.isEntityAttribute());
    ldapGroupsRoleSystemAttribute.setSchemaAttribute(ldapGroupsAttribute.getSchemaAttribute());
    ldapGroupsRoleSystemAttribute.setExtendedAttribute(ldapGroupsAttribute.isExtendedAttribute());
    ldapGroupsRoleSystemAttribute.setName(ldapGroupsAttribute.getName());
    ldapGroupsRoleSystemAttribute.setStrategyType(ldapGroupsAttribute.getStrategyType());
    ldapGroupsRoleSystemAttribute.setIdmPropertyName(ldapGroupsAttribute.getIdmPropertyName());
    ldapGroupsRoleSystemAttribute.setUid(ldapGroupsAttribute.isUid());
    ldapGroupsRoleSystemAttribute.setTransformScript(script);
    roleSystemAttributeService.save(ldapGroupsRoleSystemAttribute);
}
Also used : SysRoleSystemAttributeDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto)

Example 54 with SysRoleSystemAttributeDto

use of eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto in project CzechIdMng by bcvsolutions.

the class IdentityAccountManagementTest method initData.

private void initData() {
    // create test system
    SysSystemDto system = helper.createTestResourceSystem(true, SYSTEM_NAME);
    // 
    // Create test identity for provisioning test
    IdmIdentityDto identity = new IdmIdentityDto();
    identity.setUsername(IDENTITY_USERNAME);
    identity.setFirstName(IDENTITY_USERNAME);
    identity.setLastName(IDENTITY_USERNAME);
    identity.setEmail(IDENTITY_EMAIL);
    identity = identityService.save(identity);
    // Create mapped attributes to schema
    SysSystemMappingDto systemMapping = helper.getDefaultMapping(system);
    SysSystemAttributeMappingDto attributeHandlingLastName = schemaAttributeHandlingService.findBySystemMappingAndName(systemMapping.getId(), helper.getSchemaColumnName(TestHelper.ATTRIBUTE_MAPPING_LASTNAME));
    SysSystemAttributeMappingDto attributeHandlingFirstName = schemaAttributeHandlingService.findBySystemMappingAndName(systemMapping.getId(), helper.getSchemaColumnName(TestHelper.ATTRIBUTE_MAPPING_FIRSTNAME));
    SysSystemAttributeMappingDto attributeHandlingUserName = schemaAttributeHandlingService.findBySystemMappingAndName(systemMapping.getId(), TestHelper.ATTRIBUTE_MAPPING_NAME);
    // username is transformed
    attributeHandlingUserName.setTransformToResourceScript("return \"" + "x" + IDENTITY_USERNAME + "\";");
    attributeHandlingUserName = schemaAttributeHandlingService.save(attributeHandlingUserName);
    /*
		 * Create role with link on system (default)
		 */
    IdmRoleDto roleDefault = new IdmRoleDto();
    roleDefault.setCode(ROLE_DEFAULT);
    roleDefault = roleService.save(roleDefault);
    SysRoleSystemDto roleSystemDefault = new SysRoleSystemDto();
    roleSystemDefault.setRole(roleDefault.getId());
    roleSystemDefault.setSystem(system.getId());
    roleSystemDefault.setSystemMapping(systemMapping.getId());
    roleSystemDefault = roleSystemService.save(roleSystemDefault);
    /*
		 * Create role with link on system (overloading last name attribute)
		 */
    IdmRoleDto roleOverloadingLastName = new IdmRoleDto();
    roleOverloadingLastName.setCode(ROLE_OVERLOADING_LAST_NAME);
    roleOverloadingLastName = roleService.save(roleOverloadingLastName);
    SysRoleSystemDto roleSystemLastName = new SysRoleSystemDto();
    roleSystemLastName.setRole(roleOverloadingLastName.getId());
    roleSystemLastName.setSystem(system.getId());
    roleSystemLastName.setSystemMapping(systemMapping.getId());
    roleSystemLastName = roleSystemService.save(roleSystemLastName);
    // Attribute for overloading last name attribute
    SysRoleSystemAttributeDto attributeLastName = new SysRoleSystemAttributeDto();
    attributeLastName.setEntityAttribute(true);
    attributeLastName.setIdmPropertyName("email");
    attributeLastName.setName("Overloaded lastName with email");
    attributeLastName.setRoleSystem(roleSystemLastName.getId());
    attributeLastName.setSystemAttributeMapping(attributeHandlingLastName.getId());
    attributeLastName = roleSystemAttributeService.save(attributeLastName);
    /*
		 * Create role with link on system (overloading password attribute)
		 */
    IdmRoleDto roleOverloadingPassword = new IdmRoleDto();
    // Since 9.3.0 password can't be overridden
    roleOverloadingPassword.setCode(ROLE_OVERLOADING_PASSWORD);
    roleOverloadingPassword = roleService.save(roleOverloadingPassword);
    SysRoleSystemDto roleSystemPassword = new SysRoleSystemDto();
    roleSystemPassword.setRole(roleOverloadingPassword.getId());
    roleSystemPassword.setSystem(system.getId());
    roleSystemPassword.setSystemMapping(systemMapping.getId());
    roleSystemPassword = roleSystemService.save(roleSystemPassword);
    /*
		 * Create role with link on system (overloading (disable) first name
		 * attribute)
		 */
    IdmRoleDto roleOverloadingFirstName = new IdmRoleDto();
    roleOverloadingFirstName.setCode(ROLE_OVERLOADING_FIRST_NAME);
    roleOverloadingFirstName = roleService.save(roleOverloadingFirstName);
    SysRoleSystemDto roleSystemFirstName = new SysRoleSystemDto();
    roleSystemFirstName.setRole(roleOverloadingFirstName.getId());
    roleSystemFirstName.setSystem(system.getId());
    roleSystemFirstName.setSystemMapping(systemMapping.getId());
    roleSystemFirstName = roleSystemService.save(roleSystemFirstName);
    // Attribute for overloading first name attribute (disable him)
    SysRoleSystemAttributeDto attributeFirstName = new SysRoleSystemAttributeDto();
    attributeFirstName.setDisabledDefaultAttribute(true);
    attributeFirstName.setName("Disable first name");
    attributeFirstName.setRoleSystem(roleSystemFirstName.getId());
    attributeFirstName.setSystemAttributeMapping(attributeHandlingFirstName.getId());
    attributeFirstName = roleSystemAttributeService.save(attributeFirstName);
    /*
		 * Create role with link on system (overloading name attribute ...
		 * create Y account)
		 */
    IdmRoleDto roleOverloadingName = new IdmRoleDto();
    roleOverloadingName.setCode(ROLE_OVERLOADING_Y_ACCOUNT);
    roleOverloadingName = roleService.save(roleOverloadingName);
    SysRoleSystemDto roleSystemName = new SysRoleSystemDto();
    roleSystemName.setRole(roleOverloadingName.getId());
    roleSystemName.setSystem(system.getId());
    roleSystemName.setSystemMapping(systemMapping.getId());
    roleSystemName = roleSystemService.save(roleSystemName);
    // Attribute for overloading first name attribute (disable him)
    SysRoleSystemAttributeDto attributeName = new SysRoleSystemAttributeDto();
    attributeName.setUid(true);
    attributeName.setEntityAttribute(true);
    attributeName.setIdmPropertyName("username");
    attributeName.setName("Account with Y-prefix name");
    attributeName.setTransformScript("return \"y\" + attributeValue ;");
    attributeName.setRoleSystem(roleSystemName.getId());
    attributeName.setSystemAttributeMapping(attributeHandlingUserName.getId());
    attributeName = roleSystemAttributeService.save(attributeName);
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SysRoleSystemAttributeDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto)

Example 55 with SysRoleSystemAttributeDto

use of eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto in project CzechIdMng by bcvsolutions.

the class DefaultSysSystemAttributeMappingService method createMappingIdmPath.

/**
 * Creates a list of attribute mapping info from which an error originates
 * Contains: system name / mapping or role name / mapped attribute name
 *
 * @param attributeMapping
 * @return
 */
private List<String> createMappingIdmPath(AttributeMapping attributeMapping) {
    List<String> path = new ArrayList<>();
    // attribute name
    path.add(String.format("Attr: %s", attributeMapping.getName()));
    // role and system mapping name
    SysSystemAttributeMappingDto sysMapping = null;
    if (attributeMapping instanceof SysRoleSystemAttributeDto) {
        SysRoleSystemAttributeDto mapping = (SysRoleSystemAttributeDto) attributeMapping;
        // get role name
        SysRoleSystemDto roleSystem = DtoUtils.getEmbedded(mapping, SysRoleSystemAttribute_.roleSystem, SysRoleSystemDto.class, null);
        // mapping name and role name are not be available in case of script pre-evaluation during saving
        if (roleSystem != null) {
            IdmRoleDto roleDto = DtoUtils.getEmbedded(roleSystem, SysRoleSystem_.role, IdmRoleDto.class);
            path.add(String.format("Role: %s", roleDto.getCode()));
            sysMapping = DtoUtils.getEmbedded(mapping, SysRoleSystemAttribute_.systemAttributeMapping, SysSystemAttributeMappingDto.class, null);
        }
    } else if (attributeMapping instanceof SysSystemAttributeMappingDto) {
        sysMapping = (SysSystemAttributeMappingDto) attributeMapping;
    }
    if (sysMapping != null) {
        String mappingName = DtoUtils.getEmbedded(sysMapping, SysSystemAttributeMapping_.systemMapping, SysSystemMappingDto.class).getName();
        path.add(String.format("Mapping: %s", mappingName));
    }
    // system name
    path.add(String.format("System: %s", getSystemFromAttributeMapping(attributeMapping).getCode()));
    return path;
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) ArrayList(java.util.ArrayList) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) SysRoleSystemAttributeDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto)

Aggregations

SysRoleSystemAttributeDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto)65 SysRoleSystemDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto)50 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)47 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)44 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)42 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)41 SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)36 Test (org.junit.Test)34 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)30 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)25 SysSchemaAttributeFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter)20 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)20 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)19 UUID (java.util.UUID)19 ArrayList (java.util.ArrayList)17 SysRoleSystemAttributeService (eu.bcvsolutions.idm.acc.service.api.SysRoleSystemAttributeService)16 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)16 List (java.util.List)16 Autowired (org.springframework.beans.factory.annotation.Autowired)16 AttributeMappingStrategyType (eu.bcvsolutions.idm.acc.domain.AttributeMappingStrategyType)15