PrincipalBasedPermissionProvider implements AggregatedPermissionProvider, Constants { @Override public boolean hasPrivileges(@Nullable Tree tree, @NotNull String... privilegeNames) { return getGrantedPrivilegeBits(tree).includes(mgrProvider.getPrivilegeBitsProvider().getBits(privilegeNames)); } PrincipalBasedPermissionProvider(@NotNull Root root,
                                     @NotNull String workspaceName,
                                     @NotNull Iterable<String> principalPaths,
                                     @NotNull PrincipalBasedAuthorizationConfiguration authorizationConfiguration); @Override void refresh(); @NotNull @Override Set<String> getPrivileges(@Nullable Tree tree); @Override boolean hasPrivileges(@Nullable Tree tree, @NotNull String... privilegeNames); @Override @NotNull RepositoryPermission getRepositoryPermission(); @Override @NotNull 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); @Override @NotNull 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); @Override @NotNull TreePermission getTreePermission(@NotNull Tree tree, @NotNull TreeType type, @NotNull TreePermission parentPermission);  }
@Test public void testHasPrivileges() { assertTrue(permissionProvider.hasPrivileges(root.getTree(childPath), PrivilegeConstants.JCR_READ)); assertFalse(permissionProvider.hasPrivileges(root.getTree(childPath), PrivilegeConstants.JCR_READ, PrivilegeConstants.JCR_REMOVE_NODE)); assertTrue(permissionProvider.hasPrivileges(root.getTree(childPath + "/folder"), PrivilegeConstants.JCR_READ, PrivilegeConstants.JCR_REMOVE_NODE)); assertFalse(permissionProvider.hasPrivileges(root.getTree(childPath), PrivilegeConstants.JCR_READ, PrivilegeConstants.JCR_VERSION_MANAGEMENT)); assertTrue(permissionProvider.hasPrivileges(root.getTree(TEST_OAK_PATH), PrivilegeConstants.JCR_READ, PrivilegeConstants.JCR_VERSION_MANAGEMENT)); }