PermissionProviderImpl implements PermissionProvider, AccessControlConstants, PermissionConstants, AggregatedPermissionProvider { @Override public boolean isGranted(@NotNull Tree tree, @Nullable PropertyState property, long permissions) { return getCompiledPermissions().isGranted(PermissionUtil.getReadOnlyTree(tree, immutableRoot), property, permissions); } PermissionProviderImpl(@NotNull Root root,
                                  @NotNull String workspaceName,
                                  @NotNull Set<Principal> principals,
                                  @NotNull RestrictionProvider restrictionProvider,
                                  @NotNull ConfigurationParameters options,
                                  @NotNull Context ctx,
                                  @NotNull ProviderCtx providerCtx); @Override void refresh(); @NotNull @Override Set<String> getPrivileges(@Nullable Tree tree); @Override boolean hasPrivileges(@Nullable Tree tree, @NotNull String... privilegeNames); @NotNull @Override RepositoryPermission getRepositoryPermission(); @NotNull @Override TreePermission getTreePermission(@NotNull Tree tree, @NotNull TreePermission parentPermission); @Override boolean isGranted(@NotNull Tree tree, @Nullable PropertyState property, long permissions); @Override boolean isGranted(@NotNull String oakPath, @NotNull String jcrActions); @NotNull @Override PrivilegeBits supportedPrivileges(@Nullable Tree tree, @Nullable PrivilegeBits privilegeBits); @Override long supportedPermissions(@Nullable Tree tree, @Nullable PropertyState property, long permissions); @Override long supportedPermissions(@NotNull TreeLocation location, long permissions); @Override long supportedPermissions(@NotNull TreePermission treePermission, @Nullable PropertyState property, long permissions); @Override boolean isGranted(@NotNull TreeLocation location, long permissions); @NotNull @Override TreePermission getTreePermission(@NotNull Tree tree, @NotNull TreeType type, @NotNull TreePermission parentPermission);  }
@Test public void testIsGrantedPathForReadPaths() { for (String path : READ_PATHS) { assertTrue(pp.isGranted(path, Permissions.getString(Permissions.READ))); assertTrue(pp.isGranted(path, Permissions.getString(Permissions.READ_NODE))); assertTrue(pp.isGranted(path + '/' + JcrConstants.JCR_PRIMARYTYPE, Permissions.getString(Permissions.READ_PROPERTY))); assertFalse(pp.isGranted(path, Permissions.getString(Permissions.READ_ACCESS_CONTROL))); } }
@Test public void testIsGrantedTreeForReadPaths() { for (String path : READ_PATHS) { Tree tree = root.getTree(path); assertTrue(pp.isGranted(tree, null, Permissions.READ)); assertTrue(pp.isGranted(tree, null, Permissions.READ_NODE)); assertTrue(pp.isGranted(tree, tree.getProperty(JcrConstants.JCR_PRIMARYTYPE), Permissions.READ_PROPERTY)); assertFalse(pp.isGranted(tree, null, Permissions.READ_ACCESS_CONTROL)); } }
@Test public void testIsGrantedNonExistingLocation() { TreeLocation location = TreeLocation.create(testSession.getLatestRoot(), "/test/non/existing/tree"); assertTrue(pp.isGranted(location, Permissions.READ)); location = TreeLocation.create(testSession.getLatestRoot(), "/non/existing/tree"); assertFalse(pp.isGranted(location, Permissions.READ)); }
@Test public void testIsGrantedNonExistingVersionStoreLocation() { TreeLocation location = TreeLocation.create(testSession.getLatestRoot(), VersionConstants.VERSION_STORE_PATH + "/non/existing/tree"); assertFalse(pp.isGranted(location, Permissions.READ)); }