@Test public void testSettleNoRulesOnLocalWiki() throws Exception { Deque<SecurityRuleEntry> emptydocRules = getMockedSecurityRuleEntries("emptydocRules", docRef, Collections.<List<SecurityRule>>emptyList()); assertAccess("When no rules are defined, return default access for local wiki user on local wiki doc", userRef, docRef.getParentSecurityReference().getParentSecurityReference(), defaultAccess, authorizationSettler.settle(userRef, Collections.<GroupSecurityReference>emptyList(), emptydocRules)); assertAccess("When no rules are defined, return default access for main wiki on local wiki doc", xuserRef, docRef.getParentSecurityReference().getParentSecurityReference(), defaultAccess, authorizationSettler.settle(xuserRef, Collections.<GroupSecurityReference>emptyList(), emptydocRules)); assertAccess("When no rules are defined, deny all access for another wiki user on local wiki doc", anotherWikiUserRef, docRef.getParentSecurityReference().getParentSecurityReference(), denyAllAccess, authorizationSettler.settle(anotherWikiUserRef, Collections.<GroupSecurityReference>emptyList(), emptydocRules)); }
@Override protected XWikiSecurityAccess settle(UserSecurityReference user, Collection<GroupSecurityReference> groups, SecurityRuleEntry entry, Policies policies) { Set<Right> enabledRights = Right.getEnabledRights(entry.getReference().getSecurityType()); Set<Right> fromUser = new RightSet(); Set<Right> allowed = new RightSet(); XWikiSecurityAccess access = new XWikiSecurityAccess(); for (Right right : enabledRights) { for (SecurityRule rule : entry.getRules()) { if (rule.match(right)) { if (rule.getState() == ALLOW) { allowed.add(right); } resolveLevel(right, user, groups, rule, access, policies, fromUser); if (access.get(right) == ALLOW) { implyRights(right, access, enabledRights, policies, fromUser); } } } } for (Right right : allowed) { if (access.get(right) == UNDETERMINED) { access.deny(right); } } return access; }
DefaultAuthorizationSettler extends AbstractAuthorizationSettler { @Override protected XWikiSecurityAccess settle(UserSecurityReference user, Collection<GroupSecurityReference> groups, SecurityRuleEntry entry, Policies policies) { Set<Right> enabledRights = Right.getEnabledRights(entry.getReference().getSecurityType()); Set<Right> fromUser = new RightSet(); Set<Right> allowed = new RightSet(); XWikiSecurityAccess access = new XWikiSecurityAccess(); for (Right right : enabledRights) { for (SecurityRule rule : entry.getRules()) { if (rule.match(right)) { if (rule.getState() == ALLOW) { allowed.add(right); } resolveLevel(right, user, groups, rule, access, policies, fromUser); if (access.get(right) == ALLOW) { implyRights(right, access, enabledRights, policies, fromUser); } } } } for (Right right : allowed) { if (access.get(right) == UNDETERMINED) { access.deny(right); } } return access; } }
DefaultAuthorizationSettler extends AbstractAuthorizationSettler { @Override protected XWikiSecurityAccess settle(UserSecurityReference user, Collection<GroupSecurityReference> groups, SecurityRuleEntry entry, Policies policies) { Set<Right> enabledRights = Right.getEnabledRights(entry.getReference().getSecurityType()); Set<Right> fromUser = new RightSet(); Set<Right> allowed = new RightSet(); XWikiSecurityAccess access = new XWikiSecurityAccess(); for (Right right : enabledRights) { for (SecurityRule rule : entry.getRules()) { if (rule.match(right)) { if (rule.getState() == ALLOW) { allowed.add(right); } resolveLevel(right, user, groups, rule, access, policies, fromUser); if (access.get(right) == ALLOW) { implyRights(right, access, enabledRights, policies, fromUser); } } } } for (Right right : allowed) { if (access.get(right) == UNDETERMINED) { access.deny(right); } } return access; }  }
DefaultAuthorizationSettler extends AbstractAuthorizationSettler { @Override protected XWikiSecurityAccess settle(UserSecurityReference user, Collection<GroupSecurityReference> groups, SecurityRuleEntry entry, Policies policies) { Set<Right> enabledRights = Right.getEnabledRights(entry.getReference().getSecurityType()); Set<Right> fromUser = new RightSet(); Set<Right> allowed = new RightSet(); XWikiSecurityAccess access = new XWikiSecurityAccess(); for (Right right : enabledRights) { for (SecurityRule rule : entry.getRules()) { if (rule.match(right)) { if (rule.getState() == ALLOW) { allowed.add(right); } resolveLevel(right, user, groups, rule, access, policies, fromUser); if (access.get(right) == ALLOW) { implyRights(right, access, enabledRights, policies, fromUser); } } } } for (Right right : allowed) { if (access.get(right) == UNDETERMINED) { access.deny(right); } } return access; }   }
DefaultAuthorizationSettler extends AbstractAuthorizationSettler { @Override protected XWikiSecurityAccess settle(UserSecurityReference user, Collection<GroupSecurityReference> groups, SecurityRuleEntry entry, Policies policies) { Set<Right> enabledRights = Right.getEnabledRights(entry.getReference().getSecurityType()); Set<Right> fromUser = new RightSet(); Set<Right> allowed = new RightSet(); XWikiSecurityAccess access = new XWikiSecurityAccess(); for (Right right : enabledRights) { for (SecurityRule rule : entry.getRules()) { if (rule.match(right)) { if (rule.getState() == ALLOW) { allowed.add(right); } resolveLevel(right, user, groups, rule, access, policies, fromUser); if (access.get(right) == ALLOW) { implyRights(right, access, enabledRights, policies, fromUser); } } } } for (Right right : allowed) { if (access.get(right) == UNDETERMINED) { access.deny(right); } } return access; }    }