use of org.apache.jackrabbit.api.security.JackrabbitAccessControlList in project jackrabbit-oak by apache.
the class Jr2CompatibilityTest method after.
@Override
@After
public void after() throws Exception {
try {
AccessControlManager acMgr = getAccessControlManager(root);
JackrabbitAccessControlList acl = AccessControlUtils.getAccessControlList(acMgr, "/");
if (acl != null) {
boolean modified = false;
for (AccessControlEntry entry : acl.getAccessControlEntries()) {
if (entry.getPrincipal().equals(getTestUser().getPrincipal())) {
acl.removeAccessControlEntry(entry);
modified = true;
}
}
if (modified) {
acMgr.setPolicy("/", acl);
root.commit();
}
}
} finally {
super.after();
}
}
use of org.apache.jackrabbit.api.security.JackrabbitAccessControlList in project jackrabbit-oak by apache.
the class ImmutableACLTest method testEquals.
@Test
public void testEquals() throws Exception {
RestrictionProvider rp = getRestrictionProvider();
ACE ace1 = createEntry(testPrincipal, PrivilegeBits.BUILT_IN.get(PrivilegeConstants.JCR_VERSION_MANAGEMENT), false);
ACE ace2 = createEntry(true, PrivilegeConstants.JCR_READ, PrivilegeConstants.JCR_ADD_CHILD_NODES);
ACE ace2b = createEntry(true, PrivilegeConstants.REP_READ_NODES, PrivilegeConstants.REP_READ_PROPERTIES, PrivilegeConstants.JCR_ADD_CHILD_NODES);
JackrabbitAccessControlList acl = createACL(ace1, ace2);
assertTrue(acl instanceof ImmutableACL);
assertEquals(acl, acl);
JackrabbitAccessControlList repoAcl = createACL((String) null, ace1, ace2);
assertTrue(repoAcl instanceof ImmutableACL);
assertEquals(repoAcl, repoAcl);
assertEquals(acl, createACL(ace1, ace2));
assertEquals(acl, createACL(ace1, ace2b));
assertEquals(repoAcl, createACL((String) null, ace1, ace2b));
assertFalse(acl.equals(createACL(ace2, ace1)));
assertFalse(acl.equals(repoAcl));
assertFalse(acl.equals(createEmptyACL()));
assertFalse(acl.equals(createACL("/anotherPath", ace1, ace2)));
assertFalse(acl.equals(new TestACL("/anotherPath", rp, getNamePathMapper(), ace1, ace2)));
assertFalse(acl.equals(new TestACL("/anotherPath", rp, getNamePathMapper(), ace1, ace2)));
assertFalse(acl.equals(new TestACL("/anotherPath", rp, getNamePathMapper())));
assertFalse(acl.equals(new TestACL(getTestPath(), rp, getNamePathMapper(), ace1, ace2)));
}
use of org.apache.jackrabbit.api.security.JackrabbitAccessControlList in project jackrabbit-oak by apache.
the class ImmutableACLTest method testImmutable.
@Test
public void testImmutable() throws Exception {
List<JackrabbitAccessControlEntry> entries = new ArrayList();
entries.add(createEntry(true, PrivilegeConstants.JCR_READ, PrivilegeConstants.JCR_ADD_CHILD_NODES));
entries.add(createEntry(false, PrivilegeConstants.JCR_LIFECYCLE_MANAGEMENT));
JackrabbitAccessControlList acl = createACL(entries);
assertFalse(acl.isEmpty());
assertEquals(2, acl.size());
assertEquals(getTestPath(), acl.getPath());
assertImmutable(acl);
}
use of org.apache.jackrabbit.api.security.JackrabbitAccessControlList in project jackrabbit-oak by apache.
the class ImmutableACLTest method testEmptyIsImmutable.
@Test
public void testEmptyIsImmutable() throws Exception {
JackrabbitAccessControlList acl = createEmptyACL();
assertTrue(acl.isEmpty());
assertEquals(0, acl.size());
assertEquals(getTestPath(), acl.getPath());
assertImmutable(acl);
}
use of org.apache.jackrabbit.api.security.JackrabbitAccessControlList in project jackrabbit-oak by apache.
the class L3_PrecedenceRulesTest method testPrecedenceOfUserPrincipals.
public void testPrecedenceOfUserPrincipals() throws RepositoryException {
Privilege[] readPrivs = AccessControlUtils.privilegesFromNames(superuser, Privilege.JCR_READ);
JackrabbitAccessControlList acl = AccessControlUtils.getAccessControlList(superuser, testRoot);
acl.addEntry(testPrincipal, readPrivs, false);
acl.addEntry(testGroupPrincipal, readPrivs, true);
superuser.getAccessControlManager().setPolicy(acl.getPath(), acl);
superuser.save();
// EXERCISE what is the expected result?
testSession.refresh(false);
// EXERCISE
Boolean canRead = null;
assertEquals(canRead.booleanValue(), testSession.nodeExists(testRoot));
assertEquals(canRead.booleanValue(), testSession.nodeExists(childPath));
// EXERCISE: now change the permission setup such that the testSession has read access
// EXERCISE: how many ways to you find to achieve this?
}
Aggregations