use of org.apache.jackrabbit.api.security.JackrabbitAccessControlList in project jackrabbit-oak by apache.
the class L3_PrecedenceRulesTest method testAceOrder.
public void testAceOrder() throws RepositoryException {
assertFalse(testSession.nodeExists(testRoot));
Privilege[] readPrivs = AccessControlUtils.privilegesFromNames(superuser, Privilege.JCR_READ);
// EXERCISE: fix the permission setup such that the test success without dropping either ACE
JackrabbitAccessControlList acl = AccessControlUtils.getAccessControlList(superuser, testRoot);
acl.addEntry(testGroupPrincipal, readPrivs, true);
acl.addEntry(EveryonePrincipal.getInstance(), readPrivs, false);
superuser.getAccessControlManager().setPolicy(acl.getPath(), acl);
superuser.save();
testSession.refresh(false);
assertTrue(testSession.nodeExists(testRoot));
assertTrue(testSession.propertyExists(propertyPath));
}
use of org.apache.jackrabbit.api.security.JackrabbitAccessControlList in project jackrabbit-oak by apache.
the class ObservationQueueTest method prepareTestData.
@Override
protected void prepareTestData(Session s) throws RepositoryException {
UserManager uMgr = ((JackrabbitSession) s).getUserManager();
User user = uMgr.createUser(USER, PASSWORD);
s.save();
AccessControlManager acMgr = s.getAccessControlManager();
JackrabbitAccessControlList tmpl = AccessControlUtils.getAccessControlList(acMgr, "/");
tmpl.addEntry(user.getPrincipal(), new Privilege[] { acMgr.privilegeFromName(Privilege.JCR_ALL) }, true, Collections.<String, Value>emptyMap());
acMgr.setPolicy(tmpl.getPath(), tmpl);
s.save();
}
use of org.apache.jackrabbit.api.security.JackrabbitAccessControlList in project jackrabbit-oak by apache.
the class ImportBesteffortTest method testImportUnknownPrincipal.
@Test
public void testImportUnknownPrincipal() throws Exception {
runImport();
AccessControlManager acMgr = adminSession.getAccessControlManager();
AccessControlPolicy[] policies = acMgr.getPolicies(target.getPath());
assertEquals(1, policies.length);
assertTrue(policies[0] instanceof JackrabbitAccessControlList);
AccessControlEntry[] entries = ((JackrabbitAccessControlList) policies[0]).getAccessControlEntries();
assertEquals(1, entries.length);
AccessControlEntry entry = entries[0];
assertEquals("unknownprincipal", entry.getPrincipal().getName());
assertEquals(1, entry.getPrivileges().length);
assertEquals(acMgr.privilegeFromName(Privilege.JCR_WRITE), entry.getPrivileges()[0]);
if (entry instanceof JackrabbitAccessControlEntry) {
assertTrue(((JackrabbitAccessControlEntry) entry).isAllow());
}
}
use of org.apache.jackrabbit.api.security.JackrabbitAccessControlList in project jackrabbit-oak by apache.
the class RandomizedReadTest method setupContent.
@Override
protected void setupContent() throws Exception {
for (JackrabbitSession session : writeSessions) {
Node root = session.getRootNode();
Node n1 = root.addNode("n1");
Node n3 = n1.addNode("n3");
n1.addNode("n4");
n1.addNode("n5");
n3.addNode("n6");
n3.addNode("n7");
n3.addNode("n8");
n3.addNode("n9");
root.addNode("n2");
Principal principal = getTestPrincipal(session);
AccessControlManager acm = session.getAccessControlManager();
JackrabbitAccessControlList acl = AccessControlUtils.getAccessControlList(acm, "/");
acl.addEntry(principal, AccessControlUtils.privilegesFromNames(acm, PrivilegeConstants.JCR_READ), true);
acm.setPolicy("/", acl);
session.save();
}
}
use of org.apache.jackrabbit.api.security.JackrabbitAccessControlList in project jackrabbit-oak by apache.
the class AbstractEvaluationTest method modify.
protected JackrabbitAccessControlList modify(String path, Principal principal, Privilege[] privileges, boolean isAllow, Map<String, Value> restrictions, Map<String, Value[]> mvRestrictions) throws Exception {
// remember for restore during tearDown
rememberForRestore(path);
JackrabbitAccessControlList tmpl = AccessControlUtils.getAccessControlList(acMgr, path);
tmpl.addEntry(principal, privileges, isAllow, restrictions, mvRestrictions);
acMgr.setPolicy(tmpl.getPath(), tmpl);
superuser.save();
testSession.refresh(false);
return tmpl;
}
Aggregations