Package javax.jcr.security

Examples of javax.jcr.security.Privilege


     */
    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 testAddAggregatedPrivilegesSeparately() throws NotExecutableException, RepositoryException {
        checkCanModifyAc(path);

        Privilege aggregate = null;
        for (int i = 0; i < privs.length; i++) {
            if (privs[i].isAggregate()) {
                aggregate = privs[i];
                break;
            }
        }
        if (aggregate == null) {
            throw new NotExecutableException("No aggregate privilege supported at " + path);
        }

        AccessControlList acl = getList(acMgr, path);
        acl.addAccessControlEntry(testPrincipal, new Privilege[] {aggregate});

        Privilege[] privs = aggregate.getAggregatePrivileges();
        for (int i = 0; i < privs.length; i++) {
            boolean modified = acl.addAccessControlEntry(testPrincipal, new Privilege[] {privs[i]});
            assertFalse("Adding the aggregated privs individually later on must not modify the policy", modified);
        }
    }
View Full Code Here

    }

    public void testAddAbstractPrivilege() throws NotExecutableException, RepositoryException {
        checkCanModifyAc(path);

        Privilege abstractPriv = null;
        Privilege[] allPrivs = acMgr.privilegeFromName(Privilege.JCR_ALL).getAggregatePrivileges();
        for (int i = 0; i < allPrivs.length; i++) {
            if (allPrivs[i].isAbstract()) {
                abstractPriv = allPrivs[i];
                break;
View Full Code Here

    public void testAddAccessControlEntryInvalidPrivilege() throws NotExecutableException, RepositoryException {
        checkCanModifyAc(path);

        try {
            Privilege[] invalidPrivs = new Privilege[] {new Privilege() {
                public String getName() {
                    return null;
                }
                public boolean isAbstract() {
                    return false;
View Full Code Here

        if (twoPrivs.size() < 2) {
            throw new NotExecutableException("At least 2 supported, non-aggregate privileges required at " + path);
        }

        AccessControlList acl = getList(acMgr, path);
        Privilege privilege = twoPrivs.get(0);
        // add first privilege:
        acl.addAccessControlEntry(testPrincipal, new Privilege[] {privilege});

        // add a second privilege (but not specifying the privilege added before)
        // -> the first privilege must not be removed.
        Privilege privilege2 = twoPrivs.get(1);
        acl.addAccessControlEntry(testPrincipal, new Privilege[] {privilege2});

        List<Privilege> currentPrivileges = currentPrivileges(acl, testPrincipal);
        assertTrue("'AccessControlList.addAccessControlEntry' must not remove privileges added before", currentPrivileges.containsAll(twoPrivs));
    }
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<String> it = l.iterator(); it.hasNext();) {
            String privName = it.next();
            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<Privilege> allSet = new HashSet<Privilege>();
        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<Privilege> 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

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.