Package org.apache.jackrabbit.spi

Examples of org.apache.jackrabbit.spi.PrivilegeDefinition


     * @param declaredAggregateNames
     * @throws RepositoryException If the privilege could not be registered due
     * to constraint violations or if persisting the custom privilege fails.
     */
    void registerDefinition(Name privilegeName, boolean isAbstract, Set<Name> declaredAggregateNames) throws RepositoryException {
        PrivilegeDefinition def = new PrivilegeDefinitionImpl(privilegeName, isAbstract, declaredAggregateNames);
        Map<Name, PrivilegeDefinition> stubs = Collections.singletonMap(privilegeName, def);
        registerCustomDefinitions(stubs);

        // inform clustering about the new privilege.
        if (eventChannel != null) {
View Full Code Here


            // monitor progress of resolution into proper definitions.
            int cnt = aggregates.size();

            // look for those definitions whose declared aggregates have all been processed.
            for (Iterator<PrivilegeDefinition> itr = aggregates.iterator(); itr.hasNext();) {
                PrivilegeDefinition stub = itr.next();
                PrivilegeBits bts = getAggregateBits(stub.getDeclaredAggregateNames(), definitions);
                if (!bts.isEmpty()) {
                    // make sure the same aggregation is not yet covered by an
                    // already registered privilege
                    if (bitsToNames.containsKey(bts) && bitsToNames.get(bts).size() == 1) {
                        Name existingName = bitsToNames.get(bts).iterator().next();
                        throw new RepositoryException("Custom aggregate privilege '" + stub.getName() + "' is already covered by '" + existingName.toString() + "'");
                    }
                    // ... nor is present within the set of definitions that have
                    // been created before for registration.
                    for (Definition d : definitions.values()) {
                        if (bts.equals(d.bits)) {
                            throw new RepositoryException("Custom aggregate privilege '" + stub.getName() + "' is already defined by '"+ d.getName()+"'");
                        }
                    }

                    // now its save to create the new definition
                    Definition def = new Definition(stub, bts);
View Full Code Here

     * @param declaredAggregateName
     * @param toRegister
     * @return
     */
    private boolean isCircularAggregation(PrivilegeDefinition def, Name declaredAggregateName, Map<Name, PrivilegeDefinition> toRegister) {
        PrivilegeDefinition d = toRegister.get(declaredAggregateName);
        if (d.getDeclaredAggregateNames().isEmpty()) {
            return false;
        } else {
            boolean isCircular = false;
            for (Name n : d.getDeclaredAggregateNames()) {
                if (def.getName().equals(n)) {
                    return true;
                }
                if (toRegister.containsKey(n)) {
                    isCircular = isCircularAggregation(def, n, toRegister);
View Full Code Here

        assertTrue(l.isEmpty());
    }

    public void testJcrWrite() throws RepositoryException {
        Name rw = resolver.getQName(PrivilegeRegistry.REP_WRITE);
        PrivilegeDefinition p = privilegeRegistry.get(rw);

        assertEquals(p.getName(), rw);
        assertFalse(p.getDeclaredAggregateNames().isEmpty());
        assertFalse(p.isAbstract());

        Set<Name> l = new HashSet<Name>(p.getDeclaredAggregateNames());
        assertTrue(l.remove(NameConstants.JCR_WRITE));
        assertTrue(l.remove(NameConstants.JCR_NODE_TYPE_MANAGEMENT));
        assertTrue(l.isEmpty());
    }
View Full Code Here

        assertTrue(l.remove(NameConstants.JCR_NODE_TYPE_MANAGEMENT));
        assertTrue(l.isEmpty());
    }

    public void testRepWrite() throws RepositoryException {
        PrivilegeDefinition p = privilegeRegistry.get(NameConstants.JCR_WRITE);
        assertEquals(p.getName(), NameConstants.JCR_WRITE);
        assertFalse(p.getDeclaredAggregateNames().isEmpty());
        assertFalse(p.isAbstract());

        Set<Name> l = new HashSet<Name>(p.getDeclaredAggregateNames());
        assertTrue(l.remove(NameConstants.JCR_MODIFY_PROPERTIES));
        assertTrue(l.remove(NameConstants.JCR_ADD_CHILD_NODES));
        assertTrue(l.remove(NameConstants.JCR_REMOVE_CHILD_NODES));
        assertTrue(l.remove(NameConstants.JCR_REMOVE_NODE));
        assertTrue(l.isEmpty());
View Full Code Here

    public void testGet() throws RepositoryException {

        for (PrivilegeDefinition def : privilegeRegistry.getAll()) {

            PrivilegeDefinition d = privilegeRegistry.get(def.getName());
            assertEquals(def, d);

            assertNotNull(d.getName());
            assertEquals(def.getName(), d.getName());

            assertFalse(d.isAbstract());
            assertEquals(def.isAbstract(), d.isAbstract());

            assertNotNull(d.getDeclaredAggregateNames());
            assertTrue(def.getDeclaredAggregateNames().containsAll(d.getDeclaredAggregateNames()));
            assertTrue(d.getDeclaredAggregateNames().containsAll(def.getDeclaredAggregateNames()));

            assertFalse(privilegeRegistry.getBits(d).isEmpty());
        }
    }
View Full Code Here

            if (def.getDeclaredAggregateNames().isEmpty()) {
                continue; // ignore non aggregate
            }

            for (Name n : def.getDeclaredAggregateNames()) {
                PrivilegeDefinition d = privilegeRegistry.get(n);
                assertNotNull(d);
                Name[] names = privilegeRegistry.getNames(privilegeRegistry.getBits(d));
                assertNotNull(names);
                assertEquals(1, names.length);
                assertEquals(d.getName(), names[0]);
            }
        }
    }
View Full Code Here

            assertFalse(privilegeRegistry.getBits(def).isEmpty());
        }
    }

    public void testJcrAll() throws RepositoryException {
        PrivilegeDefinition p = privilegeRegistry.get(NameConstants.JCR_ALL);
        assertEquals(p.getName(), NameConstants.JCR_ALL);
        assertFalse(p.getDeclaredAggregateNames().isEmpty());
        assertFalse(p.isAbstract());

        Set<Name> l = new HashSet<Name>(p.getDeclaredAggregateNames());
        assertTrue(l.remove(NameConstants.JCR_READ));
        assertTrue(l.remove(NameConstants.JCR_WRITE));
        assertTrue(l.remove(resolver.getQName(PrivilegeRegistry.REP_WRITE)));
        assertTrue(l.remove(resolver.getQName(PrivilegeRegistry.REP_PRIVILEGE_MANAGEMENT)));
        assertTrue(l.remove(NameConstants.JCR_READ_ACCESS_CONTROL));
View Full Code Here

        Privilege privilege;
        synchronized (cache) {
            if (cache.containsKey(name)) {
                privilege = cache.get(name);
            } else {
                PrivilegeDefinition def = registry.get(name);
                if (def != null) {
                    privilege = new PrivilegeImpl(def);
                    cache.put(name, privilege);
                } else {
                    throw new AccessControlException("Unknown privilege " + resolver.getJCRName(name));
View Full Code Here

     * @param declaredAggregateNames
     * @throws RepositoryException If the privilege could not be registered due
     * to constraint violations or if persisting the custom privilege fails.
     */
    void registerDefinition(Name privilegeName, boolean isAbstract, Set<Name> declaredAggregateNames) throws RepositoryException {
        PrivilegeDefinition def = new PrivilegeDefinitionImpl(privilegeName, isAbstract, declaredAggregateNames);
        Map<Name, PrivilegeDefinition> stubs = Collections.singletonMap(privilegeName, def);
        registerCustomDefinitions(stubs);

        // inform clustering about the new privilege.
        if (eventChannel != null) {
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.spi.PrivilegeDefinition

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.