parent
7dd013cb9f
commit
de82cb0a85
|
|
@ -5,6 +5,9 @@
|
|||
*/
|
||||
package org.jasig.cas.client.session;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -18,8 +21,7 @@ import javax.servlet.http.HttpSession;
|
|||
* @since 3.1
|
||||
*
|
||||
*/
|
||||
public final class HashMapBackedSessionMappingStorage implements
|
||||
SessionMappingStorage {
|
||||
public final class HashMapBackedSessionMappingStorage implements SessionMappingStorage {
|
||||
|
||||
/**
|
||||
* Maps the ID from the CAS server to the Session.
|
||||
|
|
@ -31,14 +33,28 @@ public final class HashMapBackedSessionMappingStorage implements
|
|||
*/
|
||||
private final Map ID_TO_SESSION_KEY_MAPPING = new HashMap();
|
||||
|
||||
private final Log log = LogFactory.getLog(getClass());
|
||||
|
||||
public synchronized void addSessionById(String mappingId, HttpSession session) {
|
||||
ID_TO_SESSION_KEY_MAPPING.put(session.getId(), mappingId);
|
||||
MANAGED_SESSIONS.put(mappingId, session);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void removeBySessionById(String sessionId) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Attempting to remove Session=[" + sessionId + "]");
|
||||
}
|
||||
|
||||
final String key = (String) ID_TO_SESSION_KEY_MAPPING.get(sessionId);
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
if (key != null) {
|
||||
log.debug("Found mapping for session. Session Removed.");
|
||||
} else {
|
||||
log.debug("No mapping for session found. Ignoring.");
|
||||
}
|
||||
}
|
||||
MANAGED_SESSIONS.remove(key);
|
||||
ID_TO_SESSION_KEY_MAPPING.remove(sessionId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,8 +24,6 @@ import org.apache.commons.logging.LogFactory;
|
|||
*/
|
||||
public final class SingleSignOutHttpSessionListener implements HttpSessionListener {
|
||||
|
||||
private Log log = LogFactory.getLog(getClass());
|
||||
|
||||
private SessionMappingStorage SESSION_MAPPING_STORAGE;
|
||||
|
||||
public void sessionCreated(final HttpSessionEvent event) {
|
||||
|
|
@ -37,11 +35,7 @@ public final class SingleSignOutHttpSessionListener implements HttpSessionListen
|
|||
SESSION_MAPPING_STORAGE = getSessionMappingStorage();
|
||||
}
|
||||
final HttpSession session = event.getSession();
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Removing HttpSession: " + session.getId());
|
||||
}
|
||||
|
||||
|
||||
SESSION_MAPPING_STORAGE.removeBySessionById(session.getId());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue