congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
Session.setTimeout
Code IndexAdd Tabnine 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)

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

  • Start an intent from android
  • getContentResolver (Context)
  • scheduleAtFixedRate (Timer)
  • notifyDataSetChanged (ArrayAdapter)
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • ImageIO (javax.imageio)
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
  • Join (org.hibernate.mapping)
  • Logger (org.slf4j)
    The org.slf4j.Logger interface is the main user entry point of SLF4J API. It is expected that loggin
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now