Codota Logo
Session.setTimeout
Code IndexAdd Codota to your IDE (free)

How to use
setTimeout
method
in
org.apache.shiro.session.Session

Best Java code snippets using org.apache.shiro.session.Session.setTimeout (Showing top 20 results out of 315)

  • Common ways to obtain Session
private void myMethod () {
Session s =
  • Codota IconSecurityUtils.getSubject().getSession()
  • Codota IconSubject subject;subject.getSession(false)
  • Codota IconSubject subject;subject.getSession()
  • Smart code suggestions by Codota
}
origin: apache/shiro

/**
 * Immediately delegates to the underlying proxied session.
 */
public void setTimeout(long maxIdleTimeInMillis) throws InvalidSessionException {
  delegate.setTimeout(maxIdleTimeInMillis);
}
origin: apache/shiro

public void setMaxInactiveInterval(int i) {
  try {
    getSession().setTimeout(i * 1000);
  } catch (InvalidSessionException e) {
    throw new IllegalStateException(e);
  }
}
origin: apache/shiro

public void setTimeout(SessionKey key, long maxIdleTimeInMillis) throws InvalidSessionException {
  Session s = lookupRequiredSession(key);
  s.setTimeout(maxIdleTimeInMillis);
  onChange(s);
}
origin: apache/shiro

protected void applyGlobalSessionTimeout(Session session) {
  session.setTimeout(getGlobalSessionTimeout());
  onChange(session);
}
origin: wuyouzhuguli/FEBS-Shiro

@Override
public boolean forceLogout(String sessionId) {
  Session session = sessionDAO.readSession(sessionId);
  session.setTimeout(0);
  session.stop();
  sessionDAO.delete(session);
  return true;
}
origin: Graylog2/graylog2-server

if (user != null) {
  long timeoutInMillis = user.getSessionTimeoutMs();
  s.setTimeout(timeoutInMillis);
} else {
  s.setTimeout(TimeUnit.HOURS.toMillis(8));
origin: apache/shiro

/**
 * 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) {
  }
}
origin: org.apache.shiro/shiro-core

/**
 * Immediately delegates to the underlying proxied session.
 */
public void setTimeout(long maxIdleTimeInMillis) throws InvalidSessionException {
  delegate.setTimeout(maxIdleTimeInMillis);
}
origin: apache/shiro

assertEquals(1, sessionManager.getActiveSessions().size());
session.setTimeout(0L);
origin: org.apache.shiro/shiro-core

public void setTimeout(SessionKey key, long maxIdleTimeInMillis) throws InvalidSessionException {
  Session s = lookupRequiredSession(key);
  s.setTimeout(maxIdleTimeInMillis);
  onChange(s);
}
origin: org.apache.shiro/shiro-core

protected void applyGlobalSessionTimeout(Session session) {
  session.setTimeout(getGlobalSessionTimeout());
  onChange(session);
}
origin: bill1012/AdminEAP

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());
    }
  }
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.shiro

/**
 * Immediately delegates to the underlying proxied session.
 */
public void setTimeout(long maxIdleTimeInMillis) throws InvalidSessionException {
  delegate.setTimeout(maxIdleTimeInMillis);
}
origin: cn.jeeweb/jeeweb-common-security

@Override
protected Session newSessionInstance(SessionContext context) {
  Session session = super.newSessionInstance(context);
  session.setTimeout(getGlobalSessionTimeout());
  return session;
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.shiro

public void setTimeout(SessionKey key, long maxIdleTimeInMillis) throws InvalidSessionException {
  Session s = lookupRequiredSession(key);
  s.setTimeout(maxIdleTimeInMillis);
  onChange(s);
}
origin: huangjian888/jeeweb-mybatis-springboot

@Override
protected Session newSessionInstance(SessionContext context) {
  Session session = super.newSessionInstance(context);
  session.setTimeout(getGlobalSessionTimeout());
  return session;
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.shiro

protected void applyGlobalSessionTimeout(Session session) {
  session.setTimeout(getGlobalSessionTimeout());
  onChange(session);
}
origin: daijiejay/daijie

/**
 * 设置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);
}
 
origin: daijiejay/daijie

/**
 * 设置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);
}
origin: daijiejay/daijie

/**
 * 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());
}
org.apache.shiro.sessionSessionsetTimeout

Javadoc

Sets the time in milliseconds that the session may remain idle before expiring.
  • A negative value means the session will never expire.
  • A non-negative value (0 or greater) means the session expiration will occur if idle for that length of time.

*Note: if you are used to the HttpSession's getMaxInactiveInterval() method, the scale on this method is different: Shiro Sessions use millisecond values for timeout whereas HttpSession.getMaxInactiveInterval uses seconds. Always use millisecond values with Shiro sessions.

Popular methods of Session

  • getAttribute
    Returns the object bound to this session identified by the specified key. If there is no object boun
  • setAttribute
    Binds the specified value to this session, uniquely identified by the specifed key name. If there is
  • getId
    Returns the unique identifier assigned by the system upon session creation. All return values from t
  • removeAttribute
    Removes (unbinds) the object bound to this session under the specified key name.
  • getHost
    Returns the host name or IP string of the host that originated this session, or nullif the host is u
  • getTimeout
    Returns the time in milliseconds that the session session may remain idle before expiring. * A negat
  • getLastAccessTime
    Returns the last time the application received a request or method invocation from the user associat
  • getStartTimestamp
    Returns the time the session was started; that is, the time the system created the instance.
  • getAttributeKeys
    Returns the keys of all the attributes stored under this session. If there are no attributes, this r
  • stop
    Explicitly stops (invalidates) this session and releases all associated resources. If this session h
  • touch
    Explicitly updates the #getLastAccessTime() of this session to the current time when this method is
  • touch

Popular in Java

  • Finding current android device location
  • addToBackStack (FragmentTransaction)
  • setContentView (Activity)
  • scheduleAtFixedRate (ScheduledExecutorService)
    Creates and executes a periodic action that becomes enabled first after the given initial delay, and
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • BigDecimal (java.math)
    An immutable arbitrary-precision signed decimal.A value is represented by an arbitrary-precision "un
  • Permission (java.security)
    Abstract class for representing access to a system resource. All permissions have a name (whose inte
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • Iterator (java.util)
    An iterator over a collection. Iterator takes the place of Enumeration in the Java Collections Frame
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now