List of usage examples for org.springframework.security.core.session SessionRegistry getAllSessions
List<SessionInformation> getAllSessions(Object principal, boolean includeExpiredSessions);
From source file:org.schedoscope.metascope.service.MetascopeUserService.java
public void logoutUser(SessionRegistry sessionRegistry, String username) { final List<Object> allPrincipals = sessionRegistry.getAllPrincipals(); for (final Object principal : allPrincipals) { if (principal instanceof User) { User springUserDetails = (User) principal; if (springUserDetails.getUsername().equals(username)) { for (SessionInformation sessionInformation : sessionRegistry.getAllSessions(principal, true)) { sessionInformation.expireNow(); }/* w ww . ja v a 2s . c o m*/ } } } }