Search in sources :

Example 86 with PermissionProvider

use of org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider in project jackrabbit-oak by apache.

the class CompositeAuthorizationConfigurationTest method testSingleGetPermissionProvider.

@Test
public void testSingleGetPermissionProvider() {
    CompositeAuthorizationConfiguration cc = getCompositeConfiguration(createAuthorizationConfigurationImpl());
    PermissionProvider pp = cc.getPermissionProvider(root, root.getContentSession().getWorkspaceName(), Collections.<Principal>emptySet());
    assertFalse(pp instanceof CompositePermissionProvider);
}
Also used : EmptyPermissionProvider(org.apache.jackrabbit.oak.spi.security.authorization.permission.EmptyPermissionProvider) PermissionProvider(org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 87 with PermissionProvider

use of org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider in project jackrabbit-oak by apache.

the class CompositeAuthorizationConfigurationTest method testMultipleGetPermissionProvider.

@Test
public void testMultipleGetPermissionProvider() {
    CompositeAuthorizationConfiguration cc = getCompositeConfiguration(new OpenAuthorizationConfiguration(), createAuthorizationConfigurationImpl());
    PermissionProvider pp = cc.getPermissionProvider(root, root.getContentSession().getWorkspaceName(), Collections.<Principal>emptySet());
    assertFalse(pp instanceof CompositePermissionProvider);
}
Also used : EmptyPermissionProvider(org.apache.jackrabbit.oak.spi.security.authorization.permission.EmptyPermissionProvider) PermissionProvider(org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider) OpenAuthorizationConfiguration(org.apache.jackrabbit.oak.spi.security.authorization.OpenAuthorizationConfiguration) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 88 with PermissionProvider

use of org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider in project jackrabbit-oak by apache.

the class CompositeProviderAllTest method testTreePermissionIsNotGrantedOR.

@Override
@Test
public void testTreePermissionIsNotGrantedOR() throws Exception {
    PermissionProvider pp = createPermissionProviderOR();
    TreePermission parentPermission = TreePermission.EMPTY;
    PropertyState ps = PropertyStates.createProperty("propName", "val");
    for (String path : TP_PATHS) {
        Tree t = readOnlyRoot.getTree(path);
        TreePermission tp = pp.getTreePermission(t, parentPermission);
        assertFalse(tp.isGranted(Permissions.NO_PERMISSION));
        assertTrue(tp.isGranted(Permissions.MODIFY_ACCESS_CONTROL));
        assertFalse(tp.isGranted(Permissions.NO_PERMISSION, ps));
        assertTrue(tp.isGranted(Permissions.MODIFY_ACCESS_CONTROL, ps));
        parentPermission = tp;
    }
}
Also used : OpenPermissionProvider(org.apache.jackrabbit.oak.spi.security.authorization.permission.OpenPermissionProvider) PermissionProvider(org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider) AggregatedPermissionProvider(org.apache.jackrabbit.oak.spi.security.authorization.permission.AggregatedPermissionProvider) Tree(org.apache.jackrabbit.oak.api.Tree) TreePermission(org.apache.jackrabbit.oak.spi.security.authorization.permission.TreePermission) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) Test(org.junit.Test)

Example 89 with PermissionProvider

use of org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider in project jackrabbit-oak by apache.

the class CompositeProviderAllTest method testHasPrivilegesJcrAllOR.

@Override
@Test
public void testHasPrivilegesJcrAllOR() throws Exception {
    PermissionProvider pp = createPermissionProviderOR();
    for (String p : NODE_PATHS) {
        Tree tree = readOnlyRoot.getTree(p);
        assertTrue(p, pp.hasPrivileges(tree, JCR_ALL));
    }
}
Also used : OpenPermissionProvider(org.apache.jackrabbit.oak.spi.security.authorization.permission.OpenPermissionProvider) PermissionProvider(org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider) AggregatedPermissionProvider(org.apache.jackrabbit.oak.spi.security.authorization.permission.AggregatedPermissionProvider) Tree(org.apache.jackrabbit.oak.api.Tree) Test(org.junit.Test)

Example 90 with PermissionProvider

use of org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider in project jackrabbit-oak by apache.

the class CompositeProviderAllTest method testHasPrivilegesOnRepoJcrAll.

@Override
@Test
public void testHasPrivilegesOnRepoJcrAll() throws Exception {
    PermissionProvider pp = createPermissionProvider();
    assertFalse(pp.hasPrivileges(null, JCR_ALL));
    PermissionProvider ppo = createPermissionProviderOR();
    assertTrue(ppo.hasPrivileges(null, JCR_ALL));
}
Also used : OpenPermissionProvider(org.apache.jackrabbit.oak.spi.security.authorization.permission.OpenPermissionProvider) PermissionProvider(org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider) AggregatedPermissionProvider(org.apache.jackrabbit.oak.spi.security.authorization.permission.AggregatedPermissionProvider) Test(org.junit.Test)

Aggregations

PermissionProvider (org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider)93 Test (org.junit.Test)86 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)49 AggregatedPermissionProvider (org.apache.jackrabbit.oak.spi.security.authorization.permission.AggregatedPermissionProvider)33 Tree (org.apache.jackrabbit.oak.api.Tree)32 TreePermission (org.apache.jackrabbit.oak.spi.security.authorization.permission.TreePermission)20 EmptyPermissionProvider (org.apache.jackrabbit.oak.spi.security.authorization.permission.EmptyPermissionProvider)16 ContentSession (org.apache.jackrabbit.oak.api.ContentSession)15 Root (org.apache.jackrabbit.oak.api.Root)13 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)12 ImmutableTree (org.apache.jackrabbit.oak.plugins.tree.impl.ImmutableTree)12 AuthorizationConfiguration (org.apache.jackrabbit.oak.spi.security.authorization.AuthorizationConfiguration)11 OpenPermissionProvider (org.apache.jackrabbit.oak.spi.security.authorization.permission.OpenPermissionProvider)8 Principal (java.security.Principal)5 AccessControlManager (javax.jcr.security.AccessControlManager)5 PrincipalImpl (org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl)5 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)4 Nonnull (javax.annotation.Nonnull)3 AccessControlList (javax.jcr.security.AccessControlList)3 ConfigurationParameters (org.apache.jackrabbit.oak.spi.security.ConfigurationParameters)3