Search in sources :

Example 31 with IdmIdentity

use of eu.bcvsolutions.idm.core.model.entity.IdmIdentity in project CzechIdMng by bcvsolutions.

the class IdentityGuaranteesForRoleFilterIntegrationTest method testFindGuaranteesByTypeInRole.

@Test
public void testFindGuaranteesByTypeInRole() {
    // prepare data
    String guaranteeType = getHelper().createName();
    IdmIdentityDto identityOne = getHelper().createIdentity((GuardedString) null);
    IdmIdentityDto identityTwo = getHelper().createIdentity((GuardedString) null);
    IdmIdentityDto identityThree = getHelper().createIdentity((GuardedString) null);
    IdmRoleDto role = getHelper().createRole();
    IdmRoleDto roleGuarantee = getHelper().createRole();
    getHelper().createRoleGuarantee(role, identityOne, guaranteeType);
    getHelper().createRoleGuaranteeRole(role, roleGuarantee);
    getHelper().createIdentityRole(identityThree, roleGuarantee);
    getHelper().createIdentityRole(identityTwo, role);
    // 
    IdmIdentityFilter dataFilter = new IdmIdentityFilter();
    dataFilter.setGuaranteesForRole(role.getId());
    dataFilter.setGuaranteeType(guaranteeType);
    List<IdmIdentity> identities = filter.find(dataFilter, null).getContent();
    // 
    Assert.assertEquals(1, identities.size());
    Assert.assertTrue(identities.stream().anyMatch(i -> i.getId().equals(identityOne.getId())));
}
Also used : List(java.util.List) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) IdmIdentityFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Autowired(org.springframework.beans.factory.annotation.Autowired) Test(org.junit.Test) IdmIdentityService(eu.bcvsolutions.idm.core.api.service.IdmIdentityService) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) Assert(org.junit.Assert) Transactional(org.springframework.transaction.annotation.Transactional) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmIdentityFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 32 with IdmIdentity

use of eu.bcvsolutions.idm.core.model.entity.IdmIdentity in project CzechIdMng by bcvsolutions.

the class DefaultFormServiceItegrationTest method testOwnerWithoutId.

@Test(expected = IllegalArgumentException.class)
public void testOwnerWithoutId() {
    // unpersisted identity
    FormableEntity owner = new IdmIdentity();
    formService.getValues(owner);
}
Also used : IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) FormableEntity(eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 33 with IdmIdentity

use of eu.bcvsolutions.idm.core.model.entity.IdmIdentity in project CzechIdMng by bcvsolutions.

the class IdentityRoleAddAuthoritiesProcessor method checkAddedPermissions.

private void checkAddedPermissions(IdmIdentityRoleDto identityRole) {
    IdmIdentityContract contract = contractRepository.findOne(identityRole.getIdentityContract());
    IdmIdentity identity = contract.getIdentity();
    List<IdmIdentityRoleDto> withoutAdded = identityRoleService.findAllByIdentity(identity.getId());
    withoutAdded.remove(identityRole);
    // represents the final authorities set after role removal
    Collection<? extends GrantedAuthority> original = authorityHierarchy.getReachableGrantedAuthorities(authoritiesFactory.getGrantedAuthoritiesForValidRoles(identity.getId(), withoutAdded));
    Collection<? extends GrantedAuthority> addedAuthorities = authorityHierarchy.getReachableGrantedAuthorities(authoritiesFactory.getGrantedAuthoritiesForValidRoles(identity.getId(), Collections.singletonList(identityRole)));
    if (!authoritiesFactory.containsAllAuthorities(original, addedAuthorities)) {
        // authorities were changed, update identity flag
        IdmAuthorityChange ac = repository.findOneByIdentity_Id(identity.getId());
        if (ac == null) {
            ac = new IdmAuthorityChange();
            ac.setIdentity(identity);
        }
        ac.authoritiesChanged();
        repository.save(ac);
    }
}
Also used : IdmAuthorityChange(eu.bcvsolutions.idm.core.model.entity.IdmAuthorityChange) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) IdmIdentityContract(eu.bcvsolutions.idm.core.model.entity.IdmIdentityContract)

Example 34 with IdmIdentity

use of eu.bcvsolutions.idm.core.model.entity.IdmIdentity in project CzechIdMng by bcvsolutions.

the class IdentityRoleDeleteAuthoritiesProcessor method checkRevokedPermissions.

private void checkRevokedPermissions(IdmIdentityRoleDto identityRole) {
    IdmIdentityContract contract = contractRepository.findOne(identityRole.getIdentityContract());
    IdmIdentity identity = contract.getIdentity();
    List<IdmIdentityRoleDto> roles = identityRoleService.findAllByIdentity(identity.getId());
    roles.remove(identityRole);
    // represents the final authorities set after role removal
    Collection<? extends GrantedAuthority> withoutDeleted = authorityHierarchy.getReachableGrantedAuthorities(authoritiesFactory.getGrantedAuthoritiesForValidRoles(identity.getId(), roles));
    Collection<? extends GrantedAuthority> deletedAuthorities = authorityHierarchy.getReachableGrantedAuthorities(authoritiesFactory.getGrantedAuthoritiesForValidRoles(identity.getId(), Collections.singletonList(identityRole)));
    if (!authoritiesFactory.containsAllAuthorities(withoutDeleted, deletedAuthorities)) {
        // authorities were changed, update identity flag
        IdmAuthorityChange ac = repository.findOneByIdentity_Id(identity.getId());
        if (ac == null) {
            ac = new IdmAuthorityChange();
            ac.setIdentity(identity);
        }
        ac.authoritiesChanged();
        repository.save(ac);
    }
}
Also used : IdmAuthorityChange(eu.bcvsolutions.idm.core.model.entity.IdmAuthorityChange) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) IdmIdentityContract(eu.bcvsolutions.idm.core.model.entity.IdmIdentityContract)

Example 35 with IdmIdentity

use of eu.bcvsolutions.idm.core.model.entity.IdmIdentity in project CzechIdMng by bcvsolutions.

the class DefaultIdmIdentityService method createAuthorityChange.

private void createAuthorityChange(Collection<IdmIdentity> withoutAuthChange, DateTime changeTime) {
    for (IdmIdentity identity : withoutAuthChange) {
        IdmAuthorityChange ac = new IdmAuthorityChange();
        ac.setAuthChangeTimestamp(changeTime);
        ac.setIdentity(identity);
        authChangeRepository.save(ac);
    }
}
Also used : IdmAuthorityChange(eu.bcvsolutions.idm.core.model.entity.IdmAuthorityChange) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity)

Aggregations

IdmIdentity (eu.bcvsolutions.idm.core.model.entity.IdmIdentity)58 Test (org.junit.Test)44 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)28 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)20 IdmIdentityFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter)18 AbstractUnitTest (eu.bcvsolutions.idm.test.api.AbstractUnitTest)13 Transactional (org.springframework.transaction.annotation.Transactional)11 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)9 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)9 IdmIdentityService (eu.bcvsolutions.idm.core.api.service.IdmIdentityService)7 DataFilter (eu.bcvsolutions.idm.core.api.dto.filter.DataFilter)6 List (java.util.List)6 Autowired (org.springframework.beans.factory.annotation.Autowired)6 IdmIdentityContract (eu.bcvsolutions.idm.core.model.entity.IdmIdentityContract)5 Assert (org.junit.Assert)5 IdmAuthorityChange (eu.bcvsolutions.idm.core.model.entity.IdmAuthorityChange)4 UUID (java.util.UUID)4 Identifiable (eu.bcvsolutions.idm.core.api.domain.Identifiable)3 IdmEntityEventDto (eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto)3 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)3