Search in sources :

Example 1 with EnterpriseCacheSessionDAO

use of org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO 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);
}
Also used : EnterpriseCacheSessionDAO(org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO) DefaultWebSessionManager(org.apache.shiro.web.session.mgt.DefaultWebSessionManager)

Example 2 with EnterpriseCacheSessionDAO

use of org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO 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;
}
Also used : SimpleCookie(org.apache.shiro.web.servlet.SimpleCookie) EnterpriseCacheSessionDAO(org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO) DefaultWebSessionManager(org.apache.shiro.web.session.mgt.DefaultWebSessionManager) LCacheManager(org.nutz.plugins.cache.impl.lcache.LCacheManager) MemoryConstrainedCacheManager(org.apache.shiro.cache.MemoryConstrainedCacheManager) RedisCacheManager(org.nutz.plugins.cache.impl.redis.RedisCacheManager) CacheManager(org.apache.shiro.cache.CacheManager) EhCacheManager(org.apache.shiro.cache.ehcache.EhCacheManager) UU32SessionIdGenerator(org.nutz.integration.shiro.UU32SessionIdGenerator) IocBean(org.nutz.ioc.loader.annotation.IocBean)

Aggregations

EnterpriseCacheSessionDAO (org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO)2 DefaultWebSessionManager (org.apache.shiro.web.session.mgt.DefaultWebSessionManager)2 CacheManager (org.apache.shiro.cache.CacheManager)1 MemoryConstrainedCacheManager (org.apache.shiro.cache.MemoryConstrainedCacheManager)1 EhCacheManager (org.apache.shiro.cache.ehcache.EhCacheManager)1 SimpleCookie (org.apache.shiro.web.servlet.SimpleCookie)1 UU32SessionIdGenerator (org.nutz.integration.shiro.UU32SessionIdGenerator)1 IocBean (org.nutz.ioc.loader.annotation.IocBean)1 LCacheManager (org.nutz.plugins.cache.impl.lcache.LCacheManager)1 RedisCacheManager (org.nutz.plugins.cache.impl.redis.RedisCacheManager)1