Search in sources :

Example 1 with IdmIdentityRoleFilter

use of eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter in project CzechIdMng by bcvsolutions.

the class DefaultIdmAutomaticRoleAttributeService method removeAutomaticRoles.

@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void removeAutomaticRoles(UUID contractId, Set<AbstractIdmAutomaticRoleDto> automaticRoles) {
    for (AbstractIdmAutomaticRoleDto autoRole : automaticRoles) {
        IdmIdentityRoleFilter identityRoleFilter = new IdmIdentityRoleFilter();
        identityRoleFilter.setIdentityContractId(contractId);
        identityRoleFilter.setAutomaticRoleId(autoRole.getId());
        // TODO: possible performance update with pageable
        for (IdmIdentityRoleDto identityRole : identityRoleService.find(identityRoleFilter, null).getContent()) {
            // skip check granted authorities
            IdentityRoleEvent event = new IdentityRoleEvent(IdentityRoleEventType.DELETE, identityRole);
            event.getProperties().put(IdmIdentityRoleService.SKIP_CHECK_AUTHORITIES, Boolean.TRUE);
            identityRoleService.publish(event);
        }
    }
}
Also used : IdentityRoleEvent(eu.bcvsolutions.idm.core.model.event.IdentityRoleEvent) AbstractIdmAutomaticRoleDto(eu.bcvsolutions.idm.core.api.dto.AbstractIdmAutomaticRoleDto) IdmIdentityRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with IdmIdentityRoleFilter

use of eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter in project CzechIdMng by bcvsolutions.

the class DefaultIdmAutomaticRoleAttributeService method processAutomaticRolesForContract.

@Override
public void processAutomaticRolesForContract(UUID contractId, Set<AbstractIdmAutomaticRoleDto> passedAutomaticRoles, Set<AbstractIdmAutomaticRoleDto> notPassedAutomaticRoles) {
    // Assign new passed automatic roles (assign to default contract)
    IdmIdentityContractDto contract = identityContractService.get(contractId);
    // 
    if (contract == null) {
        LOG.debug(MessageFormat.format("Contract id [{0}] not found.", contractId));
        return;
    }
    // TODO: this behavior can be optimalized by add it into query
    if (!contract.isValidNowOrInFuture() || contract.getState() == ContractState.DISABLED) {
        // null all new passed automatic roles
        passedAutomaticRoles = null;
    }
    // 
    // find all automatic roles for identity
    IdmIdentityRoleFilter roleIdentityFilter = new IdmIdentityRoleFilter();
    roleIdentityFilter.setIdentityContractId(contractId);
    roleIdentityFilter.setAutomaticRole(Boolean.TRUE);
    // 
    if (passedAutomaticRoles != null && !passedAutomaticRoles.isEmpty()) {
        this.addAutomaticRoles(contract, passedAutomaticRoles);
    }
    // 
    if (notPassedAutomaticRoles != null && !notPassedAutomaticRoles.isEmpty()) {
        this.removeAutomaticRoles(contract.getId(), notPassedAutomaticRoles);
    }
}
Also used : IdmIdentityRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)

Example 3 with IdmIdentityRoleFilter

use of eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter in project CzechIdMng by bcvsolutions.

the class DefaultIdmIdentityRoleService method findValidRole.

@Override
@Transactional(readOnly = true)
public Page<IdmIdentityRoleDto> findValidRole(UUID identityId, Pageable pageable) {
    IdmIdentityRoleFilter identityRoleFilter = new IdmIdentityRoleFilter();
    identityRoleFilter.setValid(Boolean.TRUE);
    identityRoleFilter.setIdentityId(identityId);
    return this.find(identityRoleFilter, pageable);
}
Also used : IdmIdentityRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with IdmIdentityRoleFilter

use of eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter in project CzechIdMng by bcvsolutions.

the class DefaultIdentityRoleServiceTest method roleCatalogueTest.

@Test
public void roleCatalogueTest() {
    IdmIdentityDto person = testHelper.createIdentity();
    IdmIdentityDto person2 = testHelper.createIdentity();
    IdmRoleCatalogueDto catalogue = testHelper.createRoleCatalogue();
    IdmRoleCatalogueRoleDto catalogueRole = new IdmRoleCatalogueRoleDto();
    IdmRoleCatalogueRoleDto catalogueRole2 = new IdmRoleCatalogueRoleDto();
    IdmIdentityContractDto contract = testHelper.createIdentityContact(person);
    IdmIdentityContractDto contract2 = testHelper.createIdentityContact(person2);
    IdmRoleDto role = testHelper.createRole();
    IdmRoleDto role2 = testHelper.createRole();
    catalogueRole.setRoleCatalogue(catalogue.getId());
    catalogueRole.setRole(role.getId());
    catalogueRole2.setRoleCatalogue(catalogue.getId());
    catalogueRole2.setRole(role2.getId());
    IdmIdentityRoleDto roleCover = testHelper.createIdentityRole(contract, role);
    IdmIdentityRoleDto roleCover2 = testHelper.createIdentityRole(contract2, role2);
    idmRoleCatalogueRoleService.save(catalogueRole);
    idmRoleCatalogueRoleService.save(catalogueRole2);
    IdmIdentityRoleFilter filter = new IdmIdentityRoleFilter();
    filter.setRoleCatalogueId(catalogue.getId());
    Page<IdmIdentityRoleDto> result = idmIdentityRoleService.find(filter, null);
    assertEquals("Wrong CatalogueRoleId", roleCover.getId(), result.getContent().get(0).getId());
    assertEquals("Wrong CatalogueRoleId2", roleCover2.getId(), result.getContent().get(1).getId());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRoleCatalogueRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueRoleDto) IdmRoleCatalogueDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmIdentityRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 5 with IdmIdentityRoleFilter

use of eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter in project CzechIdMng by bcvsolutions.

the class DefaultIdentityRoleServiceTest method identityIdTest.

@Test
public void identityIdTest() {
    IdmRoleDto role = testHelper.createRole();
    IdmIdentityDto person = testHelper.createIdentity();
    IdmIdentityRoleDto addRole = testHelper.createIdentityRole(person, role);
    IdmIdentityRoleFilter filter = new IdmIdentityRoleFilter();
    filter.setIdentityId(person.getId());
    Page<IdmIdentityRoleDto> result = idmIdentityRoleService.find(filter, null);
    assertEquals("Wrong RoleId", addRole.getId(), result.getContent().get(0).getId());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmIdentityRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Aggregations

IdmIdentityRoleFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter)116 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)85 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)84 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)81 Test (org.junit.Test)72 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)67 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)46 UUID (java.util.UUID)41 IdmRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto)39 IdmIdentityRoleService (eu.bcvsolutions.idm.core.api.service.IdmIdentityRoleService)38 List (java.util.List)38 Autowired (org.springframework.beans.factory.annotation.Autowired)38 IdmConceptRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto)33 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)31 LocalDate (java.time.LocalDate)31 Assert (org.junit.Assert)28 IdmRoleService (eu.bcvsolutions.idm.core.api.service.IdmRoleService)27 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)25 IdmAutomaticRoleAttributeDto (eu.bcvsolutions.idm.core.api.dto.IdmAutomaticRoleAttributeDto)25 IdmFormAttributeDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto)25