Package org.apache.jackrabbit.api.security.principal

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


    public PrincipalIterator getPrincipals() throws RepositoryException {
        Collection coll = new ArrayList();
        // the first element is the main principal of this user.
        coll.add(getPrincipal());
        // in addition add all referees.
        PrincipalManager prMgr = getSession().getPrincipalManager();
        for (Iterator it = getRefereeValues().iterator(); it.hasNext();) {
            String refName = ((Value) it.next()).getString();
            Principal princ = null;
            if (prMgr.hasPrincipal(refName)) {
                try {
                    princ = prMgr.getPrincipal(refName);
                } catch (NoSuchPrincipalException e) {
                    // should not get here
                }
            }
            if (princ == null) {
View Full Code Here


    public PrincipalIterator getPrincipals() throws RepositoryException {
        Collection coll = new ArrayList();
        // the first element is the main principal of this user.
        coll.add(getPrincipal());
        // in addition add all referees.
        PrincipalManager prMgr = getSession().getPrincipalManager();
        for (Iterator it = getRefereeValues().iterator(); it.hasNext();) {
            String refName = ((Value) it.next()).getString();
            Principal princ = null;
            if (prMgr.hasPrincipal(refName)) {
                try {
                    princ = prMgr.getPrincipal(refName);
                } catch (NoSuchPrincipalException e) {
                    // should not get here
                }
            }
            if (princ == null) {
View Full Code Here

     * @throws RepositoryException
     */
    static void collectEntries(NodeImpl aclNode, Map princToEntries)
            throws RepositoryException {
        SessionImpl sImpl = (SessionImpl) aclNode.getSession();
        PrincipalManager principalMgr = sImpl.getPrincipalManager();
        AccessControlManager acMgr = sImpl.getAccessControlManager();

        NodeIterator itr = aclNode.getNodes();
        while (itr.hasNext()) {
            NodeImpl aceNode = (NodeImpl) itr.nextNode();
            String principalName = aceNode.getProperty(AccessControlConstants.P_PRINCIPAL_NAME).getString();
            // only process aceNode if 'principalName' is contained in the given set
            if (princToEntries.containsKey(principalName)) {
                Principal princ = null;
                if (principalMgr.hasPrincipal(principalName)) {
                    try {
                        princ = principalMgr.getPrincipal(principalName);
                    } catch (NoSuchPrincipalException e) {
                        // should not get here
                    }
                }
                if (princ == null) {
View Full Code Here

        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

                ValueFactory vf = session.getValueFactory();
                Map restrictions = new HashMap();
                restrictions.put(session.getJCRName(ACLTemplate.P_NODE_PATH), vf.createValue(root.getPath(), PropertyType.PATH));
                restrictions.put(session.getJCRName(ACLTemplate.P_GLOB), vf.createValue(GlobPattern.WILDCARD_ALL));

                PrincipalManager pMgr = session.getPrincipalManager();
                AccessControlManager acMgr = session.getAccessControlManager();
                Principal administrators;
                String pName = SecurityConstants.ADMINISTRATORS_NAME;
                if (pMgr.hasPrincipal(pName)) {
                    administrators = pMgr.getPrincipal(pName);
                } else {
                    log.warn("Administrators principal group is missing.");
                    administrators = new PrincipalImpl(pName);
                }
                AccessControlPolicy[] acls = editor.editAccessControlPolicies(administrators);
                ACLTemplate acl = (ACLTemplate) acls[0];
                if (acl.isEmpty()) {
                    log.debug("... Privilege.ALL for administrators principal.");
                    acl.addEntry(administrators,
                            new Privilege[] {acMgr.privilegeFromName(Privilege.JCR_ALL)},
                            true, restrictions);
                    editor.setPolicy(acl.getPath(), acl);
                } else {
                    log.debug("... policy for administrators principal already present.");
                }

                Principal everyone = pMgr.getEveryone();
                acls = editor.editAccessControlPolicies(everyone);
                acl = (ACLTemplate) acls[0];
                if (acl.isEmpty()) {
                    log.debug("... Privilege.READ for everyone principal.");
                    acl.addEntry(everyone,
View Full Code Here

     * @throws RepositoryException
     */
    static void collectEntries(NodeImpl aclNode, Map princToEntries)
            throws RepositoryException {
        SessionImpl sImpl = (SessionImpl) aclNode.getSession();
        PrincipalManager principalMgr = sImpl.getPrincipalManager();
        AccessControlManager acMgr = sImpl.getAccessControlManager();

        NodeIterator itr = aclNode.getNodes();
        while (itr.hasNext()) {
            NodeImpl aceNode = (NodeImpl) itr.nextNode();
            String principalName = aceNode.getProperty(AccessControlConstants.P_PRINCIPAL_NAME).getString();
            // only process aceNode if 'principalName' is contained in the given set
            if (princToEntries.containsKey(principalName)) {
                Principal princ = null;
                if (principalMgr.hasPrincipal(principalName)) {
                    try {
                        princ = principalMgr.getPrincipal(principalName);
                    } catch (NoSuchPrincipalException e) {
                        // should not get here
                    }
                }
                if (princ == null) {
View Full Code Here

    private Principal getValidPrincipal() throws NotExecutableException, RepositoryException {
        if (!(superuser instanceof JackrabbitSession)) {
            throw new NotExecutableException();
        }

        PrincipalManager pMgr = ((JackrabbitSession) superuser).getPrincipalManager();
        PrincipalIterator it = pMgr.getPrincipals(PrincipalManager.SEARCH_TYPE_NOT_GROUP);
        if (it.hasNext()) {
            return it.nextPrincipal();
        } else {
            throw new NotExecutableException();
        }
View Full Code Here

        return "/ab/c/d";
    }

    protected JackrabbitAccessControlList createEmptyTemplate(String path) throws RepositoryException {
        SessionImpl sImpl = (SessionImpl) superuser;
        PrincipalManager princicipalMgr = sImpl.getPrincipalManager();
        PrivilegeRegistry privilegeRegistry = new PrivilegeRegistry(sImpl);
        return new ACLTemplate(path, princicipalMgr, privilegeRegistry, sImpl.getValueFactory());
    }
View Full Code Here

            }
        }
    }

    public void testMultiplePrincipals() throws RepositoryException, NotExecutableException {
        PrincipalManager pMgr = ((JackrabbitSession) superuser).getPrincipalManager();
        Principal everyone = pMgr.getEveryone();
        Principal grPrincipal = null;
        PrincipalIterator it = pMgr.findPrincipals("", PrincipalManager.SEARCH_TYPE_GROUP);
        while (it.hasNext()) {
            Group gr = (Group) it.nextPrincipal();
            if (!everyone.equals(gr)) {
                grPrincipal = gr;
            }
View Full Code Here

            log.debug("Install initial ACL:...");
            String rootPath = session.getRootNode().getPath();
            AccessControlPolicy[] acls = editor.editAccessControlPolicies(rootPath);
            ACLTemplate acl = (ACLTemplate) acls[0];

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

            log.debug("... Privilege.ALL for administrators.");
            Principal administrators;
            String pName = SecurityConstants.ADMINISTRATORS_NAME;
            if (pMgr.hasPrincipal(pName)) {
                administrators = pMgr.getPrincipal(pName);
            } else {
                log.warn("Administrators principal group is missing.");
                administrators = new PrincipalImpl(pName);
            }
            Privilege[] privs = new Privilege[]{acMgr.privilegeFromName(Privilege.JCR_ALL)};
            acl.addAccessControlEntry(administrators, privs);

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

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

TOP

Related Classes of org.apache.jackrabbit.api.security.principal.PrincipalManager

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.