Search in sources :

Example 36 with AccessControlPolicyIterator

use of javax.jcr.security.AccessControlPolicyIterator in project kylo by Teradata.

the class JcrAccessControlUtil method getAccessControlList.

private static AccessControlList getAccessControlList(String path, AccessControlManager acm) throws PathNotFoundException, AccessDeniedException, RepositoryException {
    AccessControlList acl = null;
    AccessControlPolicyIterator it = acm.getApplicablePolicies(path);
    if (it.hasNext()) {
        acl = (AccessControlList) it.nextAccessControlPolicy();
    } else {
        acl = (AccessControlList) acm.getPolicies(path)[0];
    }
    return acl;
}
Also used : AccessControlList(javax.jcr.security.AccessControlList) AccessControlPolicyIterator(javax.jcr.security.AccessControlPolicyIterator)

Example 37 with AccessControlPolicyIterator

use of javax.jcr.security.AccessControlPolicyIterator in project pentaho-platform by pentaho.

the class JcrRepositoryFileAclUtils method getAccessControlList.

private static AccessControlList getAccessControlList(final AccessControlManager acMgr, final String path) throws RepositoryException {
    AccessControlPolicyIterator applicablePolicies = acMgr.getApplicablePolicies(path);
    while (applicablePolicies.hasNext()) {
        AccessControlPolicy policy = applicablePolicies.nextAccessControlPolicy();
        if (policy instanceof AccessControlList) {
            return (AccessControlList) policy;
        }
    }
    AccessControlPolicy[] policies = acMgr.getPolicies(path);
    for (int i = 0; i < policies.length; i++) {
        if (policies[i] instanceof AccessControlList) {
            return (AccessControlList) policies[i];
        }
    }
    throw new IllegalStateException("no access control list applies or is bound to node");
}
Also used : AccessControlList(javax.jcr.security.AccessControlList) AccessControlPolicy(javax.jcr.security.AccessControlPolicy) AccessControlPolicyIterator(javax.jcr.security.AccessControlPolicyIterator)

Example 38 with AccessControlPolicyIterator

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

the class AbstractCugTest method createCug.

void createCug(@Nonnull String absPath, @Nonnull Principal principal) throws RepositoryException {
    AccessControlManager acMgr = getAccessControlManager(root);
    AccessControlPolicyIterator it = acMgr.getApplicablePolicies(absPath);
    while (it.hasNext()) {
        AccessControlPolicy policy = it.nextAccessControlPolicy();
        if (policy instanceof CugPolicy) {
            ((CugPolicy) policy).addPrincipals(principal);
            acMgr.setPolicy(absPath, policy);
            return;
        }
    }
    throw new IllegalStateException("Unable to create CUG at " + absPath);
}
Also used : AccessControlManager(javax.jcr.security.AccessControlManager) CugPolicy(org.apache.jackrabbit.oak.spi.security.authorization.cug.CugPolicy) AccessControlPolicy(javax.jcr.security.AccessControlPolicy) AccessControlPolicyIterator(javax.jcr.security.AccessControlPolicyIterator)

Example 39 with AccessControlPolicyIterator

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

the class CugAccessControlManagerTest method testGetApplicablePoliciesAfterSet.

@Test
public void testGetApplicablePoliciesAfterSet() throws Exception {
    cugAccessControlManager.setPolicy(SUPPORTED_PATH, getApplicableCug(SUPPORTED_PATH));
    AccessControlPolicyIterator it = cugAccessControlManager.getApplicablePolicies(SUPPORTED_PATH);
    assertFalse(it.hasNext());
}
Also used : AccessControlPolicyIterator(javax.jcr.security.AccessControlPolicyIterator) Test(org.junit.Test)

Example 40 with AccessControlPolicyIterator

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

the class CugAccessControlManagerTest method testGetApplicablePoliciesNullPath.

@Test
public void testGetApplicablePoliciesNullPath() throws Exception {
    AccessControlPolicyIterator it = cugAccessControlManager.getApplicablePolicies((String) null);
    assertFalse(it.hasNext());
}
Also used : AccessControlPolicyIterator(javax.jcr.security.AccessControlPolicyIterator) Test(org.junit.Test)

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