use of org.simbasecurity.core.domain.Role in project simba-os by cegeka.
the class PolicyManagerService method addRoles.
@RequestMapping("addRoles")
@ResponseBody
public void addRoles(@JsonBody("policy") PolicyDTO policy, @JsonBody("roles") Set<RoleDTO> roles) {
Policy attachedPolicy = policyRepository.refreshWithOptimisticLocking(policy);
Collection<Role> attachedRoles = roleRepository.refreshWithOptimisticLocking(roles);
attachedPolicy.addRoles(attachedRoles);
}
use of org.simbasecurity.core.domain.Role in project simba-os by cegeka.
the class RoleManagerService method removePolicy.
@RequestMapping("removePolicy")
@ResponseBody
public void removePolicy(@JsonBody("role") RoleDTO role, @JsonBody("policy") PolicyDTO policy) {
Role attachedRole = roleRepository.refreshWithOptimisticLocking(role);
Policy attachedPolicy = policyRepository.refreshWithOptimisticLocking(policy);
attachedRole.removePolicy(attachedPolicy);
roleRepository.persist(attachedRole);
}
use of org.simbasecurity.core.domain.Role in project simba-os by cegeka.
the class RoleManagerService method createRole.
@RequestMapping("createRole")
@ResponseBody
public RoleDTO createRole(@JsonBody("roleName") String roleName) throws ValidationException {
DTOValidator.assertValidString("createRole", roleName);
if (roleRepository.findByName(roleName) != null) {
throw new IllegalArgumentException("Role with name " + roleName + " already exists");
}
Role newRole = RoleAssembler.createRole(roleName);
roleRepository.persist(newRole);
return RoleDTOAssembler.assemble(newRole);
}
use of org.simbasecurity.core.domain.Role in project simba-os by cegeka.
the class RoleManagerService method addUsers.
@RequestMapping("addUsers")
@ResponseBody
public void addUsers(@JsonBody("role") RoleDTO role, @JsonBody("users") List<UserDTO> users) {
Role attachedRole = roleRepository.refreshWithOptimisticLocking(role);
Collection<User> attachedUsers = userRepository.refreshWithOptimisticLocking(users);
attachedRole.addUsers(attachedUsers);
roleRepository.persist(attachedRole);
}
use of org.simbasecurity.core.domain.Role in project simba-os by cegeka.
the class GroupServiceImpl method addRole.
public void addRole(TGroup group, TRole role) {
Role attachedRole = roleRepository.refreshWithOptimisticLocking(role.getId(), role.getVersion());
Group attachedGroup = groupRepository.refreshWithOptimisticLocking(group.getId(), group.getVersion());
attachedGroup.addRole(attachedRole);
}
Aggregations