org.apache.shiro.session.mgt.ValidatingSession Java Examples

The following examples show how to use org.apache.shiro.session.mgt.ValidatingSession. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UpmsSessionDao.java    From zheng with MIT License 6 votes vote down vote up
@Override
protected void doUpdate(Session session) {
    // 如果会话过期/停止 没必要再更新了
    if(session instanceof ValidatingSession && !((ValidatingSession)session).isValid()) {
        return;
    }
    // 更新session的最后一次访问时间
    UpmsSession upmsSession = (UpmsSession) session;
    UpmsSession cacheUpmsSession = (UpmsSession) doReadSession(session.getId());
    if (null != cacheUpmsSession) {
        upmsSession.setStatus(cacheUpmsSession.getStatus());
        upmsSession.setAttribute("FORCE_LOGOUT", cacheUpmsSession.getAttribute("FORCE_LOGOUT"));
    }
    RedisUtil.set(ZHENG_UPMS_SHIRO_SESSION_ID + "_" + session.getId(), SerializableUtil.serialize(session), (int) session.getTimeout() / 1000);
    // 更新ZHENG_UPMS_SERVER_SESSION_ID、ZHENG_UPMS_SERVER_CODE过期时间 TODO
    LOGGER.debug("doUpdate >>>>> sessionId={}", session.getId());
}
 
Example #2
Source File: ShiroSessionDAO.java    From phone with Apache License 2.0 6 votes vote down vote up
@Override
	public void update(Session session) {
		if (session instanceof ValidatingSession && !((ValidatingSession) session).isValid()) {
			return; // 如果会话过期/停止 没必要再更新了
		}
		super.update(session);
		RedisClientSupport jedis = SpringBeanUtil.getRedisClientSupport();
		if (jedis != null) {
			String key = RedisKeyConfig.getShiroSessionCacheKey(session.getId());
//			String value = JSON.toJSONString(session);
			String value = SerializableUtils.serialize(session);
			try {
				jedis.putValue(key, value,session.getTimeout()/1000,TimeUnit.SECONDS);
			} catch (InvalidSessionException | CacheAccessException e) {
			}
		}
	}
 
Example #3
Source File: AbstractSSOComponent.java    From nano-framework with Apache License 2.0 6 votes vote down vote up
protected boolean validationSession(final String sessionSerail) {
    final Session session = SerializableUtils.decode(sessionSerail);
    if(session instanceof ValidatingSession) {
        if(!((ValidatingSession) session).isValid()) {
            return false;
        }
    }
    
    for(Object attributeKey : session.getAttributeKeys()) {
        if(!validationSession0(session, attributeKey)) {
            return false;
        }
    }
    
    accessSession(session);
    return true;
}
 
Example #4
Source File: RedisSessionDAO.java    From nano-framework with Apache License 2.0 6 votes vote down vote up
@Override
protected void doUpdate(Session session) {
    if (session instanceof ValidatingSession && !((ValidatingSession) session).isValid()) {
        return;
    }

    initRedisClient();
    RedisClient client = sessions.values().iterator().next();
    switch (persistType) {
        case SET:
            String id;
            client.set((id = sessionName + session.getId()), SerializableUtils.encode(session));
            client.expire(id, sessionExpire);
            break;

        case HSET:
            client.hset(sessionName, (String) session.getId(), SerializableUtils.encode(session));
            break;
    }
}
 
Example #5
Source File: ShiroRedisSessionDao.java    From jee-universal-bms with Apache License 2.0 5 votes vote down vote up
@Override
protected void doUpdate(Session session) {
    // 如果会话过期/停止,没必要再更新了
    if (session instanceof ValidatingSession && !((ValidatingSession) session).isValid()) {
        logger.debug("=> Invalid session.");
        return;
    }

    logger.debug("=> update session with ID [{}]", session.getId());
    this.saveSession(session);
}