PrincipalBasedPermissionProvider implements AggregatedPermissionProvider, Constants { @Override public @NotNull PrivilegeBits supportedPrivileges(@Nullable Tree tree, @Nullable PrivilegeBits privilegeBits) { return (privilegeBits != null) ? privilegeBits : new PrivilegeBitsProvider(immutableRoot).getBits(PrivilegeConstants.JCR_ALL); } 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 testSupportedPrivileges() { for (PrivilegeBits bits : PrivilegeBits.BUILT_IN.values()) { assertEquals(bits, permissionProvider.supportedPrivileges(null, bits)); assertEquals(bits, permissionProvider.supportedPrivileges(mock(Tree.class), bits)); } }
@Test public void testSupportedPrivilegesAllBits() { PrivilegeBits all = new PrivilegeBitsProvider(root).getBits(PrivilegeConstants.JCR_ALL); assertEquals(all, permissionProvider.supportedPrivileges(null, all)); assertEquals(all, permissionProvider.supportedPrivileges(mock(Tree.class), all)); }
@Test public void testSupportedPrivilegesNullBits() { PrivilegeBits all = new PrivilegeBitsProvider(root).getBits(PrivilegeConstants.JCR_ALL); assertEquals(all, permissionProvider.supportedPrivileges(null, null)); assertEquals(all, permissionProvider.supportedPrivileges(mock(Tree.class), null)); }