use of javax.jcr.security.AccessControlPolicyIterator in project jackrabbit-oak by apache.
the class CugAccessControlManagerTest method testGetApplicablePolicies.
@Test
public void testGetApplicablePolicies() throws Exception {
AccessControlPolicyIterator it = cugAccessControlManager.getApplicablePolicies(SUPPORTED_PATH);
assertTrue(it.hasNext());
AccessControlPolicy policy = cugAccessControlManager.getApplicablePolicies(SUPPORTED_PATH).nextAccessControlPolicy();
assertTrue(policy instanceof CugPolicyImpl);
}
use of javax.jcr.security.AccessControlPolicyIterator in project jackrabbit-oak by apache.
the class AdminPrincipalsBaseTest method before.
@Override
public void before() throws Exception {
super.before();
NodeUtil rootNode = new NodeUtil(root.getTree("/"), NamePathMapper.DEFAULT);
rootNode.addChild("testNode", JcrConstants.NT_UNSTRUCTURED);
administrativePrincipal = getUserManager(root).createGroup(new PrincipalImpl(ADMINISTRATORS_PRINCIPAL_NAME)).getPrincipal();
root.commit();
AccessControlManager acMgr = getAccessControlManager(root);
AccessControlPolicyIterator itr = acMgr.getApplicablePolicies("/testNode");
while (itr.hasNext() && acl == null) {
AccessControlPolicy policy = itr.nextAccessControlPolicy();
if (policy instanceof AccessControlList) {
acl = (AccessControlList) policy;
}
}
if (acl == null) {
throw new RepositoryException("No applicable policy found.");
}
}
use of javax.jcr.security.AccessControlPolicyIterator in project jackrabbit-oak by apache.
the class CompositeAccessControlManagerTest method testRemovePolicy.
@Test
public void testRemovePolicy() throws Exception {
AccessControlPolicyIterator it = acMgr.getApplicablePolicies(TEST_PATH);
while (it.hasNext()) {
AccessControlPolicy plc = it.nextAccessControlPolicy();
acMgr.setPolicy(TEST_PATH, plc);
}
root.commit();
acMgr.removePolicy(TEST_PATH, TestPolicy.INSTANCE);
root.commit();
assertEquals(1, acMgr.getPolicies(TEST_PATH).length);
acMgr.removePolicy(TEST_PATH, acMgr.getPolicies(TEST_PATH)[0]);
root.commit();
assertEquals(0, acMgr.getPolicies(TEST_PATH).length);
}
use of javax.jcr.security.AccessControlPolicyIterator in project jackrabbit-oak by apache.
the class CompositeAccessControlManagerTest method testGetEffectivePolicies.
@Test
public void testGetEffectivePolicies() throws Exception {
AccessControlPolicy[] effective = acMgr.getEffectivePolicies(TEST_PATH);
assertEquals(0, effective.length);
AccessControlPolicyIterator it = acMgr.getApplicablePolicies(TEST_PATH);
while (it.hasNext()) {
AccessControlPolicy plc = it.nextAccessControlPolicy();
acMgr.setPolicy(TEST_PATH, plc);
}
root.commit();
assertEquals(2, acMgr.getEffectivePolicies(TEST_PATH).length);
Tree child = root.getTree(TEST_PATH).addChild("child");
child.setProperty(JcrConstants.JCR_PRIMARYTYPE, NodeTypeConstants.NT_OAK_UNSTRUCTURED);
assertEquals(1, acMgr.getEffectivePolicies(child.getPath()).length);
}
use of javax.jcr.security.AccessControlPolicyIterator in project jackrabbit-oak by apache.
the class CompositeAccessControlManagerTest method testSetPolicyAtTestPath.
@Test
public void testSetPolicyAtTestPath() throws Exception {
AccessControlPolicyIterator it = acMgr.getApplicablePolicies(TEST_PATH);
int cnt = 0;
while (it.hasNext()) {
AccessControlPolicy plc = it.nextAccessControlPolicy();
acMgr.setPolicy(TEST_PATH, plc);
cnt++;
}
assertEquals(2, cnt);
}
Aggregations