Search in sources :

Example 1 with GlobalNameMapper

use of org.apache.jackrabbit.oak.namepath.GlobalNameMapper 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 2 with GlobalNameMapper

use of org.apache.jackrabbit.oak.namepath.GlobalNameMapper 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 3 with GlobalNameMapper

use of org.apache.jackrabbit.oak.namepath.GlobalNameMapper 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 4 with GlobalNameMapper

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

the class AccessControlManagerImplTest method before.

@Override
@Before
public void before() throws Exception {
    super.before();
    registerNamespace(TEST_PREFIX, TEST_URI);
    NameMapper nameMapper = new GlobalNameMapper(root);
    npMapper = new NamePathMapperImpl(nameMapper);
    acMgr = new AccessControlManagerImpl(root, npMapper, getSecurityProvider());
    NodeUtil rootNode = new NodeUtil(root.getTree("/"), getNamePathMapper());
    rootNode.addChild(testName, JcrConstants.NT_UNSTRUCTURED);
    root.commit();
    valueFactory = new ValueFactoryImpl(root, npMapper);
    testPrivileges = privilegesFromNames(PrivilegeConstants.JCR_ADD_CHILD_NODES, PrivilegeConstants.JCR_READ);
    testPrincipal = getTestUser().getPrincipal();
}
Also used : 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) ValueFactoryImpl(org.apache.jackrabbit.oak.plugins.value.jcr.ValueFactoryImpl) NamePathMapperImpl(org.apache.jackrabbit.oak.namepath.NamePathMapperImpl) NodeUtil(org.apache.jackrabbit.oak.util.NodeUtil) Before(org.junit.Before)

Example 5 with GlobalNameMapper

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

the class PrivilegeManagerImplTest method testGetPrivilegeExpandedName.

@Test
public void testGetPrivilegeExpandedName() throws Exception {
    Privilege p = create(root, new NamePathMapperImpl(new GlobalNameMapper(root))).getPrivilege(Privilege.JCR_VERSION_MANAGEMENT);
    assertNotNull(p);
    assertNotEquals(Privilege.JCR_VERSION_MANAGEMENT, p.getName());
    assertEquals(PrivilegeConstants.JCR_VERSION_MANAGEMENT, p.getName());
}
Also used : GlobalNameMapper(org.apache.jackrabbit.oak.namepath.GlobalNameMapper) Privilege(javax.jcr.security.Privilege) NamePathMapperImpl(org.apache.jackrabbit.oak.namepath.NamePathMapperImpl) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Aggregations

GlobalNameMapper (org.apache.jackrabbit.oak.namepath.GlobalNameMapper)5 NamePathMapperImpl (org.apache.jackrabbit.oak.namepath.NamePathMapperImpl)5 LocalNameMapper (org.apache.jackrabbit.oak.namepath.LocalNameMapper)3 NameMapper (org.apache.jackrabbit.oak.namepath.NameMapper)3 NamePathMapper (org.apache.jackrabbit.oak.namepath.NamePathMapper)3 Test (org.junit.Test)3 HashMap (java.util.HashMap)2 Privilege (javax.jcr.security.Privilege)1 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)1 ValueFactoryImpl (org.apache.jackrabbit.oak.plugins.value.jcr.ValueFactoryImpl)1 AbstractAccessControlList (org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AbstractAccessControlList)1 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)1 NodeUtil (org.apache.jackrabbit.oak.util.NodeUtil)1 Before (org.junit.Before)1