Package org.apache.jackrabbit.api.security.authorization

Examples of org.apache.jackrabbit.api.security.authorization.PrivilegeManager


        String privName = "testCustomPrivilegeVisibleToNewSession";
        privilegeManager.registerPrivilege(privName, isAbstract, new String[0]);

        Session s2 = getAdminSession();
        try {
            PrivilegeManager pm = getPrivilegeManager(s2);
            Privilege priv = pm.getPrivilege(privName);
            assertEquals(privName, priv.getName());
            assertEquals(isAbstract, priv.isAbstract());
            assertFalse(priv.isAggregate());
        } finally {
            s2.logout();
View Full Code Here


     * @since oak
     */
    @Test
    public void testCustomPrivilegeVisibleAfterRefresh() throws RepositoryException {
        Session s2 = getAdminSession();
        PrivilegeManager pm = getPrivilegeManager(s2);
        try {
            boolean isAbstract = false;
            String privName = "testCustomPrivilegeVisibleAfterRefresh";
            privilegeManager.registerPrivilege(privName, isAbstract, new String[0]);

            // before refreshing: privilege not visible
            try {
                Privilege priv = pm.getPrivilege(privName);
                fail("Custom privilege will show up after Session#refresh()");
            } catch (AccessControlException e) {
                // success
            }

            // latest after refresh privilege manager must be updated
            s2.refresh(true);
            Privilege priv = pm.getPrivilege(privName);
            assertEquals(privName, priv.getName());
            assertEquals(isAbstract, priv.isAbstract());
            assertFalse(priv.isAggregate());
        } finally {
            s2.logout();
View Full Code Here

        ImmutableTree rootAfter = new ImmutableTree(after);

        RestrictionProvider restrictionProvider = getConfig(AuthorizationConfiguration.class).getRestrictionProvider();

        Root root = new ImmutableRoot(before);
        PrivilegeManager privilegeManager = getConfig(PrivilegeConfiguration.class).getPrivilegeManager(root, NamePathMapper.DEFAULT);
        PrivilegeBitsProvider privilegeBitsProvider = new PrivilegeBitsProvider(root);

        return new AccessControlValidator(rootAfter, privilegeManager, privilegeBitsProvider, restrictionProvider);
    }
View Full Code Here

        }
    }

    @Test
    public void testAbstractPrivilege() throws Exception {
        PrivilegeManager pMgr = getPrivilegeManager(root);
        pMgr.registerPrivilege("abstractPrivilege", true, new String[0]);

        NodeUtil acl = createAcl();
        createACE(acl, "invalid", NT_REP_GRANT_ACE, testPrincipal.getName(), "abstractPrivilege");
        try {
            root.commit();
View Full Code Here

    protected Privilege[] privilegesFromNames(String... privilegeNames) throws RepositoryException {
        return privilegesFromNames(Arrays.asList(privilegeNames));
    }

    protected Privilege[] privilegesFromNames(Iterable<String> privilegeNames) throws RepositoryException {
        PrivilegeManager manager = getPrivilegeManager(root);
        List<Privilege> privs = newArrayList();
        for (String name : privilegeNames) {
            privs.add(manager.getPrivilege(name));
        }
        return privs.toArray(new Privilege[privs.size()]);
    }
View Full Code Here

        return new AccessControlValidator(rootBefore, rootAfter, privileges, privilegeBitsProvider, restrictionProvider, ntMgr);
    }

    private Map<String, Privilege> getPrivileges(Root root) {
        PrivilegeManager pMgr = getConfig(PrivilegeConfiguration.class).getPrivilegeManager(root, NamePathMapper.DEFAULT);
        ImmutableMap.Builder privileges = ImmutableMap.builder();
        try {
            for (Privilege privilege : pMgr.getRegisteredPrivileges()) {
                privileges.put(privilege.getName(), privilege);
            }
        } catch (RepositoryException e) {
            log.error("Unexpected error: failed to read privileges.", e);
        }
View Full Code Here

    protected Privilege[] privilegesFromNames(String... privilegeNames) throws RepositoryException {
        return privilegesFromNames(Arrays.asList(privilegeNames));
    }

    protected Privilege[] privilegesFromNames(Iterable<String> privilegeNames) throws RepositoryException {
        PrivilegeManager manager = getPrivilegeManager(root);
        List<Privilege> privs = newArrayList();
        for (String name : privilegeNames) {
            privs.add(manager.getPrivilege(name));
        }
        return privs.toArray(new Privilege[privs.size()]);
    }
View Full Code Here

    protected Privilege[] privilegesFromNames(String... privilegeNames) throws RepositoryException {
        return privilegesFromNames(Arrays.asList(privilegeNames));
    }

    protected Privilege[] privilegesFromNames(Iterable<String> privilegeNames) throws RepositoryException {
        PrivilegeManager manager = getPrivilegeManager(root);
        List<Privilege> privs = newArrayList();
        for (String name : privilegeNames) {
            privs.add(manager.getPrivilege(name));
        }
        return privs.toArray(new Privilege[privs.size()]);
    }
View Full Code Here

        return new AccessControlValidator(rootBefore, rootAfter, privileges, restrictionProvider, ntMgr);
    }

    private Map<String, Privilege> getPrivileges(NodeState beforeRoot) {
        Root root = new ImmutableRoot(beforeRoot);
        PrivilegeManager pMgr = getConfig(PrivilegeConfiguration.class).getPrivilegeManager(root, NamePathMapper.DEFAULT);
        ImmutableMap.Builder privileges = ImmutableMap.builder();
        try {
            for (Privilege privilege : pMgr.getRegisteredPrivileges()) {
                privileges.put(privilege.getName(), privilege);
            }
        } catch (RepositoryException e) {
            log.error("Unexpected error: failed to read privileges.", e);
        }
View Full Code Here

        String privName = "testCustomPrivilegeVisibleToNewSession";
        privilegeManager.registerPrivilege(privName, isAbstract, new String[0]);

        Session s2 = getAdminSession();
        try {
            PrivilegeManager pm = getPrivilegeManager(s2);
            Privilege priv = pm.getPrivilege(privName);
            assertEquals(privName, priv.getName());
            assertEquals(isAbstract, priv.isAbstract());
            assertFalse(priv.isAggregate());
        } finally {
            s2.logout();
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.api.security.authorization.PrivilegeManager

Copyright © 2018 www.massapicom. 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.