use of javax.jcr.security.AccessControlList in project jackrabbit-oak by apache.
the class ImportIgnoreTest method testImportUnknownPrincipal.
@Test
public void testImportUnknownPrincipal() throws Exception {
try {
runImport();
AccessControlManager acMgr = adminSession.getAccessControlManager();
AccessControlPolicy[] policies = acMgr.getPolicies(target.getPath());
assertEquals(1, policies.length);
assertEquals(0, ((AccessControlList) policies[0]).getAccessControlEntries().length);
} finally {
adminSession.refresh(false);
}
}
use of javax.jcr.security.AccessControlList in project jackrabbit-oak by apache.
the class AuthorizationContextTest method createAcl.
private void createAcl(@Nullable String path, String... privilegeNames) throws RepositoryException {
AccessControlManager acMgr = getAccessControlManager(root);
AccessControlList acl = AccessControlUtils.getAccessControlList(acMgr, path);
assertNotNull(acl);
acl.addAccessControlEntry(EveryonePrincipal.getInstance(), privilegesFromNames(privilegeNames));
acMgr.setPolicy(path, acl);
}
use of javax.jcr.security.AccessControlList in project jackrabbit-oak by apache.
the class CugContextTest method before.
@Before
@Override
public void before() throws Exception {
super.before();
// add more child nodes
NodeUtil n = new NodeUtil(root.getTree(SUPPORTED_PATH));
n.addChild("a", NT_OAK_UNSTRUCTURED).addChild("b", NT_OAK_UNSTRUCTURED).addChild("c", NT_OAK_UNSTRUCTURED);
n.addChild("aa", NT_OAK_UNSTRUCTURED).addChild("bb", NT_OAK_UNSTRUCTURED).addChild("cc", NT_OAK_UNSTRUCTURED);
// create cugs
createCug("/content/a", getTestUser().getPrincipal());
// setup regular acl at /content
AccessControlManager acMgr = getAccessControlManager(root);
AccessControlList acl = AccessControlUtils.getAccessControlList(acMgr, "/content");
acl.addAccessControlEntry(getTestUser().getPrincipal(), privilegesFromNames(PrivilegeConstants.JCR_READ));
acMgr.setPolicy("/content", acl);
root.commit();
}
use of javax.jcr.security.AccessControlList in project jackrabbit-oak by apache.
the class L9_RemoveAuthorizableTest method testAccessControlEntry.
public void testAccessControlEntry() throws RepositoryException, NotExecutableException {
// remove test user
removeTestUser();
boolean found = false;
AccessControlList acl = AccessControlUtils.getAccessControlList(superuser, testRoot);
if (acl != null) {
for (AccessControlEntry ace : acl.getAccessControlEntries()) {
if (testUser.getPrincipal().getName().equals(ace.getPrincipal().getName())) {
found = true;
}
}
}
// EXERCISE: do you expect the ACE for test-principal to be still present? explain why and fix the test if necessary.
assertTrue(found);
}
use of javax.jcr.security.AccessControlList in project jackrabbit-oak by apache.
the class AccessControlActionTest method assertAcAction.
private void assertAcAction(Authorizable a, String expectedPrivName) throws Exception {
AccessControlManager acMgr = getAccessControlManager(root);
AccessControlPolicy[] policies = acMgr.getPolicies(a.getPath());
assertEquals(1, policies.length);
assertTrue(policies[0] instanceof AccessControlList);
AccessControlList acl = (AccessControlList) policies[0];
assertEquals(1, acl.getAccessControlEntries().length);
assertArrayEquals(new Privilege[] { getPrivilegeManager(root).getPrivilege(expectedPrivName) }, acl.getAccessControlEntries()[0].getPrivileges());
}
Aggregations