Example usage for org.apache.shiro.session.mgt SimpleSession setStopTimestamp

List of usage examples for org.apache.shiro.session.mgt SimpleSession setStopTimestamp

Introduction

In this page you can find the example usage for org.apache.shiro.session.mgt SimpleSession setStopTimestamp.

Prototype

public void setStopTimestamp(Date stopTimestamp) 

Source Link

Usage

From source file:net.eggcanfly.spring.shiro.support.RedisSessionDao.java

License:Apache License

protected Session deserializeSession(Serializable sessionId) {

    BoundHashOperations<String, String, Object> hashOperations = redisTemplate
            .boundHashOps(SESSION_KEY + sessionId);

    SimpleSession session = new SimpleSession();

    try {/*from  w w w.ja  v a2 s.  c o m*/

        session.setHost((String) hashOperations.get("host"));
        session.setId(sessionId);
        session.setLastAccessTime(
                hashOperations.get("lastAccessTime") == null ? new Date(System.currentTimeMillis())
                        : (Date) hashOperations.get("lastAccessTime"));
        session.setStartTimestamp((Date) hashOperations.get("startTimestamp"));
        session.setStopTimestamp((Date) hashOperations.get("stopTimestamp"));
        session.setTimeout((long) hashOperations.get("timeout"));
        Set<String> hashKeys = hashOperations.keys();
        for (Iterator<String> iterator = hashKeys.iterator(); iterator.hasNext();) {
            String hashKey = iterator.next();
            session.setAttribute(hashKey, hashOperations.get(hashKey));
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);

    }

    logger.debug("read session " + sessionId + ", session is " + session);

    return session.isValid() ? session : null;
}