Package javax.jcr.security

Examples of javax.jcr.security.Privilege


            throw new AccessControlException("Privilege array is empty or null.");
        }

        PrivilegeDefinition[] defs = new PrivilegeDefinition[privileges.length];
        for (int i = 0; i < privileges.length; i++) {
            Privilege p = privileges[i];
            if (p instanceof PrivilegeImpl) {
                defs[i] = ((PrivilegeImpl) p).definition;
            } else {
                String name = (p == null) ? "null" : p.getName();
                throw new AccessControlException("Unknown privilege '" + name + "'.");
            }
        }
        return registry.getBits(defs);
    }
View Full Code Here


     * @return The privilege with the specified name.
     * @throws AccessControlException
     * @throws RepositoryException
     */
    private Privilege getPrivilege(Name name) throws AccessControlException, RepositoryException {
        Privilege privilege;
        synchronized (cache) {
            if (cache.containsKey(name)) {
                privilege = cache.get(name);
            } else {
                PrivilegeDefinition def = registry.get(name);
View Full Code Here

     */
    public Privilege[] getPrivileges(String absPath) throws PathNotFoundException, RepositoryException {
        checkInitialized();
        checkValidNodePath(absPath);

        Privilege priv;
        if (anonymous) {
            priv = privilegeManager.getPrivilege(Privilege.JCR_READ);
        } else if (system) {
            priv = privilegeManager.getPrivilege(Privilege.JCR_ALL);
        } else {
View Full Code Here

    }

    public void testPrivilegeFromName() throws RepositoryException {
        Privilege[] privileges = acMgr.getSupportedPrivileges(testRootNode.getPath());
        for (int i = 0; i < privileges.length; i++) {
            Privilege p = acMgr.privilegeFromName(privileges[i].getName());
            assertEquals("Expected equal privilege name.", privileges[i].getName(), p.getName());
            assertEquals("Expected equal privilege.", privileges[i], p);
        }
    }
View Full Code Here

        l.add(getJCRName(Privilege.JCR_WRITE, superuser));
        l.add(getJCRName(Privilege.JCR_ALL, superuser));

        for (Iterator it = l.iterator(); it.hasNext();) {
            String privName = it.next().toString();
            Privilege p = acMgr.privilegeFromName(privName);
            assertEquals("Expected equal privilege name.", privName, p.getName());
        }
    }
View Full Code Here

    }

    public void testAllPrivilegeContainsAll() throws RepositoryException, NotExecutableException {
        Privilege[] supported = acMgr.getSupportedPrivileges(testRootNode.getPath());

        Privilege all = acMgr.privilegeFromName(Privilege.JCR_ALL);
        Set allSet = new HashSet();
        allSet.addAll(Arrays.asList(all.getAggregatePrivileges()));

        String msg = "The all privilege must also contain ";
        for (int i=0; i < supported.length; i++) {
            Privilege sp = supported[i];
            if (sp.isAggregate()) {
                Collection col = Arrays.asList(sp.getAggregatePrivileges());
                assertTrue(msg + sp.getName(), allSet.containsAll(col));
            } else {
                assertTrue(msg + sp.getName(), allSet.contains(sp));
            }
        }
    }
View Full Code Here

     *
     * @throws RepositoryException
     * @throws NotExecutableException
     */
    public void testAllPrivilege() throws RepositoryException, NotExecutableException {
        Privilege all = acMgr.privilegeFromName(Privilege.JCR_ALL);
        assertFalse("All privilege must be not be abstract.", all.isAbstract());
        assertTrue("All privilege must be an aggregate privilege.", all.isAggregate());
        String expected = getJCRName(Privilege.JCR_ALL, superuser);
        assertEquals("The name of the all privilege must be " + expected, expected, all.getName());
    }
View Full Code Here

     *
     * @throws RepositoryException If an error occurs.
     * @throws NotExecutableException If the test cannot be executed.
     */
    public void testWritePrivilege() throws RepositoryException, NotExecutableException {
        Privilege w = acMgr.privilegeFromName(Privilege.JCR_WRITE);
        assertTrue("Write privilege must be an aggregate privilege.", w.isAggregate());
        String expected = getJCRName(Privilege.JCR_WRITE, superuser);
        assertEquals("The name of the write privilege must be " + expected, expected, w.getName());
    }
View Full Code Here

        l.add(getJCRName(Privilege.JCR_WRITE, superuser));
        l.add(getJCRName(Privilege.JCR_ALL, superuser));

        for (Iterator it = l.iterator(); it.hasNext();) {
            String privName = it.next().toString();
            Privilege p = acMgr.privilegeFromName(privName);

            assertTrue("write and all must always be aggregate privileges.", p.isAggregate());
            Privilege[] aggregatedPrvs = p.getAggregatePrivileges();
            Privilege[] declaredPrvs = p.getDeclaredAggregatePrivileges();

            assertNotNull("An aggregate privilege must return the aggregated privileges", aggregatedPrvs);
            assertTrue("An aggregate privilege must return the aggregated privileges", aggregatedPrvs.length > 0);

            assertNotNull("An aggregate privilege must return the declared aggregated privileges", declaredPrvs);
View Full Code Here

     * reflects changes made to the namespace prefix.
     *
     *  @throws RepositoryException If an error occurs.
     */
    public void testPrivilegeName() throws RepositoryException {
        Privilege allPriv = acMgr.privilegeFromName(Privilege.JCR_ALL);
        try {
            String remappedPrefix = "_jcr";
            superuser.setNamespacePrefix(remappedPrefix, "http://www.jcp.org/jcr/1.0");

            List l = new ArrayList();
            l.add(acMgr.privilegeFromName(Privilege.JCR_ALL));
            l.add(acMgr.privilegeFromName(remappedPrefix + ":all"));

            for (Iterator it = l.iterator(); it.hasNext();) {
                Privilege p = (Privilege) it.next();

                assertEquals("The privilege name must reflect the modified namespace prefix.",remappedPrefix + ":all", p.getName());
                assertEquals("jcr:all privileges must be equal.",allPriv, p);
            }

            try {
                acMgr.privilegeFromName("jcr:all");
View Full Code Here

TOP

Related Classes of javax.jcr.security.Privilege

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.