Examples of PrincipalManager


Examples of org.apache.jackrabbit.api.security.principal.PrincipalManager

        return princPath.toString();
    }

    private Principal getPrincipal(String pathToACNode) throws RepositoryException {
        String name = getPrincipalName(pathToACNode);
        PrincipalManager pMgr = session.getPrincipalManager();
        if (pMgr.hasPrincipal(name)) {
            return pMgr.getPrincipal(name);
        } else {
            return null;
        }
    }
View Full Code Here

Examples of org.apache.jackrabbit.api.security.principal.PrincipalManager

    public PrincipalIterator getPrincipals() throws RepositoryException {
        Collection<Principal> coll = new ArrayList<Principal>();
        // the first element is the main principal of this user.
        coll.add(getPrincipal());
        // in addition add all referees.
        PrincipalManager prMgr = getSession().getPrincipalManager();
        for (Object o : getRefereeValues()) {
            String refName = ((Value) o).getString();
            Principal princ = prMgr.getPrincipal(refName);
            if (princ == null) {
                log.warn("Principal " + refName + " unknown to PrincipalManager.");
                princ = new PrincipalImpl(refName);
            }
            coll.add(princ);
View Full Code Here

Examples of org.apache.jackrabbit.api.security.principal.PrincipalManager

            String rootPath = session.getRootNode().getPath();
            AccessControlPolicy[] acls = editor.editAccessControlPolicies(rootPath);
            if (acls.length > 0) {
                ACLTemplate acl = (ACLTemplate) acls[0];
               
                PrincipalManager pMgr = session.getPrincipalManager();
                AccessControlManager acMgr = session.getAccessControlManager();

                String pName = SecurityConstants.ADMINISTRATORS_NAME;
                if (pMgr.hasPrincipal(pName)) {
                    Principal administrators = pMgr.getPrincipal(pName);
                    log.debug("... Privilege.ALL for administrators.");
                    Privilege[] privs = new Privilege[]{acMgr.privilegeFromName(Privilege.JCR_ALL)};
                    acl.addAccessControlEntry(administrators, privs);
                } else {
                    log.info("Administrators principal group is missing -> omitting initialization of default permissions.");
                }

                Principal everyone = pMgr.getEveryone();
                log.debug("... Privilege.READ for everyone.");
                Privilege[] privs = new Privilege[]{acMgr.privilegeFromName(Privilege.JCR_READ)};
                acl.addAccessControlEntry(everyone, privs);

                editor.setPolicy(rootPath, acl);
View Full Code Here

Examples of org.apache.jackrabbit.api.security.principal.PrincipalManager

    public PrincipalIterator getImpersonators() throws RepositoryException {
        Set<String> impersonators = getImpersonatorNames();
        if (impersonators.isEmpty()) {
            return PrincipalIteratorAdapter.EMPTY;
        } else {
            final PrincipalManager pMgr = user.getSession().getPrincipalManager();

            Set<Principal> s = new HashSet<Principal>();
            for (String pName: impersonators) {
                Principal p = pMgr.getPrincipal(pName);
                if (p == null) {
                    log.debug("Impersonator " + pName + " does not correspond to a known Principal.");
                    p = new PrincipalImpl(pName);
                }
                s.add(p);
View Full Code Here

Examples of org.apache.jackrabbit.api.security.principal.PrincipalManager

                ValueFactory vf = session.getValueFactory();
                Map<String, Value> restrictions = new HashMap<String, Value>();
                restrictions.put(session.getJCRName(ACLTemplate.P_NODE_PATH), vf.createValue(root.getPath(), PropertyType.PATH));

                PrincipalManager pMgr = session.getPrincipalManager();
                AccessControlManager acMgr = session.getAccessControlManager();

                // initial default permissions for the administrators group               
                String pName = SecurityConstants.ADMINISTRATORS_NAME;
                if (pMgr.hasPrincipal(pName)) {
                    Principal administrators = pMgr.getPrincipal(pName);
                    installDefaultPermissions(administrators,
                        new Privilege[] {acMgr.privilegeFromName(Privilege.JCR_ALL)},
                        restrictions, editor);
                } else {
                    log.info("Administrators principal group is missing -> Not adding default permissions.");
                }

                // initialize default permissions for the everyone group
                installDefaultPermissions(pMgr.getEveryone(),
                        new Privilege[] {acMgr.privilegeFromName(Privilege.JCR_READ)},
                        restrictions, editor);

                session.save();
            } catch (RepositoryException e) {
View Full Code Here

Examples of org.apache.jackrabbit.api.security.principal.PrincipalManager

        //TODO: this actually does not work correctly since the jackrabbit findPrincipals API
        // currently does an exact match of the search filter so it won't match a wildcard
        Session session = resourceResolver.adaptTo(Session.class);
        if (session != null) {
          PrincipalManager principalManager = AccessControlUtil.getPrincipalManager(session);
          principals = principalManager.findPrincipals(".*", PrincipalManager.SEARCH_TYPE_NOT_GROUP);
        }

       
        if (principals != null) {
          return new ChildrenIterator(parent, principals);
View Full Code Here

Examples of org.apache.jackrabbit.api.security.principal.PrincipalManager

   * @param principalID the id of the principal to check
   * @return true if the current user has the privileges, false otherwise
   */
  public boolean canUpdateAuthorizable(Session session, String principalID) {
    try {
      PrincipalManager principalManager = AccessControlUtil.getPrincipalManager(session);
      Principal principal = principalManager.getPrincipal(principalID);
      if (principal == null) {
        return false;
      }

      String path = getAuthorizableItemPath(principal);
View Full Code Here

Examples of org.apache.jackrabbit.api.security.principal.PrincipalManager

   * @param principalID the id of the principal to check
   * @return true if the current user has the privileges, false otherwise
   */
  public boolean canDeleteAuthorizable(Session session, String principalID) {
    try {
      PrincipalManager principalManager = AccessControlUtil.getPrincipalManager(session);
      Principal principal = principalManager.getPrincipal(principalID);
      if (principal == null) {
        return false;
      }
     
      //should check if principal implements ItemBasedPrincipal, but it is not visible here so use reflection instead
View Full Code Here

Examples of org.apache.jackrabbit.api.security.principal.PrincipalManager

                ValueFactory vf = session.getValueFactory();
                Map<String, Value> restrictions = new HashMap<String, Value>();
                restrictions.put(session.getJCRName(ACLTemplate.P_NODE_PATH), vf.createValue(root.getPath(), PropertyType.PATH));

                PrincipalManager pMgr = session.getPrincipalManager();
                AccessControlManager acMgr = session.getAccessControlManager();

                // initial default permissions for the administrators group               
                String pName = SecurityConstants.ADMINISTRATORS_NAME;
                if (pMgr.hasPrincipal(pName)) {
                    Principal administrators = pMgr.getPrincipal(pName);
                    installDefaultPermissions(administrators,
                        new Privilege[] {acMgr.privilegeFromName(Privilege.JCR_ALL)},
                        restrictions, editor);
                } else {
                    log.info("Administrators principal group is missing -> Not adding default permissions.");
                }

                // initialize default permissions for the everyone group
                installDefaultPermissions(pMgr.getEveryone(),
                        new Privilege[] {acMgr.privilegeFromName(Privilege.JCR_READ)},
                        restrictions, editor);

                session.save();
            } catch (RepositoryException e) {
View Full Code Here

Examples of org.apache.jackrabbit.api.security.principal.PrincipalManager

            String rootPath = session.getRootNode().getPath();
            AccessControlPolicy[] acls = editor.editAccessControlPolicies(rootPath);
            if (acls.length > 0) {
                ACLTemplate acl = (ACLTemplate) acls[0];
               
                PrincipalManager pMgr = session.getPrincipalManager();
                AccessControlManager acMgr = session.getAccessControlManager();

                String pName = SecurityConstants.ADMINISTRATORS_NAME;
                if (pMgr.hasPrincipal(pName)) {
                    Principal administrators = pMgr.getPrincipal(pName);
                    log.debug("... Privilege.ALL for administrators.");
                    Privilege[] privs = new Privilege[]{acMgr.privilegeFromName(Privilege.JCR_ALL)};
                    acl.addAccessControlEntry(administrators, privs);
                } else {
                    log.info("Administrators principal group is missing -> omitting initialization of default permissions.");
                }

                Principal everyone = pMgr.getEveryone();
                log.debug("... Privilege.READ for everyone.");
                Privilege[] privs = new Privilege[]{acMgr.privilegeFromName(Privilege.JCR_READ)};
                acl.addAccessControlEntry(everyone, privs);

                editor.setPolicy(rootPath, acl);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.