How to get a session Object in the ContainerRequest to can use the annotation @RolesAllowed(Role_user)?

前端 未结 1 1635
孤城傲影
孤城傲影 2021-02-15 10:48

I am building an application using App Engine with Jersey. I would like use the annotation @RolesAllowed(Role_user) who permit to create a filter in the request.

1条回答
  •  天涯浪人
    2021-02-15 11:36

    I'm pretty not sure whether you can inject a HttpServletRequest on top of the ContainerRequestFilter in jersey but you still can do it programmatically instead of using annotations:

    @Override
    public ContainerRequest filter(ContainerRequest request) {
        if(request.isUserInRole("SOME_ROLE")){
        //process some treatement
        }
        return request;
    }
    

    BR.

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