use of org.simbasecurity.core.domain.Rule in project simba-os by cegeka.
the class RuleDatabaseRepositoryTest method canFindAllRulesNotLinkedToAPolicy.
@Test
public void canFindAllRulesNotLinkedToAPolicy() throws Exception {
ResourceRuleEntity notLinkedRule = new ResourceRuleEntity("hipiejipie");
notLinkedRule.setResourceName("hipiejipie");
persistAndRefresh(notLinkedRule);
Policy anotherPolicy = new PolicyEntity("hipiepolicy");
anotherPolicy.addRule(notLinkedRule);
persistAndRefresh(anotherPolicy);
Collection<Rule> rules = ruleDatabaseRepository.findNotLinked(policy);
assertTrue(rules.containsAll(Arrays.asList(notLinkedRule)));
}
use of org.simbasecurity.core.domain.Rule in project simba-os by cegeka.
the class PolicyManagerService method addRules.
@RequestMapping("addRules")
@ResponseBody
public void addRules(@JsonBody("policy") PolicyDTO policy, @JsonBody("rules") Set<RuleDTO> rules) {
Policy attachedPolicy = policyRepository.refreshWithOptimisticLocking(policy);
Collection<Rule> attachedRules = ruleRepository.refreshWithOptimisticLocking(rules);
attachedPolicy.addRules(attachedRules);
}
use of org.simbasecurity.core.domain.Rule 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.Rule in project simba-os by cegeka.
the class RuleDTOAssemblerTest method testAssembleMultipleRules.
@Test
public void testAssembleMultipleRules() {
Rule resourceRule = createResourceRule();
Rule urlRule = createUrlRule();
Collection<RuleDTO> ruleDataList = RuleDTOAssembler.assemble(Arrays.asList(resourceRule, urlRule));
assertNotNull(ruleDataList);
assertEquals(2, ruleDataList.size());
}
Aggregations