2.4. Events
During the authentication and logout processes PicketLink will fire a few events to indicate that an action should be taken or to indicate that user's state has changed. They provide a nice and clean way to customize behavior, like providing user statistics or enable auditing to your application.
Table 2.1. Authentication Events
Event Type | Description |
---|---|
org.picketlink.authentication.event.PreAuthenticateEvent
| This event is raised just before authentication. |
org.picketlink.authentication.event.LoggedInEvent
| This event is raised when user successfully logs in. |
org.picketlink.authentication.event.PostAuthenticateEvent
| This event is raised just after authentication. |
org.picketlink.authentication.event.AlreadyLoggedInEvent
| This event is fired when an already authenticated user attempts to authenticate again. |
org.picketlink.authentication.event.LoginFailedEvent
| This event is fired when an authentication attempt fails. |
org.picketlink.authentication.event.LockedAccountEvent
|
This event is fired during the authentication process if the Account is disabled.
|
org.picketlink.authentication.event.PreLoggedOutEvent
| This event is raised just before the user un-authenticates. |
org.picketlink.authentication.event.PostLoggedOutEvent
| This event is raised just after the user un-authenticates. |
You can observe any of those events by providing a
@Observer
method to any bean, as follows:
public class AuthenticationAuditor { public void onSuccessFulLogin(@Observes LoggedInEvent event) { // handle user authenticated } public void onLoginFailed(@Observes LoginFailedEvent event) { // login failed } }