Search in sources :

Example 46 with AccessControlPolicyIterator

use of javax.jcr.security.AccessControlPolicyIterator in project jackrabbit-oak by apache.

the class AccessControlManagerImplTest method testGetApplicablePoliciesForAccessControlled.

@Test
public void testGetApplicablePoliciesForAccessControlled() throws Exception {
    AccessControlPolicy policy = getApplicablePolicy(testPath);
    acMgr.setPolicy(testPath, policy);
    AccessControlPolicyIterator itr = acMgr.getApplicablePolicies(testPath);
    assertNotNull(itr);
    assertFalse(itr.hasNext());
}
Also used : JackrabbitAccessControlPolicy(org.apache.jackrabbit.api.security.JackrabbitAccessControlPolicy) AccessControlPolicy(javax.jcr.security.AccessControlPolicy) AccessControlPolicyIterator(javax.jcr.security.AccessControlPolicyIterator) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 47 with AccessControlPolicyIterator

use of javax.jcr.security.AccessControlPolicyIterator in project jackrabbit-oak by apache.

the class AccessControlManagerImplTest method testGetApplicablePoliciesOnAccessControllable.

@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());
}
Also used : AccessControlPolicyIterator(javax.jcr.security.AccessControlPolicyIterator) NodeUtil(org.apache.jackrabbit.oak.util.NodeUtil) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 48 with AccessControlPolicyIterator

use of javax.jcr.security.AccessControlPolicyIterator in project jackrabbit-oak by apache.

the class AccessControlManagerImplTest method testGetApplicablePoliciesWithCollidingNode.

@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());
}
Also used : AccessControlPolicyIterator(javax.jcr.security.AccessControlPolicyIterator) NodeUtil(org.apache.jackrabbit.oak.util.NodeUtil) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 49 with AccessControlPolicyIterator

use of javax.jcr.security.AccessControlPolicyIterator in project jackrabbit-oak by apache.

the class L2_AccessControlManagerTest method testRetrievePoliciesAtNamespaceRoot.

public void testRetrievePoliciesAtNamespaceRoot() throws RepositoryException {
    AccessControlPolicy[] policies = acMgr.getPolicies(NamespaceConstants.NAMESPACES_PATH);
    // EXERCISE
    int expectedLength = -1;
    assertEquals(expectedLength, policies.length);
    AccessControlPolicyIterator policyIterator = acMgr.getApplicablePolicies(NamespaceConstants.NAMESPACES_PATH);
    // EXERCISE
    int expectedSize = -1;
    assertEquals(expectedSize, policyIterator.getSize());
    // EXERCISE: look at the utility methods and explain the expected return value
    JackrabbitAccessControlList acl = AccessControlUtils.getAccessControlList(acMgr, NamespaceConstants.NAMESPACES_PATH);
    JackrabbitAccessControlList acl2 = AccessControlUtils.getAccessControlList(superuser, NamespaceConstants.NAMESPACES_PATH);
    // EXERCISE: is this correct?
    assertEquals(acl, acl2);
}
Also used : AccessControlPolicy(javax.jcr.security.AccessControlPolicy) AccessControlPolicyIterator(javax.jcr.security.AccessControlPolicyIterator) JackrabbitAccessControlList(org.apache.jackrabbit.api.security.JackrabbitAccessControlList)

Example 50 with AccessControlPolicyIterator

use of javax.jcr.security.AccessControlPolicyIterator in project jackrabbit-oak by apache.

the class JackrabbitAccessControlListTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    Node n = testRootNode.addNode(nodeName1, testNodeType);
    superuser.save();
    AccessControlPolicyIterator it = acMgr.getApplicablePolicies(n.getPath());
    while (it.hasNext() && acl == null) {
        AccessControlPolicy p = it.nextAccessControlPolicy();
        if (p instanceof JackrabbitAccessControlList) {
            acl = (JackrabbitAccessControlList) p;
        }
    }
    if (acl == null) {
        superuser.logout();
        throw new NotExecutableException("No JackrabbitAccessControlList to test.");
    }
    testPrincipal = getValidPrincipal();
    testPrivileges = privilegesFromName(Privilege.JCR_ALL);
}
Also used : AccessControlPolicy(javax.jcr.security.AccessControlPolicy) NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) Node(javax.jcr.Node) AccessControlPolicyIterator(javax.jcr.security.AccessControlPolicyIterator) JackrabbitAccessControlList(org.apache.jackrabbit.api.security.JackrabbitAccessControlList)

Aggregations

AccessControlPolicyIterator (javax.jcr.security.AccessControlPolicyIterator)69 AccessControlPolicy (javax.jcr.security.AccessControlPolicy)54 NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)22 Test (org.junit.Test)16 NamedAccessControlPolicy (javax.jcr.security.NamedAccessControlPolicy)15 JackrabbitAccessControlList (org.apache.jackrabbit.api.security.JackrabbitAccessControlList)15 AccessControlList (javax.jcr.security.AccessControlList)14 AccessControlManager (javax.jcr.security.AccessControlManager)13 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)11 Node (javax.jcr.Node)7 Privilege (javax.jcr.security.Privilege)6 JackrabbitAccessControlPolicy (org.apache.jackrabbit.api.security.JackrabbitAccessControlPolicy)6 AccessControlEntry (javax.jcr.security.AccessControlEntry)5 Principal (java.security.Principal)3 HashSet (java.util.HashSet)3 Item (javax.jcr.Item)3 RepositoryException (javax.jcr.RepositoryException)3 JackrabbitAccessControlManager (org.apache.jackrabbit.api.security.JackrabbitAccessControlManager)3 NodeUtil (org.apache.jackrabbit.oak.util.NodeUtil)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2