jersey security and session management

前端 未结 7 983
甜味超标
甜味超标 2020-11-29 16:53

Is there a way to get session management or security programatically in Jersey, e.g. web-application session management? Or are transactions, sessions, and security all han

相关标签:
7条回答
  • 2020-11-29 17:30

    I solved this problem by having the clients add the Authorization header and testing it in the REST methode like this:

    @GET
    @PRODUCES(MediaType.APPLICATION_JSON)
    public String returnClients(@Context HTTPServletRequest request(
        String auth = request.getHeader("Authorization");
        Account acc = null;
        if (auth!=null) {
           Account acc = Utils.LoginAccount(auth);
        }
        if (acc == null)
         // not logged in, handle it gracefully
    

    This way there is authentication without starting a session.

    0 讨论(0)
提交回复
热议问题