Search in sources :

Example 1 with IdmAuthorizationPolicyFilter

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

the class RoleExportBulkActionIntegrationTest method findPolicy.

private List<IdmAuthorizationPolicyDto> findPolicy(IdmRoleDto role) {
    IdmAuthorizationPolicyFilter filter = new IdmAuthorizationPolicyFilter();
    filter.setRoleId(role.getId());
    return authorizationPolicyService.find(filter, null).getContent();
}
Also used : IdmAuthorizationPolicyFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmAuthorizationPolicyFilter)

Example 2 with IdmAuthorizationPolicyFilter

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

the class AuthorizationPolicyDisableBulkActionIntegrationTest method processBulkActionByFilter.

@Test
public void processBulkActionByFilter() {
    List<IdmAuthorizationPolicyDto> policies = createPolicies(5);
    IdmAuthorizationPolicyFilter filter = new IdmAuthorizationPolicyFilter();
    filter.setId(policies.get(2).getId());
    List<IdmAuthorizationPolicyDto> checkPolicies = service.find(filter, null).getContent();
    Assert.assertEquals(1, checkPolicies.size());
    IdmBulkActionDto bulkAction = findBulkAction(IdmAuthorizationPolicy.class, AuthorizationPolicyDisableBulkAction.NAME);
    bulkAction.setTransformedFilter(filter);
    bulkAction.setFilter(toMap(filter));
    IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
    checkResultLrt(processAction, 1l, null, null);
    Assert.assertTrue(service.get(policies.get(2)).isDisabled());
    Assert.assertFalse(service.get(policies.get(1)).isDisabled());
    Assert.assertFalse(service.get(policies.get(3)).isDisabled());
}
Also used : IdmBulkActionDto(eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto) IdmAuthorizationPolicyDto(eu.bcvsolutions.idm.core.api.dto.IdmAuthorizationPolicyDto) IdmAuthorizationPolicyFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmAuthorizationPolicyFilter) AbstractBulkActionTest(eu.bcvsolutions.idm.test.api.AbstractBulkActionTest) Test(org.junit.Test)

Example 3 with IdmAuthorizationPolicyFilter

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

the class AuthorizationPolicyDeleteBulkActionIntegrationTest method processBulkActionByFilter.

@Test
public void processBulkActionByFilter() {
    List<IdmAuthorizationPolicyDto> policies = createPolicies(5);
    IdmAuthorizationPolicyFilter filter = new IdmAuthorizationPolicyFilter();
    filter.setId(policies.get(2).getId());
    List<IdmAuthorizationPolicyDto> checkPolicies = service.find(filter, null).getContent();
    Assert.assertEquals(1, checkPolicies.size());
    IdmBulkActionDto bulkAction = findBulkAction(IdmAuthorizationPolicy.class, AuthorizationPolicyDeleteBulkAction.NAME);
    bulkAction.setTransformedFilter(filter);
    bulkAction.setFilter(toMap(filter));
    IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
    checkResultLrt(processAction, 1l, null, null);
    Assert.assertNull(service.get(policies.get(2)));
    Assert.assertNotNull(service.get(policies.get(1)));
    Assert.assertNotNull(service.get(policies.get(3)));
}
Also used : IdmBulkActionDto(eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto) IdmAuthorizationPolicyDto(eu.bcvsolutions.idm.core.api.dto.IdmAuthorizationPolicyDto) IdmAuthorizationPolicyFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmAuthorizationPolicyFilter) AbstractBulkActionTest(eu.bcvsolutions.idm.test.api.AbstractBulkActionTest) Test(org.junit.Test)

Example 4 with IdmAuthorizationPolicyFilter

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

the class AuthorizationPolicyEnableBulkActionIntegrationTest method processBulkActionByFilter.

@Test
public void processBulkActionByFilter() {
    List<IdmAuthorizationPolicyDto> policies = createPolicies(5);
    IdmAuthorizationPolicyFilter filter = new IdmAuthorizationPolicyFilter();
    filter.setId(policies.get(2).getId());
    List<IdmAuthorizationPolicyDto> checkPolicies = service.find(filter, null).getContent();
    Assert.assertEquals(1, checkPolicies.size());
    IdmBulkActionDto bulkAction = findBulkAction(IdmAuthorizationPolicy.class, AuthorizationPolicyEnableBulkAction.NAME);
    bulkAction.setTransformedFilter(filter);
    bulkAction.setFilter(toMap(filter));
    IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
    checkResultLrt(processAction, 1l, null, null);
    Assert.assertFalse(service.get(policies.get(2)).isDisabled());
    Assert.assertTrue(service.get(policies.get(1)).isDisabled());
    Assert.assertTrue(service.get(policies.get(3)).isDisabled());
}
Also used : IdmBulkActionDto(eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto) IdmAuthorizationPolicyDto(eu.bcvsolutions.idm.core.api.dto.IdmAuthorizationPolicyDto) IdmAuthorizationPolicyFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmAuthorizationPolicyFilter) AbstractBulkActionTest(eu.bcvsolutions.idm.test.api.AbstractBulkActionTest) Test(org.junit.Test)

Example 5 with IdmAuthorizationPolicyFilter

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

the class IdentityRoleDeleteAuthoritiesProcessor method process.

@Override
public EventResult<IdmIdentityRoleDto> process(EntityEvent<IdmIdentityRoleDto> event) {
    IdmIdentityRoleDto identityRole = event.getContent();
    UUID roleId = identityRole.getRole();
    // If removed roles hasn't any authorization policy, then will be this processor skipped.
    IdmAuthorizationPolicyFilter authorizationPolicyFilter = new IdmAuthorizationPolicyFilter();
    authorizationPolicyFilter.setRoleId(roleId);
    long countOfAuthorizationPolicies = authorizationPolicyService.count(authorizationPolicyFilter);
    if (countOfAuthorizationPolicies == 0) {
        return new DefaultEventResult<>(event, this);
    }
    // 
    IdmIdentityContractDto contract = DtoUtils.getEmbedded(identityRole, IdmIdentityRole_.identityContract);
    UUID identityId = contract.getIdentity();
    List<IdmIdentityRoleDto> roles = identityRoleService.findAllByIdentity(identityId);
    roles.remove(identityRole);
    // represents the final authorities set after role removal
    Collection<? extends GrantedAuthority> withoutDeleted = authorityHierarchy.getReachableGrantedAuthorities(authoritiesFactory.getGrantedAuthoritiesForValidRoles(identityId, roles));
    Collection<? extends GrantedAuthority> deletedAuthorities = authorityHierarchy.getReachableGrantedAuthorities(authoritiesFactory.getGrantedAuthoritiesForValidRoles(identityId, Collections.singletonList(identityRole)));
    if (!authoritiesFactory.containsAllAuthorities(withoutDeleted, deletedAuthorities)) {
        // authorities were changed, disable active identity tokens
        tokenManager.disableTokens(new IdmIdentityDto(identityId));
    }
    // 
    return new DefaultEventResult<>(event, this);
}
Also used : DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) IdmAuthorizationPolicyFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmAuthorizationPolicyFilter) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) UUID(java.util.UUID) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)

Aggregations

IdmAuthorizationPolicyFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmAuthorizationPolicyFilter)19 IdmAuthorizationPolicyDto (eu.bcvsolutions.idm.core.api.dto.IdmAuthorizationPolicyDto)13 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)12 Test (org.junit.Test)11 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)9 List (java.util.List)9 Autowired (org.springframework.beans.factory.annotation.Autowired)9 CoreGroupPermission (eu.bcvsolutions.idm.core.model.domain.CoreGroupPermission)7 IdmRole (eu.bcvsolutions.idm.core.model.entity.IdmRole)7 IdmBasePermission (eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission)7 IdmIdentity (eu.bcvsolutions.idm.core.model.entity.IdmIdentity)6 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)6 Assert (org.junit.Assert)6 RoleConfiguration (eu.bcvsolutions.idm.core.api.config.domain.RoleConfiguration)5 IdmGroupPermission (eu.bcvsolutions.idm.core.security.api.domain.IdmGroupPermission)5 StringUtils (org.apache.commons.lang3.StringUtils)5 IdmBulkActionDto (eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto)4 AbstractReadWriteDtoController (eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoController)4 AbstractReadWriteDtoControllerRestTest (eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest)4 IdmAuthorizationPolicyService (eu.bcvsolutions.idm.core.api.service.IdmAuthorizationPolicyService)4