request.changeSessionId(newSessionId);
@Test public final void testChangeSessionIdForRelocatedSession() throws IOException, ServletException { final String sessionId = "bar"; final String newSessionId = "newId"; when( _request.getRequestedSessionId() ).thenReturn( sessionId ); when( _service.changeSessionIdOnMemcachedFailover( eq( sessionId ) ) ).thenReturn( newSessionId ); _sessionTrackerValve.invoke( _request, _response ); verify( _request ).changeSessionId( eq( newSessionId ) ); verify(_request).setNote(eq(RequestTrackingHostValve.SESSION_ID_CHANGED), eq(Boolean.TRUE)); }
/** * If there's a session for a requested session id that is taken over (tomcat failover) or * that will be relocated (memcached failover), the new session id will be set (via {@link Request#changeSessionId(String)}). * * @param request the request * @param response the response * * @return <code>true</code> if the id of a valid session was changed. * * @see Request#changeSessionId(String) */ private boolean changeRequestedSessionId( final Request request, final Response response ) { /* * Check for session relocation only if a session id was requested */ if ( request.getRequestedSessionId() != null ) { String newSessionId = _sessionBackupService.changeSessionIdOnTomcatFailover( request.getRequestedSessionId() ); if ( newSessionId == null ) { newSessionId = _sessionBackupService.changeSessionIdOnMemcachedFailover( request.getRequestedSessionId() ); } if ( newSessionId != null ) { request.changeSessionId( newSessionId ); return true; } } return false; }
public String run() { return request.changeSessionId(); } }
public String changeSessionId() { return httpRequest.changeSessionId(); }
@Override public String changeSessionId() { if (request == null) { throw new IllegalStateException( sm.getString("requestFacade.nullRequest")); } return request.changeSessionId(); }
@Override public String changeSessionId() { if (request == null) { throw new IllegalStateException( sm.getString("requestFacade.nullRequest")); } return request.changeSessionId(); }
@Override public String changeSessionId() { if (request == null) { throw new IllegalStateException( sm.getString("requestFacade.nullRequest")); } return request.changeSessionId(); }
@Override public String changeSessionId() { if (request == null) { throw new IllegalStateException(rb.getString(LogFacade.CANNOT_USE_REQUEST_OBJECT_OUTSIDE_SCOPE_EXCEPTION)); } if (SecurityUtil.isPackageProtectionEnabled()){ return AccessController. doPrivileged(new ChangeSessionIdPrivilegedAction()); } else { return request.changeSessionId(); } }
@Override protected String changeHttpSessionId(boolean create) { Request request = this.request; HttpSession session = request.getSession(false); if (session == null) { return request.getSession(true).getId(); } if (!deployment.isTurnOffChangeSessionIdOnLogin()) return request.changeSessionId(); else return session.getId(); } }
@Override protected String changeSessionId(Session session) { Request request = this.request; if (!deployment.turnOffChangeSessionIdOnLogin()) return request.changeSessionId(); else return session.getId(); } }
request.changeSessionId(newSessionId);
/** * Change Request Session id * @param request current request * @param sessionId * original session id * @param newSessionID * new session id for node migration */ protected void changeRequestSessionID(Request request, String sessionId, String newSessionID) { request.changeSessionId(newSessionID); // set original sessionid at request, to allow application detect the // change if (sessionIdAttribute != null && !"".equals(sessionIdAttribute)) { if (log.isDebugEnabled()) { log.debug(sm.getString("jvmRoute.set.orignalsessionid",sessionIdAttribute,sessionId)); } request.setAttribute(sessionIdAttribute, sessionId); } }
/** * Change Request Session id * @param request current request * @param sessionId * original session id * @param newSessionID * new session id for node migration */ protected void changeRequestSessionID(Request request, String sessionId, String newSessionID) { request.changeSessionId(newSessionID); // set original sessionid at request, to allow application detect the // change if (sessionIdAttribute != null && !"".equals(sessionIdAttribute)) { if (log.isDebugEnabled()) { log.debug(sm.getString("jvmRoute.set.orignalsessionid",sessionIdAttribute,sessionId)); } request.setAttribute(sessionIdAttribute, sessionId); } }
/** * Change Request Session id * @param request current request * @param sessionId * original session id * @param newSessionID * new session id for node migration */ protected void changeRequestSessionID(Request request, String sessionId, String newSessionID) { request.changeSessionId(newSessionID); // set original sessionid at request, to allow application detect the // change if (sessionIdAttribute != null && !"".equals(sessionIdAttribute)) { if (log.isDebugEnabled()) { log.debug(sm.getString("jvmRoute.set.orignalsessionid",sessionIdAttribute,sessionId)); } request.setAttribute(sessionIdAttribute, sessionId); } }
/** * Changes the session ID of the session associated with this request. * * @return the old session ID before it was changed * @see javax.servlet.http.HttpSessionIdListener * @since Servlet 3.1 */ @Override public String changeSessionId() { Session session = this.getSessionInternal(false); if (session == null) { throw new IllegalStateException( sm.getString("coyoteRequest.changeSessionId")); } Manager manager = this.getContext().getManager(); manager.changeSessionId(session); String newSessionId = session.getId(); this.changeSessionId(newSessionId); return newSessionId; }
/** * Changes the session ID of the session associated with this request. * * @return the old session ID before it was changed * @see javax.servlet.http.HttpSessionIdListener * @since Servlet 3.1 */ @Override public String changeSessionId() { Session session = this.getSessionInternal(false); if (session == null) { throw new IllegalStateException( sm.getString("coyoteRequest.changeSessionId")); } Manager manager = this.getContext().getManager(); manager.changeSessionId(session); String newSessionId = session.getId(); this.changeSessionId(newSessionId); return newSessionId; }
/** * Changes the session ID of the session associated with this request. * * @return the old session ID before it was changed * @see javax.servlet.http.HttpSessionIdListener * @since Servlet 3.1 */ @Override public String changeSessionId() { Session session = this.getSessionInternal(false); if (session == null) { throw new IllegalStateException( sm.getString("coyoteRequest.changeSessionId")); } Manager manager = this.getContext().getManager(); manager.changeSessionId(session); String newSessionId = session.getId(); this.changeSessionId(newSessionId); return newSessionId; }
/** * If there's a session for a requested session id that is taken over (tomcat failover) or * that will be relocated (memcached failover), the new session id will be set (via {@link Request#changeSessionId(String)}). * * @param request the request * @param response the response * * @return <code>true</code> if the id of a valid session was changed. * * @see Request#changeSessionId(String) */ private boolean changeRequestedSessionId( final Request request, final Response response ) { /* * Check for session relocation only if a session id was requested */ if ( request.getRequestedSessionId() != null ) { String newSessionId = _sessionBackupService.changeSessionIdOnTomcatFailover( request.getRequestedSessionId() ); if ( newSessionId == null ) { newSessionId = _sessionBackupService.changeSessionIdOnMemcachedFailover( request.getRequestedSessionId() ); } if ( newSessionId != null ) { request.changeSessionId( newSessionId ); return true; } } return false; }
Manager manager = request.getContext().getManager(); manager.changeSessionId(session, request.getRandom()); request.changeSessionId(session.getId());