@Test void testUpdateUserEntityClassPermissions() { WebRequest webRequest = mock(WebRequest.class); when(webRequest.getParameter("radio-1")).thenReturn("write"); when(webRequest.getParameter("radio-2")).thenReturn("none"); when(webRequest.getParameter("radio-3")).thenReturn("read"); ObjectIdentity objectIdentity1 = new EntityTypeIdentity(entityType1); ObjectIdentity objectIdentity2 = new EntityTypeIdentity(entityType2); ObjectIdentity objectIdentity3 = new EntityTypeIdentity(entityType3); MutableAcl acl1 = mock(MutableAcl.class); MutableAcl acl2 = mock(MutableAcl.class); MutableAcl acl3 = mock(MutableAcl.class); AccessControlEntry ace1 = mock(AccessControlEntry.class); AccessControlEntry ace2 = mock(AccessControlEntry.class); PrincipalSid sid = new PrincipalSid("Ipsum"); when(ace1.getSid()).thenReturn(sid); when(ace2.getSid()).thenReturn(sid); when(acl1.getEntries()).thenReturn(Collections.singletonList(ace1)); when(acl2.getEntries()).thenReturn(Collections.singletonList(ace2)); when(acl3.getEntries()).thenReturn(Collections.emptyList()); when(mutableAclService.readAclById(objectIdentity1, singletonList(sid))).thenReturn(acl1); when(mutableAclService.readAclById(objectIdentity2, singletonList(sid))).thenReturn(acl2); when(mutableAclService.readAclById(objectIdentity3, singletonList(sid))).thenReturn(acl3); permissionManagerController.updateUserEntityClassPermissions("Ipsum", webRequest); verify(acl1).deleteAce(0); verify(acl1).insertAce(0, PermissionSet.WRITE, sid, true); verify(acl2).deleteAce(0); verify(acl3).insertAce(0, PermissionSet.READ, sid, true); verify(mutableAclService).updateAcl(acl1); verify(mutableAclService).updateAcl(acl2); verify(mutableAclService).updateAcl(acl3); }
@PreAuthorize("hasAnyRole('ROLE_SU')") @Transactional @PostMapping("/update/entityclass/user") @ResponseStatus(HttpStatus.OK) public void updateUserEntityClassPermissions( @RequestParam String username, WebRequest webRequest) { Sid sid = createUserSid(username); updateEntityTypePermissions(webRequest, sid); }
PermissionManagerController extends PluginController { @PreAuthorize("hasAnyRole('ROLE_SU')") @Transactional @PostMapping("/update/entityclass/user") @ResponseStatus(HttpStatus.OK) public void updateUserEntityClassPermissions( @RequestParam String username, WebRequest webRequest) { Sid sid = createUserSid(username); updateEntityTypePermissions(webRequest, sid); } }
PermissionManagerController extends PluginController { @PreAuthorize("hasAnyRole('ROLE_SU')") @Transactional @PostMapping("/update/entityclass/user") @ResponseStatus(HttpStatus.OK) public void updateUserEntityClassPermissions( @RequestParam String username, WebRequest webRequest) { Sid sid = createUserSid(username); updateEntityTypePermissions(webRequest, sid); } PermissionManagerController(
      DataService dataService,
      MutableAclService mutableAclService,
      MutableAclClassService mutableAclClassService,
      SystemEntityTypeRegistry systemEntityTypeRegistry,
      PermissionRegistry permissionRegistry); }
PermissionManagerController extends PluginController { @PreAuthorize("hasAnyRole('ROLE_SU')") @Transactional @PostMapping("/update/entityclass/user") @ResponseStatus(HttpStatus.OK) public void updateUserEntityClassPermissions( @RequestParam String username, WebRequest webRequest) { Sid sid = createUserSid(username); updateEntityTypePermissions(webRequest, sid); } 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 { @PreAuthorize("hasAnyRole('ROLE_SU')") @Transactional @PostMapping("/update/entityclass/user") @ResponseStatus(HttpStatus.OK) public void updateUserEntityClassPermissions( @RequestParam String username, WebRequest webRequest) { Sid sid = createUserSid(username); updateEntityTypePermissions(webRequest, sid); } 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; }