use of org.simbasecurity.core.domain.Policy 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.Policy 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.Policy in project simba-os by cegeka.
the class ConditionManagerService method addOrUpdate.
@RequestMapping("addOrUpdate")
@ResponseBody
public ConditionDTO addOrUpdate(@RequestBody ConditionWithPoliciesAndExcludedUsersDTO conditionWithPoliciesAndExcludedUsersDTO) {
final Condition attachedCondition = findOrCreate(conditionWithPoliciesAndExcludedUsersDTO.getCondition());
final Collection<User> attachedUsers = userRepository.refreshWithOptimisticLocking(conditionWithPoliciesAndExcludedUsersDTO.getExcludedUsers());
attachedCondition.setExemptedUsers(new HashSet<>(attachedUsers));
final Collection<Policy> attachedPolicies = policyRepository.refreshWithOptimisticLocking(conditionWithPoliciesAndExcludedUsersDTO.getPolicies());
conditionRepository.updatePolicies(attachedCondition, attachedPolicies);
conditionRepository.flush();
return assemble(attachedCondition);
}
use of org.simbasecurity.core.domain.Policy in project simba-os by cegeka.
the class PolicyManagerService method removeRule.
@RequestMapping("removeRule")
@ResponseBody
public void removeRule(@JsonBody("policy") PolicyDTO policy, @JsonBody("rule") RuleDTO rule) {
Policy attachedPolicy = policyRepository.refreshWithOptimisticLocking(policy);
Rule attachedRule = ruleRepository.refreshWithOptimisticLocking(rule);
attachedPolicy.removeRule(attachedRule);
}
use of org.simbasecurity.core.domain.Policy in project simba-os by cegeka.
the class PolicyManagerService method deletePolicy.
@RequestMapping("delete")
@ResponseBody
public void deletePolicy(@JsonBody("policy") PolicyDTO policy) throws ValidationException {
DTOValidator.assertValid(policy);
Policy policyToRemove = policyRepository.lookUp(policy);
policyRepository.remove(policyToRemove);
}
Aggregations