Search in sources :

Example 11 with RestrictionProvider

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);
}
Also used : AuthorizationConfigurationImpl(org.apache.jackrabbit.oak.security.authorization.AuthorizationConfigurationImpl) RestrictionProvider(org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider) CompositeRestrictionProvider(org.apache.jackrabbit.oak.spi.security.authorization.restriction.CompositeRestrictionProvider) CompositeRestrictionProvider(org.apache.jackrabbit.oak.spi.security.authorization.restriction.CompositeRestrictionProvider) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 12 with RestrictionProvider

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);
}
Also used : Nonnull(javax.annotation.Nonnull) AuthorizationConfigurationImpl(org.apache.jackrabbit.oak.security.authorization.AuthorizationConfigurationImpl) RestrictionProvider(org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider) CompositeRestrictionProvider(org.apache.jackrabbit.oak.spi.security.authorization.restriction.CompositeRestrictionProvider) CompositeRestrictionProvider(org.apache.jackrabbit.oak.spi.security.authorization.restriction.CompositeRestrictionProvider) OpenAuthorizationConfiguration(org.apache.jackrabbit.oak.spi.security.authorization.OpenAuthorizationConfiguration) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 13 with RestrictionProvider

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
    }
}
Also used : RestrictionProvider(org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider) AbstractRestrictionProvider(org.apache.jackrabbit.oak.spi.security.authorization.restriction.AbstractRestrictionProvider) ArrayList(java.util.ArrayList) AccessControlException(javax.jcr.security.AccessControlException) JackrabbitAccessControlList(org.apache.jackrabbit.api.security.JackrabbitAccessControlList) Test(org.junit.Test)

Example 14 with RestrictionProvider

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
    }
}
Also used : RestrictionProvider(org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider) AbstractRestrictionProvider(org.apache.jackrabbit.oak.spi.security.authorization.restriction.AbstractRestrictionProvider) ArrayList(java.util.ArrayList) AccessControlException(javax.jcr.security.AccessControlException) JackrabbitAccessControlList(org.apache.jackrabbit.api.security.JackrabbitAccessControlList) Test(org.junit.Test)

Example 15 with RestrictionProvider

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
    }
}
Also used : RestrictionProvider(org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider) CompositeRestrictionProvider(org.apache.jackrabbit.oak.spi.security.authorization.restriction.CompositeRestrictionProvider) AccessControlException(javax.jcr.security.AccessControlException) NodeUtil(org.apache.jackrabbit.oak.util.NodeUtil) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Aggregations

RestrictionProvider (org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider)20 Test (org.junit.Test)16 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)11 AuthorizationConfigurationImpl (org.apache.jackrabbit.oak.security.authorization.AuthorizationConfigurationImpl)7 CompositeRestrictionProvider (org.apache.jackrabbit.oak.spi.security.authorization.restriction.CompositeRestrictionProvider)7 AccessControlException (javax.jcr.security.AccessControlException)5 JackrabbitAccessControlList (org.apache.jackrabbit.api.security.JackrabbitAccessControlList)5 WhiteboardRestrictionProvider (org.apache.jackrabbit.oak.security.authorization.restriction.WhiteboardRestrictionProvider)5 SecurityProvider (org.apache.jackrabbit.oak.spi.security.SecurityProvider)5 AuthorizationConfiguration (org.apache.jackrabbit.oak.spi.security.authorization.AuthorizationConfiguration)5 ArrayList (java.util.ArrayList)4 AbstractRestrictionProvider (org.apache.jackrabbit.oak.spi.security.authorization.restriction.AbstractRestrictionProvider)4 CompositeAuthorizationConfiguration (org.apache.jackrabbit.oak.security.authorization.composite.CompositeAuthorizationConfiguration)3 Nonnull (javax.annotation.Nonnull)2 PrivilegeManager (org.apache.jackrabbit.api.security.authorization.PrivilegeManager)2 Root (org.apache.jackrabbit.oak.api.Root)2 OpenAuthorizationConfiguration (org.apache.jackrabbit.oak.spi.security.authorization.OpenAuthorizationConfiguration)2 NodeUtil (org.apache.jackrabbit.oak.util.NodeUtil)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 Sets.newHashSet (com.google.common.collect.Sets.newHashSet)1