PrincipalBasedPermissionProvider implements AggregatedPermissionProvider, Constants { @Override public long supportedPermissions(@Nullable Tree tree, @Nullable PropertyState property, long permissions) { return permissions; } 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 testSupportedPermissions() { Tree tree = mock(Tree.class); PropertyState property = mock(PropertyState.class); for (long permission : Permissions.aggregates(Permissions.ALL)) { assertEquals(permission, permissionProvider.supportedPermissions(tree, property, permission)); assertEquals(permission, permissionProvider.supportedPermissions(tree, null, permission)); } assertEquals(Permissions.ALL, permissionProvider.supportedPermissions(tree, property, Permissions.ALL)); assertEquals(Permissions.ALL, permissionProvider.supportedPermissions(tree, null, Permissions.ALL)); }
@Test public void testSupportedPermissionsTreeLocation() { TreeLocation location = mock(TreeLocation.class); for (long permission : Permissions.aggregates(Permissions.ALL)) { assertEquals(permission, permissionProvider.supportedPermissions(location, permission)); } assertEquals(Permissions.ALL, permissionProvider.supportedPermissions(location, Permissions.ALL)); }
@Test public void testSupportedPermissionsTreePermission() { TreePermission tp = mock(TreePermission.class); PropertyState property = mock(PropertyState.class); for (long permission : Permissions.aggregates(Permissions.ALL)) { assertEquals(permission, permissionProvider.supportedPermissions(tp, property, permission)); assertEquals(permission, permissionProvider.supportedPermissions(tp, null, permission)); } assertEquals(Permissions.ALL, permissionProvider.supportedPermissions(tp, property, Permissions.ALL)); assertEquals(Permissions.ALL, permissionProvider.supportedPermissions(tp, null, Permissions.ALL)); }