use of javax.servlet.http.HttpSessionListener in project jodd by oblac.
the class SessionMonitor method sessionCreated.
// ---------------------------------------------------------------- broadcast
/**
* Stores session in map and broadcasts event to registered listeners.
*/
@Override
public void sessionCreated(final HttpSessionEvent httpSessionEvent) {
HttpSession session = httpSessionEvent.getSession();
sessionMap.putIfAbsent(session.getId(), session);
for (HttpSessionListener listener : listeners) {
listener.sessionCreated(httpSessionEvent);
}
}
use of javax.servlet.http.HttpSessionListener in project drill by apache.
the class WebServer method createSessionHandler.
/**
* Create a {@link SessionHandler}
*
* @param securityHandler Set of init parameters that are used by the Authentication
* @return session handler
*/
private SessionHandler createSessionHandler(final SecurityHandler securityHandler) {
SessionHandler sessionHandler = new SessionHandler();
// SessionManager sessionManager = new HashSessionManager();
sessionHandler.setMaxInactiveInterval(config.getInt(ExecConstants.HTTP_SESSION_MAX_IDLE_SECS));
// response cookie will be returned with HttpOnly flag
sessionHandler.getSessionCookieConfig().setHttpOnly(true);
sessionHandler.addEventListener(new HttpSessionListener() {
@Override
public void sessionCreated(HttpSessionEvent se) {
}
@Override
public void sessionDestroyed(HttpSessionEvent se) {
final HttpSession session = se.getSession();
if (session == null) {
return;
}
final Object authCreds = session.getAttribute(SessionAuthentication.__J_AUTHENTICATED);
if (authCreds != null) {
final SessionAuthentication sessionAuth = (SessionAuthentication) authCreds;
securityHandler.logout(sessionAuth);
session.removeAttribute(SessionAuthentication.__J_AUTHENTICATED);
}
// Clear all the resources allocated for this session
final WebSessionResources webSessionResources = (WebSessionResources) session.getAttribute(WebSessionResources.class.getSimpleName());
if (webSessionResources != null) {
webSessionResources.close();
session.removeAttribute(WebSessionResources.class.getSimpleName());
}
}
});
return sessionHandler;
}
Aggregations