Search in sources :

Example 6 with NamePathMapperImpl

use of org.apache.jackrabbit.oak.namepath.NamePathMapperImpl in project jackrabbit-oak by apache.

the class PrivilegeManagerImplTest method testRegisterPrivilegeReservedRemappedNamespace.

@Test(expected = RepositoryException.class)
public void testRegisterPrivilegeReservedRemappedNamespace() throws Exception {
    NamePathMapper mapper = new NamePathMapperImpl(new LocalNameMapper(root, ImmutableMap.of("prefix", NamespaceRegistry.NAMESPACE_JCR)));
    PrivilegeManager pmgr = create(root, mapper);
    pmgr.registerPrivilege("prefix:customPrivilege", true, new String[] { "prefix:read", "prefix:write" });
}
Also used : PrivilegeManager(org.apache.jackrabbit.api.security.authorization.PrivilegeManager) NamePathMapper(org.apache.jackrabbit.oak.namepath.NamePathMapper) NamePathMapperImpl(org.apache.jackrabbit.oak.namepath.NamePathMapperImpl) LocalNameMapper(org.apache.jackrabbit.oak.namepath.LocalNameMapper) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 7 with NamePathMapperImpl

use of org.apache.jackrabbit.oak.namepath.NamePathMapperImpl in project jackrabbit-oak by apache.

the class AbstractAccessControlListTest method testGetPath.

@Test
public void testGetPath() {
    NameMapper nameMapper = new GlobalNameMapper(Collections.singletonMap("jr", "http://jackrabbit.apache.org"));
    NamePathMapper npMapper = new NamePathMapperImpl(nameMapper);
    // map of jcr-path to standard jcr-path
    Map<String, String> paths = new HashMap<String, String>();
    paths.put(null, null);
    paths.put(getTestPath(), getTestPath());
    paths.put("/", "/");
    paths.put("/jr:testPath", "/jr:testPath");
    paths.put("/{http://jackrabbit.apache.org}testPath", "/jr:testPath");
    for (String path : paths.keySet()) {
        AbstractAccessControlList acl = createACL(path, Collections.<JackrabbitAccessControlEntry>emptyList(), npMapper);
        assertEquals(paths.get(path), acl.getPath());
    }
}
Also used : HashMap(java.util.HashMap) GlobalNameMapper(org.apache.jackrabbit.oak.namepath.GlobalNameMapper) GlobalNameMapper(org.apache.jackrabbit.oak.namepath.GlobalNameMapper) NameMapper(org.apache.jackrabbit.oak.namepath.NameMapper) LocalNameMapper(org.apache.jackrabbit.oak.namepath.LocalNameMapper) NamePathMapper(org.apache.jackrabbit.oak.namepath.NamePathMapper) NamePathMapperImpl(org.apache.jackrabbit.oak.namepath.NamePathMapperImpl) Test(org.junit.Test)

Example 8 with NamePathMapperImpl

use of org.apache.jackrabbit.oak.namepath.NamePathMapperImpl in project jackrabbit-oak by apache.

the class NodeObserver method contentChanged.

@Override
public void contentChanged(@Nonnull NodeState root, @Nonnull CommitInfo info) {
    if (previousRoot != null) {
        try {
            long start = PERF_LOGGER.start();
            NamePathMapper namePathMapper = new NamePathMapperImpl(new GlobalNameMapper(RootFactory.createReadOnlyRoot(root)));
            Set<String> oakPropertyNames = Sets.newHashSet();
            for (String name : propertyNames) {
                String oakName = namePathMapper.getOakNameOrNull(name);
                if (oakName == null) {
                    LOG.warn("Ignoring invalid property name: {}", name);
                } else {
                    oakPropertyNames.add(oakName);
                }
            }
            NodeState before = previousRoot;
            NodeState after = root;
            EventHandler handler = new FilteredHandler(VISIBLE_FILTER, new NodeEventHandler("/", info, namePathMapper, oakPropertyNames));
            String oakPath = namePathMapper.getOakPath(path);
            if (oakPath == null) {
                LOG.warn("Cannot listen for changes on invalid path: {}", path);
                return;
            }
            for (String oakName : PathUtils.elements(oakPath)) {
                before = before.getChildNode(oakName);
                after = after.getChildNode(oakName);
                handler = handler.getChildHandler(oakName, before, after);
            }
            EventGenerator generator = new EventGenerator(before, after, handler);
            while (!generator.isDone()) {
                generator.generate();
            }
            PERF_LOGGER.end(start, 100, "Generated events (before: {}, after: {})", previousRoot, root);
        } catch (Exception e) {
            LOG.warn("Error while dispatching observation events", e);
        }
    }
    previousRoot = root;
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) GlobalNameMapper(org.apache.jackrabbit.oak.namepath.GlobalNameMapper) NamePathMapper(org.apache.jackrabbit.oak.namepath.NamePathMapper) NamePathMapperImpl(org.apache.jackrabbit.oak.namepath.NamePathMapperImpl)

Example 9 with NamePathMapperImpl

use of org.apache.jackrabbit.oak.namepath.NamePathMapperImpl in project jackrabbit-oak by apache.

the class ACLTest method testGetPath.

@Test
public void testGetPath() {
    NameMapper nameMapper = new GlobalNameMapper(Collections.singletonMap("jr", "http://jackrabbit.apache.org"));
    NamePathMapper npMapper = new NamePathMapperImpl(nameMapper);
    // map of jcr-path to standard jcr-path
    Map<String, String> paths = new HashMap<String, String>();
    paths.put(null, null);
    paths.put(TEST_PATH, TEST_PATH);
    paths.put("/", "/");
    paths.put("/jr:testPath", "/jr:testPath");
    paths.put("/{http://jackrabbit.apache.org}testPath", "/jr:testPath");
    for (String path : paths.keySet()) {
        AbstractAccessControlList acl = createACL(path, Collections.<ACE>emptyList(), npMapper);
        assertEquals(paths.get(path), acl.getPath());
    }
}
Also used : AbstractAccessControlList(org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AbstractAccessControlList) HashMap(java.util.HashMap) GlobalNameMapper(org.apache.jackrabbit.oak.namepath.GlobalNameMapper) NameMapper(org.apache.jackrabbit.oak.namepath.NameMapper) GlobalNameMapper(org.apache.jackrabbit.oak.namepath.GlobalNameMapper) LocalNameMapper(org.apache.jackrabbit.oak.namepath.LocalNameMapper) NamePathMapper(org.apache.jackrabbit.oak.namepath.NamePathMapper) NamePathMapperImpl(org.apache.jackrabbit.oak.namepath.NamePathMapperImpl) Test(org.junit.Test)

Example 10 with NamePathMapperImpl

use of org.apache.jackrabbit.oak.namepath.NamePathMapperImpl in project jackrabbit-oak by apache.

the class ACLTest method testGetOakPath.

@Test
public void testGetOakPath() {
    NamePathMapper npMapper = new NamePathMapperImpl(new LocalNameMapper(singletonMap("oak", "http://jackrabbit.apache.org"), singletonMap("jcr", "http://jackrabbit.apache.org")));
    // map of jcr-path to oak path
    Map<String, String> paths = new HashMap();
    paths.put(null, null);
    paths.put(TEST_PATH, TEST_PATH);
    paths.put("/", "/");
    String oakPath = "/oak:testPath";
    String jcrPath = "/jcr:testPath";
    paths.put(jcrPath, oakPath);
    jcrPath = "/{http://jackrabbit.apache.org}testPath";
    paths.put(jcrPath, oakPath);
    // test if oak-path is properly set.
    for (String path : paths.keySet()) {
        AbstractAccessControlList acl = createACL(path, Collections.<ACE>emptyList(), npMapper);
        assertEquals(paths.get(path), acl.getOakPath());
    }
}
Also used : AbstractAccessControlList(org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AbstractAccessControlList) HashMap(java.util.HashMap) NamePathMapper(org.apache.jackrabbit.oak.namepath.NamePathMapper) NamePathMapperImpl(org.apache.jackrabbit.oak.namepath.NamePathMapperImpl) LocalNameMapper(org.apache.jackrabbit.oak.namepath.LocalNameMapper) Test(org.junit.Test)

Aggregations

NamePathMapperImpl (org.apache.jackrabbit.oak.namepath.NamePathMapperImpl)15 LocalNameMapper (org.apache.jackrabbit.oak.namepath.LocalNameMapper)13 NamePathMapper (org.apache.jackrabbit.oak.namepath.NamePathMapper)12 Test (org.junit.Test)12 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)7 GlobalNameMapper (org.apache.jackrabbit.oak.namepath.GlobalNameMapper)6 HashMap (java.util.HashMap)4 Privilege (javax.jcr.security.Privilege)4 NameMapper (org.apache.jackrabbit.oak.namepath.NameMapper)4 ArrayList (java.util.ArrayList)2 PrivilegeManager (org.apache.jackrabbit.api.security.authorization.PrivilegeManager)2 AbstractAccessControlList (org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AbstractAccessControlList)2 ParseException (java.text.ParseException)1 AccessControlManager (javax.jcr.security.AccessControlManager)1 JackrabbitAccessControlManager (org.apache.jackrabbit.api.security.JackrabbitAccessControlManager)1 Tree (org.apache.jackrabbit.oak.api.Tree)1 ReadWriteNamespaceRegistry (org.apache.jackrabbit.oak.plugins.name.ReadWriteNamespaceRegistry)1 ValueFactoryImpl (org.apache.jackrabbit.oak.plugins.value.jcr.ValueFactoryImpl)1 NodeTypeInfoProvider (org.apache.jackrabbit.oak.query.ast.NodeTypeInfoProvider)1 XPathToSQL2Converter (org.apache.jackrabbit.oak.query.xpath.XPathToSQL2Converter)1