Search in sources :

Example 11 with Role

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());
}
Also used : Role(org.simbasecurity.core.domain.Role) RoleEntity(org.simbasecurity.core.domain.RoleEntity) RoleDTO(org.simbasecurity.core.service.manager.dto.RoleDTO) Test(org.junit.Test)

Example 12 with Role

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);
}
Also used : Policy(org.simbasecurity.core.domain.Policy) Role(org.simbasecurity.core.domain.Role) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 13 with Role

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);
}
Also used : Role(org.simbasecurity.core.domain.Role) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 14 with Role

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);
}
Also used : Role(org.simbasecurity.core.domain.Role) Policy(org.simbasecurity.core.domain.Policy) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 15 with Role

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);
}
Also used : Role(org.simbasecurity.core.domain.Role) User(org.simbasecurity.core.domain.User) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

Role (org.simbasecurity.core.domain.Role)16 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)9 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)8 Policy (org.simbasecurity.core.domain.Policy)6 Group (org.simbasecurity.core.domain.Group)4 TGroup (org.simbasecurity.api.service.thrift.TGroup)3 TRole (org.simbasecurity.api.service.thrift.TRole)3 RoleEntity (org.simbasecurity.core.domain.RoleEntity)3 User (org.simbasecurity.core.domain.User)3 Test (org.junit.Test)2 UserEntity (org.simbasecurity.core.domain.UserEntity)2 RoleDTO (org.simbasecurity.core.service.manager.dto.RoleDTO)2 Collection (java.util.Collection)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Before (org.junit.Before)1 GroupService (org.simbasecurity.api.service.thrift.GroupService)1 TUser (org.simbasecurity.api.service.thrift.TUser)1 GroupEntity (org.simbasecurity.core.domain.GroupEntity)1 PolicyEntity (org.simbasecurity.core.domain.PolicyEntity)1