Search in sources :

Example 1 with TreePermission

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

the class CompositeProviderCoverageTest method testTreePermissionCanReadProperty.

@Test
public void testTreePermissionCanReadProperty() throws Exception {
    TreePermission parentPermission = TreePermission.EMPTY;
    for (String path : TP_PATHS) {
        Tree t = readOnlyRoot.getTree(path);
        TreePermission tp = cpp.getTreePermission(t, parentPermission);
        assertFalse(tp.canRead(PROPERTY_STATE));
        parentPermission = tp;
    }
}
Also used : 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) Test(org.junit.Test)

Example 2 with TreePermission

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

the class CompositeProviderAllTest method testTreePermissionIsGrantedProperty.

@Test
public void testTreePermissionIsGrantedProperty() throws Exception {
    TreePermission parentPermission = TreePermission.EMPTY;
    for (String path : TP_PATHS) {
        TreePermission tp = cpp.getTreePermission(readOnlyRoot.getTree(path), parentPermission);
        Long toTest = (defPermissions.containsKey(path)) ? defPermissions.get(path) : defPermissions.get(PathUtils.getAncestorPath(path, 1));
        if (toTest != null) {
            assertTrue(tp.isGranted(toTest, PROPERTY_STATE));
        }
        parentPermission = tp;
    }
}
Also used : TreePermission(org.apache.jackrabbit.oak.spi.security.authorization.permission.TreePermission) Test(org.junit.Test)

Example 3 with TreePermission

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

the class CompositeProviderAllTest method testTreePermissionIsGranted.

@Test
public void testTreePermissionIsGranted() throws Exception {
    TreePermission parentPermission = TreePermission.EMPTY;
    for (String path : TP_PATHS) {
        TreePermission tp = cpp.getTreePermission(root.getTree(path), parentPermission);
        Long toTest = (defPermissions.containsKey(path)) ? defPermissions.get(path) : defPermissions.get(PathUtils.getAncestorPath(path, 1));
        if (toTest != null) {
            assertTrue(tp.isGranted(toTest));
        }
        parentPermission = tp;
    }
}
Also used : TreePermission(org.apache.jackrabbit.oak.spi.security.authorization.permission.TreePermission) Test(org.junit.Test)

Example 4 with TreePermission

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

the class CompositeProviderEmptyTest method testTreePermissionIsGranted.

@Test
public void testTreePermissionIsGranted() throws Exception {
    TreePermission parentPermission = TreePermission.EMPTY;
    for (String path : TP_PATHS) {
        TreePermission tp = cpp.getTreePermission(readOnlyRoot.getTree(path), parentPermission);
        assertFalse(tp.isGranted(Permissions.READ_NODE));
        assertFalse(tp.isGranted(Permissions.REMOVE_NODE));
        assertFalse(tp.isGranted(Permissions.ALL));
        parentPermission = tp;
    }
}
Also used : TreePermission(org.apache.jackrabbit.oak.spi.security.authorization.permission.TreePermission) Test(org.junit.Test)

Example 5 with TreePermission

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

the class CompositeProviderEmptyTest method testTreePermissionIsGrantedProperty.

@Test
public void testTreePermissionIsGrantedProperty() throws Exception {
    TreePermission parentPermission = TreePermission.EMPTY;
    for (String path : TP_PATHS) {
        TreePermission tp = cpp.getTreePermission(readOnlyRoot.getTree(path), parentPermission);
        assertFalse(tp.isGranted(Permissions.READ_PROPERTY, PROPERTY_STATE));
        assertFalse(tp.isGranted(Permissions.REMOVE_PROPERTY, PROPERTY_STATE));
        parentPermission = tp;
    }
}
Also used : TreePermission(org.apache.jackrabbit.oak.spi.security.authorization.permission.TreePermission) Test(org.junit.Test)

Aggregations

TreePermission (org.apache.jackrabbit.oak.spi.security.authorization.permission.TreePermission)135 Test (org.junit.Test)118 Tree (org.apache.jackrabbit.oak.api.Tree)67 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)46 ImmutableTree (org.apache.jackrabbit.oak.plugins.tree.impl.ImmutableTree)31 PermissionProvider (org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider)20 AggregatedPermissionProvider (org.apache.jackrabbit.oak.spi.security.authorization.permission.AggregatedPermissionProvider)18 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)13 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)10 Nonnull (javax.annotation.Nonnull)4 AccessControlManager (javax.jcr.security.AccessControlManager)4 Root (org.apache.jackrabbit.oak.api.Root)4 TreeType (org.apache.jackrabbit.oak.plugins.tree.TreeType)4 JackrabbitAccessControlList (org.apache.jackrabbit.api.security.JackrabbitAccessControlList)3 OpenPermissionProvider (org.apache.jackrabbit.oak.spi.security.authorization.permission.OpenPermissionProvider)3 Field (java.lang.reflect.Field)2 AuthorizationConfiguration (org.apache.jackrabbit.oak.spi.security.authorization.AuthorizationConfiguration)2 NodeUtil (org.apache.jackrabbit.oak.util.NodeUtil)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1