- Object contextFromSession = session
- .getAttribute(SPRING_SECURITY_CONTEXT_KEY);
- if (contextFromSession != null
- && contextFromSession instanceof SecurityContext) {
- String storedUserName = ((SecurityContext) contextFromSession)
- .getAuthentication().getName();
- if (storedUserName != null && storedUserName.equals(username)) {
- sessionsList.add(session);
- sessIterator.remove();
- }
- else {
- logger.debug("storedUserName is null or did not match username " + username);
- }
- } else {
- logger.debug("contextFromSession is null or not instance of SecurityContext");
- }