Search in sources :

Example 81 with PermissionProvider

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

the class AbstractCompositeProviderTest method testTreePermissionIsNotGrantedOR.

@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));
        assertFalse(tp.isGranted(Permissions.MODIFY_ACCESS_CONTROL));
        assertFalse(tp.isGranted(Permissions.NO_PERMISSION, ps));
        assertFalse(tp.isGranted(Permissions.MODIFY_ACCESS_CONTROL, ps));
        parentPermission = tp;
    }
}
Also used : 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) ImmutableTree(org.apache.jackrabbit.oak.plugins.tree.impl.ImmutableTree) TreePermission(org.apache.jackrabbit.oak.spi.security.authorization.permission.TreePermission) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 82 with PermissionProvider

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

the class AbstractCompositeProviderTest method testIsGrantedAll.

@Test
public void testIsGrantedAll() throws Exception {
    PermissionProvider pp = createPermissionProvider();
    PermissionProvider ppo = createPermissionProviderOR();
    for (String p : NODE_PATHS) {
        Tree tree = readOnlyRoot.getTree(p);
        PropertyState ps = tree.getProperty(JcrConstants.JCR_PRIMARYTYPE);
        assertFalse(p, pp.isGranted(tree, null, Permissions.ALL));
        assertFalse(PathUtils.concat(p, JcrConstants.JCR_PRIMARYTYPE), pp.isGranted(tree, ps, Permissions.ALL));
        assertFalse(p, ppo.isGranted(tree, null, Permissions.ALL));
        assertFalse(PathUtils.concat(p, JcrConstants.JCR_PRIMARYTYPE), ppo.isGranted(tree, ps, Permissions.ALL));
    }
}
Also used : 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) ImmutableTree(org.apache.jackrabbit.oak.plugins.tree.impl.ImmutableTree) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 83 with PermissionProvider

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

the class AbstractCompositeProviderTest method testHasPrivilegesNone.

@Test
public void testHasPrivilegesNone() throws Exception {
    PermissionProvider pp = createPermissionProvider();
    PermissionProvider ppo = createPermissionProviderOR();
    for (String p : NODE_PATHS) {
        Tree tree = readOnlyRoot.getTree(p);
        assertTrue(p, pp.hasPrivileges(tree));
        assertTrue(p, ppo.hasPrivileges(tree));
    }
}
Also used : 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) ImmutableTree(org.apache.jackrabbit.oak.plugins.tree.impl.ImmutableTree) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 84 with PermissionProvider

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

the class AbstractCompositeProviderTest method testGetTreePermissionInstanceOR.

@Test
public void testGetTreePermissionInstanceOR() throws Exception {
    PermissionProvider pp = createPermissionProviderOR();
    TreePermission parentPermission = TreePermission.EMPTY;
    for (String path : TP_PATHS) {
        TreePermission tp = pp.getTreePermission(readOnlyRoot.getTree(path), parentPermission);
        assertCompositeTreePermission(tp);
        parentPermission = tp;
    }
}
Also used : PermissionProvider(org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider) AggregatedPermissionProvider(org.apache.jackrabbit.oak.spi.security.authorization.permission.AggregatedPermissionProvider) TreePermission(org.apache.jackrabbit.oak.spi.security.authorization.permission.TreePermission) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 85 with PermissionProvider

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

the class AbstractCompositeProviderTest method testHasPrivilegesOnRepoJcrAll.

@Test
public void testHasPrivilegesOnRepoJcrAll() throws Exception {
    PermissionProvider pp = createPermissionProvider();
    assertFalse(pp.hasPrivileges(null, JCR_ALL));
    PermissionProvider ppo = createPermissionProviderOR();
    assertFalse(ppo.hasPrivileges(null, JCR_ALL));
}
Also used : PermissionProvider(org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider) AggregatedPermissionProvider(org.apache.jackrabbit.oak.spi.security.authorization.permission.AggregatedPermissionProvider) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) 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