Examples of PermissionProvider


Examples of org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider

    @Test
    public void testHasPrivileges() throws Exception {
        ContentSession testSession = createTestSession();
        try {
            PermissionProvider pp = createPermissionProvider(testSession);

            assertTrue(pp.hasPrivileges(null));
            assertTrue(pp.hasPrivileges(null, new String[0]));
            assertFalse(pp.hasPrivileges(null, PrivilegeConstants.JCR_WORKSPACE_MANAGEMENT));
        } finally {
            testSession.close();
        }
    }
View Full Code Here

Examples of org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider

    @Test
    public void testReadPath() throws Exception {
        ContentSession testSession = createTestSession();
        try {
            Root r = testSession.getLatestRoot();
            PermissionProvider pp = createPermissionProvider(testSession);

            Tree tree = r.getTree("/");
            assertFalse(tree.exists());
            assertFalse(pp.getTreePermission(tree, TreePermission.EMPTY).canRead());

            for (String path : READ_PATHS) {
                tree = r.getTree(path);
                assertTrue(tree.exists());
                assertTrue(pp.getTreePermission(tree, TreePermission.EMPTY).canRead());
            }
        } finally {
            testSession.close();
        }
    }
View Full Code Here

Examples of org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider

    @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 {
View Full Code Here

Examples of org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider

    @Test
    public void testGetPrivilegesForReadPaths() throws Exception {
        ContentSession testSession = createTestSession();
        try {
            PermissionProvider pp = createPermissionProvider(testSession) ;
            for (String path : READ_PATHS) {
                Tree tree = root.getTree(path);
                assertEquals(Collections.singleton(PrivilegeConstants.JCR_READ), pp.getPrivileges(tree));
            }
            assertEquals(Collections.<String>emptySet(), pp.getPrivileges(null));
        } finally {
            testSession.close();
        }
    }
View Full Code Here

Examples of org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider

    @Test
    public void testHasPrivilegesForReadPaths() throws Exception {
        ContentSession testSession = createTestSession();
        try {
            PermissionProvider pp = createPermissionProvider(testSession) ;
            for (String path : READ_PATHS) {
                Tree tree = root.getTree(path);
                assertTrue(pp.hasPrivileges(tree, PrivilegeConstants.JCR_READ));
                assertTrue(pp.hasPrivileges(tree, PrivilegeConstants.REP_READ_NODES));
                assertTrue(pp.hasPrivileges(tree, PrivilegeConstants.REP_READ_PROPERTIES));
                assertFalse(pp.hasPrivileges(tree, PrivilegeConstants.JCR_READ_ACCESS_CONTROL));
            }
            assertFalse(pp.hasPrivileges(null, PrivilegeConstants.JCR_READ));
        } finally {
            testSession.close();
        }
    }
View Full Code Here

Examples of org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider

        ContentSession testSession = createTestSession();
        try {
            Root r = testSession.getLatestRoot();
            Root immutableRoot = new ImmutableRoot(r, TreeTypeProvider.EMPTY);

            PermissionProvider pp = createPermissionProvider(testSession) ;
            assertTrue(r.getTree("/").exists());
            TreePermission tp = pp.getTreePermission(immutableRoot.getTree("/"), TreePermission.EMPTY);
            assertSame(TreePermission.ALL, tp);

            for (String path : READ_PATHS) {
                Tree tree = r.getTree(path);
                assertTrue(tree.exists());
                assertSame(TreePermission.ALL, pp.getTreePermission(tree, TreePermission.EMPTY));
            }
        } finally {
            testSession.close();
        }
    }
View Full Code Here

Examples of org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider

        assertFalse(ps.exists());
    }

    @Test
    public void testGetTreePermission() {
        PermissionProvider pp = createPermissionProvider();

        Tree t = root.getTree(PermissionConstants.PERMISSIONS_STORE_PATH);
        assertSame(TreePermission.EMPTY, pp.getTreePermission(t, TreePermission.ALL));
    }
View Full Code Here

Examples of org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider

        assertSame(TreePermission.EMPTY, pp.getTreePermission(t, TreePermission.ALL));
    }

    @Test
    public void testIsGranted() {
        PermissionProvider pp = createPermissionProvider();

        Tree t = root.getTree(PermissionConstants.PERMISSIONS_STORE_PATH);

        assertFalse(pp.isGranted(t, null, Permissions.READ));
        assertFalse(pp.isGranted(t, t.getProperty(JcrConstants.JCR_PRIMARYTYPE), Permissions.READ));
    }
View Full Code Here

Examples of org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider

        assertFalse(pp.isGranted(t, t.getProperty(JcrConstants.JCR_PRIMARYTYPE), Permissions.READ));
    }

    @Test
    public void testIsGrantedAtPath() {
        PermissionProvider pp = createPermissionProvider();

        assertFalse(pp.isGranted(PermissionConstants.PERMISSIONS_STORE_PATH, Session.ACTION_READ));
        assertFalse(pp.isGranted(PermissionConstants.PERMISSIONS_STORE_PATH, Session.ACTION_ADD_NODE));
    }
View Full Code Here

Examples of org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider

    @Override
    public boolean hasPrivileges(@Nullable String absPath, @Nonnull Set<Principal> principals, @Nullable Privilege[] privileges) throws RepositoryException {
        if (getPrincipals().equals(principals)) {
            return hasPrivileges(absPath, privileges);
        } else {
            PermissionProvider provider = acConfig.getPermissionProvider(root, principals);
            return hasPrivileges(absPath, privileges, provider, Permissions.READ_ACCESS_CONTROL);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.