use of javax.jcr.security.AccessControlPolicyIterator in project jackrabbit-oak by apache.
the class CompositeAccessControlManagerTest method testGetPolicies.
@Test
public void testGetPolicies() throws Exception {
int len = 0;
AccessControlPolicy[] policies = acMgr.getPolicies(TEST_PATH);
assertEquals(len, policies.length);
acMgr.setPolicy(TEST_PATH, TestPolicy.INSTANCE);
len++;
policies = acMgr.getPolicies(TEST_PATH);
assertEquals(len, policies.length);
assertSame(TestPolicy.INSTANCE, policies[0]);
AccessControlPolicyIterator it = acMgr.getApplicablePolicies(TEST_PATH);
while (it.hasNext()) {
AccessControlPolicy plc = it.nextAccessControlPolicy();
if (plc == TestPolicy.INSTANCE) {
fail("TestPolicy should only be applicable at /test.");
} else {
acMgr.setPolicy(TEST_PATH, plc);
len++;
Set<AccessControlPolicy> policySet = ImmutableSet.copyOf(acMgr.getPolicies(TEST_PATH));
assertEquals(len, policySet.size());
assertTrue(policySet.contains(TestPolicy.INSTANCE));
assertTrue(policySet.contains(plc));
}
}
}
use of javax.jcr.security.AccessControlPolicyIterator in project jackrabbit-oak by apache.
the class CompositeAccessControlManagerTest method testGetApplicablePolicies.
@Test
public void testGetApplicablePolicies() throws Exception {
AccessControlPolicyIterator it = acMgr.getApplicablePolicies("/");
while (it.hasNext()) {
if (it.nextAccessControlPolicy() == TestPolicy.INSTANCE) {
fail("TestPolicy should only be applicable at /test.");
}
}
Set<AccessControlPolicy> applicable = ImmutableSet.copyOf(acMgr.getApplicablePolicies(TEST_PATH));
assertEquals(2, applicable.size());
assertTrue(applicable.contains(TestPolicy.INSTANCE));
}
use of javax.jcr.security.AccessControlPolicyIterator in project jackrabbit-oak by apache.
the class CompositeAccessControlManagerTest method testSetPolicyAtRoot.
@Test
public void testSetPolicyAtRoot() throws Exception {
AccessControlPolicyIterator it = acMgr.getApplicablePolicies("/");
int cnt = 0;
while (it.hasNext()) {
AccessControlPolicy plc = it.nextAccessControlPolicy();
assertTrue(plc instanceof JackrabbitAccessControlList);
acMgr.setPolicy("/", plc);
cnt++;
}
assertEquals(1, cnt);
}
use of javax.jcr.security.AccessControlPolicyIterator in project jackrabbit-oak by apache.
the class AccessControlImporterTest method createImportTargetWithPolicy.
private Node createImportTargetWithPolicy(@Nullable Principal principal) throws RepositoryException {
Node target = testRootNode.addNode("test", "test:sameNameSibsFalseChildNodeDefinition");
AccessControlManager acMgr = superuser.getAccessControlManager();
for (AccessControlPolicyIterator it = acMgr.getApplicablePolicies(target.getPath()); it.hasNext(); ) {
AccessControlPolicy policy = it.nextAccessControlPolicy();
if (policy instanceof AccessControlList) {
if (principal != null) {
Privilege[] privs = new Privilege[] { acMgr.privilegeFromName(Privilege.JCR_LOCK_MANAGEMENT) };
((AccessControlList) policy).addAccessControlEntry(principal, privs);
}
acMgr.setPolicy(target.getPath(), policy);
}
}
if (!isSessionImport()) {
superuser.save();
}
return target;
}
use of javax.jcr.security.AccessControlPolicyIterator in project jackrabbit-oak by apache.
the class CugAccessControlManagerTest method testGetApplicablePoliciesUnsupportedPath.
@Test
public void testGetApplicablePoliciesUnsupportedPath() throws Exception {
AccessControlPolicyIterator it = cugAccessControlManager.getApplicablePolicies(UNSUPPORTED_PATH);
assertFalse(it.hasNext());
}
Aggregations