@Test void testGetPermissionSets() { when(permissionRegistry.getPermissionSets()) .thenReturn( ImmutableMap.of( PermissionSet.READ, singleton(TestPermission.READ), PermissionSet.WRITE, ImmutableSet.of( TestPermission.READ, TestPermission.UPDATE, TestPermission.DELETE))); List<PermissionSetResponse> actual = permissionManagerController.getPermissionSets(); List<PermissionSetResponse> expected = ImmutableList.of( PermissionSetResponse.create( "Read", ImmutableList.of( PermissionResponse.create("TestPermission", "READ", "Description of READ"))), PermissionSetResponse.create( "Write", ImmutableList.of( PermissionResponse.create("TestPermission", "READ", "Description of READ"), PermissionResponse.create("TestPermission", "UPDATE", "Description of UPDATE"), PermissionResponse.create( "TestPermission", "DELETE", "Description of DELETE")))); assertEquals(expected, actual); }
@ApiOperation( value = "Get all permission sets", response = PermissionSetResponse.class, responseContainer = "List") @GetMapping("/permissionSets") @ResponseBody public List<PermissionSetResponse> getPermissionSets() { return permissionRegistry.getPermissionSets().entrySet().stream() .map(entry -> PermissionSetResponse.create(entry.getKey(), entry.getValue())) .sorted(comparing(PermissionSetResponse::getPermissions, comparingInt(List::size))) .collect(toList()); }
PermissionManagerController extends PluginController { @ApiOperation( value = "Get all permission sets", response = PermissionSetResponse.class, responseContainer = "List") @GetMapping("/permissionSets") @ResponseBody public List<PermissionSetResponse> getPermissionSets() { return permissionRegistry.getPermissionSets().entrySet().stream() .map(entry -> PermissionSetResponse.create(entry.getKey(), entry.getValue())) .sorted(comparing(PermissionSetResponse::getPermissions, comparingInt(List::size))) .collect(toList()); } }
PermissionManagerController extends PluginController { @ApiOperation( value = "Get all permission sets", response = PermissionSetResponse.class, responseContainer = "List") @GetMapping("/permissionSets") @ResponseBody public List<PermissionSetResponse> getPermissionSets() { return permissionRegistry.getPermissionSets().entrySet().stream() .map(entry -> PermissionSetResponse.create(entry.getKey(), entry.getValue())) .sorted(comparing(PermissionSetResponse::getPermissions, comparingInt(List::size))) .collect(toList()); } PermissionManagerController(
      DataService dataService,
      MutableAclService mutableAclService,
      MutableAclClassService mutableAclClassService,
      SystemEntityTypeRegistry systemEntityTypeRegistry,
      PermissionRegistry permissionRegistry); }
PermissionManagerController extends PluginController { @ApiOperation( value = "Get all permission sets", response = PermissionSetResponse.class, responseContainer = "List") @GetMapping("/permissionSets") @ResponseBody public List<PermissionSetResponse> getPermissionSets() { return permissionRegistry.getPermissionSets().entrySet().stream() .map(entry -> PermissionSetResponse.create(entry.getKey(), entry.getValue())) .sorted(comparing(PermissionSetResponse::getPermissions, comparingInt(List::size))) .collect(toList()); } PermissionManagerController(
      DataService dataService,
      MutableAclService mutableAclService,
      MutableAclClassService mutableAclClassService,
      SystemEntityTypeRegistry systemEntityTypeRegistry,
      PermissionRegistry permissionRegistry); @GetMapping String init(Model model); @PreAuthorize("hasAnyRole('ROLE_SU')") @Transactional(readOnly = true) @GetMapping("/entityclass/role/{rolename}") @ResponseBody Permissions getRoleEntityClassPermissions(@PathVariable String rolename); @PreAuthorize("hasAnyRole('ROLE_SU')") @Transactional(readOnly = true) @GetMapping("/plugin/user/{username}") @ResponseBody Permissions getUserPluginPermissions(@PathVariable String username); @PreAuthorize("hasAnyRole('ROLE_SU')") @Transactional(readOnly = true) @GetMapping("/package/user/{username}") @ResponseBody Permissions getUserPackagePermissions(@PathVariable String username); @PreAuthorize("hasAnyRole('ROLE_SU')") @Transactional(readOnly = true) @GetMapping("/package/role/{rolename}") @ResponseBody Permissions getRolePackagePermissions(@PathVariable String rolename); @PreAuthorize("hasAnyRole('ROLE_SU')") @Transactional(readOnly = true) @GetMapping("/entityclass/user/{username}") @ResponseBody Permissions getUserEntityClassPermissions(@PathVariable String username); @PreAuthorize("hasAnyRole('ROLE_SU')") @Transactional @PostMapping("/update/plugin/role") @ResponseStatus(HttpStatus.OK) void updateRolePluginPermissions(@RequestParam String rolename, WebRequest webRequest); @PreAuthorize("hasAnyRole('ROLE_SU')") @Transactional @PostMapping("/update/entityclass/role") @ResponseStatus(HttpStatus.OK) void updateRoleEntityClassPermissions(
      @RequestParam String rolename, WebRequest webRequest); @PreAuthorize("hasAnyRole('ROLE_SU')") @Transactional @PostMapping("/update/package/role") @ResponseStatus(HttpStatus.OK) void updateRolePackagePermissions(@RequestParam String rolename, WebRequest webRequest); @PreAuthorize("hasAnyRole('ROLE_SU')") @Transactional @PostMapping("/update/package/user") @ResponseStatus(HttpStatus.OK) void updateUserPackagePermissions(@RequestParam String username, WebRequest webRequest); @PreAuthorize("hasAnyRole('ROLE_SU')") @Transactional @PostMapping("/update/plugin/user") @ResponseStatus(HttpStatus.OK) void updateUserPluginPermissions(@RequestParam String username, WebRequest webRequest); @PreAuthorize("hasAnyRole('ROLE_SU')") @Transactional(readOnly = true) @GetMapping("/plugin/role/{rolename}") @ResponseBody Permissions getRolePluginPermissions(@PathVariable String rolename); @PreAuthorize("hasAnyRole('ROLE_SU')") @Transactional @PostMapping("/update/entityclass/user") @ResponseStatus(HttpStatus.OK) void updateUserEntityClassPermissions(
      @RequestParam String username, WebRequest webRequest); @PreAuthorize("hasAnyRole('ROLE_SU')") @Transactional @PostMapping("/update/entityclass/rls") @ResponseStatus(HttpStatus.OK) void updateEntityClassRls(@Valid @RequestBody EntityTypeRlsRequest entityTypeRlsRequest); @ApiOperation( value = "Get all permission sets", response = PermissionSetResponse.class, responseContainer = "List") @GetMapping("/permissionSets") @ResponseBody List<PermissionSetResponse> getPermissionSets(); @ExceptionHandler(RuntimeException.class) @ResponseBody @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) Map<String, String> handleRuntimeException(RuntimeException e); }
PermissionManagerController extends PluginController { @ApiOperation( value = "Get all permission sets", response = PermissionSetResponse.class, responseContainer = "List") @GetMapping("/permissionSets") @ResponseBody public List<PermissionSetResponse> getPermissionSets() { return permissionRegistry.getPermissionSets().entrySet().stream() .map(entry -> PermissionSetResponse.create(entry.getKey(), entry.getValue())) .sorted(comparing(PermissionSetResponse::getPermissions, comparingInt(List::size))) .collect(toList()); } PermissionManagerController(
      DataService dataService,
      MutableAclService mutableAclService,
      MutableAclClassService mutableAclClassService,
      SystemEntityTypeRegistry systemEntityTypeRegistry,
      PermissionRegistry permissionRegistry); @GetMapping String init(Model model); @PreAuthorize("hasAnyRole('ROLE_SU')") @Transactional(readOnly = true) @GetMapping("/entityclass/role/{rolename}") @ResponseBody Permissions getRoleEntityClassPermissions(@PathVariable String rolename); @PreAuthorize("hasAnyRole('ROLE_SU')") @Transactional(readOnly = true) @GetMapping("/plugin/user/{username}") @ResponseBody Permissions getUserPluginPermissions(@PathVariable String username); @PreAuthorize("hasAnyRole('ROLE_SU')") @Transactional(readOnly = true) @GetMapping("/package/user/{username}") @ResponseBody Permissions getUserPackagePermissions(@PathVariable String username); @PreAuthorize("hasAnyRole('ROLE_SU')") @Transactional(readOnly = true) @GetMapping("/package/role/{rolename}") @ResponseBody Permissions getRolePackagePermissions(@PathVariable String rolename); @PreAuthorize("hasAnyRole('ROLE_SU')") @Transactional(readOnly = true) @GetMapping("/entityclass/user/{username}") @ResponseBody Permissions getUserEntityClassPermissions(@PathVariable String username); @PreAuthorize("hasAnyRole('ROLE_SU')") @Transactional @PostMapping("/update/plugin/role") @ResponseStatus(HttpStatus.OK) void updateRolePluginPermissions(@RequestParam String rolename, WebRequest webRequest); @PreAuthorize("hasAnyRole('ROLE_SU')") @Transactional @PostMapping("/update/entityclass/role") @ResponseStatus(HttpStatus.OK) void updateRoleEntityClassPermissions(
      @RequestParam String rolename, WebRequest webRequest); @PreAuthorize("hasAnyRole('ROLE_SU')") @Transactional @PostMapping("/update/package/role") @ResponseStatus(HttpStatus.OK) void updateRolePackagePermissions(@RequestParam String rolename, WebRequest webRequest); @PreAuthorize("hasAnyRole('ROLE_SU')") @Transactional @PostMapping("/update/package/user") @ResponseStatus(HttpStatus.OK) void updateUserPackagePermissions(@RequestParam String username, WebRequest webRequest); @PreAuthorize("hasAnyRole('ROLE_SU')") @Transactional @PostMapping("/update/plugin/user") @ResponseStatus(HttpStatus.OK) void updateUserPluginPermissions(@RequestParam String username, WebRequest webRequest); @PreAuthorize("hasAnyRole('ROLE_SU')") @Transactional(readOnly = true) @GetMapping("/plugin/role/{rolename}") @ResponseBody Permissions getRolePluginPermissions(@PathVariable String rolename); @PreAuthorize("hasAnyRole('ROLE_SU')") @Transactional @PostMapping("/update/entityclass/user") @ResponseStatus(HttpStatus.OK) void updateUserEntityClassPermissions(
      @RequestParam String username, WebRequest webRequest); @PreAuthorize("hasAnyRole('ROLE_SU')") @Transactional @PostMapping("/update/entityclass/rls") @ResponseStatus(HttpStatus.OK) void updateEntityClassRls(@Valid @RequestBody EntityTypeRlsRequest entityTypeRlsRequest); @ApiOperation( value = "Get all permission sets", response = PermissionSetResponse.class, responseContainer = "List") @GetMapping("/permissionSets") @ResponseBody List<PermissionSetResponse> getPermissionSets(); @ExceptionHandler(RuntimeException.class) @ResponseBody @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) Map<String, String> handleRuntimeException(RuntimeException e); static final String URI; static final String RADIO; }