use of javax.jcr.security.AccessControlManager in project jackrabbit-oak by apache.
the class AccessControlImporterTest method createImportTargetWithPolicy.
private Node createImportTargetWithPolicy(@Nullable Principal principal) throws RepositoryException {
Node target = testRootNode.addNode("test", "test:sameNameSibsFalseChildNodeDefinition");
AccessControlManager acMgr = superuser.getAccessControlManager();
for (AccessControlPolicyIterator it = acMgr.getApplicablePolicies(target.getPath()); it.hasNext(); ) {
AccessControlPolicy policy = it.nextAccessControlPolicy();
if (policy instanceof AccessControlList) {
if (principal != null) {
Privilege[] privs = new Privilege[] { acMgr.privilegeFromName(Privilege.JCR_LOCK_MANAGEMENT) };
((AccessControlList) policy).addAccessControlEntry(principal, privs);
}
acMgr.setPolicy(target.getPath(), policy);
}
}
if (!isSessionImport()) {
superuser.save();
}
return target;
}
use of javax.jcr.security.AccessControlManager in project jackrabbit-oak by apache.
the class AccessControlManagementTest method testAclReferingToRemovedPrincipal.
@Test
public void testAclReferingToRemovedPrincipal() throws Exception {
JackrabbitAccessControlList acl = allow(path, repWritePrivileges);
String acPath = acl.getPath();
// remove the test user
testUser.remove();
superuser.save();
testUser = null;
// try to retrieve the acl again
Session s = getHelper().getSuperuserSession();
try {
AccessControlManager acMgr = getAccessControlManager(s);
acMgr.getPolicies(acPath);
} finally {
s.logout();
}
}
use of javax.jcr.security.AccessControlManager 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.AccessControlManager in project jackrabbit-oak by apache.
the class OpvIgnoreTest method addIgnoredChild.
private void addIgnoredChild(@Nonnull Node node) throws Exception {
AccessControlManager acMgr = superuser.getAccessControlManager();
JackrabbitAccessControlList acl = AccessControlUtils.getAccessControlList(acMgr, node.getPath());
acl.addAccessControlEntry(EveryonePrincipal.getInstance(), AccessControlUtils.privilegesFromNames(acMgr, Privilege.JCR_READ));
acMgr.setPolicy(acl.getPath(), acl);
superuser.save();
Node c = node.getNode(AccessControlConstants.REP_POLICY);
assertEquals(OnParentVersionAction.IGNORE, c.getDefinition().getOnParentVersion());
}
use of javax.jcr.security.AccessControlManager 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);
}
Aggregations