use of org.apache.jackrabbit.oak.spi.security.authorization.cug.CugPolicy in project jackrabbit-oak by apache.
the class CugAccessControlManager method getEffectivePolicies.
@Override
public AccessControlPolicy[] getEffectivePolicies(String absPath) throws RepositoryException {
String oakPath = getOakPath(absPath);
getTree(oakPath, Permissions.READ_ACCESS_CONTROL, true);
boolean enabled = config.getConfigValue(CugConstants.PARAM_CUG_ENABLED, false);
if (enabled) {
Root r = getRoot().getContentSession().getLatestRoot();
List<AccessControlPolicy> effective = new ArrayList<>();
while (oakPath != null) {
if (isSupportedPath(oakPath)) {
CugPolicy cug = getCugPolicy(oakPath, r.getTree(oakPath));
if (cug != null) {
effective.add(cug);
}
}
oakPath = (PathUtils.denotesRoot(oakPath)) ? null : PathUtils.getAncestorPath(oakPath, 1);
}
return effective.toArray(new AccessControlPolicy[effective.size()]);
} else {
return new AccessControlPolicy[0];
}
}
use of org.apache.jackrabbit.oak.spi.security.authorization.cug.CugPolicy in project jackrabbit-oak by apache.
the class CugPolicyImplTest method testAddNullPrincipalName.
@Test(expected = AccessControlException.class)
public void testAddNullPrincipalName() throws Exception {
CugPolicy cug = new CugPolicyImpl(path, NamePathMapper.DEFAULT, principalManager, ImportBehavior.BESTEFFORT);
cug.addPrincipals(new Principal() {
@Override
public String getName() {
return null;
}
});
}
use of org.apache.jackrabbit.oak.spi.security.authorization.cug.CugPolicy in project jackrabbit-oak by apache.
the class CugPolicyImplTest method testRemoveNullPrincipal.
@Test
public void testRemoveNullPrincipal() throws Exception {
CugPolicy cug = new CugPolicyImpl(path, NamePathMapper.DEFAULT, principalManager, ImportBehavior.ABORT, principals);
assertTrue(cug.removePrincipals(testPrincipal, null));
assertTrue(cug.getPrincipals().isEmpty());
}
use of org.apache.jackrabbit.oak.spi.security.authorization.cug.CugPolicy in project jackrabbit-oak by apache.
the class CugPolicyImplTest method testAddNullPrincipal.
@Test
public void testAddNullPrincipal() throws Exception {
CugPolicy cug = new CugPolicyImpl(path, NamePathMapper.DEFAULT, principalManager, ImportBehavior.ABORT, principals);
assertTrue(cug.addPrincipals(EveryonePrincipal.getInstance(), null));
assertTrue(cug.getPrincipals().contains(EveryonePrincipal.getInstance()));
assertTrue(cug.getPrincipals().contains(testPrincipal));
}
use of org.apache.jackrabbit.oak.spi.security.authorization.cug.CugPolicy in project jackrabbit-oak by apache.
the class CugPolicyImplTest method testAddInvalidPrincipalsBestEffort.
@Test
public void testAddInvalidPrincipalsBestEffort() throws Exception {
CugPolicy cug = new CugPolicyImpl(path, NamePathMapper.DEFAULT, principalManager, ImportBehavior.BESTEFFORT, principals);
assertTrue(cug.addPrincipals(EveryonePrincipal.getInstance(), new PrincipalImpl("unknown")));
Set<Principal> principalSet = cug.getPrincipals();
assertEquals(3, principalSet.size());
}
Aggregations