Jersey SecurityContext有什么好处,以及如何使用它?

时间:2016-02-24 09:31:35

标签: java rest swagger security-context

我有这样的API

@GET
@Path("/tasks")
@Consumes({ "application/json" })
@Produces({ "application/json" })
@io.swagger.annotations.ApiOperation(value = "List all tasks", notes = "", response = Tasks.class, authorizations = {
@io.swagger.annotations.Authorization(value = "api_key")
}, tags={ "tasks",  })
@io.swagger.annotations.ApiResponses(value = { 
@io.swagger.annotations.ApiResponse(code = 200, message = "An array of tasks", response = Tasks.class),
@io.swagger.annotations.ApiResponse(code = 200, message = "unexpected error", response = Tasks.class) })
public Response getTasks(@Context SecurityContext securityContext) throws NotFoundException {
    return delegate.getTasks(securityContext);
}

参数是Jersey SecurityContext。我的问题是, 我可以用这个securitycontext做什么? 请问这个api的请求怎么样?

我已阅读此https://jersey.java.net/documentation/latest/security.html但我根本没有完全了解SecurityContext。

如果可能,愿望的行为将像用户和密钥一样发送两个信息。

0 个答案:

没有答案