Examples of JackrabbitAccessControlEntry


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

        // match the required ones.
        Privilege[] privs = privilegesFromName(Privilege.JCR_ALL);

        Map<String, Value> restr = new HashMap<String, Value>();
        restr.put(nodePath, new StringValue("/a/b/c/d"));
        JackrabbitAccessControlEntry pe = createEntry(testPrincipal, privs, true, restr);

        assertEquals("/a/b/c/d", pe.getRestriction(nodePath).getString());
        assertEquals(PropertyType.PATH, pe.getRestriction(nodePath).getType());

        restr = new HashMap<String, Value>();
        restr.put(nodePath,  restrictions.get(nodePath));
        restr.put(glob,  new BooleanValue(true));
        pe = createEntry(testPrincipal, privs, true, restr);

        assertEquals(true, pe.getRestriction(glob).getBoolean());
        assertEquals(PropertyType.STRING, pe.getRestriction(glob).getType());
    }
View Full Code Here

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

    protected abstract JackrabbitAccessControlEntry createEntry(Principal principal, Privilege[] privileges, boolean isAllow)
            throws RepositoryException;

    public void testIsAllow() throws RepositoryException, NotExecutableException {
        JackrabbitAccessControlEntry tmpl = createEntry(new String[] {Privilege.JCR_READ}, true);
        assertTrue(tmpl.isAllow());

        tmpl = createEntry(new String[] {Privilege.JCR_READ}, false);
        assertFalse(tmpl.isAllow());
    }
View Full Code Here

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

        tmpl = createEntry(new String[] {Privilege.JCR_READ}, false);
        assertFalse(tmpl.isAllow());
    }

    public void testGetPrincipal() throws RepositoryException, NotExecutableException {
        JackrabbitAccessControlEntry tmpl = createEntry(new String[] {Privilege.JCR_READ}, true);
        assertNotNull(tmpl.getPrincipal());
        assertEquals(testPrincipal.getName(), tmpl.getPrincipal().getName());
        assertSame(testPrincipal, tmpl.getPrincipal());
    }
View Full Code Here

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

        assertEquals(testPrincipal.getName(), tmpl.getPrincipal().getName());
        assertSame(testPrincipal, tmpl.getPrincipal());
    }

    public void testGetPrivilegeBits() throws RepositoryException, NotExecutableException {
        JackrabbitAccessControlEntry tmpl = createEntry(new String[] {Privilege.JCR_READ}, true);

        int privs = PrivilegeRegistry.getBits(tmpl.getPrivileges());
        assertEquals(1, tmpl.getPrivileges().length);
        assertEquals(getAccessControlManager(superuser).privilegeFromName(Privilege.JCR_READ),
                tmpl.getPrivileges()[0]);

        tmpl = createEntry(new String[] {PrivilegeRegistry.REP_WRITE}, true);
        assertEquals(getAccessControlManager(superuser).privilegeFromName(PrivilegeRegistry.REP_WRITE),
                tmpl.getPrivileges()[0]);
    }
View Full Code Here

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

        assertEquals(getAccessControlManager(superuser).privilegeFromName(PrivilegeRegistry.REP_WRITE),
                tmpl.getPrivileges()[0]);
    }

    public void testGetPrivileges() throws RepositoryException, NotExecutableException {
        JackrabbitAccessControlEntry entry = createEntry(new String[] {Privilege.JCR_READ}, true);

        Privilege[] privs = entry.getPrivileges();
        assertNotNull(privs);
        assertEquals(1, privs.length);
        assertEquals(privs[0], acMgr.privilegeFromName(Privilege.JCR_READ));
        assertTrue(PrivilegeRegistry.getBits(privs) == PrivilegeRegistry.getBits(entry.getPrivileges()));

        entry = createEntry(new String[] {PrivilegeRegistry.REP_WRITE}, true);
        privs = entry.getPrivileges();
        assertNotNull(privs);
        assertEquals(1, privs.length);
        assertEquals(privs[0], acMgr.privilegeFromName(PrivilegeRegistry.REP_WRITE));
        assertTrue(PrivilegeRegistry.getBits(privs) == PrivilegeRegistry.getBits(entry.getPrivileges()));

        entry = createEntry(new String[] {Privilege.JCR_ADD_CHILD_NODES,
                Privilege.JCR_REMOVE_CHILD_NODES}, true);
        privs = entry.getPrivileges();
        assertNotNull(privs);
        assertEquals(2, privs.length);

        Privilege[] param = privilegesFromNames(new String[] {
                Privilege.JCR_ADD_CHILD_NODES,
                Privilege.JCR_REMOVE_CHILD_NODES
        });
        assertEquals(Arrays.asList(param), Arrays.asList(privs));
        assertEquals(PrivilegeRegistry.getBits(privs), PrivilegeRegistry.getBits(entry.getPrivileges()));
    }
View Full Code Here

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

        assertEquals(PrivilegeRegistry.getBits(privs), PrivilegeRegistry.getBits(entry.getPrivileges()));
    }

    public void testEquals() throws RepositoryException, NotExecutableException  {

        JackrabbitAccessControlEntry ace = createEntry(new String[] {Privilege.JCR_ALL}, true);
        List<JackrabbitAccessControlEntry> equalAces = new ArrayList<JackrabbitAccessControlEntry>();
        equalAces.add(createEntry(new String[] {Privilege.JCR_ALL}, true));

        Privilege[] privs = acMgr.privilegeFromName(Privilege.JCR_ALL).getDeclaredAggregatePrivileges();
        equalAces.add(createEntry(testPrincipal, privs, true));
View Full Code Here

Examples of org.apache.jackrabbit.core.security.authorization.JackrabbitAccessControlEntry

        // now (re) create it
        aclNode = createAclNode(nodePath);

        AccessControlEntry[] entries = ((ACLTemplate) policy).getAccessControlEntries();
        for (int i = 0; i < entries.length; i++) {
            JackrabbitAccessControlEntry ace = (JackrabbitAccessControlEntry) entries[i];

            Name nodeName = getUniqueNodeName(aclNode, ace.isAllow() ? "allow" : "deny");
            Name ntName = (ace.isAllow()) ? NT_REP_GRANT_ACE : NT_REP_DENY_ACE;
            ValueFactory vf = session.getValueFactory();

            // create the ACE node
            NodeImpl aceNode = addNode(aclNode, nodeName, ntName);

            // write the rep:principalName property
            String principalName = ace.getPrincipal().getName();
            setProperty(aceNode, P_PRINCIPAL_NAME, vf.createValue(principalName));

            // ... and the rep:privileges property
            Privilege[] pvlgs = ace.getPrivileges();
            Value[] names = getPrivilegeNames(pvlgs, vf);
            setProperty(aceNode, P_PRIVILEGES, names);
        }
    }
View Full Code Here

Examples of org.apache.jackrabbit.core.security.authorization.JackrabbitAccessControlEntry

    }

    public void testGetGlob() throws RepositoryException, NotExecutableException {
        Privilege[] privs = privilegesFromName(Privilege.JCR_ALL);

        JackrabbitAccessControlEntry pe = createEntry(testPrincipal, privs, true);

        assertEquals(restrictions.get(glob), pe.getRestriction(glob));
        assertEquals(PropertyType.STRING, pe.getRestriction(glob).getType());

        Map restr = new HashMap();
        restr.put(nodePath,  restrictions.get(nodePath));
        pe = createEntry(testPrincipal, privs, true, restr);
        assertNull(pe.getRestriction(glob));

        restr = new HashMap();
        restr.put(nodePath,  restrictions.get(nodePath));
        restr.put(glob,  new StringValue(""));

        pe = createEntry(testPrincipal, privs, true, restr);
        assertEquals("", pe.getRestriction(glob).getString());

        restr = new HashMap();
        restr.put(nodePath,  restrictions.get(nodePath));
        restr.put(glob,  new BooleanValue(true));
        assertEquals(PropertyType.STRING, pe.getRestriction(glob).getType());
    }
View Full Code Here

Examples of org.apache.jackrabbit.core.security.authorization.JackrabbitAccessControlEntry

        // match the required ones.
        Privilege[] privs = privilegesFromName(Privilege.JCR_ALL);

        Map restr = new HashMap();
        restr.put(nodePath, new StringValue("/a/b/c/d"));
        JackrabbitAccessControlEntry pe = createEntry(testPrincipal, privs, true, restr);

        assertEquals("/a/b/c/d", pe.getRestriction(nodePath).getString());
        assertEquals(PropertyType.PATH, pe.getRestriction(nodePath).getType());

        restr = new HashMap();
        restr.put(nodePath,  restrictions.get(nodePath));
        restr.put(glob,  new BooleanValue(true));
        pe = createEntry(testPrincipal, privs, true, restr);

        assertEquals(true, pe.getRestriction(glob).getBoolean());
        assertEquals(PropertyType.STRING, pe.getRestriction(glob).getType());
    }
View Full Code Here

Examples of org.apache.jackrabbit.core.security.authorization.JackrabbitAccessControlEntry

        }
    }

    public void testGetNodePath() throws RepositoryException, NotExecutableException {
        Privilege[] privs = privilegesFromName(Privilege.JCR_ALL);
        JackrabbitAccessControlEntry pe = createEntry(testPrincipal, privs, true);

        assertEquals(restrictions.get(nodePath), pe.getRestriction(nodePath));
        assertEquals(PropertyType.PATH, pe.getRestriction(nodePath).getType());
    }
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.