Search in sources :

Example 6 with LocalNameMapper

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

use of org.apache.jackrabbit.oak.namepath.LocalNameMapper 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)

Example 8 with LocalNameMapper

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

the class PrivilegeManagerImplTest method testGetPrivilegeRemappedNamespace.

@Test
public void testGetPrivilegeRemappedNamespace() throws Exception {
    NamePathMapper mapper = new NamePathMapperImpl(new LocalNameMapper(root, ImmutableMap.of("prefix", NamespaceRegistry.NAMESPACE_JCR)));
    Privilege p = create(root, mapper).getPrivilege("prefix:read");
    assertNotNull(p);
    assertNotEquals(Privilege.JCR_READ, p.getName());
    assertNotEquals(PrivilegeConstants.JCR_READ, p.getName());
    assertEquals("prefix:read", p.getName());
}
Also used : NamePathMapper(org.apache.jackrabbit.oak.namepath.NamePathMapper) NamePathMapperImpl(org.apache.jackrabbit.oak.namepath.NamePathMapperImpl) Privilege(javax.jcr.security.Privilege) LocalNameMapper(org.apache.jackrabbit.oak.namepath.LocalNameMapper) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 9 with LocalNameMapper

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

the class QueryUtilTest method testEscapeForQuery.

@Test
public void testEscapeForQuery() throws Exception {
    NamePathMapper namePathMapper = new NamePathMapperImpl(new LocalNameMapper(ImmutableMap.of(NamespaceRegistry.PREFIX_JCR, NamespaceRegistry.NAMESPACE_JCR), ImmutableMap.of("myPrefix", NamespaceRegistry.NAMESPACE_JCR)));
    String value = "'string\\value";
    assertEquals(QueryUtils.escapeForQuery("myPrefix:" + value), QueryUtil.escapeForQuery("jcr:" + value, namePathMapper));
}
Also used : 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)

Example 10 with LocalNameMapper

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

the class AbstractAccessControlListTest 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<String, String>();
    paths.put(null, null);
    paths.put(getTestPath(), getTestPath());
    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.<JackrabbitAccessControlEntry>emptyList(), npMapper);
        assertEquals(paths.get(path), acl.getOakPath());
    }
}
Also used : 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

LocalNameMapper (org.apache.jackrabbit.oak.namepath.LocalNameMapper)10 NamePathMapperImpl (org.apache.jackrabbit.oak.namepath.NamePathMapperImpl)10 NamePathMapper (org.apache.jackrabbit.oak.namepath.NamePathMapper)9 Test (org.junit.Test)9 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)6 Privilege (javax.jcr.security.Privilege)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 PrivilegeManager (org.apache.jackrabbit.api.security.authorization.PrivilegeManager)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 GlobalNameMapper (org.apache.jackrabbit.oak.namepath.GlobalNameMapper)1 NameMapper (org.apache.jackrabbit.oak.namepath.NameMapper)1 ReadWriteNamespaceRegistry (org.apache.jackrabbit.oak.plugins.name.ReadWriteNamespaceRegistry)1 NodeTypeInfoProvider (org.apache.jackrabbit.oak.query.ast.NodeTypeInfoProvider)1 XPathToSQL2Converter (org.apache.jackrabbit.oak.query.xpath.XPathToSQL2Converter)1 AbstractAccessControlList (org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AbstractAccessControlList)1 AbstractAccessControlManager (org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AbstractAccessControlManager)1