List of usage examples for javax.servlet.http HttpSession getId
public String getId();
From source file:nl.ctrlaltdev.harbinger.response.InvalidateSessionAction.java
@Override public boolean perform(HarbingerContext ctx) { ServletRequestAttributes sra = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); if (sra != null) { HttpSession session = sra.getRequest().getSession(false); if (session != null) { LoggerFactory.getLogger(getClass()).warn("Invalidated session '{}'", session.getId()); session.invalidate();//from ww w . j a v a2 s . co m } } return true; }
From source file:com.twinsoft.convertigo.engine.requesters.HttpSessionListener.java
public void valueBound(HttpSessionBindingEvent event) { try {/*from w ww.ja va 2 s . com*/ Engine.logContext.debug("HTTP session starting..."); HttpSession httpSession = event.getSession(); String httpSessionID = httpSession.getId(); synchronized (httpSessions) { httpSessions.put(httpSessionID, httpSession); } Engine.logContext.debug("HTTP session started [" + httpSessionID + "]"); if (Engine.isEngineMode()) { KeyManager.start(com.twinsoft.api.Session.EmulIDSE); } } catch (TASException e) { if (e.isOverflow()) { String line = dateFormat.format(new Date()) + "\t" + e.getCvMax() + "\t" + e.getCvCurrent() + "\n"; try { FileUtils.write(new File(Engine.LOG_PATH + "/Session License exceeded.log"), line, "UTF-8", true); } catch (IOException e1) { Engine.logContext.error("Failed to write the 'Session License exceeded.log' file", e1); } } else { event.getSession().setAttribute("__exception", e); HttpUtils.terminateSession(event.getSession()); } } catch (Exception e) { Engine.logContext.error("Exception during binding HTTP session listener", e); } }
From source file:org.jasig.cas.web.flow.TerminateWebSessionListener.java
@Override public void sessionEnded(final RequestContext context, final FlowSession session, final String outcome, final AttributeMap output) { final HttpServletRequest request = WebUtils.getHttpServletRequest(context); // get session but don't create it if it doesn't already exist final HttpSession webSession = request.getSession(false); if (webSession != null) { logger.debug("Terminate web session {} in {} seconds", webSession.getId(), this.timeToDieInSeconds); // set the web session to die in timeToDieInSeconds webSession.setMaxInactiveInterval(this.timeToDieInSeconds); }//from w w w . j a va 2s . c o m }
From source file:com.sonicle.webtop.core.app.PushEndpoint.java
private boolean isSessionValid(AtmosphereResource resource) { HttpSession session = resource.session(false); return (session == null) ? false : StringUtils.equals(session.getId(), sessionId); }
From source file:fi.helsinki.opintoni.audit.AuditEventConverterTest.java
@Test public void thatDataIsConvertedToStrings() { HttpServletRequest request = mock(HttpServletRequest.class); when(request.getRemoteAddr()).thenReturn("127.0.0.1"); HttpSession session = mock(HttpSession.class); when(request.getSession(false)).thenReturn(session); when(session.getId()).thenReturn("ABCDEFGHIJK"); Map<String, Object> data = Maps.newHashMap(); data.put("key", "value"); data.put("authenticationDetails", new WebAuthenticationDetails(request)); Map<String, String> stringsByKey = auditEventConverter.convertDataToStrings(data); assertThat(stringsByKey).hasSize(3); assertThat(stringsByKey.get("key")).isEqualTo("value"); assertThat(stringsByKey.get("remoteAddress")).isEqualTo("127.0.0.1"); assertThat(stringsByKey.get("sessionId")).isEqualTo("ABCDEFGHIJK"); }
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 www .ja v a 2 s . com // 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:filters.ActionValidationFilter.java
/** Creates the user-dependent credential. * /* w w w. ja v a 2s . c om*/ * Currently we use the hashed email-address + session-id of user. Another (better) * option would be the password + session-id. * Even better would be separate credentials for each specific action (delete, change * email, etc.). * * @param user * @param session * @return */ private String getNewCredential(User user, HttpSession session) { return (StringUtils.getMD5Hash(user.getEmail() + session.getId())); }
From source file:th.co.geniustree.osgi.prototype.authen.impl.AuthenStoreImpl.java
@Override public void storeAuthentication(HttpSession session, Authentication authentication) { if (store != null) { validateSessionStore();//from w w w .j a v a 2 s.c o m HttpSession ssion = store.findSession(session.getId()); if (ssion == null) { ssion = session; store.storeSession(ssion.getId(), ssion); } ssion.setAttribute(AUTHENTICATION_SESSION, authentication); } }
From source file:com.bluexml.side.framework.alfresco.shareLanguagePicker.MyLocalResolver.java
public Locale resolveLocale(HttpServletRequest request) { HttpSession session = request.getSession(); logger.debug("[resolveLocale] ..."); logger.debug("[resolveLocale] session Id :" + session.getId()); Locale l = null;/*from ww w. j a v a 2 s . c o m*/ RequestContext initRequestContext; try { initRequestContext = RequestContextUtil.initRequestContext(applicationContext, request); String languageFromLayoutParam = LanguageSetter.getLanguageFromLayoutParam(request, initRequestContext); l = new Locale(languageFromLayoutParam); } catch (Exception e) { logger.error("oups " + e.getMessage(), e); e.printStackTrace(); } logger.debug("[resolveLocale] resolveLocale = " + l); if (l == null) { l = Locale.getDefault(); logger.warn("[resolveLocale] back to default (local is null)= " + l); } setLocale(request, null, l); return l; }
From source file:ch.rasc.wampspring.session.SessionRepositoryHandshakeInterceptor.java
@Override public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, Map<String, Object> attributes) throws Exception { if (request instanceof ServletServerHttpRequest) { ServletServerHttpRequest servletRequest = (ServletServerHttpRequest) request; HttpSession session = servletRequest.getServletRequest().getSession(false); if (session != null) { attributes.put(SessionSupport.SPRING_SESSION_ID_ATTR_NAME, session.getId()); }//from w ww.j a va 2 s .c o m } return true; }