I have an application running in JBoss AS6. Authentication is working using the “FORM” auth method, and the user is logging in correctly.
I would like to be able to call a piece of custom, static code whenever a user successfully logs in.
Unfortunately, I cannot find any listener, or hook, or callback, which will execute code on successful login. The HttpSessionListener does have an event for “sessionCreated”, but this is called as soon as a user accesses any page, even if they have not successfully logged in. That means that even viewing the login form triggers the event.
Could anyone point me to some documentation for JBoss AS 6 (or equivalent) which shows how to run custom code at the point when a user first successfully logs in?
Thanks in advance.
You can add a
ServletFilterimplementation in front of secured Servlet.At each invocation, the filter will test a boolean flag
notFirstCallinHttpSession.If the flag is not present, the request is the first one after user’s login. It can invoke the specified job and then set the flag
notFirstCallto mark the job as done for this session.