Search in sources :

Example 56 with AccessControlPolicyIterator

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

the class ACLEditorTest method testNodeNotRepAccessControllable.

public void testNodeNotRepAccessControllable() throws RepositoryException, LockException, ConstraintViolationException, NoSuchNodeTypeException, ItemExistsException, VersionException {
    AccessControlPolicy[] plcs = acMgr.getPolicies(testPath);
    assertNotNull(plcs);
    assertEquals(0, plcs.length);
    AccessControlPolicyIterator it = acMgr.getApplicablePolicies(testPath);
    assertNotNull(it);
    assertEquals(0, it.getSize());
}
Also used : AccessControlPolicy(javax.jcr.security.AccessControlPolicy) AccessControlPolicyIterator(javax.jcr.security.AccessControlPolicyIterator)

Example 57 with AccessControlPolicyIterator

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

the class AccessControlPolicyIteratorTest method testGetSize.

public void testGetSize() throws RepositoryException, AccessDeniedException, NotExecutableException {
    checkCanReadAc(path);
    AccessControlPolicyIterator it = acMgr.getApplicablePolicies(path);
    // get size must succeed. its value however is indefined.
    long size = it.getSize();
    assertTrue("Size must be -1 or any value >= 0", size == -1 || size >= 0);
}
Also used : AccessControlPolicyIterator(javax.jcr.security.AccessControlPolicyIterator)

Example 58 with AccessControlPolicyIterator

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

the class AccessControlPolicyIteratorTest method testGetInitialPosition.

public void testGetInitialPosition() throws RepositoryException, AccessDeniedException, NotExecutableException {
    checkCanReadAc(path);
    AccessControlPolicyIterator it = acMgr.getApplicablePolicies(path);
    // the initial position of the policy iterator must be 0.
    assertTrue("Initial position of AccessControlPolicyIterator must be 0.", it.getPosition() == 0);
}
Also used : AccessControlPolicyIterator(javax.jcr.security.AccessControlPolicyIterator)

Example 59 with AccessControlPolicyIterator

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

the class AccessControlPolicyTest method testNodeIsModifiedAfterSetPolicy.

public void testNodeIsModifiedAfterSetPolicy() throws RepositoryException, AccessDeniedException, NotExecutableException {
    checkCanModifyAc(path);
    AccessControlPolicyIterator it = acMgr.getApplicablePolicies(path);
    if (it.hasNext()) {
        Item item = superuser.getItem(path);
        AccessControlPolicy policy = it.nextAccessControlPolicy();
        acMgr.setPolicy(path, policy);
        assertTrue("After setting a policy the node must be marked modified.", item.isModified());
    } else {
        throw new NotExecutableException();
    }
}
Also used : Item(javax.jcr.Item) NamedAccessControlPolicy(javax.jcr.security.NamedAccessControlPolicy) AccessControlPolicy(javax.jcr.security.AccessControlPolicy) NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) AccessControlPolicyIterator(javax.jcr.security.AccessControlPolicyIterator)

Example 60 with AccessControlPolicyIterator

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

the class AccessControlPolicyTest method testSetPolicyOnNewNode.

public void testSetPolicyOnNewNode() throws NotExecutableException, RepositoryException, AccessDeniedException {
    Node n;
    try {
        n = ((Node) superuser.getItem(path)).addNode(nodeName2, testNodeType);
    } catch (RepositoryException e) {
        throw new NotExecutableException();
    }
    AccessControlPolicyIterator it = acMgr.getApplicablePolicies(n.getPath());
    while (it.hasNext()) {
        AccessControlPolicy policy = it.nextAccessControlPolicy();
        acMgr.setPolicy(n.getPath(), policy);
        AccessControlPolicy[] plcs = acMgr.getPolicies(n.getPath());
        assertNotNull("After calling setPolicy the manager must return a non-null policy array for the new Node.", plcs);
        assertTrue("After calling setPolicy the manager must return a policy array with a length greater than zero for the new Node.", plcs.length > 0);
    }
}
Also used : NamedAccessControlPolicy(javax.jcr.security.NamedAccessControlPolicy) AccessControlPolicy(javax.jcr.security.AccessControlPolicy) NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) Node(javax.jcr.Node) RepositoryException(javax.jcr.RepositoryException) AccessControlPolicyIterator(javax.jcr.security.AccessControlPolicyIterator)

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