Reputation: 1542
i am running wicket with spring and use spring security , when tomcat session , the one which declared in the web.xml expired
<session-config>
<session-timeout>1</session-timeout>
</session-config>
I want to catch this event using a filter(not overiding existing httpSession or Session ) how can I achive that using spring ?
10x
Upvotes: 2
Views: 2713
Reputation: 10622
You can use a listener class to achieve this. Define a listener component as below:
@Component
public class AppLogoutListener implements
ApplicationListener<SessionDestroyedEvent> {
@Override
public void onApplicationEvent(SessionDestroyedEvent event) {
// from event you can obtain SecurityContexts to work with
}
}
You need to define a session event publisher in your web.xml:
<listener>
<listener-class>org.springframework.security.web.session.HttpSessionEventPublisher</listener-class>
</listener>
Here the HttpSessionEventPublisher
publishes the session life cycle events whenever sessions are created and expired.
Upvotes: 7