use of org.apache.jackrabbit.api.security.JackrabbitAccessControlList in project jackrabbit-oak by apache.
the class L3_AccessControlListTest method testRemoveEntry.
public void testRemoveEntry() throws RepositoryException {
assertTrue(AccessControlUtils.addAccessControlEntry(superuser, testRoot, testPrincipal, new String[] { Privilege.JCR_READ }, true));
assertTrue(AccessControlUtils.addAccessControlEntry(superuser, testRoot, EveryonePrincipal.getInstance(), new String[] { Privilege.JCR_READ }, false));
// EXERCISE remove the Everyone-ACE from the list and verify that the list still contains the entry for testPrincipal.
JackrabbitAccessControlList acl = AccessControlUtils.getAccessControlList(superuser, testRoot);
assertNotNull(acl);
assertEquals(1, acl.size());
}
use of org.apache.jackrabbit.api.security.JackrabbitAccessControlList in project jackrabbit-oak by apache.
the class L2_AccessControlManagerTest method testRetrievePoliciesAtTestRoot.
public void testRetrievePoliciesAtTestRoot() throws RepositoryException {
AccessControlPolicy[] policies = acMgr.getPolicies(testRoot);
// EXERCISE
int expectedLength = -1;
assertEquals(expectedLength, policies.length);
AccessControlPolicyIterator policyIterator = acMgr.getApplicablePolicies(testRoot);
// EXERCISE
int expectedSize = -1;
assertEquals(expectedSize, policyIterator.getSize());
// EXERCISE: look at the utility methods and explain the expected return value
JackrabbitAccessControlList acl = AccessControlUtils.getAccessControlList(acMgr, testRoot);
JackrabbitAccessControlList acl2 = AccessControlUtils.getAccessControlList(superuser, testRoot);
// EXERCISE: is this correct?
assertEquals(acl, acl2);
}
use of org.apache.jackrabbit.api.security.JackrabbitAccessControlList in project jackrabbit-oak by apache.
the class L2_AccessControlManagerTest method testSetPolicy.
public void testSetPolicy() throws RepositoryException {
JackrabbitAccessControlList acl = AccessControlUtils.getAccessControlList(acMgr, testRoot);
assertTrue(acl.addEntry(testPrincipal, AccessControlUtils.privilegesFromNames(acMgr, Privilege.JCR_READ), false));
// EXERCISE: fix the test.
assertFalse(acMgr.getApplicablePolicies(testRoot).hasNext());
AccessControlPolicy[] policies = acMgr.getPolicies(testRoot);
assertEquals(1, policies.length);
assertTrue(policies[0] instanceof JackrabbitAccessControlList);
JackrabbitAccessControlList acl2 = (JackrabbitAccessControlList) policies[0];
assertFalse(acl2.isEmpty());
assertEquals(1, acl2.size());
AccessControlEntry ace = acl2.getAccessControlEntries()[0];
assertTrue(ace instanceof JackrabbitAccessControlEntry);
assertEquals(testPrincipal, ace.getPrincipal());
assertFalse(((JackrabbitAccessControlEntry) ace).isAllow());
}
use of org.apache.jackrabbit.api.security.JackrabbitAccessControlList in project jackrabbit-oak by apache.
the class L2_AccessControlManagerTest method testRemovePolicy.
public void testRemovePolicy() throws RepositoryException {
JackrabbitAccessControlList acl = AccessControlUtils.getAccessControlList(acMgr, testRoot);
// EXERCISE: explain why
try {
acMgr.removePolicy(testRoot, acl);
fail("EXERCISE");
} catch (AccessControlException e) {
// success
}
AccessControlUtils.addAccessControlEntry(superuser, testRoot, testPrincipal, new String[] { Privilege.JCR_READ }, false);
acl = AccessControlUtils.getAccessControlList(acMgr, testRoot);
acMgr.removePolicy(testRoot, acl);
}
use of org.apache.jackrabbit.api.security.JackrabbitAccessControlList in project jackrabbit-oak by apache.
the class L2_AccessControlManagerTest method testModifyPolicy.
public void testModifyPolicy() throws RepositoryException {
JackrabbitAccessControlList acl = AccessControlUtils.getAccessControlList(acMgr, testRoot);
assertNotNull(acl);
assertEquals(0, acl.getAccessControlEntries().length);
acl.addAccessControlEntry(EveryonePrincipal.getInstance(), new Privilege[] { acMgr.privilegeFromName(Privilege.JCR_READ) });
// EXERCISE
int expectedLength = -1;
assertEquals(expectedLength, acl.getAccessControlEntries().length);
// EXERCISE
int expectedSize = -1;
assertEquals(expectedSize, acMgr.getApplicablePolicies(testRoot).getSize());
// EXERCISE
expectedLength = -1;
assertEquals(expectedLength, acMgr.getPolicies(testRoot).length);
}
Aggregations