use of org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider in project jackrabbit-oak by apache.
the class CompositeAuthorizationConfigurationTest method testMultipleRestrictionProvider.
@Test
public void testMultipleRestrictionProvider() {
CompositeAuthorizationConfiguration cc = getCompositeConfiguration(new AuthorizationConfigurationImpl(getSecurityProvider()), new AuthorizationConfigurationImpl(getSecurityProvider()));
RestrictionProvider rp = cc.getRestrictionProvider();
assertTrue(rp instanceof CompositeRestrictionProvider);
}
use of org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider in project jackrabbit-oak by apache.
the class CompositeAuthorizationConfigurationTest method testMultipleWithEmptyRestrictionProvider.
@Test
public void testMultipleWithEmptyRestrictionProvider() {
CompositeAuthorizationConfiguration cc = getCompositeConfiguration(new AuthorizationConfigurationImpl(getSecurityProvider()), new OpenAuthorizationConfiguration() {
@Nonnull
@Override
public RestrictionProvider getRestrictionProvider() {
return RestrictionProvider.EMPTY;
}
});
RestrictionProvider rp = cc.getRestrictionProvider();
assertFalse(rp instanceof CompositeRestrictionProvider);
assertNotSame(RestrictionProvider.EMPTY, rp);
}
use of org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider in project jackrabbit-oak by apache.
the class ACLTest method testMandatoryRestrictions.
@Test
public void testMandatoryRestrictions() throws Exception {
RestrictionProvider rp = new TestRestrictionProvider("mandatory", Type.NAME, true);
JackrabbitAccessControlList acl = createACL(TEST_PATH, new ArrayList(), namePathMapper, rp);
try {
acl.addEntry(testPrincipal, testPrivileges, false, Collections.<String, Value>emptyMap());
fail("Mandatory restriction must be enforced.");
} catch (AccessControlException e) {
// mandatory restriction missing -> success
}
}
use of org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider in project jackrabbit-oak by apache.
the class ACLTest method testUnsupportedRestrictions2.
@Test
public void testUnsupportedRestrictions2() throws Exception {
RestrictionProvider rp = new TestRestrictionProvider("restr", Type.NAME, false);
JackrabbitAccessControlList acl = createACL(TEST_PATH, new ArrayList(), namePathMapper, rp);
try {
acl.addEntry(testPrincipal, testPrivileges, false, Collections.<String, Value>singletonMap("unsupported", getValueFactory().createValue("value")));
fail("Unsupported restriction must be detected.");
} catch (AccessControlException e) {
// mandatory restriction missing -> success
}
}
use of org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider in project jackrabbit-oak by apache.
the class CompositeRestrictionProviderTest method testValidateInvalidRestrictionDef.
@Test
public void testValidateInvalidRestrictionDef() throws Exception {
RestrictionProvider rp = CompositeRestrictionProvider.newInstance(rp1, rp3);
NodeUtil aceNode = new NodeUtil(root.getTree("/")).addChild("test", NT_REP_GRANT_ACE);
NodeUtil rNode = aceNode.addChild(REP_RESTRICTIONS, NT_REP_RESTRICTIONS);
rNode.setValues(REP_GLOB, new Value[] { vf.createValue(10), vf.createValue(290) });
try {
rp.validateRestrictions("/test", aceNode.getTree());
fail("Validation must detect invalid restriction definition");
} catch (AccessControlException e) {
// success
}
}
Aggregations