CheckinTest
180181182183184185186187
NodeImpl aclNode = getAclNode(nodePath); if (aclNode != null) { removeSecurityItem(aclNode); } else { throw new AccessControlException("No policy to remove at " + nodePath); } }
198199200201202203204205
* @throws RepositoryException */ private void checkProtectsNode(String nodePath) throws RepositoryException { NodeImpl node = getNode(nodePath); if (utils.isAcItem(node)) { throw new AccessControlException("Node " + nodePath + " defines ACL or ACE itself."); } }
211212213214215216217218219220221222
* @param policy * @throws AccessControlException */ private static void checkValidPolicy(String nodePath, AccessControlPolicy policy) throws AccessControlException { if (policy == null || !(policy instanceof ACLTemplate)) { throw new AccessControlException("Attempt to set/remove invalid policy " + policy); } ACLTemplate acl = (ACLTemplate) policy; if (!nodePath.equals(acl.getPath())) { throw new AccessControlException("Policy " + policy + " cannot be applied/removed from the node at " + nodePath); } }
124125126127128129130131
public Privilege getPrivilege(String privilegeName) throws AccessControlException, RepositoryException { Name name = resolver.getQName(privilegeName); if (localCache.containsKey(name)) { return (Privilege) localCache.get(name); } else { throw new AccessControlException("Unknown privilege " + privilegeName); } }
163164165166167168169170171172173174175176177178179180
* @throws AccessControlException If the specified array is null * or if it contains an unregistered privilege. */ public static int getBits(Privilege[] privileges) throws AccessControlException { if (privileges == null || privileges.length == 0) { throw new AccessControlException(); } int bits = NO_PRIVILEGE; for (int i = 0; i < privileges.length; i++) { Privilege priv = privileges[i]; if (priv instanceof PrivilegeImpl) { bits |= ((PrivilegeImpl) priv).internalPrivilege.getBits(); } else { throw new AccessControlException("Unknown privilege '" + priv.getName() + "'."); } } return bits; }
248249250251252253254255256257258259
* @throws AccessControlException */ private void checkValidEntry(Principal principal, Privilege[] privileges, boolean isAllow) throws AccessControlException { // validate principal if (!principalMgr.hasPrincipal(principal.getName())) { throw new AccessControlException("Principal " + principal.getName() + " does not exist."); } // additional validation: a group may not have 'denied' permissions if (!isAllow && principal instanceof Group) { throw new AccessControlException("For group principals permissions can only be added but not denied."); } }
279280281282283284285286287288289290291292293294
* @see org.apache.jackrabbit.api.jsr283.security.AccessControlList#removeAccessControlEntry(AccessControlEntry) */ public synchronized void removeAccessControlEntry(AccessControlEntry ace) throws AccessControlException, RepositoryException { if (!(ace instanceof Entry)) { throw new AccessControlException("Invalid AccessControlEntry implementation " + ace.getClass().getName() + "."); } List l = internalGetEntries(ace.getPrincipal()); if (l.remove(ace)) { if (l.isEmpty()) { entries.remove(ace.getPrincipal().getName()); } } else { throw new AccessControlException("AccessControlEntry " + ace + " cannot be removed from ACL defined at " + getPath()); } }
328329330331332333334335336337338
*/ public boolean addEntry(Principal principal, Privilege[] privileges, boolean isAllow, Map restrictions) throws AccessControlException, RepositoryException { if (restrictions != null && !restrictions.isEmpty()) { throw new AccessControlException("This AccessControlList does not allow for additional restrictions."); } checkValidEntry(principal, privileges, isAllow); Entry ace = new Entry(principal, privileges, isAllow); return internalAdd(ace);
105106107108109110111
// ignore and try next } } // none accepted -> throw throw new AccessControlException("None of the editors accepted policy " + template + " at " + nodePath); }
126127128129130131132
log.debug(e.getMessage()); // ignore and try next } } // neither of the editors was able to remove a policy at nodePath throw new AccessControlException("Unable to remove template " + policy); }