开发者

Spring security 3 : Save informations about authentification in database

开发者 https://www.devze.com 2023-02-13 08:36 出处:网络
I need to save some informations ab开发者_JAVA技巧out user when he is authentificated like his IP Adress and authentification date and other stuff into the database. In other words i want to keepconne

I need to save some informations ab开发者_JAVA技巧out user when he is authentificated like his IP Adress and authentification date and other stuff into the database. In other words i want to keep connections history. I am using a custom authentification provider, an implementation of UserDetailsService but i dont know where to put code of saving these informations.

Any suggestions?


Since the AbstractAuthenticationProcessingFilter implements ApplicationEventPublisherAware and fires the event InteractiveAuthenticationSuccessEvent on successful authentication, you just need to listen to that event and update database. This will keep your database code clean and decoupled from the security code.


You need to implement your custom AuthenticationSuccessHandler.

0

精彩评论

暂无评论...
验证码 换一张
取 消