Package org.apache.jackrabbit.api.jsr283.query.qom

Examples of org.apache.jackrabbit.api.jsr283.query.qom.ChildNodeJoinConditionTest


        if (user == null) {
            user = userManager.createUser("test", "quatloos");
        }
        // 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 {
            throw new Exception("could not set access control for path "
                    + permissionsPath);
        }
View Full Code Here


        if (user == null) {
            user = userManager.createUser("test", "quatloos");
        }
        // 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 {
            throw new Exception("could not set access control for path "
                    + permissionsPath);
        }
View Full Code Here

                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.info("... Privilege.ALL for administrators principal.");
                    acl.addEntry(administrators,
                            new Privilege[] {acMgr.privilegeFromName(Privilege.JCR_ALL)},
                            true, restrictions);
                    editor.setPolicy(acl.getPath(), acl);
                } else {
                    log.info("... policy for administrators principal already present.");
                }

                Principal everyone = pMgr.getEveryone();
                acls = editor.editAccessControlPolicies(everyone);
                acl = (ACLTemplate) acls[0];
                if (acl.isEmpty()) {
                    log.info("... Privilege.READ for everyone principal.");
                    acl.addEntry(everyone,
                            new Privilege[] {acMgr.privilegeFromName(Privilege.JCR_READ)},
                            true, restrictions);
                    editor.setPolicy(acl.getPath(), acl);
                } else {
                    log.info("... policy for everyone principal already present.");
                }
View Full Code Here

                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.info("... Privilege.ALL for administrators principal.");
                    acl.addEntry(administrators,
                            new Privilege[] {acMgr.privilegeFromName(Privilege.JCR_ALL)},
                            true, restrictions);
                    editor.setPolicy(acl.getPath(), acl);
                } else {
                    log.info("... policy for administrators principal already present.");
                }

                Principal everyone = pMgr.getEveryone();
                acls = editor.editAccessControlPolicies(everyone);
                acl = (ACLTemplate) acls[0];
                if (acl.isEmpty()) {
                    log.info("... Privilege.READ for everyone principal.");
                    acl.addEntry(everyone,
                            new Privilege[] {acMgr.privilegeFromName(Privilege.JCR_READ)},
                            true, restrictions);
                    editor.setPolicy(acl.getPath(), acl);
                } else {
                    log.info("... policy for everyone principal already present.");
                }
View Full Code Here

        jcrGlobName = resolver.getJCRName(P_GLOB);

        if (acNode != null && acNode.hasNode(N_POLICY)) {
            // build the list of policy entries;
            NodeImpl aclNode = acNode.getNode(N_POLICY);
            AccessControlManager acMgr = ((SessionImpl) aclNode.getSession()).getAccessControlManager();

            // loop over all entries in the aclNode for the princ-Principal
            for (NodeIterator aceNodes = aclNode.getNodes(); aceNodes.hasNext();) {
                NodeImpl aceNode = (NodeImpl) aceNodes.nextNode();
                if (aceNode.isNodeType(NT_REP_ACE)) {
                    // the isAllow flag:
                    boolean isAllow = aceNode.isNodeType(NT_REP_GRANT_ACE);
                    // the privileges
                    Value[] pValues = aceNode.getProperty(P_PRIVILEGES).getValues();
                    Privilege[] privileges = new Privilege[pValues.length];
                    for (int i = 0; i < pValues.length; i++) {
                        privileges[i] = acMgr.privilegeFromName(pValues[i].getString());
                    }
                    // the restrictions:
                    Map restrictions = new HashMap(2);
                    Property prop = aceNode.getProperty(P_NODE_PATH);
                    restrictions.put(prop.getName(), prop.getValue());
View Full Code Here

            String rootPath = session.getRootNode().getPath();
            AccessControlPolicy[] acls = editor.editAccessControlPolicies(rootPath);
            ACLTemplate acl = (ACLTemplate) acls[0];

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

            log.info("... 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.info("... Privilege.READ for everyone.");
            privs = new Privilege[]{acMgr.privilegeFromName(Privilege.JCR_READ)};
            acl.addAccessControlEntry(everyone, privs);

            editor.setPolicy(rootPath, acl);
            session.save();
            log.info("... done.");
View Full Code Here

        path = aclNode.getParent().getPath();
        principalMgr = sImpl.getPrincipalManager();
        this.privilegeRegistry = privilegeRegistry;

        // load the entries:
        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();
            Principal princ = principalMgr.getPrincipal(principalName);

            Value[] privValues = aceNode.getProperty(AccessControlConstants.P_PRIVILEGES).getValues();
            Privilege[] privs = new Privilege[privValues.length];
            for (int i = 0; i < privValues.length; i++) {
                privs[i] = acMgr.privilegeFromName(privValues[i].getString());
            }
            // create a new ACEImpl (omitting validation check)
            Entry ace = new Entry(
                    princ,
                    privs,
View Full Code Here

     */
    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 = principalMgr.getPrincipal(principalName);

                Value[] privValues = aceNode.getProperty(AccessControlConstants.P_PRIVILEGES).getValues();
                Privilege[] privs = new Privilege[privValues.length];
                for (int i = 0; i < privValues.length; i++) {
                    privs[i] = acMgr.privilegeFromName(privValues[i].getString());
                }
                // create a new ACEImpl (omitting validation check)
                Entry ace = new Entry(
                        princ,
                        privs,
View Full Code Here

        if (user == null) {
            user = userManager.createUser("test", "quatloos");
        }
        // 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 {
            throw new Exception("could not set access control for path "
                    + permissionsPath);
        }
View Full Code Here

        }
    }

    private static void changeReadPermission(Principal principal, Node n, boolean allowRead) throws RepositoryException, NotExecutableException {
        SessionImpl s = (SessionImpl) n.getSession();
        AccessControlManager acMgr = s.getAccessControlManager();
        AccessControlPolicyIterator it = acMgr.getApplicablePolicies(n.getPath());
        while (it.hasNext()) {
            AccessControlPolicy acp = it.nextAccessControlPolicy();
            if (acp instanceof JackrabbitAccessControlList) {
                JackrabbitAccessControlList acl = (JackrabbitAccessControlList) acp;
                acl.addEntry(principal, new Privilege[] {acMgr.privilegeFromName(Privilege.JCR_READ)}, allowRead);
                acMgr.setPolicy(n.getPath(), acp);
                s.save();
                return;
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.api.jsr283.query.qom.ChildNodeJoinConditionTest

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.