List of usage examples for javax.servlet.http HttpSessionEvent getSession
public HttpSession getSession()
From source file:cc.kune.core.server.UserSessionMonitor.java
@Override public void sessionDestroyed(final HttpSessionEvent event) { LOG.debug(String.format("Session destroyed (with max inactive: %d)", event.getSession().getMaxInactiveInterval())); // , new Throwable()); }
From source file:com.nec.harvest.servlet.listener.HarvestSessionListener.java
@Override public void sessionDestroyed(HttpSessionEvent event) { activeSessions--;/*from ww w . ja v a 2 s . c o m*/ // ? HttpSession session = event.getSession(); Assert.notNull(session, "No HttpSession Specified"); ServletContext ctx = session.getServletContext(); ctx.removeAttribute(Constants.USER_LOGGED_IN_LASTTIME); ctx.removeAttribute(Constants.SESS_ORGANIZATION_CODE); ctx.removeAttribute(Constants.SESS_BUSINESS_DAY); if (SecurityContextHolder.getContext().getAuthentication() != null) { // Remove from LRU Cache AuthenticatedUserDetails.removeUserPrincipal(); // Empty authentication SecurityContextHolder.getContext().setAuthentication(null); } // ?????? logger.info("A HttpSession [{}] is going to be destroyed", session.getId()); }
From source file:edu.harvard.iq.dvn.core.web.util.InputFileSessionCleaner.java
/** * This method is called by the servlet container when the session * is about to expire. This method will attempt to delete all files that * where uploaded into the folder which has the same name as the session * id.//from w w w . ja va 2 s . c o m * * @param event JSF session event. */ public void sessionDestroyed(HttpSessionEvent event) { // get the session id, so we know which folder to remove String sessionId = event.getSession().getId(); String applicationPath = event.getSession().getServletContext() .getRealPath(event.getSession().getServletContext().getServletContextName()); String sessionFileUploadPath = applicationPath + FILE_UPLOAD_DIRECTORY + sessionId; File sessionfileUploadDirectory = new File(sessionFileUploadPath); if (sessionfileUploadDirectory.isDirectory()) { try { sessionfileUploadDirectory.delete(); } catch (SecurityException e) { log.error("Error deleting file upload directory: ", e); } } }
From source file:com.cubusmail.server.services.CubusSessionListener.java
public void sessionDestroyed(HttpSessionEvent event) { try {/*from w w w. j ava 2s. co m*/ log.debug("Session expired. Execute logout."); if (SessionManager.get(event.getSession()) != null) { IMailbox mailbox = SessionManager.get(event.getSession()).getMailbox(); if (mailbox != null && mailbox.isLoggedIn()) { mailbox.logout(); } } } catch (Throwable ex) { // nothing to do log.warn(ex.getMessage()); } }
From source file:com.liferay.portal.servlet.PortalSessionListener.java
public void sessionDestroyed(HttpSessionEvent event) { HttpSession ses = event.getSession(); PortalSessionContext.remove(ses.getId()); String companyId = (String) ses.getAttribute(WebKeys.COMPANY_ID); String userId = (String) ses.getAttribute(WebKeys.USER_ID); // Close mail connections // Shared session String sharedSessionId = (String) ses.getAttribute(WebKeys.SHARED_SESSION_ID); _log.debug("Shared session id is " + sharedSessionId); // Just in case the session is not properly removed in time, MainServlet // and SharedServletWrapper also make calls to ensure the session is // removed from the pool for garbage collection if (sharedSessionId != null) { _log.debug("Removing session from pool"); SharedSessionPool.remove(sharedSessionId); }/*from w ww . j a v a 2 s . c o m*/ // User tracker if (companyId != null) { Map currentUsers = (Map) WebAppPool.get(companyId, WebKeys.CURRENT_USERS); UserTracker userTracker = (UserTracker) currentUsers.remove(ses.getId()); try { if (userTracker != null) { UserTrackerLocalManagerUtil.addUserTracker(userTracker.getCompanyId(), userTracker.getUserId(), userTracker.getModifiedDate(), userTracker.getRemoteAddr(), userTracker.getRemoteHost(), userTracker.getUserAgent(), userTracker.getPaths()); } } catch (Exception e) { Logger.error(this, e.getMessage(), e); } } // Process session destroyed events try { EventsProcessor.process(PropsUtil.getArray(PropsUtil.SERVLET_SESSION_DESTROY_EVENTS), ses); } catch (ActionException ae) { Logger.error(this, ae.getMessage(), ae); } }
From source file:net.ymate.module.sso.event.SSOSessionEventListener.java
@Override public void register(Events events) throws Exception { events.registerListener(Events.MODE.NORMAL, WebEvent.class, new IEventListener<WebEvent>() { @Override//from w w w . j a v a 2 s .c om public boolean handle(WebEvent context) { switch (context.getEventName()) { case SESSION_DESTROYED: HttpSessionEvent _source = context.getEventSource(); UserSessionBean _sessionBean = (UserSessionBean) _source.getSession() .getAttribute(UserSessionBean.class.getName()); if (_sessionBean != null) { ISSOToken _token = _sessionBean.getAttribute(ISSOToken.class.getName()); if (_token != null/* && _token.timeout()*/) { try { SSO.get().getModuleCfg().getTokenStorageAdapter().cleanup(_token.getUid()); } catch (Exception e) { _LOG.warn("An exception occurred while cleaning token for user '" + _token.getUid() + "'", RuntimeUtils.unwrapThrow(e)); } } } break; default: break; } return false; } }); }
From source file:MyServlet.java
/** * Record the fact that a session has been created. * * @param event The session event/*from w ww. j a v a 2 s. c om*/ */ public void sessionCreated(HttpSessionEvent event) { log("sessionCreated('" + event.getSession().getId() + "')"); }
From source file:com.flexive.war.listener.SessionTimeoutListener.java
@Override public void sessionDestroyed(HttpSessionEvent event) { final HttpSession session = event.getSession(); if (LOG.isDebugEnabled()) { LOG.debug("Session destroyed: " + session.getId()); }/* www.j a va 2 s . com*/ // set parameters needed for logout final FxContext ctx = FxContext.get(); try { ctx.setSessionID(session.getId()); // retrieve context path final ServletContext servletContext = session.getServletContext(); if (servletContext != null) { ctx.setContextPath(servletContext.getContextPath()); } // get division ID from session final String divisionIdKey = FxSessionWrapper.encodeAttributeName(FxContext.SESSION_DIVISIONID); if (session.getAttribute(divisionIdKey) != null) { ctx.setDivisionId((Integer) session.getAttribute(divisionIdKey)); } if (ctx.getDivisionId() == -1 || !CacheAdmin.isEnvironmentLoaded()) { // probably during undeploy return; } ctx.setTicket(FxContext.getTicketFromEJB(session)); if (!ctx.getTicket().isGuest()) { // perform logout only when the user is logged in if (LOG.isDebugEnabled()) { LOG.debug("Performing logout for user of destroyed session (possible session timeout): " + session.getId()); } onLogout(ctx.getTicket()); ctx.logout(); } } catch (FxLogoutFailedException e) { LOG.error("Failed to logout user after session timeout: " + e.getMessage(), e); } finally { FxContext.cleanup(); } }
From source file:MyServlet.java
/** * Record the fact that a session has been destroyed. * * @param event The session event// ww w .j a v a 2s . co m */ public void sessionDestroyed(HttpSessionEvent event) { log("sessionDestroyed('" + event.getSession().getId() + "')"); }
From source file:com.flexive.war.listener.SessionTimeoutListener.java
@Override public void sessionCreated(HttpSessionEvent event) { if (LOG.isDebugEnabled()) { LOG.debug("Session created: " + event.getSession().getId()); }//from w w w . j av a 2 s . c o m }