PermissionProviderImpl implements PermissionProvider, AccessControlConstants, PermissionConstants, AggregatedPermissionProvider { @Override public boolean hasPrivileges(@Nullable Tree tree, @NotNull String... privilegeNames) { return getCompiledPermissions().hasPrivileges(PermissionUtil.getReadOnlyTreeOrNull(tree, immutableRoot), privilegeNames); } 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 testHasPrivileges() { assertTrue(pp.hasPrivileges(null)); assertTrue(pp.hasPrivileges(null, new String[0])); assertFalse(pp.hasPrivileges(null, PrivilegeConstants.JCR_WORKSPACE_MANAGEMENT)); }
@Test public void testHasPrivilegesForReadPaths() { for (String path : READ_PATHS) { Tree tree = root.getTree(path); assertTrue(pp.hasPrivileges(tree, PrivilegeConstants.JCR_READ)); assertTrue(pp.hasPrivileges(tree, PrivilegeConstants.REP_READ_NODES)); assertTrue(pp.hasPrivileges(tree, PrivilegeConstants.REP_READ_PROPERTIES)); assertFalse(pp.hasPrivileges(tree, PrivilegeConstants.JCR_READ_ACCESS_CONTROL)); } assertFalse(pp.hasPrivileges(null, PrivilegeConstants.JCR_READ)); }