Execute code when successful JAAS login is done

99封情书 提交于 2019-12-11 08:42:17

问题


Is there something like a listener that I can use when JAAS authentication is done successfully, so that I can execute code in that moment?

Right now I'm using JBoss AS 7 with the DatabaseLoginModule.

One way would be to implement a custom login class extending DatabaseLoginModule, however it feels like overkill for this requirement. I not completely clear about some aspects of the Java EE application life cycle, maybe an application or session listener is fired when login is done.

What would be the best way to achieve this?


回答1:


You're on the right track: just write another LoginModule and configure it last, as 'required' so it always gets executed.

I tried making a session-scoped UserBean that implements SessionBindingListener, on the expectation that when bound, that user has just logged in, but it doesn't work quite like that in reality. Trying to do it at the bean level is tricky. You also need to organize it so that that user bean is referenced by every page the user could reach on his first login and by no pages that can be reached without a login, and deciding whether the user really is logged in is problematic as well. JAAS LoginModules are the way to go for both.



来源:https://stackoverflow.com/questions/8124001/execute-code-when-successful-jaas-login-is-done

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