Search in sources :

Example 1 with NameMapper

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

the class AccessControlManagerImplTest method testGetSupportedPrivilegesIncludingPathConversion.

@Test
public void testGetSupportedPrivilegesIncludingPathConversion() throws Exception {
    List<Privilege> allPrivileges = Arrays.asList(getPrivilegeManager(root).getRegisteredPrivileges());
    List<String> testPaths = new ArrayList();
    testPaths.add('/' + TEST_LOCAL_PREFIX + ":testRoot");
    testPaths.add("/{" + TEST_URI + "}testRoot");
    NameMapper remapped = new LocalNameMapper(root, singletonMap(TEST_LOCAL_PREFIX, TEST_URI));
    AccessControlManager acMgr = createAccessControlManager(root, new NamePathMapperImpl(remapped));
    for (String path : testPaths) {
        Privilege[] supported = acMgr.getSupportedPrivileges(path);
        assertNotNull(supported);
        assertEquals(allPrivileges.size(), supported.length);
        assertTrue(allPrivileges.containsAll(Arrays.asList(supported)));
    }
}
Also used : AbstractAccessControlManager(org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AbstractAccessControlManager) AccessControlManager(javax.jcr.security.AccessControlManager) JackrabbitAccessControlManager(org.apache.jackrabbit.api.security.JackrabbitAccessControlManager) ArrayList(java.util.ArrayList) NameMapper(org.apache.jackrabbit.oak.namepath.NameMapper) LocalNameMapper(org.apache.jackrabbit.oak.namepath.impl.LocalNameMapper) GlobalNameMapper(org.apache.jackrabbit.oak.namepath.impl.GlobalNameMapper) Privilege(javax.jcr.security.Privilege) NamePathMapperImpl(org.apache.jackrabbit.oak.namepath.impl.NamePathMapperImpl) LocalNameMapper(org.apache.jackrabbit.oak.namepath.impl.LocalNameMapper) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 2 with NameMapper

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

the class NamePathMapperImplTest method testJcrToOakKeepIndexNoRemap.

@Test
public void testJcrToOakKeepIndexNoRemap() {
    NameMapper mapper = new GlobalNameMapper(GLOBAL);
    NamePathMapper npMapper = new NamePathMapperImpl(mapper);
    assertEquals("/", npMapper.getOakPath("/"));
    assertEquals("/foo:bar", npMapper.getOakPath("/foo:bar"));
    assertEquals("/foo:bar/quu:qux", npMapper.getOakPath("/foo:bar/quu:qux"));
    assertEquals("foo:bar", npMapper.getOakPath("foo:bar"));
}
Also used : NameMapper(org.apache.jackrabbit.oak.namepath.NameMapper) NamePathMapper(org.apache.jackrabbit.oak.namepath.NamePathMapper) Test(org.junit.Test)

Example 3 with NameMapper

use of org.apache.jackrabbit.oak.namepath.NameMapper 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.impl.GlobalNameMapper) NameMapper(org.apache.jackrabbit.oak.namepath.NameMapper) LocalNameMapper(org.apache.jackrabbit.oak.namepath.impl.LocalNameMapper) GlobalNameMapper(org.apache.jackrabbit.oak.namepath.impl.GlobalNameMapper) ValueFactoryImpl(org.apache.jackrabbit.oak.plugins.value.jcr.ValueFactoryImpl) NamePathMapperImpl(org.apache.jackrabbit.oak.namepath.impl.NamePathMapperImpl) NodeUtil(org.apache.jackrabbit.oak.util.NodeUtil) Before(org.junit.Before)

Example 4 with NameMapper

use of org.apache.jackrabbit.oak.namepath.NameMapper 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.impl.GlobalNameMapper) NameMapper(org.apache.jackrabbit.oak.namepath.NameMapper) LocalNameMapper(org.apache.jackrabbit.oak.namepath.impl.LocalNameMapper) GlobalNameMapper(org.apache.jackrabbit.oak.namepath.impl.GlobalNameMapper) NamePathMapper(org.apache.jackrabbit.oak.namepath.NamePathMapper) NamePathMapperImpl(org.apache.jackrabbit.oak.namepath.impl.NamePathMapperImpl) Test(org.junit.Test)

Aggregations

NameMapper (org.apache.jackrabbit.oak.namepath.NameMapper)4 GlobalNameMapper (org.apache.jackrabbit.oak.namepath.impl.GlobalNameMapper)3 LocalNameMapper (org.apache.jackrabbit.oak.namepath.impl.LocalNameMapper)3 NamePathMapperImpl (org.apache.jackrabbit.oak.namepath.impl.NamePathMapperImpl)3 Test (org.junit.Test)3 NamePathMapper (org.apache.jackrabbit.oak.namepath.NamePathMapper)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 AccessControlManager (javax.jcr.security.AccessControlManager)1 Privilege (javax.jcr.security.Privilege)1 JackrabbitAccessControlManager (org.apache.jackrabbit.api.security.JackrabbitAccessControlManager)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 AbstractAccessControlManager (org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AbstractAccessControlManager)1 NodeUtil (org.apache.jackrabbit.oak.util.NodeUtil)1 Before (org.junit.Before)1