コード例 #1
0
  @Bean(name = "sessionManager")
  public ValidatingSessionManager sessionManager() {
    logger.debug("create session manager.");

    DefaultWebSessionManager sessionManager = new DefaultWebSessionManager();
    sessionManager.setGlobalSessionTimeout(1800000);
    sessionManager.setSessionDAO(shiroSessionDao());
    sessionManager.setCacheManager(cacheManager());
    return sessionManager;
  }
コード例 #2
0
 public void stop(SessionKey key) {
   try {
     super.stop(key);
   } catch (InvalidSessionException e) {
     // 获取不到SESSION不抛出异常
   }
 }
コード例 #3
0
 public void checkValid(SessionKey key) {
   try {
     super.checkValid(key);
   } catch (InvalidSessionException e) {
     // 获取不到SESSION不抛出异常
   }
 }
コード例 #4
0
 public void setTimeout(SessionKey key, long maxIdleTimeInMillis) {
   try {
     super.setTimeout(key, maxIdleTimeInMillis);
   } catch (InvalidSessionException e) {
     // 获取不到SESSION不抛出异常
   }
 }
コード例 #5
0
 public void setAttribute(SessionKey sessionKey, Object attributeKey, Object value) {
   try {
     super.setAttribute(sessionKey, attributeKey, value);
   } catch (InvalidSessionException e) {
     // 获取不到SESSION不抛出异常
   }
 }
コード例 #6
0
  /**
   * Stores the Session's ID, usually as a Cookie, to associate with future requests.
   *
   * @param session the session that was just {@link #createSession created}.
   */
  @Override
  protected void onStart(Session session, SessionContext context) {
    super.onStart(session, context);

    if (!WebUtils.isHttp(context)) {
      log.debug(
          "SessionContext argument is not HTTP compatible or does not have an HTTP request/response "
              + "pair. No session ID cookie will be set.");
      return;
    }
    HttpServletRequest request = WebUtils.getHttpRequest(context);
    HttpServletResponse response = WebUtils.getHttpResponse(context);

    if (isSessionIdCookieEnabled()) {
      Serializable sessionId = session.getId();
      storeSessionId(sessionId, request, response);
    } else {
      log.debug(
          "Session ID cookie is disabled.  No cookie has been set for new session with id {}",
          session.getId());
    }

    request.removeAttribute(ShiroHttpServletRequest.REFERENCED_SESSION_ID_SOURCE);
    request.setAttribute(ShiroHttpServletRequest.REFERENCED_SESSION_IS_NEW, Boolean.TRUE);
  }
コード例 #7
0
 @Override
 protected void onStop(Session session, SessionKey key) {
   super.onStop(session, key);
   if (WebUtils.isHttp(key)) {
     HttpServletRequest request = WebUtils.getHttpRequest(key);
     HttpServletResponse response = WebUtils.getHttpResponse(key);
     log.debug(
         "Session has been stopped (subject logout or explicit stop).  Removing session ID cookie.");
     removeSessionIdCookie(request, response);
   } else {
     log.debug(
         "SessionKey argument is not HTTP compatible or does not have an HTTP request/response "
             + "pair. Session ID cookie will not be removed due to stopped session.");
   }
 }
コード例 #8
0
 @Override
 public void validateSessions() {
   super.validateSessions();
 }
コード例 #9
0
 public ShiroSessionManager() {
   super();
   super.getSessionIdCookie().setName(COOKIE_NAME);
 }
コード例 #10
0
 public void setDomain(String domain) {
   if (StringUtils.isNotEmpty(domain)) super.getSessionIdCookie().setDomain(domain);
 }
コード例 #11
0
 public void setPath(String path) {
   if (StringUtils.isNotEmpty(path)) super.getSessionIdCookie().setPath(path);
 }
コード例 #12
0
 @Override
 protected void onInvalidation(Session session, InvalidSessionException ise, SessionKey key) {
   super.onInvalidation(session, ise, key);
   onInvalidation(key);
 }
コード例 #13
0
 @Override
 protected void onExpiration(Session s, ExpiredSessionException ese, SessionKey key) {
   super.onExpiration(s, ese, key);
   onInvalidation(key);
 }