use of org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider in project jackrabbit-oak by apache.
the class AccessControlManagerImplTest method createPolicy.
private ACL createPolicy(@Nullable String path) {
final PrincipalManager pm = getPrincipalManager(root);
final PrivilegeManager pvMgr = getPrivilegeManager(root);
final RestrictionProvider rp = getRestrictionProvider();
return new ACL(path, null, getNamePathMapper()) {
@Override
ACE createACE(Principal principal, PrivilegeBits privilegeBits, boolean isAllow, Set<Restriction> restrictions) {
throw new UnsupportedOperationException();
}
@Override
boolean checkValidPrincipal(Principal principal) throws AccessControlException {
Util.checkValidPrincipal(principal, pm);
return true;
}
@Override
PrivilegeManager getPrivilegeManager() {
return pvMgr;
}
@Override
PrivilegeBits getPrivilegeBits(Privilege[] privileges) {
return getBitsProvider().getBits(privileges, getNamePathMapper());
}
@Nonnull
@Override
public RestrictionProvider getRestrictionProvider() {
return rp;
}
};
}
use of org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider in project jackrabbit-oak by apache.
the class CompositeAuthorizationConfigurationTest method testSingleRestrictionProvider.
@Test
public void testSingleRestrictionProvider() {
CompositeAuthorizationConfiguration cc = getCompositeConfiguration(new AuthorizationConfigurationImpl(getSecurityProvider()));
RestrictionProvider rp = cc.getRestrictionProvider();
assertFalse(rp instanceof CompositeRestrictionProvider);
}
use of org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider in project jackrabbit-oak by apache.
the class ImmutableACLTest method testEquals.
@Test
public void testEquals() throws Exception {
RestrictionProvider rp = getRestrictionProvider();
ACE ace1 = createEntry(testPrincipal, PrivilegeBits.BUILT_IN.get(PrivilegeConstants.JCR_VERSION_MANAGEMENT), false);
ACE ace2 = createEntry(true, PrivilegeConstants.JCR_READ, PrivilegeConstants.JCR_ADD_CHILD_NODES);
ACE ace2b = createEntry(true, PrivilegeConstants.REP_READ_NODES, PrivilegeConstants.REP_READ_PROPERTIES, PrivilegeConstants.JCR_ADD_CHILD_NODES);
JackrabbitAccessControlList acl = createACL(ace1, ace2);
assertTrue(acl instanceof ImmutableACL);
assertEquals(acl, acl);
JackrabbitAccessControlList repoAcl = createACL((String) null, ace1, ace2);
assertTrue(repoAcl instanceof ImmutableACL);
assertEquals(repoAcl, repoAcl);
assertEquals(acl, createACL(ace1, ace2));
assertEquals(acl, createACL(ace1, ace2b));
assertEquals(repoAcl, createACL((String) null, ace1, ace2b));
assertFalse(acl.equals(createACL(ace2, ace1)));
assertFalse(acl.equals(repoAcl));
assertFalse(acl.equals(createEmptyACL()));
assertFalse(acl.equals(createACL("/anotherPath", ace1, ace2)));
assertFalse(acl.equals(new TestACL("/anotherPath", rp, getNamePathMapper(), ace1, ace2)));
assertFalse(acl.equals(new TestACL("/anotherPath", rp, getNamePathMapper(), ace1, ace2)));
assertFalse(acl.equals(new TestACL("/anotherPath", rp, getNamePathMapper())));
assertFalse(acl.equals(new TestACL(getTestPath(), rp, getNamePathMapper(), ace1, ace2)));
}
use of org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider in project jackrabbit-oak by apache.
the class AccessControlValidatorProvider method getRootValidator.
//--------------------------------------------------< ValidatorProvider >---
@Nonnull
@Override
public Validator getRootValidator(NodeState before, NodeState after, CommitInfo info) {
RestrictionProvider restrictionProvider = getConfig(AuthorizationConfiguration.class).getRestrictionProvider();
Root root = RootFactory.createReadOnlyRoot(before);
PrivilegeManager privilegeManager = getConfig(PrivilegeConfiguration.class).getPrivilegeManager(root, NamePathMapper.DEFAULT);
PrivilegeBitsProvider privilegeBitsProvider = new PrivilegeBitsProvider(root);
return new AccessControlValidator(after, privilegeManager, privilegeBitsProvider, restrictionProvider);
}
use of org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider in project jackrabbit-oak by apache.
the class CompositeAuthorizationConfigurationTest method testOnlyEmptyRestrictionProvider.
@Test
public void testOnlyEmptyRestrictionProvider() {
AuthorizationConfiguration ac = new OpenAuthorizationConfiguration() {
@Nonnull
@Override
public RestrictionProvider getRestrictionProvider() {
return RestrictionProvider.EMPTY;
}
};
CompositeAuthorizationConfiguration cc = getCompositeConfiguration(ac, ac);
RestrictionProvider rp = cc.getRestrictionProvider();
assertFalse(rp instanceof CompositeRestrictionProvider);
assertSame(RestrictionProvider.EMPTY, rp);
}
Aggregations