@Test void testDeletePermission() throws Exception { when(entityHelper.getObjectIdentity("typeId", "identifier")).thenReturn(objectIdentity); String requestJson = "{" + "user:user1" + "}"; mockMvc .perform( MockMvcRequestBuilders.delete(BASE_URI + "/typeId/identifier") .contentType(APPLICATION_JSON_UTF8) .content(requestJson)) .andExpect(status().isNoContent()); verify(permissionsService).deletePermission(user1, objectIdentity); }
@DeleteMapping(value = "{" + TYPE_ID + "}/{" + OBJECT_ID + "}") @ApiOperation( value = "Delete a permission on an object for a single user or role", code = 204, response = ResponseEntity.class) public ResponseEntity deletePermission( @PathVariable(value = TYPE_ID) String typeId, @PathVariable(value = OBJECT_ID) String identifier, @RequestBody DeletePermissionRequest request) { Sid sid = getSid(request.getUser(), request.getRole()); permissionService.deletePermission(sid, entityHelper.getObjectIdentity(typeId, identifier)); return ResponseEntity.noContent().build(); }
PermissionsController extends ApiController { @DeleteMapping(value = "{" + TYPE_ID + "}/{" + OBJECT_ID + "}") @ApiOperation( value = "Delete a permission on an object for a single user or role", code = 204, response = ResponseEntity.class) public ResponseEntity deletePermission( @PathVariable(value = TYPE_ID) String typeId, @PathVariable(value = OBJECT_ID) String identifier, @RequestBody DeletePermissionRequest request) { Sid sid = getSid(request.getUser(), request.getRole()); permissionService.deletePermission(sid, entityHelper.getObjectIdentity(typeId, identifier)); return ResponseEntity.noContent().build(); } }
PermissionsController extends ApiController { @DeleteMapping(value = "{" + TYPE_ID + "}/{" + OBJECT_ID + "}") @ApiOperation( value = "Delete a permission on an object for a single user or role", code = 204, response = ResponseEntity.class) public ResponseEntity deletePermission( @PathVariable(value = TYPE_ID) String typeId, @PathVariable(value = OBJECT_ID) String identifier, @RequestBody DeletePermissionRequest request) { Sid sid = getSid(request.getUser(), request.getRole()); permissionService.deletePermission(sid, entityHelper.getObjectIdentity(typeId, identifier)); return ResponseEntity.noContent().build(); } PermissionsController(
      PermissionService permissionService,
      RSQLParser rsqlParser,
      ObjectIdentityService objectIdentityService,
      UserRoleTools userRoleTools,
      EntityHelper entityHelper); }
PermissionsController extends ApiController { @DeleteMapping(value = "{" + TYPE_ID + "}/{" + OBJECT_ID + "}") @ApiOperation( value = "Delete a permission on an object for a single user or role", code = 204, response = ResponseEntity.class) public ResponseEntity deletePermission( @PathVariable(value = TYPE_ID) String typeId, @PathVariable(value = OBJECT_ID) String identifier, @RequestBody DeletePermissionRequest request) { Sid sid = getSid(request.getUser(), request.getRole()); permissionService.deletePermission(sid, entityHelper.getObjectIdentity(typeId, identifier)); return ResponseEntity.noContent().build(); } PermissionsController(
      PermissionService permissionService,
      RSQLParser rsqlParser,
      ObjectIdentityService objectIdentityService,
      UserRoleTools userRoleTools,
      EntityHelper entityHelper); @PostMapping(value = TYPES + "/{" + TYPE_ID + "}") @ApiOperation( value = "Create a type this enables row level secure an entity", code = 201, response = ResponseEntity.class) ResponseEntity enableRLS(
      HttpServletRequest request, @PathVariable(value = TYPE_ID) String typeId); @DeleteMapping(value = TYPES + "/{" + TYPE_ID + "}") @ApiOperation( value = "Delete a type this removes row level security from an entity", code = 204, response = ResponseEntity.class) ResponseEntity disableRLS(@PathVariable(value = TYPE_ID) String typeId); @GetMapping(value = TYPES) @ApiOperation(value = "Get a list of ACL types in the system", response = ApiResponse.class) ApiResponse getRlsEntities(); @GetMapping(value = TYPES + "/permissions/{" + TYPE_ID + "}") @ApiOperation( value = "Get a list of permissions that can be used on a type", response = ApiResponse.class) ApiResponse getSuitablePermissions(@PathVariable(value = TYPE_ID) String typeId); @PostMapping(value = OBJECTS + "/{" + TYPE_ID + "}/{" + OBJECT_ID + "}") @ApiOperation(value = "Create a type for a entity", code = 201, response = ResponseEntity.class) ResponseEntity createAcl(
      HttpServletRequest request,
      @PathVariable(TYPE_ID) String typeId,
      @PathVariable(OBJECT_ID) String identifier); @GetMapping(value = OBJECTS + "/{" + TYPE_ID + "}") @ApiOperation( value = "Get a list object's for a type. Typically this is a row in a row level secured entity.", response = PagedApiResponse.class) PagedApiResponse getAcls(
      @PathVariable(value = TYPE_ID) String typeId,
      @RequestParam(value = "page", required = false) Integer page,
      @RequestParam(value = "pageSize", required = false) Integer pageSize); @GetMapping(value = "{" + TYPE_ID + "}/{" + OBJECT_ID + "}") @ApiOperation(value = "Gets permissions on a single object", response = ApiResponse.class) ApiResponse getPermissionsForObject(
      @PathVariable(TYPE_ID) String typeId,
      @PathVariable(OBJECT_ID) String identifier,
      @RequestParam(value = "q", required = false) String queryString,
      @RequestParam(value = "inheritance", defaultValue = "false", required = false)
          boolean inheritance); @GetMapping(value = "{" + TYPE_ID + "}") @ApiOperation( value = "Gets all permissions for all objects of a certain type", response = PagedApiResponse.class) PagedApiResponse getPermissionsForType(
      @PathVariable(value = TYPE_ID) String typeId,
      @RequestParam(value = "q", required = false) String queryString,
      @RequestParam(value = "page", required = false) Integer page,
      @RequestParam(value = "pageSize", required = false) Integer pageSize,
      @RequestParam(value = "inheritance", defaultValue = "false", required = false)
          boolean inheritance); @GetMapping() @ApiOperation( value = "Gets all permissions for one or more users or roles", response = ApiResponse.class) ApiResponse getPermissionsForUser(
      @RequestParam(value = "q", required = false) String queryString,
      @RequestParam(value = "inheritance", defaultValue = "false", required = false)
          boolean inheritance); @PatchMapping(value = "{" + TYPE_ID + "}/{" + OBJECT_ID + "}") @ApiOperation( value = "Update a permission on a single object for one or more users or roles", code = 204, response = ResponseEntity.class) ResponseEntity setPermission(
      @PathVariable(value = TYPE_ID) String typeId,
      @PathVariable(value = OBJECT_ID) String identifier,
      @RequestBody SetObjectPermissionRequest request); @PatchMapping(value = "{" + TYPE_ID + "}") @ApiOperation( value = "Update a list of permissions on objects of a certain type", code = 204, response = ResponseEntity.class) ResponseEntity setTypePermissions(
      @PathVariable(value = TYPE_ID) String typeId,
      @RequestBody SetTypePermissionsRequest request); @PostMapping(value = "{" + TYPE_ID + "}") @ApiOperation( value = "Create a list of permissions on an type for a single user or role", code = 201, response = ResponseEntity.class) ResponseEntity<Object> createPermissions(
      HttpServletRequest request,
      @PathVariable(value = TYPE_ID) String typeId,
      @RequestBody SetTypePermissionsRequest setTypePermissionsRequest); @PostMapping(value = "{" + TYPE_ID + "}/{" + OBJECT_ID + "}") @ApiOperation( value = "Create a permission on an object for a single user or role", code = 201, response = ResponseEntity.class) ResponseEntity<Object> createPermission(
      HttpServletRequest request,
      @PathVariable(value = TYPE_ID) String typeId,
      @PathVariable(value = OBJECT_ID) String identifier,
      @RequestBody SetObjectPermissionRequest setIdentityPermissionRequest); @DeleteMapping(value = "{" + TYPE_ID + "}/{" + OBJECT_ID + "}") @ApiOperation( value = "Delete a permission on an object for a single user or role", code = 204, response = ResponseEntity.class) ResponseEntity deletePermission(
      @PathVariable(value = TYPE_ID) String typeId,
      @PathVariable(value = OBJECT_ID) String identifier,
      @RequestBody DeletePermissionRequest request); }
PermissionsController extends ApiController { @DeleteMapping(value = "{" + TYPE_ID + "}/{" + OBJECT_ID + "}") @ApiOperation( value = "Delete a permission on an object for a single user or role", code = 204, response = ResponseEntity.class) public ResponseEntity deletePermission( @PathVariable(value = TYPE_ID) String typeId, @PathVariable(value = OBJECT_ID) String identifier, @RequestBody DeletePermissionRequest request) { Sid sid = getSid(request.getUser(), request.getRole()); permissionService.deletePermission(sid, entityHelper.getObjectIdentity(typeId, identifier)); return ResponseEntity.noContent().build(); } PermissionsController(
      PermissionService permissionService,
      RSQLParser rsqlParser,
      ObjectIdentityService objectIdentityService,
      UserRoleTools userRoleTools,
      EntityHelper entityHelper); @PostMapping(value = TYPES + "/{" + TYPE_ID + "}") @ApiOperation( value = "Create a type this enables row level secure an entity", code = 201, response = ResponseEntity.class) ResponseEntity enableRLS(
      HttpServletRequest request, @PathVariable(value = TYPE_ID) String typeId); @DeleteMapping(value = TYPES + "/{" + TYPE_ID + "}") @ApiOperation( value = "Delete a type this removes row level security from an entity", code = 204, response = ResponseEntity.class) ResponseEntity disableRLS(@PathVariable(value = TYPE_ID) String typeId); @GetMapping(value = TYPES) @ApiOperation(value = "Get a list of ACL types in the system", response = ApiResponse.class) ApiResponse getRlsEntities(); @GetMapping(value = TYPES + "/permissions/{" + TYPE_ID + "}") @ApiOperation( value = "Get a list of permissions that can be used on a type", response = ApiResponse.class) ApiResponse getSuitablePermissions(@PathVariable(value = TYPE_ID) String typeId); @PostMapping(value = OBJECTS + "/{" + TYPE_ID + "}/{" + OBJECT_ID + "}") @ApiOperation(value = "Create a type for a entity", code = 201, response = ResponseEntity.class) ResponseEntity createAcl(
      HttpServletRequest request,
      @PathVariable(TYPE_ID) String typeId,
      @PathVariable(OBJECT_ID) String identifier); @GetMapping(value = OBJECTS + "/{" + TYPE_ID + "}") @ApiOperation( value = "Get a list object's for a type. Typically this is a row in a row level secured entity.", response = PagedApiResponse.class) PagedApiResponse getAcls(
      @PathVariable(value = TYPE_ID) String typeId,
      @RequestParam(value = "page", required = false) Integer page,
      @RequestParam(value = "pageSize", required = false) Integer pageSize); @GetMapping(value = "{" + TYPE_ID + "}/{" + OBJECT_ID + "}") @ApiOperation(value = "Gets permissions on a single object", response = ApiResponse.class) ApiResponse getPermissionsForObject(
      @PathVariable(TYPE_ID) String typeId,
      @PathVariable(OBJECT_ID) String identifier,
      @RequestParam(value = "q", required = false) String queryString,
      @RequestParam(value = "inheritance", defaultValue = "false", required = false)
          boolean inheritance); @GetMapping(value = "{" + TYPE_ID + "}") @ApiOperation( value = "Gets all permissions for all objects of a certain type", response = PagedApiResponse.class) PagedApiResponse getPermissionsForType(
      @PathVariable(value = TYPE_ID) String typeId,
      @RequestParam(value = "q", required = false) String queryString,
      @RequestParam(value = "page", required = false) Integer page,
      @RequestParam(value = "pageSize", required = false) Integer pageSize,
      @RequestParam(value = "inheritance", defaultValue = "false", required = false)
          boolean inheritance); @GetMapping() @ApiOperation( value = "Gets all permissions for one or more users or roles", response = ApiResponse.class) ApiResponse getPermissionsForUser(
      @RequestParam(value = "q", required = false) String queryString,
      @RequestParam(value = "inheritance", defaultValue = "false", required = false)
          boolean inheritance); @PatchMapping(value = "{" + TYPE_ID + "}/{" + OBJECT_ID + "}") @ApiOperation( value = "Update a permission on a single object for one or more users or roles", code = 204, response = ResponseEntity.class) ResponseEntity setPermission(
      @PathVariable(value = TYPE_ID) String typeId,
      @PathVariable(value = OBJECT_ID) String identifier,
      @RequestBody SetObjectPermissionRequest request); @PatchMapping(value = "{" + TYPE_ID + "}") @ApiOperation( value = "Update a list of permissions on objects of a certain type", code = 204, response = ResponseEntity.class) ResponseEntity setTypePermissions(
      @PathVariable(value = TYPE_ID) String typeId,
      @RequestBody SetTypePermissionsRequest request); @PostMapping(value = "{" + TYPE_ID + "}") @ApiOperation( value = "Create a list of permissions on an type for a single user or role", code = 201, response = ResponseEntity.class) ResponseEntity<Object> createPermissions(
      HttpServletRequest request,
      @PathVariable(value = TYPE_ID) String typeId,
      @RequestBody SetTypePermissionsRequest setTypePermissionsRequest); @PostMapping(value = "{" + TYPE_ID + "}/{" + OBJECT_ID + "}") @ApiOperation( value = "Create a permission on an object for a single user or role", code = 201, response = ResponseEntity.class) ResponseEntity<Object> createPermission(
      HttpServletRequest request,
      @PathVariable(value = TYPE_ID) String typeId,
      @PathVariable(value = OBJECT_ID) String identifier,
      @RequestBody SetObjectPermissionRequest setIdentityPermissionRequest); @DeleteMapping(value = "{" + TYPE_ID + "}/{" + OBJECT_ID + "}") @ApiOperation( value = "Delete a permission on an object for a single user or role", code = 204, response = ResponseEntity.class) ResponseEntity deletePermission(
      @PathVariable(value = TYPE_ID) String typeId,
      @PathVariable(value = OBJECT_ID) String identifier,
      @RequestBody DeletePermissionRequest request); static final String BASE_URI; static final String TYPES; static final String OBJECTS; }