Examples of AccessControlPolicyIterator


Examples of javax.jcr.security.AccessControlPolicyIterator

        assertFalse(getTestSession().hasPermission(policyPath, javax.jcr.Session.ACTION_REMOVE));
        assertTrue(testAcMgr.hasPrivileges(policyPath, new Privilege[] {rmChildNodes[0], rmNode[0]}));
    }

    public void testApplicablePolicies() throws RepositoryException {
        AccessControlPolicyIterator it = acMgr.getApplicablePolicies(childNPath);
        assertTrue(it.hasNext());

        // the same should be true, if the rep:AccessControllable mixin has
        // been manually added
        Node n = (Node) superuser.getItem(childNPath);
        n.addMixin(((SessionImpl) superuser).getJCRName(AccessControlConstants.NT_REP_ACCESS_CONTROLLABLE));
        it = acMgr.getApplicablePolicies(childNPath);
        assertTrue(it.hasNext());
    }
View Full Code Here

Examples of javax.jcr.security.AccessControlPolicyIterator

    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

Examples of javax.jcr.security.AccessControlPolicyIterator

            AccessControlPolicy[] effective = acMgr.getEffectivePolicies(null);
            assertNotNull(effective);
            assertEquals(0, effective.length);

            AccessControlPolicyIterator it = acMgr.getApplicablePolicies(null);
            assertNotNull(it);
            assertTrue(it.hasNext());
            AccessControlPolicy acp = it.nextAccessControlPolicy();
            assertNotNull(acp);
            assertTrue(acp instanceof JackrabbitAccessControlPolicy);

            // modify the repo level policy
            modifyPrivileges(null, NameConstants.JCR_NODE_TYPE_DEFINITION_MANAGEMENT.toString(), false);
            modifyPrivileges(null, NameConstants.JCR_NAMESPACE_MANAGEMENT.toString(), true);

            AccessControlPolicy[] plcs = acMgr.getPolicies(null);
            assertNotNull(plcs);
            assertEquals(1, plcs.length);
            assertTrue(plcs[0] instanceof AccessControlList);

            AccessControlList acl = (AccessControlList) plcs[0];
            AccessControlEntry[] aces = acl.getAccessControlEntries();
            assertNotNull(aces);
            assertEquals(2, aces.length);

            assertPrivilege(NameConstants.JCR_NAMESPACE_MANAGEMENT, true);
            assertPermission(Permission.NAMESPACE_MNGMT, true);

            assertPrivilege(NameConstants.JCR_NODE_TYPE_DEFINITION_MANAGEMENT, false);
            assertPermission(Permission.NODE_TYPE_DEF_MNGMT, false);

            effective = acMgr.getEffectivePolicies(null);
            assertNotNull(effective);
            assertEquals(1, effective.length);
            assertTrue(effective[0] instanceof AccessControlList);

            acl = (AccessControlList) effective[0];
            aces = acl.getAccessControlEntries();
            assertNotNull(aces);
            assertEquals(2, aces.length);

            // change the policy
            acl = (AccessControlList) acMgr.getPolicies(null)[0];
            acl.removeAccessControlEntry(aces[0]);
            acMgr.setPolicy(null, acl);
            superuser.save();

            acl = (AccessControlList) acMgr.getPolicies(null)[0];
            aces = acl.getAccessControlEntries();
            assertNotNull(aces);
            assertEquals(1, aces.length);

            assertPrivilege(NameConstants.JCR_NAMESPACE_MANAGEMENT, false);
            assertPermission(Permission.NAMESPACE_MNGMT, false);

            assertPrivilege(NameConstants.JCR_NODE_TYPE_DEFINITION_MANAGEMENT, false);
            assertPermission(Permission.NODE_TYPE_DEF_MNGMT, false);


            // remove it again
            acMgr.removePolicy(null, acl);
            superuser.save();

            // back to initial state: no repo level policy
            policies = acMgr.getPolicies(null);
            assertNotNull(policies);
            assertEquals(0, policies.length);

            effective = acMgr.getEffectivePolicies(null);
            assertNotNull(effective);
            assertEquals(0, effective.length);

            it = acMgr.getApplicablePolicies(null);
            assertNotNull(it);
            assertTrue(it.hasNext());
            acp = it.nextAccessControlPolicy();
            assertNotNull(acp);
            assertTrue(acp instanceof JackrabbitAccessControlPolicy);
        } catch (UnsupportedRepositoryOperationException e) {
            throw new NotExecutableException();
        }
View Full Code Here

Examples of javax.jcr.security.AccessControlPolicyIterator

        assertFalse(getTestSession().hasPermission(policyPath, javax.jcr.Session.ACTION_REMOVE));
        assertTrue(testAcMgr.hasPrivileges(policyPath, new Privilege[] {rmChildNodes[0], rmNode[0]}));
    }

    public void testApplicablePolicies() throws RepositoryException {
        AccessControlPolicyIterator it = acMgr.getApplicablePolicies(childNPath);
        assertTrue(it.hasNext());

        // the same should be true, if the rep:AccessControllable mixin has
        // been manually added
        Node n = (Node) superuser.getItem(childNPath);
        n.addMixin(((SessionImpl) superuser).getJCRName(AccessControlConstants.NT_REP_ACCESS_CONTROLLABLE));
        it = acMgr.getApplicablePolicies(childNPath);
        assertTrue(it.hasNext());
    }
View Full Code Here

Examples of javax.jcr.security.AccessControlPolicyIterator

        NameMapper remapped = new TestNameMapper(nameMapper, TestNameMapper.LOCAL_MAPPING);
        return new NamePathMapperImpl(remapped);
    }

    private ACL getApplicablePolicy(@Nullable String path) throws RepositoryException {
        AccessControlPolicyIterator itr = acMgr.getApplicablePolicies(path);
        if (itr.hasNext()) {
            return (ACL) itr.nextAccessControlPolicy();
        } else {
            throw new RepositoryException("No applicable policy found.");
        }
    }
View Full Code Here

Examples of javax.jcr.security.AccessControlPolicyIterator

    //--------------------------------------< getApplicablePolicies(String) >---

    @Test
    public void testGetApplicablePolicies() throws Exception {
        AccessControlPolicyIterator itr = acMgr.getApplicablePolicies(testPath);

        assertNotNull(itr);
        assertTrue(itr.hasNext());

        AccessControlPolicy policy = itr.nextAccessControlPolicy();
        assertNotNull(policy);
        assertTrue(policy instanceof ACL);

        ACL acl = (ACL) policy;
        assertTrue(acl.isEmpty());
        assertEquals(testPath, acl.getPath());

        assertFalse(itr.hasNext());
    }
View Full Code Here

Examples of javax.jcr.security.AccessControlPolicyIterator

    @Test
    public void testGetApplicablePoliciesOnAccessControllable() throws Exception {
        NodeUtil node = new NodeUtil(root.getTree(testPath));
        node.setNames(JcrConstants.JCR_MIXINTYPES, MIX_REP_ACCESS_CONTROLLABLE);

        AccessControlPolicyIterator itr = acMgr.getApplicablePolicies(testPath);

        assertNotNull(itr);
        assertTrue(itr.hasNext());
    }
View Full Code Here

Examples of javax.jcr.security.AccessControlPolicyIterator

        assertTrue(itr.hasNext());
    }

    @Test
    public void testGetApplicableRepoPolicies() throws Exception {
        AccessControlPolicyIterator itr = acMgr.getApplicablePolicies((String) null);

        assertNotNull(itr);
        assertTrue(itr.hasNext());

        AccessControlPolicy policy = itr.nextAccessControlPolicy();
        assertNotNull(policy);
        assertTrue(policy instanceof ACL);

        ACL acl = (ACL) policy;
        assertTrue(acl.isEmpty());
        assertNull(acl.getPath());

        assertFalse(itr.hasNext());
    }
View Full Code Here

Examples of javax.jcr.security.AccessControlPolicyIterator

    @Test
    public void testGetApplicablePoliciesWithCollidingNode() throws Exception {
        NodeUtil testTree = new NodeUtil(root.getTree(testPath));
        testTree.addChild(REP_POLICY, JcrConstants.NT_UNSTRUCTURED);

        AccessControlPolicyIterator itr = acMgr.getApplicablePolicies(testPath);
        assertNotNull(itr);
        assertFalse(itr.hasNext());
    }
View Full Code Here

Examples of javax.jcr.security.AccessControlPolicyIterator

    @Test
    public void testGetApplicablePoliciesForAccessControlled() throws Exception {
        AccessControlPolicy policy = getApplicablePolicy(testPath);
        acMgr.setPolicy(testPath, policy);

        AccessControlPolicyIterator itr = acMgr.getApplicablePolicies(testPath);
        assertNotNull(itr);
        assertFalse(itr.hasNext());
    }
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.