I have to solve the following scenario, in a Spring Security 3.2.5-RELEASE with Spring Core 4.1.2-RELEASE application running Java 1.7 on wildfly 8.1.
- user 'bob' logs in
- and Admin deletes 'bob'
- if 'bob' logs out, he can't log in. again but he`s current session remains active.
i want to kick 'bob' out
//this doesn't work for (final SessionInformation session : sessionRegistry.getAllSessions(user, true)) { session.expireNow(); }
HttpSessionCreatedEventandHttpSessionDestroyedEventand register it as anApplicationListenerand maintain a cache of SessionId to HttoSession.AskToExpireSessionEvent-SessionRegistryandApplicationEventPublisherso that you could list through the currently active user sessions and find the ones (cause there could be many) which are active for the user you are looking for i.e. 'bob'AskToExpireSessionEventfor each of his sessions.user service:
Application event:
http session caching listener: