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

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


        }
    }

    @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


        }
    }

    @Test
    public void testAbstractPrivilege() throws Exception {
        PrivilegeManager pMgr = getSecurityProvider().getPrivilegeConfiguration().getPrivilegeManager(root, getNamePathMapper());
        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

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

    private Map<String, Privilege> getPrivileges(NodeState beforeRoot, PrivilegeConfiguration config) {
        Root root = new ImmutableRoot(beforeRoot);
        PrivilegeManager pMgr = config.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

    @Override
    protected void setUp() throws Exception {
        super.setUp();

        SessionImpl s = (SessionImpl) superuser;
        PrivilegeManager privMgr = ((JackrabbitWorkspace) superuser.getWorkspace()).getPrivilegeManager();

        acl = new ACLTemplate(testPath, s.getPrincipalManager(), privMgr, s.getValueFactory(), s);
    }
View Full Code Here

        }
    }

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

        NodeUtil acl = createAcl();
        createACE(acl, "invalid", NT_REP_GRANT_ACE, testPrincipal2.getName(), "abstractPrivilege");
        try {
            root.commit();
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

     * @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

    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

        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

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.