use of javax.jcr.security.AccessControlManager in project jackrabbit-oak by apache.
the class CompositeAccessControlManager method getSupportedPrivileges.
//-----------------------------------------------< AccessControlManager >---
@Nonnull
@Override
public Privilege[] getSupportedPrivileges(String absPath) throws RepositoryException {
ImmutableSet.Builder<Privilege> privs = ImmutableSet.builder();
for (AccessControlManager acMgr : acMgrs) {
privs.add(acMgr.getSupportedPrivileges(absPath));
}
Set<Privilege> s = privs.build();
return s.toArray(new Privilege[s.size()]);
}
use of javax.jcr.security.AccessControlManager in project jackrabbit-oak by apache.
the class CompositeAccessControlManager method getApplicablePolicies.
//-------------------------------------< JackrabbitAccessControlManager >---
@Override
public JackrabbitAccessControlPolicy[] getApplicablePolicies(Principal principal) throws RepositoryException {
ImmutableList.Builder<JackrabbitAccessControlPolicy> policies = ImmutableList.builder();
for (AccessControlManager acMgr : acMgrs) {
if (acMgr instanceof JackrabbitAccessControlManager && acMgr instanceof PolicyOwner) {
policies.add(((JackrabbitAccessControlManager) acMgr).getApplicablePolicies(principal));
}
}
List<JackrabbitAccessControlPolicy> l = policies.build();
return l.toArray(new JackrabbitAccessControlPolicy[l.size()]);
}
use of javax.jcr.security.AccessControlManager 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 javax.jcr.security.AccessControlManager 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());
}
use of javax.jcr.security.AccessControlManager in project jackrabbit-oak by apache.
the class L4_EffectivePoliciesTest method testSessionGetEffectivePolicies.
public void testSessionGetEffectivePolicies() throws Exception {
// grant 'testUser' READ + WRITE privileges at the test root
setupPolicy(testRoot, testPrivileges, testPrincipal);
// grant 'testUser' READ + READ_AC privileges at child path
Privilege[] privileges = AccessControlUtils.privilegesFromNames(acMgr, Privilege.JCR_READ, Privilege.JCR_READ_ACCESS_CONTROL);
setupPolicy(childPath, privileges, testPrincipal);
superuser.save();
testSession = getTestSession();
AccessControlManager testAcMgr = testSession.getAccessControlManager();
AccessControlPolicy[] effective = testAcMgr.getEffectivePolicies(childPath);
// EXERCISE
int expectedLength = -1;
assertEquals(expectedLength, effective.length);
}
Aggregations