Spring security 3 : Save informations about authentification in database
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.
精彩评论