use of org.simbasecurity.core.domain.Policy in project simba-os by cegeka.
the class PolicyDTOAssemblerTest method testAssembleSinglePolicy.
@Test
public void testAssembleSinglePolicy() {
Policy policy = new PolicyEntity("policy name");
PolicyDTO policyData = PolicyDTOAssembler.assemble(policy);
assertNotNull(policyData);
assertEquals(0, policyData.getId());
assertEquals(policy.getName(), policyData.getName());
assertEquals(0, policyData.getId());
assertEquals(0, policyData.getVersion());
}
use of org.simbasecurity.core.domain.Policy 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.Policy 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.Policy in project simba-os by cegeka.
the class RoleManagerService method addPolicies.
@RequestMapping("addPolicies")
@ResponseBody
public void addPolicies(@JsonBody("role") RoleDTO role, @JsonBody("policies") List<PolicyDTO> policies) {
Role attachedRole = roleRepository.refreshWithOptimisticLocking(role);
Collection<Policy> attachedPolicies = policyRepository.refreshWithOptimisticLocking(policies);
attachedRole.addPolicies(attachedPolicies);
roleRepository.persist(attachedRole);
}
Aggregations