Package org.apache.jackrabbit.api.jsr283.lock

Examples of org.apache.jackrabbit.api.jsr283.lock.LockManager


    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


        }
        // set up permissions
        String permissionsPath = session.getRootNode().getPath();
        AccessControlManager accessControlManager = session
                .getAccessControlManager();
        AccessControlPolicyIterator acls = accessControlManager
                .getApplicablePolicies(permissionsPath);
        if (acls.hasNext()) {
            JackrabbitAccessControlList acl = (JackrabbitAccessControlList) acls
                    .nextAccessControlPolicy();
            acl.addEntry(user.getPrincipal(), accessControlManager
                    .getSupportedPrivileges(permissionsPath), true);
            accessControlManager.setPolicy(permissionsPath, acl);
        } else {
View Full Code Here

    }

    try {
      AccessControlManager accessControlManager = AccessControlUtil.getAccessControlManager(session);
      AccessControlList updatedAcl = null;
      AccessControlPolicyIterator applicablePolicies = accessControlManager.getApplicablePolicies(resourcePath);
      while (applicablePolicies.hasNext()) {
        AccessControlPolicy policy = applicablePolicies.nextAccessControlPolicy();
        if (policy instanceof AccessControlList) {
          updatedAcl = (AccessControlList)policy;
          break;
        }
      }
View Full Code Here

        }
        // set up permissions
        String permissionsPath = session.getRootNode().getPath();
        AccessControlManager accessControlManager = session
                .getAccessControlManager();
        AccessControlPolicyIterator acls = accessControlManager
                .getApplicablePolicies(permissionsPath);
        if (acls.hasNext()) {
            JackrabbitAccessControlList acl = (JackrabbitAccessControlList) acls
                    .nextAccessControlPolicy();
            acl.addEntry(user.getPrincipal(), accessControlManager
                    .getSupportedPrivileges(permissionsPath), true);
            accessControlManager.setPolicy(permissionsPath, acl);
        } else {
View Full Code Here

        }
        // set up permissions
        String permissionsPath = session.getRootNode().getPath();
        AccessControlManager accessControlManager = session
                .getAccessControlManager();
        AccessControlPolicyIterator acls = accessControlManager
                .getApplicablePolicies(permissionsPath);
        if (acls.hasNext()) {
            JackrabbitAccessControlList acl = (JackrabbitAccessControlList) acls
                    .nextAccessControlPolicy();
            acl.addEntry(user.getPrincipal(), accessControlManager
                    .getSupportedPrivileges(permissionsPath), true);
            accessControlManager.setPolicy(permissionsPath, acl);
        } else {
View Full Code Here

            throw new NotExecutableException();
        }
    }

    private JackrabbitAccessControlList getACL(String path) throws RepositoryException, AccessDeniedException, NotExecutableException {
        AccessControlPolicyIterator it = acMgr.getApplicablePolicies(path);
        while (it.hasNext()) {
            AccessControlPolicy acp = it.nextAccessControlPolicy();
            if (acp instanceof JackrabbitAccessControlList) {
                return (JackrabbitAccessControlList) acp;
            }
        }
        throw new NotExecutableException("No JackrabbitAccessControlList found at " + path + " .");
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.lock.LockManager

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.