Search in sources :

Example 1 with RepositoryPermission

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

the class CompositeProviderEmptyTest method testRepositoryPermissionsIsGranted.

@Test
public void testRepositoryPermissionsIsGranted() throws Exception {
    RepositoryPermission rp = cpp.getRepositoryPermission();
    assertFalse(rp.isGranted(Permissions.NAMESPACE_MANAGEMENT));
    assertFalse(rp.isGranted(Permissions.NODE_TYPE_DEFINITION_MANAGEMENT));
}
Also used : RepositoryPermission(org.apache.jackrabbit.oak.spi.security.authorization.permission.RepositoryPermission) Test(org.junit.Test)

Example 2 with RepositoryPermission

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

the class CompositeProviderAllTest method testRepositoryPermissionsIsGranted.

@Test
public void testRepositoryPermissionsIsGranted() throws Exception {
    RepositoryPermission rp = cpp.getRepositoryPermission();
    assertTrue(rp.isGranted(Permissions.NAMESPACE_MANAGEMENT));
    assertTrue(rp.isGranted(Permissions.NODE_TYPE_DEFINITION_MANAGEMENT));
    assertTrue(rp.isGranted(Permissions.NAMESPACE_MANAGEMENT | Permissions.NODE_TYPE_DEFINITION_MANAGEMENT));
}
Also used : RepositoryPermission(org.apache.jackrabbit.oak.spi.security.authorization.permission.RepositoryPermission) Test(org.junit.Test)

Example 3 with RepositoryPermission

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

the class AbstractCompositeProviderTest method testRepositoryPermissionIsNotGranted.

@Test
public void testRepositoryPermissionIsNotGranted() throws Exception {
    RepositoryPermission rp = createPermissionProvider().getRepositoryPermission();
    assertFalse(rp.isGranted(Permissions.PRIVILEGE_MANAGEMENT));
    assertFalse(rp.isGranted(Permissions.NAMESPACE_MANAGEMENT | Permissions.PRIVILEGE_MANAGEMENT));
    assertFalse(rp.isGranted(Permissions.WORKSPACE_MANAGEMENT));
    assertFalse(rp.isGranted(Permissions.ALL));
    assertFalse(rp.isGranted(Permissions.NO_PERMISSION));
}
Also used : RepositoryPermission(org.apache.jackrabbit.oak.spi.security.authorization.permission.RepositoryPermission) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 4 with RepositoryPermission

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

the class AbstractCompositeProviderTest method testGetRepositoryPermissionInstance.

@Test
public void testGetRepositoryPermissionInstance() throws Exception {
    RepositoryPermission rp = createPermissionProvider().getRepositoryPermission();
    assertTrue(rp.getClass().getName().endsWith("CompositeRepositoryPermission"));
}
Also used : RepositoryPermission(org.apache.jackrabbit.oak.spi.security.authorization.permission.RepositoryPermission) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 5 with RepositoryPermission

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

the class PermissionProviderImplTest method testIsGrantedForReadPaths.

@Test
public void testIsGrantedForReadPaths() throws Exception {
    ContentSession testSession = createTestSession();
    try {
        PermissionProvider pp = createPermissionProvider(testSession);
        for (String path : READ_PATHS) {
            assertTrue(pp.isGranted(path, Permissions.getString(Permissions.READ)));
            assertTrue(pp.isGranted(path, Permissions.getString(Permissions.READ_NODE)));
            assertTrue(pp.isGranted(path + '/' + JcrConstants.JCR_PRIMARYTYPE, Permissions.getString(Permissions.READ_PROPERTY)));
            assertFalse(pp.isGranted(path, Permissions.getString(Permissions.READ_ACCESS_CONTROL)));
        }
        for (String path : READ_PATHS) {
            Tree tree = root.getTree(path);
            assertTrue(pp.isGranted(tree, null, Permissions.READ));
            assertTrue(pp.isGranted(tree, null, Permissions.READ_NODE));
            assertTrue(pp.isGranted(tree, tree.getProperty(JcrConstants.JCR_PRIMARYTYPE), Permissions.READ_PROPERTY));
            assertFalse(pp.isGranted(tree, null, Permissions.READ_ACCESS_CONTROL));
        }
        RepositoryPermission rp = pp.getRepositoryPermission();
        assertFalse(rp.isGranted(Permissions.READ));
        assertFalse(rp.isGranted(Permissions.READ_NODE));
        assertFalse(rp.isGranted(Permissions.READ_PROPERTY));
        assertFalse(rp.isGranted(Permissions.READ_ACCESS_CONTROL));
    } finally {
        testSession.close();
    }
}
Also used : RepositoryPermission(org.apache.jackrabbit.oak.spi.security.authorization.permission.RepositoryPermission) PermissionProvider(org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider) ContentSession(org.apache.jackrabbit.oak.api.ContentSession) Tree(org.apache.jackrabbit.oak.api.Tree) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Aggregations

RepositoryPermission (org.apache.jackrabbit.oak.spi.security.authorization.permission.RepositoryPermission)12 Test (org.junit.Test)12 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)3 ContentSession (org.apache.jackrabbit.oak.api.ContentSession)1 Tree (org.apache.jackrabbit.oak.api.Tree)1 PermissionProvider (org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider)1