use of org.apache.shiro.web.session.mgt.DefaultWebSessionManager in project vip by guangdada.
the class ShiroConfig method defaultWebSessionManager.
/**
* 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;
}
use of org.apache.shiro.web.session.mgt.DefaultWebSessionManager in project mica2 by obiba.
the class SecurityManagerFactory method initializeSessionManager.
private void initializeSessionManager(DefaultWebSecurityManager dsm) {
DefaultWebSessionManager sessionManager = new DefaultWebSessionManager();
sessionManager.setSessionDAO(new EnterpriseCacheSessionDAO());
sessionManager.setSessionValidationInterval(SESSION_VALIDATION_INTERVAL);
sessionManager.setSessionValidationSchedulerEnabled(true);
dsm.setSessionManager(sessionManager);
}
use of org.apache.shiro.web.session.mgt.DefaultWebSessionManager in project nutzboot by nutzam.
the class ShiroEnvStarter method getWebSessionManager.
@IocBean(name = "shiroWebSessionManager")
public WebSessionManager getWebSessionManager() {
DefaultWebSessionManager webSessionManager = conf.make(DefaultWebSessionManager.class, "shiro.session.manager.");
// 带缓存的shiro会话
EnterpriseCacheSessionDAO sessionDAO = new EnterpriseCacheSessionDAO();
sessionDAO.setSessionIdGenerator(new UU32SessionIdGenerator());
webSessionManager.setSessionDAO(sessionDAO);
// cookie
conf.putIfAbsent(PROP_SESSION_COOKIE_NAME, "sid");
conf.putIfAbsent(PROP_SESSION_COOKIE_MAXAGE, "946080000");
conf.putIfAbsent(PROP_SESSION_COOKIE_HTTPONLY, "true");
SimpleCookie cookie = conf.make(SimpleCookie.class, "shiro.session.cookie.");
webSessionManager.setSessionIdCookie(cookie);
webSessionManager.setSessionIdCookieEnabled(true);
webSessionManager.setCacheManager(ioc.get(CacheManager.class, "shiroCacheManager"));
return webSessionManager;
}
use of org.apache.shiro.web.session.mgt.DefaultWebSessionManager in project tesla by linking12.
the class AuthzConfig method sessionManager.
@Bean
public SessionManager sessionManager() {
DefaultWebSessionManager sessionManager = new DefaultWebSessionManager();
Collection<SessionListener> listeners = new ArrayList<SessionListener>();
listeners.add(new TeslaSessionListener());
sessionManager.setSessionListeners(listeners);
sessionManager.setSessionDAO(sessionDAO());
return sessionManager;
}
use of org.apache.shiro.web.session.mgt.DefaultWebSessionManager in project wechat by dllwh.
the class ShiroConfig method sessionManager.
/**
* @方法描述 : session管理器
* @return
*/
// @Bean("sessionManager")
public DefaultWebSessionManager sessionManager() {
DefaultWebSessionManager sessionManager = new DefaultWebSessionManager();
// session的失效时长,默认是30 分钟((1800000)),该值以毫秒为时间单位
sessionManager.setGlobalSessionTimeout(TIMEOUT);
// 是否在会话过期后会调用SessionDAO的delete方法删除会话,默认true
sessionManager.setDeleteInvalidSessions(true);
// 间隔多少时间检查,不配置是60分钟
sessionManager.setSessionValidationScheduler(sessionValidationScheduler());
// 是否开启session验证检测
sessionManager.setSessionValidationSchedulerEnabled(true);
// 定时清理失效session , 清理用户直接关闭浏览器造成的孤立会话 :默认每小时检测一次
sessionManager.setSessionValidationInterval(INTERVAL);
// 是否启用/禁用,默认是启用的;如果禁用后将不会设置Session Id Cookie,即默认使用了Servlet容器的JSESSIONID
sessionManager.setSessionIdCookieEnabled(true);
sessionManager.setSessionIdCookie(sessionIdCookie());
// sessionManager.setSessionIdUrlRewritingEnabled(false);
// sessionManager.setSessionDAO(sessionDAO);
// session 监听
Collection<SessionListener> sessionListeners = Lists.newArrayList();
sessionListeners.add(new CustomSessionListener());
sessionManager.setSessionListeners(sessionListeners);
return sessionManager;
}
Aggregations