use of eu.bcvsolutions.idm.core.api.dto.IdmAuthorizationPolicyDto in project CzechIdMng by bcvsolutions.
the class AbstractIdentityAuthoritiesProcessorTest method getTestPolicy.
protected IdmAuthorizationPolicyDto getTestPolicy(IdmRoleDto role, BasePermission base, GroupPermission group) {
IdmAuthorizationPolicyDto policy = new IdmAuthorizationPolicyDto();
policy.setGroupPermission(group.getName());
policy.setPermissions(base);
policy.setRole(role.getId());
policy.setEvaluator(BasePermissionEvaluator.class);
return authorizationPolicyService.get(authorizationPolicyService.save(policy).getId());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmAuthorizationPolicyDto in project CzechIdMng by bcvsolutions.
the class CodeableEvaluatorIntegrationTest method testPermissionByWrongUuid.
@Test
public void testPermissionByWrongUuid() {
loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
// prepare role
IdmRoleDto role = helper.createRole();
//
IdmAuthorizationPolicyDto dto = new IdmAuthorizationPolicyDto();
dto.setRole(role.getId());
dto.setEvaluator(CodeableEvaluator.class);
dto.setGroupPermission(CoreGroupPermission.ROLE.getName());
dto.setAuthorizableType(IdmRole.class.getCanonicalName());
dto.getEvaluatorProperties().put(CodeableEvaluator.PARAMETER_IDENTIFIER, "wrong");
dto.setPermissions(IdmBasePermission.READ);
authorizationPolicyService.save(dto);
// prepare identity
IdmIdentityDto identity = helper.createIdentity();
identity.setPassword(new GuardedString("heslo"));
identityService.save(identity);
// assign role
helper.createIdentityRole(identity, role);
logout();
//
try {
loginService.login(new LoginDto(identity.getUsername(), identity.getPassword()));
//
// evaluate access
assertEquals(0, roleService.find(null, IdmBasePermission.READ).getTotalElements());
;
} finally {
logout();
}
}
use of eu.bcvsolutions.idm.core.api.dto.IdmAuthorizationPolicyDto in project CzechIdMng by bcvsolutions.
the class ConfigurationEvaluatorIntegrationTest method testUpdateWithoutPermissions.
@Test(expected = ForbiddenEntityException.class)
public void testUpdateWithoutPermissions() {
loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
// prepare role
IdmRoleDto role = helper.createRole();
//
IdmAuthorizationPolicyDto dto = new IdmAuthorizationPolicyDto();
dto.setRole(role.getId());
dto.setEvaluator(ConfigurationEvaluator.class);
dto.setGroupPermission(CoreGroupPermission.CONFIGURATION.getName());
dto.setAuthorizableType(IdmConfiguration.class.getCanonicalName());
dto.setPermissions(IdmBasePermission.READ);
authorizationPolicyService.save(dto);
// prepare identity
IdmIdentityDto identity = helper.createIdentity();
identity.setPassword(new GuardedString("heslo"));
identityService.save(identity);
// assign role
helper.createIdentityRole(identity, role);
logout();
//
try {
loginService.login(new LoginDto(identity.getUsername(), identity.getPassword()));
//
publicConfig.setValue("update");
configurationService.save(publicConfig, IdmBasePermission.UPDATE);
} finally {
logout();
}
}
use of eu.bcvsolutions.idm.core.api.dto.IdmAuthorizationPolicyDto in project CzechIdMng by bcvsolutions.
the class UuidEvaluatorUnitTest method testEvaluateReadOnly.
@Test
public void testEvaluateReadOnly() {
IdmAuthorizationPolicyDto policy = new IdmAuthorizationPolicyDto();
UUID uuid = UUID.randomUUID();
IdmRole authorizable = new IdmRole(uuid);
policy.getEvaluatorProperties().put(UuidEvaluator.PARAMETER_UUID, uuid);
policy.setPermissions(IdmBasePermission.READ);
//
assertTrue(evaluator.evaluate(authorizable, policy, IdmBasePermission.READ));
assertFalse(evaluator.evaluate(authorizable, policy, IdmBasePermission.UPDATE));
assertFalse(evaluator.evaluate(authorizable, policy, IdmBasePermission.ADMIN));
}
use of eu.bcvsolutions.idm.core.api.dto.IdmAuthorizationPolicyDto in project CzechIdMng by bcvsolutions.
the class RoleForRequestEvaluatorIntegrationTest method createPolicy.
private IdmAuthorizationPolicyDto createPolicy(UUID roleId, IdmBasePermission... permissions) {
IdmAuthorizationPolicyDto policy = new IdmAuthorizationPolicyDto();
// add autocomplete data access
policy.setPermissions(permissions);
policy.setGroupPermission(CoreGroupPermission.ROLE.getName());
policy.setAuthorizableType(IdmRole.class.getCanonicalName());
policy.setRole(roleId);
policy.setEvaluator(RoleCanBeRequestedEvaluator.class);
return authorizationPolicyService.save(policy);
}
Aggregations