use of org.simbasecurity.core.domain.Policy in project simba-os by cegeka.
the class PolicyServiceImpl method addRules.
@Override
public void addRules(TPolicy policy, Set<TRule> rules) throws TException {
simbaExceptionHandlingCaller.call(() -> {
Policy attachedPolicy = policyRepository.refreshWithOptimisticLocking(policy.getId(), policy.getVersion());
Set<Rule> attachedRules = rules.stream().map(r -> ruleRepository.refreshWithOptimisticLocking(r.getId(), r.getVersion())).collect(Collectors.toSet());
audit.log("Rules ''{0}'' added to policy ''{1}''", join(attachedRules, Rule::getName), attachedPolicy.getName());
attachedPolicy.addRules(attachedRules);
});
}
use of org.simbasecurity.core.domain.Policy in project simba-os by cegeka.
the class PolicyServiceImpl method deletePolicy.
@Override
public void deletePolicy(TPolicy policy) throws TException {
simbaExceptionHandlingCaller.call(() -> {
Policy policyToRemove = policyRepository.lookUp(policy.getId());
audit.log("Policy ''{0}'' removed", policyToRemove.getName());
policyRepository.remove(policyToRemove);
});
}
use of org.simbasecurity.core.domain.Policy in project simba-os by cegeka.
the class PolicyServiceImpl method removeRole.
@Override
public void removeRole(TPolicy policy, TRole role) throws TException {
simbaExceptionHandlingCaller.call(() -> {
Policy attachedPolicy = policyRepository.refreshWithOptimisticLocking(policy.getId(), policy.getVersion());
Role attachedRole = roleRepository.refreshWithOptimisticLocking(role.getId(), role.getVersion());
audit.log("Role ''{0}'' removed from policy ''{1}''", attachedRole.getName(), attachedPolicy.getName());
attachedPolicy.removeRole(attachedRole);
});
}
use of org.simbasecurity.core.domain.Policy in project simba-os by cegeka.
the class RoleServiceImpl method addPolicy.
public void addPolicy(TRole role, TPolicy policy) throws TException {
simbaExceptionHandlingCaller.call(() -> {
final Role attachedRole = roleRepository.refreshWithOptimisticLocking(role.getId(), role.getVersion());
final Policy attachedPolicy = policyRepository.refreshWithOptimisticLocking(policy.getId(), policy.getVersion());
attachedRole.addPolicy(attachedPolicy);
managementAudit.log("Policy ''{0}'' added to role ''{1}''", attachedPolicy.getName(), attachedRole.getName());
roleRepository.persist(attachedRole);
});
}
Aggregations