@Override public void invoke(Request request, Response response) throws IOException, ServletException { String sessionId = request.getRequestedSessionId(); Session session = request.getContext().getManager().findSession(sessionId); if (session != null) { if (!session.isValid()) { session.expire(); request.getContext().getManager().remove(session); } else { manager.add(session); session.access(); session.endAccess(); } } try { getNext().invoke(request, response); } finally { manager.store(request.getSession(false)); } }
@Override public void setPrincipal(Principal principal) { super.setPrincipal(principal); // Put the session into the region to serialize the principal if (getManager() != null) { // TODO convert this to a delta getManager().add(this); DeltaSessionManager mgr = (DeltaSessionManager) getManager(); if (mgr.getLogger().isDebugEnabled()) { mgr.getLogger().debug(this + ": Cached principal: " + principal); // mgr.logCurrentStack(); } } }
/** * Set a new id for this session.<br/> * Before setting the new id, it removes itself from the associated * manager. After the new id is set, this session adds itself to the * session manager. * * @param id * the new session id */ protected void setIdForRelocate( final String id ) { if ( this.id == null ) { throw new IllegalStateException( "There's no session id set." ); } if ( this.manager == null ) { throw new IllegalStateException( "There's no manager set." ); } /* * and mark it as a node-failure-session, so that remove(session) does * not try to remove it from memcached... (the session is removed and * added when the session id is changed) */ setNote( MemcachedSessionService.NODE_FAILURE, Boolean.TRUE ); manager.remove( this ); removeNote( MemcachedSessionService.NODE_FAILURE ); this.id = id; manager.add( this ); }
Context context = getManager().getContext(); Log contextLog = context.getLogger(); if (contextLog.isDebugEnabled()) { contextLog.debug(sm.getString(getStoreName()+".loading", id, file.getAbsolutePath())); ClassLoader oldThreadContextCL = context.bind(Globals.IS_SECURITY_ENABLED, null); StandardSession session = (StandardSession) manager.createEmptySession(); session.readObjectData(ois); session.setManager(manager); return session; } catch (FileNotFoundException e) { if (contextLog.isDebugEnabled()) { contextLog.debug("No persisted data file found"); context.unbind(Globals.IS_SECURITY_ENABLED, oldThreadContextCL);
throws IOException { if (log.isDebugEnabled()) { log.debug(sm.getString("formAuthenticator.forwardLogin", request.getRequestURI(), request.getMethod(), config.getLoginPage(), context.getName())); String msg = sm.getString("formAuthenticator.noLoginPage", context.getName()); log.warn(msg); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg); Session session = request.getSessionInternal(false); if (session != null) { Manager manager = request.getContext().getManager(); manager.changeSessionId(session); request.changeSessionId(session.getId()); String msg = sm.getString("formAuthenticator.forwardLoginFail"); log.warn(msg, t); request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, t);
if (session != null && session.isValid()) { return session.getSession(); try { localSession = context.getManager().findSession(other.getId()); if (localSession != null && !localSession.isValid()) { localSession = null; context.getManager().createSession(other.getId());
/** * Perform the internal processing required to passivate * this session. */ public void passivate() { // Notify interested session event listeners fireSessionEvent(Session.SESSION_PASSIVATED_EVENT, null); // Notify ActivationListeners HttpSessionEvent event = null; String keys[] = keys(); for (int i = 0; i < keys.length; i++) { Object attribute = attributes.get(keys[i]); if (attribute instanceof HttpSessionActivationListener) { if (event == null) event = new HttpSessionEvent(getSession()); try { ((HttpSessionActivationListener)attribute) .sessionWillPassivate(event); } catch (Throwable t) { ExceptionUtils.handleThrowable(t); manager.getContainer().getLogger().error (sm.getString("standardSession.attributeEvent"), t); } } } }
/** * Reset DeltaRequest from session * @param session HttpSession from current request or cross context session */ protected void resetDeltaRequest(Session session) { if(log.isDebugEnabled()) { log.debug(sm.getString("ReplicationValve.resetDeltaRequest" , session.getManager().getContainer().getName() )); } ((DeltaSession)session).resetDeltaRequest(); }
Context currentContext = (Context) host.findChild(current.getName()); if (previousContext != null && currentContext != null && currentContext.getState().isAvailable() && !isServiced(previous.getName())) { Manager manager = previousContext.getManager(); if (manager != null) { int sessionCount; sessionCount = ((DistributedManager) manager).getActiveSessionsFull(); } else { sessionCount = manager.getActiveSessions(); if (log.isInfoEnabled()) { log.info(sm.getString( "hostConfig.undeployVersion", previous.getName()));
/** * Remove the Session with the specified session identifier from * this Store, if present. If no such Session is present, this method * takes no action. * * @param id Session identifier of the Session to be removed * * @exception IOException if an input/output error occurs */ @Override public void remove(String id) throws IOException { File file = file(id); if (file == null) { return; } if (manager.getContainer().getLogger().isDebugEnabled()) { manager.getContainer().getLogger().debug(sm.getString(getStoreName()+".removing", id, file.getAbsolutePath())); } file.delete(); }
fireSessionEvent(Session.SESSION_CREATED_EVENT, null); Context context = (Context) manager.getContainer(); Object listeners[] = context.getApplicationLifecycleListeners(); if (listeners != null) { HttpSessionEvent event = new HttpSessionEvent(getSession()); for (int i = 0; i < listeners.length; i++) { if (!(listeners[i] instanceof HttpSessionListener)) (HttpSessionListener) listeners[i]; try { fireContainerEvent(context, "beforeSessionCreated", listener); manager.getContainer().getLogger().error (sm.getString("standardSession.sessionEvent"), t);
private void expire(SingleSignOnSessionKey key) { if (engine == null) { containerLog.warn(sm.getString("singleSignOn.sessionExpire.engineNull", key)); return; containerLog.warn(sm.getString("singleSignOn.sessionExpire.hostNotFound", key)); return; Context context = (Context) host.findChild(key.getContextName()); if (context == null) { containerLog.warn(sm.getString("singleSignOn.sessionExpire.contextNotFound", key)); return; Manager manager = context.getManager(); if (manager == null) { containerLog.warn(sm.getString("singleSignOn.sessionExpire.managerNotFound", key)); session = manager.findSession(key.getSessionId()); } catch (IOException e) { containerLog.warn(sm.getString("singleSignOn.sessionExpire.managerError", key), e); return; session.expire();
cluster.backgroundProcess(); } catch (Exception e) { log.warn(sm.getString("containerBase.backgroundProcess.cluster", cluster), e); loader.backgroundProcess(); } catch (Exception e) { log.warn(sm.getString("containerBase.backgroundProcess.loader", loader), e); manager.backgroundProcess(); } catch (Exception e) { log.warn(sm.getString("containerBase.backgroundProcess.manager", manager), e);
args[1] = smClient.getString("htmlManagerServlet.title"); writer.print(MessageFormat.format (Constants.BODY_HEADER_SECTION, args)); args[0] = smClient.getString("htmlManagerServlet.messageLabel"); if (message == null || message.length() == 0) { args[1] = "OK"; args[0] = smClient.getString("htmlManagerServlet.manager"); args[1] = response.encodeURL(request.getContextPath() + "/html/list"); args[2] = smClient.getString("htmlManagerServlet.list"); String contextNames[] = new String[children.length]; for (int i = 0; i < children.length; i++) contextNames[i] = children[i].getName(); String contextPath = ctxt.getPath(); String displayPath = contextPath; if (displayPath.equals("")) { ((DistributedManager)manager).getActiveSessionsFull()); } else if (manager != null){ args[5] = Integer.valueOf(manager.getActiveSessions()); } else { args[5] = Integer.valueOf(0);
return (null); if (manager.getContext().getLogger().isDebugEnabled()) { manager.getContext().getLogger().debug(sm.getString(getStoreName()+".loading", id, file.getAbsolutePath())); fis = new FileInputStream(file.getAbsolutePath()); bis = new BufferedInputStream(fis); Context context = manager.getContext(); if (context != null) loader = context.getLoader(); if (loader != null) classLoader = loader.getClassLoader(); (StandardSession) manager.createEmptySession(); session.readObjectData(ois); session.setManager(manager); return (session); } catch (FileNotFoundException e) { if (manager.getContext().getLogger().isDebugEnabled()) manager.getContext().getLogger().debug("No persisted data file found"); return (null); } catch (IOException e) {
logger.debug("Querying webapp: {}", context.getName()); app.setName(context.getName().length() > 0 ? context.getName() : "/"); app.setDocBase(context.getDocBase()); app.setDisplayName(context.getDisplayName()); logger.debug("collecting session information"); app.setSessionCount(context.getManager().findSessions().length); long size = 0; for (Session session : context.getManager().findSessions()) { ApplicationSession appSession = getApplicationSession(session, calcSize, false); if (appSession != null) {
/** * change session id and send to all cluster nodes * * @param request current request * @param sessionId * original session id * @param newSessionID * new session id for node migration * @param catalinaSession * current session with original session id */ protected void changeSessionID(Request request, String sessionId, String newSessionID, Session catalinaSession) { fireLifecycleEvent("Before session migration", catalinaSession); catalinaSession.getManager().changeSessionId(catalinaSession, newSessionID); changeRequestSessionID(request, sessionId, newSessionID); fireLifecycleEvent("After session migration", catalinaSession); if (log.isDebugEnabled()) { log.debug(sm.getString("jvmRoute.changeSession", sessionId, newSessionID)); } }
fireSessionEvent(Session.SESSION_CREATED_EVENT, null); Context context = (Context) manager.getContainer(); Object listeners[] = context.getApplicationLifecycleListeners(); if (listeners != null) { HttpSessionEvent event = new HttpSessionEvent(getSession()); for (int i = 0; i < listeners.length; i++) { if (!(listeners[i] instanceof HttpSessionListener)) (HttpSessionListener) listeners[i]; try { context.fireContainerEvent("beforeSessionCreated", listener); listener.sessionCreated(event); context.fireContainerEvent("afterSessionCreated", listener); } catch (Throwable t) { ExceptionUtils.handleThrowable(t); manager.getContainer().getLogger().error (sm.getString("standardSession.sessionEvent"), t);
/** * 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; }
path = cn.getPath(); throw new IllegalArgumentException(smClient.getString( "managerServlet.invalidPath", Escape.htmlElementContent(path))); throw new IllegalArgumentException(smClient.getString( "managerServlet.noContext", Escape.htmlElementContent(cn.getDisplayName()))); Manager manager = ctxt.getManager(); List<Session> sessions = new ArrayList<>(); sessions.addAll(Arrays.asList(manager.findSessions())); if (manager instanceof DistributedManager && showProxySessions) { sessionIds.remove(session.getId());