Package org.apache.jackrabbit.api.security

Examples of org.apache.jackrabbit.api.security.JackrabbitAccessControlList


            // success
        }
    }

    public void testRemoveInvalidEntry() throws RepositoryException {
        JackrabbitAccessControlList pt = createEmptyTemplate(getTestPath());
        try {
            pt.removeAccessControlEntry(new JackrabbitAccessControlEntry() {
                public boolean isAllow() {
                    return false;
                }
                public int getPrivilegeBits() throws RepositoryException, NotExecutableException {
                    return PrivilegeRegistry.getBits(privilegesFromName(Privilege.JCR_READ));
View Full Code Here


            // success
        }
    }

    public void testRemoveInvalidEntry2() throws RepositoryException {
        JackrabbitAccessControlList pt = createEmptyTemplate(getTestPath());
        try {
            pt.removeAccessControlEntry(new JackrabbitAccessControlEntry() {
                public boolean isAllow() {
                    return false;
                }
                public int getPrivilegeBits() {
                    return 0;
View Full Code Here

            // success
        }
    }

    public void testAddEntry() throws RepositoryException, NotExecutableException {
        JackrabbitAccessControlList pt = createEmptyTemplate(getTestPath());
        Privilege[] privs = privilegesFromName(Privilege.JCR_READ);
        assertTrue(pt.addEntry(testPrincipal, privs, true, Collections.<String, Value>emptyMap()));
    }
View Full Code Here

        Privilege[] privs = privilegesFromName(Privilege.JCR_READ);
        assertTrue(pt.addEntry(testPrincipal, privs, true, Collections.<String, Value>emptyMap()));
    }

    public void testAddEntryTwice() throws RepositoryException, NotExecutableException {
        JackrabbitAccessControlList pt = createEmptyTemplate(getTestPath());
        Privilege[] privs = privilegesFromName(Privilege.JCR_READ);

        pt.addEntry(testPrincipal, privs, true, Collections.<String, Value>emptyMap());
        assertFalse(pt.addEntry(testPrincipal, privs, true, Collections.<String, Value>emptyMap()));
    }
View Full Code Here

        pt.addEntry(testPrincipal, privs, true, Collections.<String, Value>emptyMap());
        assertFalse(pt.addEntry(testPrincipal, privs, true, Collections.<String, Value>emptyMap()));
    }

    public void testEffect() throws RepositoryException, NotExecutableException {
        JackrabbitAccessControlList pt = createEmptyTemplate(getTestPath());
        Privilege[] read = privilegesFromName(Privilege.JCR_READ);
        Privilege[] modProp = privilegesFromName(Privilege.JCR_MODIFY_PROPERTIES);

        pt.addAccessControlEntry(testPrincipal, read);

        // add deny entry for mod_props
        assertTrue(pt.addEntry(testPrincipal, modProp, false, null));

        // test net-effect
        int allows = PrivilegeRegistry.NO_PRIVILEGE;
        int denies = PrivilegeRegistry.NO_PRIVILEGE;
        AccessControlEntry[] entries = pt.getAccessControlEntries();
        for (AccessControlEntry ace : entries) {
            if (testPrincipal.equals(ace.getPrincipal()) && ace instanceof JackrabbitAccessControlEntry) {
                int entryBits = PrivilegeRegistry.getBits(ace.getPrivileges());
                if (((JackrabbitAccessControlEntry) ace).isAllow()) {
                    allows |= Permission.diff(entryBits, denies);
View Full Code Here

        assertEquals(PrivilegeRegistry.getBits(read), allows);
        assertEquals(PrivilegeRegistry.getBits(modProp), denies);
    }

    public void testEffect2() throws RepositoryException, NotExecutableException {
        JackrabbitAccessControlList pt = createEmptyTemplate(getTestPath());
        pt.addEntry(testPrincipal, privilegesFromName(Privilege.JCR_READ), true, Collections.<String, Value>emptyMap());

        // same entry but with revers 'isAllow' flag
        assertTrue(pt.addEntry(testPrincipal, privilegesFromName(Privilege.JCR_READ), false, Collections.<String, Value>emptyMap()));

        // test net-effect
        int allows = PrivilegeRegistry.NO_PRIVILEGE;
        int denies = PrivilegeRegistry.NO_PRIVILEGE;
        AccessControlEntry[] entries = pt.getAccessControlEntries();
        for (AccessControlEntry ace : entries) {
            if (testPrincipal.equals(ace.getPrincipal()) && ace instanceof JackrabbitAccessControlEntry) {
                int entryBits = PrivilegeRegistry.getBits(ace.getPrivileges());
                if (((JackrabbitAccessControlEntry) ace).isAllow()) {
                    allows |= Permission.diff(entryBits, denies);
View Full Code Here

        assertEquals(PrivilegeRegistry.getBits(privilegesFromName(Privilege.JCR_READ)), denies);
    }

    public void testRemoveEntry() throws RepositoryException,
            NotExecutableException {
        JackrabbitAccessControlList pt = createEmptyTemplate(getTestPath());
        pt.addAccessControlEntry(testPrincipal, privilegesFromName(Privilege.JCR_READ));
        pt.removeAccessControlEntry(pt.getAccessControlEntries()[0]);
    }
View Full Code Here

        pt.addAccessControlEntry(testPrincipal, privilegesFromName(Privilege.JCR_READ));
        pt.removeAccessControlEntry(pt.getAccessControlEntries()[0]);
    }

    public void testRemoveNonExisting() throws RepositoryException {
        JackrabbitAccessControlList pt = createEmptyTemplate(getTestPath());
        try {
            pt.removeAccessControlEntry(new AccessControlEntry() {
                public Principal getPrincipal() {
                    return testPrincipal;
                }
                public Privilege[] getPrivileges() {
                    return new Privilege[0];
View Full Code Here

        // give 'testUser' READ_AC|MODIFY_AC privileges at 'path'
        Privilege[] privileges = privilegesFromNames(new String[] {
                Privilege.JCR_READ_ACCESS_CONTROL,
                Privilege.JCR_MODIFY_ACCESS_CONTROL
        });
        JackrabbitAccessControlList tmpl = givePrivileges(path, privileges, getRestrictions(superuser, path));
        /*
         testuser must
         - still have the inherited READ permission.
         - must have permission to view AC items at 'path' (and below)
         - must have permission to modify AC items at 'path'

         testuser must not have
         - permission to view AC items outside of the tree defined by path.
        */

        // make sure the 'rep:policy' node has been created.
        assertTrue(superuser.itemExists(tmpl.getPath() + "/rep:policy"));

        Session testSession = getTestSession();
        AccessControlManager testAcMgr = getTestACManager();
        // test: MODIFY_AC granted at 'path'
        assertTrue(testAcMgr.hasPrivileges(path, privilegesFromName(Privilege.JCR_MODIFY_ACCESS_CONTROL)));
View Full Code Here

            assertTrue(testAcMgr.hasPrivileges(path, privs));

            // reorder the ACEs
            AccessControlEntry srcEntry = null;
            AccessControlEntry destEntry = null;
            JackrabbitAccessControlList acl = (JackrabbitAccessControlList) acMgr.getPolicies(path)[0];
            for (AccessControlEntry entry : acl.getAccessControlEntries()) {
                Principal princ = entry.getPrincipal();
                if (testGroup.getPrincipal().equals(princ)) {
                    destEntry = entry;
                } else if (group2.getPrincipal().equals(princ)) {
                    srcEntry = entry;
                }

            }

            acl.orderBefore(srcEntry, destEntry);
            acMgr.setPolicy(path, acl);
            superuser.save();

            /* after reordering the permissions must be denied */
            assertFalse(getTestSession().hasPermission(path, actions));
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.api.security.JackrabbitAccessControlList

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.