Store and invalidate Java HttpSession from different user

后端 未结 2 1547
情深已故
情深已故 2021-01-25 09:24

Okay. What I want to do is be able to, when I update a user, invalidate any session that they currently have in order to force a refresh of credentials. I don\'t care about bein

2条回答
  •  北荒
    北荒 (楼主)
    2021-01-25 10:05

    Well, as far as I can tell, there's no way around it. Using a request-scoped bean didn't work as I expected (although it did give me good insights into how Spring operates, intercepting field accesses). I ended up using a dirty flag on my SessionHandler (a session-scoped bean) with a very high-priority aspect checking and, if necessary, calling invalidate() on the session in the user's next request. I still ended up having all my SessionHandlers register with a SessionManager, and a @PreDestroy method to unregister them in order to avoid a bunch of null entries in the map.

提交回复
热议问题