Hi All,
does anybody know how to execute code directly after the webcontainer authenticates an user using form-based JAAS-login? Among other duties I inted to log (i.e. to create a log entry) every login attempt into the database. Because the webcontainer handles the authentication automatically there is no way to get called from the framework.
There where two attempts I've done:
1. Writing a web-filter.
2. Writing a custom LoginModule.
The precondition for the first attempt is that the task handling the request "j_security_check" has also to be a filter. This is not the case. "j_security_check" runs completely isolated.
For the second attempt I wrote:
public class LoggedDatabaseServerLoginModule extends DatabaseServerLoginModule{ public boolean login() throws LoginException { boolean loginResult = super.login(); if ( loginResult == true) { write_into_database("user logged in successfully"); } else { write_into_database("user logged in not successfully"); } return loginResult; } }
You can achieve what you want if you set up a filter to check the session for a flag, and to check for login with getRemoteUser()
When login is true but flag is null, do your 'write_into_database' and then put the flag in the session.