use of javax.jcr.security.AccessControlPolicy in project jackrabbit-oak by apache.
the class AccessControlManagerImplTest method testGetApplicablePolicies.
//--------------------------------------< 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());
}
use of javax.jcr.security.AccessControlPolicy in project jackrabbit-oak by apache.
the class AccessControlManagerImplTest method testGetPolicies.
//------------------------------------------------< getPolicies(String) >---
@Test
public void testGetPolicies() throws Exception {
AccessControlPolicy policy = getApplicablePolicy(testPath);
acMgr.setPolicy(testPath, policy);
AccessControlPolicy[] policies = acMgr.getPolicies(testPath);
assertNotNull(policies);
assertEquals(1, policies.length);
assertTrue(policies[0] instanceof ACL);
ACL acl = (ACL) policies[0];
assertTrue(acl.isEmpty());
assertEquals(testPath, acl.getOakPath());
}
use of javax.jcr.security.AccessControlPolicy in project jackrabbit-oak by apache.
the class AccessControlManagerImplTest method testRemovePolicyPropertyPath.
@Test
public void testRemovePolicyPropertyPath() throws Exception {
try {
String path = "/jcr:primaryType";
AccessControlPolicy acl = createPolicy(path);
acMgr.removePolicy(path, acl);
fail("Removing access control policy at property path should fail");
} catch (PathNotFoundException e) {
// success
}
}
use of javax.jcr.security.AccessControlPolicy in project jackrabbit-oak by apache.
the class AccessControlManagerImplTest method testEffectiveSorting.
@Test
public void testEffectiveSorting() throws Exception {
Set<Principal> principalSet = ImmutableSet.of(testPrincipal, EveryonePrincipal.getInstance());
ACL nullPathPolicy = null;
try {
// 1. policy at 'testPath'
ACL policy = getApplicablePolicy(testPath);
policy.addEntry(testPrincipal, testPrivileges, true, getGlobRestriction("*"));
policy.addEntry(testPrincipal, privilegesFromNames(PrivilegeConstants.JCR_VERSION_MANAGEMENT), false);
policy.addEntry(EveryonePrincipal.getInstance(), privilegesFromNames(PrivilegeConstants.JCR_LIFECYCLE_MANAGEMENT), false);
acMgr.setPolicy(testPath, policy);
// 2. policy at child node
NodeUtil child = new NodeUtil(root.getTree(testPath)).addChild("child", JcrConstants.NT_UNSTRUCTURED);
String childPath = child.getTree().getPath();
setupPolicy(childPath);
// 3. policy for null-path
nullPathPolicy = getApplicablePolicy(null);
assertNotNull(nullPathPolicy);
nullPathPolicy.addEntry(testPrincipal, privilegesFromNames(PrivilegeConstants.REP_PRIVILEGE_MANAGEMENT), true);
acMgr.setPolicy(null, nullPathPolicy);
root.commit();
AccessControlPolicy[] effectivePolicies = acMgr.getEffectivePolicies(principalSet);
assertEquals(3, effectivePolicies.length);
assertNull(((JackrabbitAccessControlPolicy) effectivePolicies[0]).getPath());
assertEquals(testPath, ((JackrabbitAccessControlPolicy) effectivePolicies[1]).getPath());
assertEquals(childPath, ((JackrabbitAccessControlPolicy) effectivePolicies[2]).getPath());
} finally {
if (nullPathPolicy != null) {
acMgr.removePolicy(null, nullPathPolicy);
root.commit();
}
}
}
use of javax.jcr.security.AccessControlPolicy in project jackrabbit-oak by apache.
the class AccessControlManagerImplTest method testGetPoliciesByPrincipal.
@Test
public void testGetPoliciesByPrincipal() throws Exception {
List<Principal> principals = ImmutableList.of(testPrincipal, EveryonePrincipal.getInstance());
for (Principal principal : principals) {
AccessControlPolicy[] policies = acMgr.getPolicies(principal);
assertNotNull(policies);
assertEquals(0, policies.length);
}
}
Aggregations