Examples of JackrabbitAccessControlList


Examples of org.apache.jackrabbit.api.security.JackrabbitAccessControlList

    }

    @Test
    public void testEqualsForEmpty() throws Exception {

        JackrabbitAccessControlList acl = createEmptyACL();

        assertEquals(acl, createEmptyACL());
        ACE entry = createEntry(testPrincipal, testPrivileges, true);
        assertFalse(acl.equals(createACL(entry)));
        assertFalse(acl.equals(new TestACL(getTestPath(), getRestrictionProvider(), Collections.<JackrabbitAccessControlEntry>emptyList())));
    }
View Full Code Here

Examples of org.apache.jackrabbit.api.security.JackrabbitAccessControlList

        RestrictionProvider rp = getRestrictionProvider();
        ACE ace1 = createEntry(testPrincipal, false, null, PrivilegeConstants.JCR_VERSION_MANAGEMENT);
        ACE ace2 = createEntry(testPrincipal, testPrivileges, true);
        ACE ace2b = createEntry(testPrincipal, getAggregatedPrivileges(testPrivileges), true);

        JackrabbitAccessControlList acl = createACL(ace1, ace2);
        JackrabbitAccessControlList repoAcl = createACL((String) null, ace1, ace2);

        assertEquals(acl, createACL(ace1, ace2));
        assertEquals(acl, createACL(ace1, ace2b));

        assertEquals(repoAcl, createACL((String) null, ace1, ace2b));
View Full Code Here

Examples of org.apache.jackrabbit.api.security.JackrabbitAccessControlList

        RestrictionProvider rp = getRestrictionProvider();
        ACE ace1 = createEntry(testPrincipal, privilegesFromNames(PrivilegeConstants.JCR_VERSION_MANAGEMENT), false);
        ACE ace2 = createEntry(testPrincipal, testPrivileges, true);
        ACE ace2b = createEntry(testPrincipal, getAggregatedPrivileges(testPrivileges), true);

        JackrabbitAccessControlList acl = createACL(ace1, ace2);
        JackrabbitAccessControlList repoAcl = createACL((String) null, ace1, ace2);

        int hc = acl.hashCode();
        assertTrue(hc == createACL(ace1, ace2).hashCode());
        assertTrue(hc == createACL(ace1, ace2b).hashCode());

        assertTrue(repoAcl.hashCode() == createACL((String) null, ace1, ace2b).hashCode());

        assertFalse(hc == createACL(ace2, ace1).hashCode());
        assertFalse(hc == repoAcl.hashCode());
        assertFalse(hc == createEmptyACL().hashCode());
        assertFalse(hc == createACL("/anotherPath", ace1, ace2).hashCode());
        assertFalse(hc == new TestACL("/anotherPath", rp, ace1, ace2).hashCode());
        assertFalse(hc == new TestACL("/anotherPath", rp, ace1, ace2).hashCode());
        assertFalse(hc == new TestACL("/anotherPath", rp).hashCode());
View Full Code Here

Examples of org.apache.jackrabbit.api.security.JackrabbitAccessControlList

    @CheckForNull
    private JackrabbitAccessControlList getACL(Tree tree) throws RepositoryException {
        String nodeName = tree.getName();

        JackrabbitAccessControlList acl = null;
        if (!tree.isRoot()) {
            Tree parent = tree.getParent();
            if (AccessControlConstants.REP_POLICY.equals(nodeName)
                    && ntMgr.isNodeType(tree, AccessControlConstants.NT_REP_ACL)) {
                acl = getACL(parent.getPath());
            } else if (AccessControlConstants.REP_REPO_POLICY.equals(nodeName)
                    && ntMgr.isNodeType(tree, AccessControlConstants.NT_REP_ACL)
                    && parent.isRoot()) {
                acl = getACL((String) null);
            }
        }

        if (acl != null) {
            // clear all existing entries
            for (AccessControlEntry ace: acl.getAccessControlEntries()) {
                acl.removeAccessControlEntry(ace);
            }
        }

        return acl;
    }
View Full Code Here

Examples of org.apache.jackrabbit.api.security.JackrabbitAccessControlList

        return acl;
    }

    @CheckForNull
    private JackrabbitAccessControlList getACL(String path) throws RepositoryException {
        JackrabbitAccessControlList acl = null;
        for (AccessControlPolicy p : acMgr.getPolicies(path)) {
            if (p instanceof JackrabbitAccessControlList) {
                acl = (JackrabbitAccessControlList) p;
                break;
            }
View Full Code Here

Examples of org.apache.jackrabbit.api.security.JackrabbitAccessControlList

        String childPath = child.getTree().getPath();

        Privilege[] privs = privilegesFromNames(PrivilegeConstants.JCR_READ, PrivilegeConstants.JCR_READ_ACCESS_CONTROL);
        setupPolicy(testPath, privilegesFromNames(PrivilegeConstants.JCR_READ, PrivilegeConstants.JCR_READ_ACCESS_CONTROL));

        JackrabbitAccessControlList acl = getApplicablePolicy(childPath);
        acl.addEntry(EveryonePrincipal.getInstance(), privs, true);
        acMgr.setPolicy(childPath, acl);

        root.commit();

        Root testRoot = getTestRoot();
View Full Code Here

Examples of org.apache.jackrabbit.api.security.JackrabbitAccessControlList

        String childPath = child.getTree().getPath();

        Privilege[] privs = privilegesFromNames(PrivilegeConstants.JCR_READ, PrivilegeConstants.JCR_READ_ACCESS_CONTROL);

        // create policy on testPath -> but deny access to test session
        JackrabbitAccessControlList acl = getApplicablePolicy(testPath);
        acl.addEntry(getTestPrincipal(), privs, false);
        acMgr.setPolicy(testPath, acl);

        // grant access at childpath
        setupPolicy(childPath, privilegesFromNames(PrivilegeConstants.JCR_READ, PrivilegeConstants.JCR_READ_ACCESS_CONTROL));
        root.commit();
View Full Code Here

Examples of org.apache.jackrabbit.api.security.JackrabbitAccessControlList

    @Override
    @After
    public void after() throws Exception {
        try {
            AccessControlManager acMgr = getAccessControlManager(root);
            JackrabbitAccessControlList acl = AccessControlUtils.getAccessControlList(acMgr, "/");
            if (acl != null) {
                boolean modified = false;
                for (AccessControlEntry entry : acl.getAccessControlEntries()) {
                    if (entry.getPrincipal().equals(getTestUser().getPrincipal())) {
                        acl.removeAccessControlEntry(entry);
                        modified = true;
                    }
                }
                if (modified) {
                    acMgr.setPolicy("/", acl);
View Full Code Here

Examples of org.apache.jackrabbit.api.security.JackrabbitAccessControlList

        NodeUtil rootNode = new NodeUtil(root.getTree("/"), namePathMapper);
        NodeUtil testNode = rootNode.addChild("testPath", JcrConstants.NT_UNSTRUCTURED);
        testNode.addChild("childNode", JcrConstants.NT_UNSTRUCTURED);

        AccessControlManager acMgr = getAccessControlManager(root);
        JackrabbitAccessControlList acl = AccessControlUtils.getAccessControlList(acMgr, testPath);
        acl.addAccessControlEntry(testPrincipal, privilegesFromNames(JCR_ADD_CHILD_NODES));
        acl.addAccessControlEntry(EveryonePrincipal.getInstance(), privilegesFromNames(JCR_READ));
        acMgr.setPolicy(testPath, acl);
        root.commit();

        testPrincipalName = testPrincipal.getName();
        bitsProvider = new PrivilegeBitsProvider(root);
View Full Code Here

Examples of org.apache.jackrabbit.api.security.JackrabbitAccessControlList

    @Test
    public void testReorderAddAndRemoveAces2() throws Exception {
        createPrincipals();

        AccessControlManager acMgr = getAccessControlManager(root);
        JackrabbitAccessControlList acl = AccessControlUtils.getAccessControlList(acMgr, testPath);
        for (int i = 0; i < 4; i++) {
            acl.addAccessControlEntry(principals.get(i), privilegesFromNames(JCR_READ));
        }
        acMgr.setPolicy(testPath, acl);
        root.commit();

        AccessControlEntry[] aces = acl.getAccessControlEntries();
        acl.removeAccessControlEntry(aces[0]);
        acl.removeAccessControlEntry(aces[2]);
        acl.orderBefore(aces[4], aces[3]);
        acl.addAccessControlEntry(principals.get(4), privilegesFromNames(JCR_READ));
        acl.addAccessControlEntry(principals.get(5), privilegesFromNames(JCR_READ));
        acMgr.setPolicy(testPath, acl);
        root.commit();

        Tree entry = getEntry(principals.get(2).getName(), testPath, 1);
        assertEquals(1, entry.getProperty(REP_INDEX).getValue(Type.LONG).longValue());
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.