MountPermissionProvider extends PermissionProviderImpl { @NotNull public static String getPermissionRootName(@NotNull Mount mount, @NotNull String workspace) { if (mount.isDefault()) { return workspace; } else { return mount.getPathFragmentName() + "-" + workspace; } } MountPermissionProvider(@NotNull Root root, @NotNull String workspaceName,
                                   @NotNull Set<Principal> principals, @NotNull RestrictionProvider restrictionProvider,
                                   @NotNull ConfigurationParameters options, @NotNull Context ctx,
                                   @NotNull ProviderCtx providerCtx); @NotNull static String getPermissionRootName(@NotNull Mount mount, @NotNull String workspace);  }
@Test public void multiplexingProvider() throws Exception { Tree permStore = root.getTree(PERMISSIONS_STORE_PATH); String wsName = adminSession.getWorkspaceName(); assertTrue(permStore.hasChild(wsName)); for (Mount m : mountInfoProvider.getNonDefaultMounts()) { assertTrue(permStore.hasChild(MountPermissionProvider.getPermissionRootName(m, wsName))); } Tree rootNode = root.getTree("/"); Tree test = TreeUtil.addChild(rootNode, testNode, JcrConstants.NT_UNSTRUCTURED); Tree content = TreeUtil.addChild(test, "content", JcrConstants.NT_UNSTRUCTURED); root.commit(); Principal p = getTestUser().getPrincipal(); setPrivileges(p, test.getPath(), true, JCR_READ); setPrivileges(p, content.getPath(), false, JCR_READ); permStore = root.getTree(PERMISSIONS_STORE_PATH); assertFalse(permStore.getChild(wsName).hasChild(p.getName())); for (Mount m : mountInfoProvider.getNonDefaultMounts()) { Tree mps = permStore.getChild(MountPermissionProvider.getPermissionRootName(m, wsName)); assertTrue(mps.hasChild(p.getName())); } try (ContentSession testSession = createTestSession()) { Root r = testSession.getLatestRoot(); assertFalse(r.getTree("/").exists()); assertTrue(r.getTree(test.getPath()).exists()); assertFalse(r.getTree(content.getPath()).exists()); } }
@Test public void testPermissionProviderName() { assertEquals("oak.default", MountPermissionProvider.getPermissionRootName(mountInfoProvider.getDefaultMount(), "oak.default")); assertEquals("oak:mount-testMount-oak.default", MountPermissionProvider .getPermissionRootName(mountInfoProvider.getMountByName("testMount"), "oak.default")); }