org.apache.shiro.web.session.mgt.DefaultWebSessionManager Java Examples
The following examples show how to use
org.apache.shiro.web.session.mgt.DefaultWebSessionManager.
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 MeetingFilm with Apache License 2.0 | 6 votes |
/** * session管理器(单机环境) */ @Bean @ConditionalOnProperty(prefix = "guns", name = "spring-session-open", havingValue = "false") public DefaultWebSessionManager defaultWebSessionManager(CacheManager cacheShiroManager, GunsProperties gunsProperties) { DefaultWebSessionManager sessionManager = new DefaultWebSessionManager(); sessionManager.setCacheManager(cacheShiroManager); sessionManager.setSessionValidationInterval(gunsProperties.getSessionValidationInterval() * 1000); sessionManager.setGlobalSessionTimeout(gunsProperties.getSessionInvalidateTime() * 1000); sessionManager.setDeleteInvalidSessions(true); sessionManager.setSessionValidationSchedulerEnabled(true); Cookie cookie = new SimpleCookie(ShiroHttpSession.DEFAULT_SESSION_ID_NAME); cookie.setName("shiroCookie"); cookie.setHttpOnly(true); sessionManager.setSessionIdCookie(cookie); return sessionManager; }
Example #2
Source File: ShiroConfig.java From WebStack-Guns with MIT License | 6 votes |
/** * session管理器(单机环境) */ @Bean @ConditionalOnProperty(prefix = "guns", name = "spring-session-open", havingValue = "false") public DefaultWebSessionManager defaultWebSessionManager(CacheManager cacheShiroManager, GunsProperties gunsProperties) { DefaultWebSessionManager sessionManager = new DefaultWebSessionManager(); sessionManager.setCacheManager(cacheShiroManager); sessionManager.setSessionValidationInterval(gunsProperties.getSessionValidationInterval() * 1000); sessionManager.setGlobalSessionTimeout(gunsProperties.getSessionInvalidateTime() * 1000); sessionManager.setDeleteInvalidSessions(true); sessionManager.setSessionValidationSchedulerEnabled(true); Cookie cookie = new SimpleCookie(ShiroHttpSession.DEFAULT_SESSION_ID_NAME); cookie.setName("shiroCookie"); cookie.setHttpOnly(true); sessionManager.setSessionIdCookie(cookie); return sessionManager; }
Example #3
Source File: ShiroConfig.java From springboot-learn with MIT License | 6 votes |
/** * 会话管理器 */ @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 #4
Source File: ShiroConfig.java From SpringBootBucket with MIT License | 6 votes |
@Bean(name = "sessionManager") public DefaultWebSessionManager defaultWebSessionManager() { DefaultWebSessionManager sessionManager = new DefaultWebSessionManager(); sessionManager.setGlobalSessionTimeout(18000000); // url中是否显示session Id sessionManager.setSessionIdUrlRewritingEnabled(false); // 删除失效的session sessionManager.setDeleteInvalidSessions(true); sessionManager.setSessionValidationSchedulerEnabled(true); sessionManager.setSessionValidationInterval(18000000); sessionManager.setSessionValidationScheduler(getExecutorServiceSessionValidationScheduler()); //设置SessionIdCookie 导致认证不成功,不从新设置新的cookie,从sessionManager获取sessionIdCookie //sessionManager.setSessionIdCookie(simpleIdCookie()); sessionManager.getSessionIdCookie().setName("session-z-id"); sessionManager.getSessionIdCookie().setPath("/"); sessionManager.getSessionIdCookie().setMaxAge(60 * 60 * 24 * 7); return sessionManager; }
Example #5
Source File: ShiroAutoConfiguration.java From spring-boot-shiro with Apache License 2.0 | 6 votes |
@Bean(name = "sessionValidationScheduler") @DependsOn(value = {"sessionManager"}) @ConditionalOnMissingBean(SessionValidationScheduler.class) public SessionValidationScheduler sessionValidationScheduler(DefaultWebSessionManager sessionManager) { ExecutorServiceSessionValidationScheduler validationScheduler = new ExecutorServiceSessionValidationScheduler(sessionManager); sessionManager.setDeleteInvalidSessions(shiroSessionProperties.isDeleteInvalidSessions()); sessionManager.setSessionValidationInterval(shiroSessionProperties.getValidationInterval()); sessionManager.setSessionValidationSchedulerEnabled(shiroSessionProperties.isValidationSchedulerEnabled()); sessionManager.setSessionValidationScheduler(validationScheduler); return validationScheduler; }
Example #6
Source File: ShiroConfiguration.java From jee-universal-bms with Apache License 2.0 | 5 votes |
@Bean public DefaultWebSessionManager getSessionManager() { CustomWebSessionManager sessionManager = new CustomWebSessionManager(); sessionManager.setGlobalSessionTimeout(1800000); // 设置全局会话超时时间,默认30分钟(1800000) sessionManager.setDeleteInvalidSessions(true); // 是否在会话过期后会调用SessionDAO的delete方法删除会话 默认true sessionManager.setSessionValidationInterval(1800000); // 会话验证器调度时间 sessionManager.setSessionDAO(getSessionDao()); // 自定义SessionDao // sessionManager.setSessionIdCookie(getSessionIdCookie()); // 自定义Cookie sessionManager.setSessionValidationSchedulerEnabled(true); // 定时检查失效的session return sessionManager; }
Example #7
Source File: ShiroConfig.java From erp-framework with MIT License | 5 votes |
/** * 配置会话管理器,设定会话超时及保存 * @return */ @Bean public SessionManager sessionManager() { DefaultWebSessionManager manager = new DefaultWebSessionManager(); //设置session过期时间为1小时(单位:毫秒),默认为30分钟 manager.setGlobalSessionTimeout(60 * 60 * 1000); // 是否开启定时调度器进行检测过期session manager.setSessionValidationSchedulerEnabled(true); manager.setSessionDAO(sessionDao()); return manager; }
Example #8
Source File: ShiroAutoConfiguration.java From utils with Apache License 2.0 | 5 votes |
@Bean(name = "sessionValidationScheduler") @DependsOn(value = {"sessionManager"}) @ConditionalOnMissingBean(SessionValidationScheduler.class) public SessionValidationScheduler sessionValidationScheduler(DefaultWebSessionManager sessionManager) { ExecutorServiceSessionValidationScheduler scheduler = new ExecutorServiceSessionValidationScheduler(sessionManager); sessionManager.setDeleteInvalidSessions(shiroSessionProperties.isDeleteInvalidSessions()); sessionManager.setSessionValidationInterval(shiroSessionProperties.getValidationInterval()); sessionManager.setSessionValidationSchedulerEnabled(shiroSessionProperties.isValidationSchedulerEnabled()); sessionManager.setSessionValidationScheduler(scheduler); return scheduler; }
Example #9
Source File: ShiroConfig.java From server-boilerplate with MIT License | 5 votes |
@Bean public SessionManager getSessionManager() { DefaultWebSessionManager sessionManager = new DefaultWebSessionManager(); sessionManager.setGlobalSessionTimeout(180000); sessionManager.setDeleteInvalidSessions(true); return sessionManager; }
Example #10
Source File: ShiroConfiguration.java From easyweb with Apache License 2.0 | 5 votes |
@Bean(name = "sessionManager") public DefaultWebSessionManager getSessionManager( RedisSessionDAO sessionDAO, SimpleCookie sessionIdCookie) { SessionManager sessionManager = new SessionManager(); sessionManager.setSessionDAO(sessionDAO); sessionManager.setGlobalSessionTimeout(1800000); //定时清理失效会话, 清理用户直接关闭浏览器造成的孤立会话4分钟检查一次 sessionManager.setSessionValidationInterval(24000); sessionManager.setSessionValidationSchedulerEnabled(true); sessionManager.setSessionIdCookie(sessionIdCookie); sessionManager.setSessionIdCookieEnabled(true); return sessionManager; }
Example #11
Source File: ShiroConfiguration.java From easyweb with Apache License 2.0 | 5 votes |
@Bean(name = "securityManager") public DefaultWebSecurityManager getDefaultWebSecurityManager( SystemAuthorizingRealm myShiroRealm, DefaultWebSessionManager sessionManager, CacheManager shiroCacheManager) { DefaultWebSecurityManager dwsm = new DefaultWebSecurityManager(); dwsm.setRealm(myShiroRealm); dwsm.setSessionManager(sessionManager); // <!-- 用户授权/认证信息Cache, 采用redis 缓存 --> dwsm.setCacheManager(shiroCacheManager); return dwsm; }
Example #12
Source File: ShiroConfig.java From Spring-Shiro-Spark with Apache License 2.0 | 5 votes |
@Bean(name = "sessionManager") public DefaultWebSessionManager sessionManager(){ DefaultWebSessionManager manager = new DefaultWebSessionManager(); //manager.setCacheManager(cacheManager);// 加入缓存管理器 manager.setSessionFactory(shiroSessionFactory());//设置sessionFactory manager.setSessionDAO(shiroSessionDao());// 设置SessionDao manager.setDeleteInvalidSessions(true);// 删除过期的session manager.setGlobalSessionTimeout(shiroSessionDao().getExpireTime());// 设置全局session超时时间 manager.setSessionValidationSchedulerEnabled(true);// 是否定时检查session return manager; }
Example #13
Source File: ShiroConfig.java From wetech-admin with MIT License | 5 votes |
/** * 会话管理器 * * @return */ @Bean public DefaultWebSessionManager sessionManager() { DefaultWebSessionManager defaultSessionManager = new DefaultWebSessionManager(); defaultSessionManager.setSessionValidationSchedulerEnabled(false); return defaultSessionManager; }
Example #14
Source File: ShiroConfig.java From mysiteforme with Apache License 2.0 | 5 votes |
@Bean public SessionManager webSessionManager(){ DefaultWebSessionManager manager = new DefaultWebSessionManager(); //设置session过期时间为1小时(单位:毫秒),默认为30分钟 manager.setGlobalSessionTimeout(60 * 60 * 1000); manager.setSessionValidationSchedulerEnabled(true); manager.setSessionDAO(redisSessionDAO()); return manager; }
Example #15
Source File: ShiroConfiguration.java From spring-boot-seed with MIT License | 5 votes |
/** * SessionManager,设置Session超时 * * @return SessionManager */ @Bean public SessionManager sessionManager() { DefaultWebSessionManager defaultWebSessionManager = new DefaultWebSessionManager(); defaultWebSessionManager.setGlobalSessionTimeout(7200000); defaultWebSessionManager.setDeleteInvalidSessions(true); return defaultWebSessionManager; }
Example #16
Source File: ShiroConfiguration.java From chronus with Apache License 2.0 | 5 votes |
@Bean public DefaultWebSecurityManager securityManager(MyShiroRealm myShiroRealm, DefaultWebSessionManager sessionManager) { DefaultWebSecurityManager manager = new DefaultWebSecurityManager(); manager.setRealm(myShiroRealm); manager.setSessionManager(sessionManager); return manager; }
Example #17
Source File: ShiroConfig.java From jsets-shiro-spring-boot-starter with Apache License 2.0 | 4 votes |
public DefaultWebSessionManager getSessionManager() { return this.sessionManager; }
Example #18
Source File: ShiroConfig.java From scaffold-cloud with MIT License | 4 votes |
@Bean public DefaultWebSessionManager sessionManager() { return new MySessionManager(); }