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();
}
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());
}
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)));
}
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());
}
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);
}
Aggregations