Package org.apache.jackrabbit.api.jsr283.security

Examples of org.apache.jackrabbit.api.jsr283.security.AccessControlPolicyIterator


        super.setUp();

        Node n = testRootNode.addNode(nodeName1, testNodeType);
        superuser.save();

        AccessControlPolicyIterator it = acMgr.getApplicablePolicies(n.getPath());
        if (it.hasNext()) {
            AccessControlPolicy p = it.nextAccessControlPolicy();
            if (p instanceof JackrabbitAccessControlList) {
                templ = (JackrabbitAccessControlList) p;
            } else {
                throw new NotExecutableException("No JackrabbitAccessControlList to test.");
            }
View Full Code Here


    private static void changeReadPermission(Principal principal, Node n, boolean allowRead) throws RepositoryException, NotExecutableException {
        SessionImpl s = (SessionImpl) n.getSession();
        JackrabbitAccessControlList acl = null;
        AccessControlManager acMgr = s.getAccessControlManager();
        AccessControlPolicyIterator it = acMgr.getApplicablePolicies(n.getPath());
        while (it.hasNext()) {
            AccessControlPolicy acp = it.nextAccessControlPolicy();
            if (acp instanceof JackrabbitAccessControlList) {
                acl = (JackrabbitAccessControlList) acp;
                break;
            }
        }
View Full Code Here

    }

    static JackrabbitAccessControlList getPolicy(AccessControlManager acM, String path, Principal principal) throws RepositoryException,
            AccessDeniedException, NotExecutableException {
        // try applicable (new) acls first
        AccessControlPolicyIterator itr = acM.getApplicablePolicies(path);
        while (itr.hasNext()) {
            AccessControlPolicy policy = itr.nextAccessControlPolicy();
            if (policy instanceof ACLTemplate) {
                return (ACLTemplate) policy;
            }
        }
        // try if there is an acl that has been set before:
View Full Code Here

        return EvaluationUtil.isExecutable(acMgr);
    }

    protected JackrabbitAccessControlList getPolicy(AccessControlManager acM, String path, Principal principal) throws RepositoryException, AccessDeniedException, NotExecutableException {
        // first try if there is a new applicable policy
        AccessControlPolicyIterator it = acM.getApplicablePolicies(path);
        while (it.hasNext()) {
            AccessControlPolicy acp = it.nextAccessControlPolicy();
            if (acp instanceof ACLTemplate) {
                return (ACLTemplate) acp;
            }
        }
        // try if there is an acl that has been set before:
View Full Code Here

        assertFalse(getTestSession().hasPermission(policyPath, org.apache.jackrabbit.api.jsr283.Session.ACTION_REMOVE));
        assertTrue(testAcMgr.hasPrivileges(policyPath, new Privilege[] {rmChildNodes[0], rmNode[0]}));
    }

    public void testApplicablePolicies() throws RepositoryException {
        AccessControlPolicyIterator it = acMgr.getApplicablePolicies(childNPath);
        assertTrue(it.hasNext());

        // the same should be true, if the rep:AccessControllable mixin has
        // been manually added
        Node n = (Node) superuser.getItem(childNPath);
        n.addMixin(((SessionImpl) superuser).getJCRName(AccessControlConstants.NT_REP_ACCESS_CONTROLLABLE));
        it = acMgr.getApplicablePolicies(childNPath);
        assertTrue(it.hasNext());
    }
View Full Code Here

        super.setUp();

        Node n = testRootNode.addNode(nodeName1, testNodeType);
        superuser.save();

        AccessControlPolicyIterator it = acMgr.getApplicablePolicies(n.getPath());
        while (it.hasNext() && templ == null) {
            AccessControlPolicy p = it.nextAccessControlPolicy();
            if (p instanceof JackrabbitAccessControlList) {
                templ = (JackrabbitAccessControlList) p;
            }
        }
        if (templ == null) {
View Full Code Here

      List<Privilege> grantedPrivilegeList = new ArrayList<Privilege>();
      for (String name : grantedPrivilegeNames) {
        if (name.length() == 0) {
          continue; //empty, skip it.
        }
        Privilege privilege = accessControlManager.privilegeFromName(name);
        grantedPrivilegeList.add(privilege);
         
        if (log.isDebugEnabled()) {
          if (newPrivileges.length() > 0) {
            newPrivileges.append(", "); //separate entries by commas
          }
          newPrivileges.append("granted=");
          newPrivileges.append(privilege.getName());
        }
      }
      if (grantedPrivilegeList.size() > 0) {
        Principal principal = authorizable.getPrincipal();
        updatedAcl.addAccessControlEntry(principal, grantedPrivilegeList.toArray(new Privilege[grantedPrivilegeList.size()]));
      }

      //if the authorizable is a user (not a group) process any denied privileges
      if (!authorizable.isGroup()) {
        //add a fresh ACE with the denied privileges
        List<Privilege> deniedPrivilegeList = new ArrayList<Privilege>();
        for (String name : deniedPrivilegeNames) {
          if (name.length() == 0) {
            continue; //empty, skip it.
          }
          Privilege privilege = accessControlManager.privilegeFromName(name);
          deniedPrivilegeList.add(privilege);

          if (log.isDebugEnabled()) {
            if (newPrivileges.length() > 0) {
              newPrivileges.append(", "); //separate entries by commas
            }
            newPrivileges.append("denied=");
            newPrivileges.append(privilege.getName());
          }
        }
        if (deniedPrivilegeList.size() > 0) {
          Principal principal = authorizable.getPrincipal();
          AccessControlUtil.addEntry(updatedAcl, principal, deniedPrivilegeList.toArray(new Privilege[deniedPrivilegeList.size()]), false);
View Full Code Here

        }
         
        if (granted.size() == 1) {
          //check if the single privilege is jcr:all or jcr:read
          Iterator<Privilege> iterator = granted.iterator();
          Privilege next = iterator.next();
          if ("jcr:all".equals(next.getName())) {
            //full control privilege set
            return getResourceBundle(locale).getString("privilegeset.all");
          } else if ("jcr:read".equals(next.getName())) {
            //readonly privilege set
            return getResourceBundle(locale).getString("privilegeset.readonly");
          }
        } else if (granted.size() == 2) {
          //check if the two privileges are jcr:read and jcr:write
          Iterator<Privilege> iterator = granted.iterator();
          Privilege next = iterator.next();
          Privilege next2 = iterator.next();
          if ( ("jcr:read".equals(next.getName()) && "jcr:write".equals(next2.getName())) ||
              ("jcr:read".equals(next2.getName()) && "jcr:write".equals(next.getName())) ) {
            //read/write privileges
            return getResourceBundle(locale).getString("privilegeset.readwrite");
          }
        }
View Full Code Here

    public PrivilegeRegistry(NameResolver resolver) {
        this.resolver = resolver;
        localCache = new HashMap(REGISTERED_PRIVILEGES.size());
        for (Iterator it = REGISTERED_PRIVILEGES.iterator(); it.hasNext();) {
            InternalPrivilege ip = (InternalPrivilege) it.next();
            Privilege priv = new PrivilegeImpl(ip, resolver);
            localCache.put(ip.name, priv);
        }
    }
View Full Code Here

        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;
    }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.api.jsr283.security.AccessControlPolicyIterator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.