Package org.apache.jackrabbit.oak.spi.security.privilege

Examples of org.apache.jackrabbit.oak.spi.security.privilege.ImmutablePrivilegeDefinition


    }

    private static Collection<PrivilegeDefinition> getBuiltInDefinitions() {
        Map<String, PrivilegeDefinition> definitions = new LinkedHashMap<String, PrivilegeDefinition>();
        for (String privilegeName : NON_AGGR_PRIVILEGES) {
            PrivilegeDefinition def = new ImmutablePrivilegeDefinition(privilegeName, false, null);
            definitions.put(privilegeName, def);
        }
        for (String privilegeName : AGGREGATE_PRIVILEGES.keySet()) {
            PrivilegeDefinition def = new ImmutablePrivilegeDefinition(privilegeName, false, asList(AGGREGATE_PRIVILEGES.get(privilegeName)));
            definitions.put(privilegeName, def);
        }
        PrivilegeDefinition all = new ImmutablePrivilegeDefinition(JCR_ALL, false, definitions.keySet());
        definitions.put(JCR_ALL, all);
        return definitions.values();
    }
View Full Code Here


    }

    private static Collection<PrivilegeDefinition> getBuiltInDefinitions() {
        Map<String, PrivilegeDefinition> definitions = new LinkedHashMap<String, PrivilegeDefinition>();
        for (String privilegeName : NON_AGGR_PRIVILEGES) {
            PrivilegeDefinition def = new ImmutablePrivilegeDefinition(privilegeName, false, null);
            definitions.put(privilegeName, def);
        }
        for (String privilegeName : AGGREGATE_PRIVILEGES.keySet()) {
            PrivilegeDefinition def = new ImmutablePrivilegeDefinition(privilegeName, false, asList(AGGREGATE_PRIVILEGES.get(privilegeName)));
            definitions.put(privilegeName, def);
        }
        PrivilegeDefinition all = new ImmutablePrivilegeDefinition(JCR_ALL, false, definitions.keySet());
        definitions.put(JCR_ALL, all);
        return definitions.values();
    }
View Full Code Here

    }

    private static Collection<PrivilegeDefinition> getBuiltInDefinitions() {
        Map<String, PrivilegeDefinition> definitions = new LinkedHashMap<String, PrivilegeDefinition>();
        for (String privilegeName : NON_AGGR_PRIVILEGES) {
            PrivilegeDefinition def = new ImmutablePrivilegeDefinition(privilegeName, false, null);
            definitions.put(privilegeName, def);
        }
        for (String privilegeName : AGGREGATE_PRIVILEGES.keySet()) {
            PrivilegeDefinition def = new ImmutablePrivilegeDefinition(privilegeName, false, asList(AGGREGATE_PRIVILEGES.get(privilegeName)));
            definitions.put(privilegeName, def);
        }
        PrivilegeDefinition all = new ImmutablePrivilegeDefinition(JCR_ALL, false, definitions.keySet());
        definitions.put(JCR_ALL, all);
        return definitions.values();
    }
View Full Code Here

            throw new InvalidItemStateException("Attempt to register a new privilege while there are pending changes.");
        }
        if (privilegeName == null || privilegeName.isEmpty()) {
            throw new RepositoryException("Invalid privilege name " + privilegeName);
        }
        PrivilegeDefinition definition = new ImmutablePrivilegeDefinition(getOakName(privilegeName), isAbstract, getOakNames(declaredAggregateNames));
        PrivilegeDefinitionWriter writer = new PrivilegeDefinitionWriter(getWriteRoot());
        writer.writeDefinition(definition);

        // refresh the current root to make sure the definition is visible
        root.refresh();
View Full Code Here

    @Test
    public void testNameCollision() {
        try {
            PrivilegeDefinitionWriter writer = new PrivilegeDefinitionWriter(root);
            writer.writeDefinition(new ImmutablePrivilegeDefinition(JCR_READ, true, null));
            fail("name collision");
        } catch (RepositoryException e) {
            // success
        }
    }
View Full Code Here

    public void testMissingPrivilegeRoot() throws Exception {
        ContentRepository repo = new Oak().with(new OpenSecurityProvider()).createContentRepository();
        Root tmpRoot = repo.login(null, null).getLatestRoot();
        try {
            PrivilegeDefinitionWriter writer = new PrivilegeDefinitionWriter(tmpRoot);
            writer.writeDefinition(new ImmutablePrivilegeDefinition("newName", true, null));
            fail("missing privilege root");
        } catch (RepositoryException e) {
            // success
        } finally {
            tmpRoot.getContentSession().close();
View Full Code Here

    }

    @Test
    public void testWriteDefinition() throws Exception {
        PrivilegeDefinitionWriter writer = new PrivilegeDefinitionWriter(root);
        writer.writeDefinition(new ImmutablePrivilegeDefinition(
                "tmp", true, asList(JCR_READ_ACCESS_CONTROL, JCR_MODIFY_ACCESS_CONTROL)));

        Tree privRoot = root.getTree(PRIVILEGES_PATH);
        assertTrue(privRoot.hasChild("tmp"));
View Full Code Here

    @Test
    public void testNameCollision() {
        try {
            PrivilegeDefinitionWriter writer = new PrivilegeDefinitionWriter(root);
            writer.writeDefinition(new ImmutablePrivilegeDefinition(JCR_READ, true, Collections.<String>emptySet()));
            fail("name collision");
        } catch (RepositoryException e) {
            // success
        }
    }
View Full Code Here

    public void testMissingPrivilegeRoot() throws Exception {
        ContentRepository repo = new Oak().with(new OpenSecurityProvider()).createContentRepository();
        Root tmpRoot = repo.login(null, null).getLatestRoot();
        try {
            PrivilegeDefinitionWriter writer = new PrivilegeDefinitionWriter(tmpRoot);
            writer.writeDefinition(new ImmutablePrivilegeDefinition("newName", true, Collections.<String>emptySet()));
            fail("missing privilege root");
        } catch (RepositoryException e) {
            // success
        } finally {
            tmpRoot.getContentSession().close();
View Full Code Here

    }

    @Test
    public void testWriteDefinition() throws Exception {
        PrivilegeDefinitionWriter writer = new PrivilegeDefinitionWriter(root);
        writer.writeDefinition(new ImmutablePrivilegeDefinition("tmp", true, JCR_READ_ACCESS_CONTROL, JCR_MODIFY_ACCESS_CONTROL));

        Tree privRoot = root.getTree(PRIVILEGES_PATH);
        assertTrue(privRoot.hasChild("tmp"));

        Tree tmpTree = privRoot.getChild("tmp");
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.oak.spi.security.privilege.ImmutablePrivilegeDefinition

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.