Package org.apache.catalina

Examples of org.apache.catalina.Session


                    String sessionId = ss[0];
                    String appName = ss[1];
                    Context context = getContainerWrapper().getTomcatContainer().findContext(appName);
                    if (context != null) {
                        Manager manager = context.getManager();
                        Session session = manager.findSession(sessionId);
                        if (session != null && session.isValid()) {
                            session.expire();
                        }
                    } else {
                        return new ModelAndView("errors/paramerror");
                    }
                } else {
View Full Code Here


public class ExpireSessionController extends ContextHandlerController {

    protected ModelAndView handleContext(String contextName, Context context,
                                         HttpServletRequest request, HttpServletResponse response) throws Exception {
        String sessionID= ServletRequestUtils.getStringParameter(request, "sid");
        Session session = context.getManager().findSession(sessionID);
        if (session != null) {
            session.expire();
        }
        return new ModelAndView(new InternalResourceView(getViewName()));
    }
View Full Code Here

                                         HttpServletRequest request,
                                         HttpServletResponse response) throws Exception {

        String sid = ServletRequestUtils.getStringParameter(request, "sid");
        String attrName = ServletRequestUtils.getStringParameter(request, "attr");
        Session session = context.getManager().findSession(sid);
        if (session != null) {
            session.getSession().removeAttribute(attrName);
        }

        return new ModelAndView(new RedirectView(request.getContextPath() + getViewName() + "?"+request.getQueryString()));
    }
View Full Code Here

        for (Iterator it = ctxs.iterator(); it.hasNext();) {
            Context ctx = (Context) it.next();
            if (ctx != null && ctx.getManager() != null && (!searchInfo.isApply() || searchInfo.isUseSearch())) {
                Session[] sessions = ctx.getManager().findSessions();
                for (int i = 0; i < sessions.length; i++) {
                    Session session = sessions[i];
                    ApplicationSession appSession = ApplicationUtils.getApplicationSession(
                            session, calcSize, searchInfo.isUseAttr());
                    if (appSession != null && matchSession(appSession, searchInfo)) {
                        if (ctx.getName() != null) {
                            appSession.setApplicationName(ctx.getName().length() > 0 ? ctx.getName() : "/");
View Full Code Here

         managers[i].start();
      }
     
      // Set up a session
      String id = "1";
      Session sess = managers[0].findSession(id);
      assertNull("session does not exist", sess);
     
      sess = managers[0].createSession(id);
      sess.access();
      sess.getSession().setAttribute("test", "test");     
      managers[0].storeSession(sess);     
      sess.endAccess();
     
      assertEquals("Session count correct", 1, managers[0].getActiveSessionCount());
      assertEquals("Local session count correct", 1, managers[0].getLocalActiveSessionCount());     
      assertEquals("Session count correct", 1, managers[1].getActiveSessionCount());
      assertEquals("Local session count correct", 0, managers[1].getLocalActiveSessionCount());
     
      // Confirm a session timeout clears space
      sess = managers[0].findSession(id);
      sess.access();
      sess.setMaxInactiveInterval(1);       
      managers[0].storeSession(sess);     
      sess.endAccess();
     
      SessionTestUtil.sleepThread(1005);     
          
      managers[1].backgroundProcess();
     
View Full Code Here

      // We only care about session destroyed events
      if (!Session.SESSION_DESTROYED_EVENT.equals(event.getType()))
         return;

      // Look up the single session id associated with this session (if any)
      Session session = event.getSession();
      if (LOG.isTraceEnabled())
          LOG.trace("Process session destroyed on " + session);

      String ssoId = null;
      synchronized (reverse)
      {
         ssoId = reverse.get(session);
      }
      if (ssoId == null)
      {
         if (LOG.isTraceEnabled())
             LOG.trace("ignoring as SSO is already closed for session " + session);
         return;
      }

      try
      {
         // Was the session destroyed as the result of a timeout or
         // the undeployment of the containing webapp?
         // If so, we'll just remove the expired session from the
         // SSO.  If the session was logged out, we'll log out
         // of all sessions associated with the SSO.
         boolean timedOut;
         boolean stopped = false;
         if ( (timedOut = isSessionTimedOut(session)) || (stopped=isManagerStopped(session)))
         {
            if (LOG.isTraceEnabled())
                LOG.trace(
                   "remove session " + session + " from SSO " + ssoId +
                      ", isSessionTimedOut=" + timedOut +
                      ", isManagerStopped=" + stopped
                );

            removeSession(ssoId, session);

            // Quite poor.  We hijack the caller thread (the Tomcat background thread)
            // to do our cleanup of expired sessions
            processExpires();
         }
         else
         {
            if (LOG.isTraceEnabled())
                LOG.trace("user logged out of SSO " + ssoId);
            // The session was logged out.
            logout(ssoId);
         }
      }
      catch (Exception e)
      {
         // Don't propagate back to the webapp; we don't want to disrupt
         // the session expiration process
         LOG.error("Caught exception updating SSO " + ssoId +
                                          " following destruction of session " +
                                          session.getIdInternal(), e);
      }
   }
View Full Code Here

      if (sso == null)
         return;

      // Expire any associated sessions
      Session sessions[] = sso.findSessions();
      for (int i = 0; i < sessions.length; i++)
      {
         if (LOG.isTraceEnabled())
             LOG.trace(" Invalidating session " + sessions[i]);
         // Remove from reverse cache first to avoid recursion
View Full Code Here

      for (int i = 0; i < sessions.length; i++)
      {
         if (session == sessions[i])
            return false;
      }
      Session results[] = new Session[sessions.length + 1];
      System.arraycopy(sessions, 0, results, 0, sessions.length);
      results[sessions.length] = session;
      sessions = results;
      session.addSessionListener(sso);
      return true;
View Full Code Here

   {
   }

   public Session createSession(String s)
   {
      Session session = new MockSession(this);
      session.setId(s);
      return session;
   }
View Full Code Here

     
      assertFalse("Passivation is disabled", managers[0].isPassivationEnabled());
      assertEquals("Correct max active count", 2, managers[0].getMaxActiveAllowed());
     
      // Set up a session
      Session sess1 = createAndUseSession(managers[0], "1", true, true);
     
      assertEquals("Session count correct", 1, managers[0].getActiveSessionCount());
      assertEquals("Local session count correct", 1, managers[0].getLocalActiveSessionCount());
     
      createAndUseSession(managers[0], "2", true, true);
     
      assertEquals("Session count correct", 2, managers[0].getActiveSessionCount());
      assertEquals("Local session count correct", 2, managers[0].getLocalActiveSessionCount());
     
      // Should fail to create a 3rd
      createAndUseSession(managers[0], "3", false, false);
     
      // Confirm a session timeout clears space
      sess1.setMaxInactiveInterval(1);      
      SessionTestUtil.sleepThread(1100);     
     
      createAndUseSession(managers[0], "3", true, true);     
     
      assertEquals("Session count correct", 2, managers[0].getActiveSessionCount());
View Full Code Here

TOP

Related Classes of org.apache.catalina.Session

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.