@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; }
public void stop(SessionKey key) { try { super.stop(key); } catch (InvalidSessionException e) { // 获取不到SESSION不抛出异常 } }
public void checkValid(SessionKey key) { try { super.checkValid(key); } catch (InvalidSessionException e) { // 获取不到SESSION不抛出异常 } }
public void setTimeout(SessionKey key, long maxIdleTimeInMillis) { try { super.setTimeout(key, maxIdleTimeInMillis); } catch (InvalidSessionException e) { // 获取不到SESSION不抛出异常 } }
public void setAttribute(SessionKey sessionKey, Object attributeKey, Object value) { try { super.setAttribute(sessionKey, attributeKey, value); } catch (InvalidSessionException e) { // 获取不到SESSION不抛出异常 } }
/** * 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); }
@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."); } }
@Override public void validateSessions() { super.validateSessions(); }
public ShiroSessionManager() { super(); super.getSessionIdCookie().setName(COOKIE_NAME); }
public void setDomain(String domain) { if (StringUtils.isNotEmpty(domain)) super.getSessionIdCookie().setDomain(domain); }
public void setPath(String path) { if (StringUtils.isNotEmpty(path)) super.getSessionIdCookie().setPath(path); }
@Override protected void onInvalidation(Session session, InvalidSessionException ise, SessionKey key) { super.onInvalidation(session, ise, key); onInvalidation(key); }
@Override protected void onExpiration(Session s, ExpiredSessionException ese, SessionKey key) { super.onExpiration(s, ese, key); onInvalidation(key); }