Search in sources :

Example 26 with SysRoleSystemDto

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

the class DefaultSysProvisioningServiceTest method initOverloadedAttributes.

private void initOverloadedAttributes(List<SysRoleSystemAttributeDto> overloadingAttributes, List<AttributeMapping> defaultAttributes) {
    SysSchemaAttributeDto attOne = new SysSchemaAttributeDto();
    attOne.setName("attOne");
    attOne.setObjectClass(objectClasses.get(0).getId());
    attOne.setClassType(String.class.getName());
    attOne = schemaAttributeService.save(attOne);
    SysSchemaAttributeDto attTwo = new SysSchemaAttributeDto();
    attTwo.setName("attTwo");
    attTwo.setObjectClass(objectClasses.get(0).getId());
    attTwo.setClassType(String.class.getName());
    attTwo = schemaAttributeService.save(attTwo);
    SysSystemAttributeMappingDto defOne = new SysSystemAttributeMappingDto();
    defOne.setEntityAttribute(true);
    defOne.setIdmPropertyName("one");
    defOne.setName("defOne");
    defOne.setDisabledAttribute(true);
    defOne.setSchemaAttribute(attOne.getId());
    defOne.setSystemMapping(systemMapping.getId());
    defOne = systemAttributeMappingService.save(defOne);
    defaultAttributes.add(defOne);
    SysSystemAttributeMappingDto defTwo = new SysSystemAttributeMappingDto();
    defTwo.setEntityAttribute(true);
    defTwo.setIdmPropertyName("two");
    defTwo.setName("defTwo");
    defTwo.setSchemaAttribute(attTwo.getId());
    defTwo.setSystemMapping(systemMapping.getId());
    defTwo = systemAttributeMappingService.save(defTwo);
    defaultAttributes.add(defTwo);
    IdmRoleDto roleTwo = new IdmRoleDto();
    roleTwo.setName("roleTwo");
    roleTwo.setPriority(100);
    roleTwo = roleService.save(roleTwo);
    IdmRoleDto roleOne = new IdmRoleDto();
    roleOne.setName("roleOne");
    roleOne.setPriority(100);
    roleOne = roleService.save(roleOne);
    SysRoleSystemDto roleSystemTwo = new SysRoleSystemDto();
    roleSystemTwo.setRole(roleTwo.getId());
    roleSystemTwo.setSystem(system.getId());
    roleSystemTwo.setSystemMapping(systemMapping.getId());
    roleSystemTwo = roleSystemService.save(roleSystemTwo);
    SysRoleSystemDto roleSystemOne = new SysRoleSystemDto();
    roleSystemOne.setRole(roleOne.getId());
    roleSystemOne.setSystem(system.getId());
    roleSystemOne.setSystemMapping(systemMapping.getId());
    roleSystemOne = roleSystemService.save(roleSystemOne);
    SysRoleSystemAttributeDto overloadedRoleOne = new SysRoleSystemAttributeDto();
    overloadedRoleOne.setSystemAttributeMapping(defOne.getId());
    overloadedRoleOne.setEntityAttribute(true);
    overloadedRoleOne.setIdmPropertyName("one");
    overloadedRoleOne.setName("defOneOverloaded");
    overloadedRoleOne.setDisabledDefaultAttribute(false);
    overloadedRoleOne.setRoleSystem(roleSystemOne.getId());
    overloadedRoleOne = roleSystemAttributeService.save(overloadedRoleOne);
    overloadingAttributes.add(overloadedRoleOne);
    SysRoleSystemAttributeDto overloadedRoleTwo = new SysRoleSystemAttributeDto();
    overloadedRoleTwo.setSystemAttributeMapping(defOne.getId());
    overloadedRoleTwo.setEntityAttribute(true);
    overloadedRoleTwo.setIdmPropertyName("one");
    overloadedRoleTwo.setName("defOneOverloadedRoleTwo");
    overloadedRoleTwo.setDisabledDefaultAttribute(false);
    overloadedRoleTwo.setRoleSystem(roleSystemTwo.getId());
    overloadedRoleTwo = roleSystemAttributeService.save(overloadedRoleTwo);
    overloadingAttributes.add(overloadedRoleTwo);
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) SysRoleSystemAttributeDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto)

Example 27 with SysRoleSystemDto

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

the class DefaultSysRoleSystemServiceFilterTest method createRoleSystem.

/**
 * Create {@link SysRoleSystemDto}
 *
 * @param roleId
 * @param systemId
 * @param systemMappingId
 * @return
 */
private SysRoleSystemDto createRoleSystem(UUID roleId, UUID systemId, UUID systemMappingId) {
    helper.createRole();
    SysRoleSystemDto role = new SysRoleSystemDto();
    role.setRole(roleId);
    role.setSystem(systemId);
    role.setSystemMapping(systemMappingId);
    return roleSystemService.save(role);
}
Also used : SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto)

Example 28 with SysRoleSystemDto

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

the class DefaultSysRoleSystemServiceFilterTest method testSystemIdFilter.

@Test
public void testSystemIdFilter() {
    IdmRoleDto role1 = helper.createRole();
    IdmRoleDto role2 = helper.createRole();
    SysSystemDto system1 = helper.createTestResourceSystem(true);
    SysSystemDto system2 = helper.createTestResourceSystem(true);
    // 
    SysSystemMappingDto sysSystemMappingDto = mappingService.findBySystemId(system1.getId(), SystemOperationType.PROVISIONING, SystemEntityType.IDENTITY).get(0);
    createRoleSystem(role1.getId(), system1.getId(), sysSystemMappingDto.getId());
    SysRoleSystemDto roleSystem2 = createRoleSystem(role2.getId(), system2.getId(), sysSystemMappingDto.getId());
    // 
    SysRoleSystemFilter roleFilter = new SysRoleSystemFilter();
    roleFilter.setSystemId(system2.getId());
    Page<SysRoleSystemDto> pages = roleSystemService.find(roleFilter, null);
    // 
    assertEquals(1, pages.getTotalElements());
    assertEquals(roleSystem2.getId(), pages.getContent().get(0).getId());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysRoleSystemFilter(eu.bcvsolutions.idm.acc.dto.filter.SysRoleSystemFilter) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 29 with SysRoleSystemDto

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

the class DefaultSysRoleSystemService method save.

@Override
public SysRoleSystemDto save(SysRoleSystemDto dto, BasePermission... permission) {
    Assert.notNull(dto, "RoleSystem cannot be null!");
    Assert.notNull(dto.getRole(), "Role cannot be null!");
    Assert.notNull(dto.getSystem(), "System cannot be null!");
    SysRoleSystemFilter filter = new SysRoleSystemFilter();
    filter.setRoleId(dto.getRole());
    filter.setSystemId(dto.getSystem());
    List<SysRoleSystemDto> roleSystems = this.find(filter, null).getContent();
    boolean isDuplicated = roleSystems.stream().filter(roleSystem -> {
        return !roleSystem.getId().equals(dto.getId());
    }).findFirst().isPresent();
    if (isDuplicated) {
        IdmRoleDto roleDto = roleService.get(dto.getRole());
        SysSystemDto systemDto = DtoUtils.getEmbedded(dto, SysRoleSystem_.system, SysSystemDto.class);
        throw new ResultCodeException(AccResultCode.ROLE_SYSTEM_ALREADY_EXISTS, ImmutableMap.of("role", roleDto.getName(), "system", systemDto.getName()));
    }
    return super.save(dto, permission);
}
Also used : SysRoleSystemFilter(eu.bcvsolutions.idm.acc.dto.filter.SysRoleSystemFilter) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto)

Example 30 with SysRoleSystemDto

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

the class DefaultTestHelper method createRoleSystem.

@Override
public SysRoleSystemDto createRoleSystem(IdmRoleDto role, SysSystemDto system) {
    SysRoleSystemDto roleSystem = new SysRoleSystemDto();
    roleSystem.setRole(role.getId());
    roleSystem.setSystem(system.getId());
    // default mapping
    List<SysSystemMappingDto> mappings = systemMappingService.findBySystem(system, SystemOperationType.PROVISIONING, SystemEntityType.IDENTITY);
    // 
    roleSystem.setSystemMapping(mappings.get(0).getId());
    return roleSystemService.save(roleSystem);
}
Also used : SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)

Aggregations

SysRoleSystemDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto)30 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)26 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)24 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)23 SysRoleSystemAttributeDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto)19 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)17 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)17 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)16 Test (org.junit.Test)16 ArrayList (java.util.ArrayList)15 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)14 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)13 AccIdentityAccountDto (eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)13 AccIdentityAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter)13 ProvisioningException (eu.bcvsolutions.idm.acc.exception.ProvisioningException)13 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)12 SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)12 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)12 AccAccountService (eu.bcvsolutions.idm.acc.service.api.AccAccountService)12 SysRoleSystemAttributeService (eu.bcvsolutions.idm.acc.service.api.SysRoleSystemAttributeService)12