org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO Java Examples

The following examples show how to use org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO. 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: ShiroConfig.java    From springboot-learn with MIT License 6 votes vote down vote up
/**
 * 会话管理器
 */
@Bean
public DefaultWebSessionManager sessionManager() {
    DefaultWebSessionManager manager = new DefaultWebSessionManager();
    // 加入缓存管理器
    manager.setCacheManager(getEhCacheManager());
    // 删除过期的session
    manager.setDeleteInvalidSessions(true);
    // 设置全局session超时时间
    manager.setGlobalSessionTimeout(30 * 60 * 1000);
    // 是否定时检查session
    manager.setSessionValidationSchedulerEnabled(true);
    // 自定义SessionDao
    manager.setSessionDAO(new EnterpriseCacheSessionDAO());
    return manager;
}
 
Example #2
Source File: ShiroAutoConfiguration.java    From utils with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public SessionDAO sessionDAO(CacheManager cacheManager) {
    EnterpriseCacheSessionDAO dao = new EnterpriseCacheSessionDAO();
    dao.setActiveSessionsCacheName(shiroSessionProperties.getActiveSessionsCacheName());
    Class<? extends SessionIdGenerator> idGenerator = shiroSessionProperties.getIdGenerator();
    if (idGenerator != null) {
        SessionIdGenerator sessionIdGenerator = BeanUtils.instantiate(idGenerator);
        dao.setSessionIdGenerator(sessionIdGenerator);
    }
    dao.setCacheManager(cacheManager);

    return dao;
}