use of org.simbasecurity.core.domain.Role in project simba-os by cegeka.
the class RoleDTOAssemblerTest method testAssembleMultipleRoles.
@Test
public void testAssembleMultipleRoles() {
Role role = new RoleEntity("role name");
Collection<RoleDTO> roleDataList = RoleDTOAssembler.assemble(Arrays.asList(role));
assertNotNull(roleDataList);
assertEquals(1, roleDataList.size());
}
use of org.simbasecurity.core.domain.Role in project simba-os by cegeka.
the class PolicyManagerService method removeRole.
@RequestMapping("removeRole")
@ResponseBody
public void removeRole(@JsonBody("policy") PolicyDTO policy, @JsonBody("role") RoleDTO role) {
Policy attachedPolicy = policyRepository.refreshWithOptimisticLocking(policy);
Role attachedRole = roleRepository.refreshWithOptimisticLocking(role);
attachedPolicy.removeRole(attachedRole);
}
use of org.simbasecurity.core.domain.Role in project simba-os by cegeka.
the class RoleManagerService method deleteRole.
@RequestMapping("deleteRole")
public void deleteRole(@JsonBody("role") RoleDTO role) throws ValidationException {
DTOValidator.assertValid(role);
Role roleToDelete = roleRepository.lookUp(role);
roleRepository.remove(roleToDelete);
}
use of org.simbasecurity.core.domain.Role in project simba-os by cegeka.
the class RoleManagerService method addPolicy.
@RequestMapping("addPolicy")
@ResponseBody
public void addPolicy(@JsonBody("role") RoleDTO role, @JsonBody("policy") PolicyDTO policy) {
final Role attachedRole = roleRepository.refreshWithOptimisticLocking(role);
final Policy attachedPolicy = policyRepository.refreshWithOptimisticLocking(policy);
attachedRole.addPolicy(attachedPolicy);
roleRepository.persist(attachedRole);
}
use of org.simbasecurity.core.domain.Role in project simba-os by cegeka.
the class RoleManagerService method removeUser.
@RequestMapping("removeUser")
@ResponseBody
public void removeUser(@JsonBody("user") UserDTO user, @JsonBody("role") RoleDTO role) {
Role attachedRole = roleRepository.refreshWithOptimisticLocking(role);
User attachedUser = userRepository.refreshWithOptimisticLocking(user);
attachedRole.removeUser(attachedUser);
roleRepository.persist(attachedRole);
}
Aggregations