Spring security: initializing bean after succesful authentication?
Joined: Nov 01, 2006
New to Spring and Spring Security.
I'm learning by doing (and googling alot!), but I can't find a solution to this problem:
As far as I can see, the chain of event are as follows:
1) UserBean is instantiated by Spring as it's defined as a bean in the web.xml file.
2) The user is presented with my login page
3) User authenticates himself
4) User is redirected to "page1.xhtml" in a secured area if 3) is successful
I would like to do a post-login initialization of the UserBean, as I would like to fetch user info (name, address, etc.) from a database. But I only want this to happen once, since that data of course only should be loaded once, so it should be like 3.5) in the chain of events.
Until now, I'm thinking of these solutions:
1) After login, the user to redirected to a pre-home screen, where the UserBean post-login initialization is handled and then redirected to "page1.xhtml" afterwards.
2) In the "page1.xhtml", I have the following code:
- and then I could do the data base stuff in the getUserName() in UserBean (and handle the one-time-only requirement by a isPostLoginInitialized boolean value)