Glassfish Security: Role changes should take effect immediately

时间秒杀一切 提交于 2019-12-13 02:21:36

问题


I'm using a JDBC realm for authentication and authorization. When I remove a role from a user in the DB, the changes are not reflected immediately in the application, only at the next user login. Is it possible that role changes take effect immediately? I know I have to put this logic in the application itself, but I don't know how to apply this changes to a specific user while he's logged in. I'm using GF 3.1.


回答1:


There are no API-provided ways for this. Your best bet is to wrap the logged-in user (the UserPrincipal) in your own User model object (can be as good a (JPA) entity of the very same table) which allows changing the role and then collect all logged-in users in some static/application-wide set/map with help of a Filter and HttpSessionListener. Finally, in the admin panel, just check if the User is there in the set/map then get and alter it accordingly. It'll be reflected immediately for the actual enduser.

Related questions

  • How to listen on realm events?
  • How to check which users are all logged-in?


来源:https://stackoverflow.com/questions/4774361/glassfish-security-role-changes-should-take-effect-immediately

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!