/** * Immediately delegates to the underlying proxied session. */ public void setTimeout(long maxIdleTimeInMillis) throws InvalidSessionException { delegate.setTimeout(maxIdleTimeInMillis); }
public void setMaxInactiveInterval(int i) { try { getSession().setTimeout(i * 1000); } catch (InvalidSessionException e) { throw new IllegalStateException(e); } }
public void setTimeout(SessionKey key, long maxIdleTimeInMillis) throws InvalidSessionException { Session s = lookupRequiredSession(key); s.setTimeout(maxIdleTimeInMillis); onChange(s); }
protected void applyGlobalSessionTimeout(Session session) { session.setTimeout(getGlobalSessionTimeout()); onChange(session); }
@Override public boolean forceLogout(String sessionId) { Session session = sessionDAO.readSession(sessionId); session.setTimeout(0); session.stop(); sessionDAO.delete(session); return true; }
if (user != null) { long timeoutInMillis = user.getSessionTimeoutMs(); s.setTimeout(timeoutInMillis); } else { s.setTimeout(TimeUnit.HOURS.toMillis(8));
/** * Test that validates functionality for issue * <a href="https://issues.apache.org/jira/browse/JSEC-46">JSEC-46</a> */ @Test public void testAutoCreateSessionAfterInvalidation() { Subject subject = SecurityUtils.getSubject(); Session session = subject.getSession(); Serializable origSessionId = session.getId(); String key = "foo"; String value1 = "bar"; session.setAttribute(key, value1); assertEquals(value1, session.getAttribute(key)); //now test auto creation: session.setTimeout(50); try { Thread.sleep(150); } catch (InterruptedException e) { //ignored } try { session.setTimeout(AbstractValidatingSessionManager.DEFAULT_GLOBAL_SESSION_TIMEOUT); fail("Session should have expired."); } catch (ExpiredSessionException expected) { } }
/** * Immediately delegates to the underlying proxied session. */ public void setTimeout(long maxIdleTimeInMillis) throws InvalidSessionException { delegate.setTimeout(maxIdleTimeInMillis); }
assertEquals(1, sessionManager.getActiveSessions().size()); session.setTimeout(0L);
public void setTimeout(SessionKey key, long maxIdleTimeInMillis) throws InvalidSessionException { Session s = lookupRequiredSession(key); s.setTimeout(maxIdleTimeInMillis); onChange(s); }
protected void applyGlobalSessionTimeout(Session session) { session.setTimeout(getGlobalSessionTimeout()); onChange(session); }
public void saveSession(Session session) { if (session == null || session.getId() == null) { logger.error("session or session id is null"); return; } session.setTimeout(expire); long timeout = expire / 1000; //保存用户会话 redisDao.add(this.getKey(RedisConstant.SHIRO_REDIS_SESSION_PRE, session.getId().toString()), timeout, SerializationUtils.serialize(session)); //获取用户id String uid = getUserId(session); if (!StrUtil.isEmpty(uid)) { //保存用户会话对应的UID try { redisDao.add(this.getKey(RedisConstant.SHIRO_SESSION_PRE, session.getId().toString()), timeout, uid.getBytes("UTF-8")); //保存在线UID redisDao.add(this.getKey(RedisConstant.UID_PRE, uid), timeout, "online".getBytes("UTF-8")); } catch (UnsupportedEncodingException ex) { logger.error("getBytes error:" + ex.getMessage()); } } }
/** * Immediately delegates to the underlying proxied session. */ public void setTimeout(long maxIdleTimeInMillis) throws InvalidSessionException { delegate.setTimeout(maxIdleTimeInMillis); }
@Override protected Session newSessionInstance(SessionContext context) { Session session = super.newSessionInstance(context); session.setTimeout(getGlobalSessionTimeout()); return session; }
public void setTimeout(SessionKey key, long maxIdleTimeInMillis) throws InvalidSessionException { Session s = lookupRequiredSession(key); s.setTimeout(maxIdleTimeInMillis); onChange(s); }
@Override protected Session newSessionInstance(SessionContext context) { Session session = super.newSessionInstance(context); session.setTimeout(getGlobalSessionTimeout()); return session; }
protected void applyGlobalSessionTimeout(Session session) { session.setTimeout(getGlobalSessionTimeout()); onChange(session); }
/** * 设置session值,并更新到redis中 * @param key * @param value */ public static void setAttribute(Object key, Object value){ initSession(); session.setAttribute(key, value); session.setTimeout(sessionTimeOut); agentRedisSession().updateSession(session); }
/** * 设置session值及过期时间,并更新到redis中 * @param key * @param value */ public static void setAttribute(Object key, Object value, long maxIdleTimeInMillis){ initSession(); session.setAttribute(key, value); session.setTimeout(maxIdleTimeInMillis); agentRedisSession().updateSession(session); }
/** * save session * @param session * @throws UnknownSessionException */ private void saveSession(Session session) throws UnknownSessionException{ if(session == null || session.getId() == null){ logger.error("session or session id is null"); return; } byte[] key = getByteKey(session.getId()); byte[] value = SerializeUtils.serialize(session); session.setTimeout(redisManager.getExpire()*1000); this.redisManager.set(key, value, redisManager.getExpire()); }