当前位置: 首页>>代码示例>>Java>>正文


Java DefaultWebSessionManager类代码示例

本文整理汇总了Java中org.apache.shiro.web.session.mgt.DefaultWebSessionManager的典型用法代码示例。如果您正苦于以下问题:Java DefaultWebSessionManager类的具体用法?Java DefaultWebSessionManager怎么用?Java DefaultWebSessionManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DefaultWebSessionManager类属于org.apache.shiro.web.session.mgt包,在下文中一共展示了DefaultWebSessionManager类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: defaultWebSessionManager

import org.apache.shiro.web.session.mgt.DefaultWebSessionManager; //导入依赖的package包/类
/**
 * @see DefaultWebSessionManager
 */
@Bean(name = "sessionManager")
public DefaultWebSessionManager defaultWebSessionManager() {
    DefaultWebSessionManager sessionManager = new DefaultWebSessionManager();
    //sessionManager.setSessionDAO(new CustomSessionDAO());
    sessionManager.setCacheManager(ehCacheManager());
    //单位为毫秒(1秒=1000毫秒) 3600000毫秒为1个小时
    sessionManager.setSessionValidationInterval(3600000 * 12);
    //3600000 milliseconds = 1 hour
    sessionManager.setGlobalSessionTimeout(3600000 * 12);
    sessionManager.setDeleteInvalidSessions(true);
    sessionManager.setSessionValidationSchedulerEnabled(true);
    Cookie cookie = new SimpleCookie(ShiroHttpSession.DEFAULT_SESSION_ID_NAME);
    cookie.setName("WEBID");
    cookie.setHttpOnly(true);
    sessionManager.setSessionIdCookie(cookie);
    return sessionManager;
}
 
开发者ID:wu05281,项目名称:admin-shiro,代码行数:21,代码来源:ShiroConfig.java

示例2: sessionManager

import org.apache.shiro.web.session.mgt.DefaultWebSessionManager; //导入依赖的package包/类
@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;
}
 
开发者ID:ZhuXS,项目名称:Spring-Shiro-Spark,代码行数:12,代码来源:ShiroConfig.java

示例3: getDefaultWebSecurityManager

import org.apache.shiro.web.session.mgt.DefaultWebSessionManager; //导入依赖的package包/类
@Bean(name = "securityManager")
    public DefaultWebSecurityManager getDefaultWebSecurityManager(
            SystemAuthorizingRealm myShiroRealm,
            DefaultWebSessionManager sessionManager,
            EhCacheManager shiroCacheManager) {
        DefaultWebSecurityManager dwsm = new DefaultWebSecurityManager();
        dwsm.setRealm(myShiroRealm);
        dwsm.setSessionManager(sessionManager);
//      <!-- 用户授权/认证信息Cache, 采用EhCache 缓存 -->
        dwsm.setCacheManager(shiroCacheManager);
        return dwsm;
    }
 
开发者ID:egojit8,项目名称:easyweb,代码行数:13,代码来源:ShiroConfiguration.java

示例4: getSessionManager

import org.apache.shiro.web.session.mgt.DefaultWebSessionManager; //导入依赖的package包/类
@Bean(name = "sessionManager")
    public DefaultWebSessionManager getSessionManager(
            SessionDAO sessionDAO,
            SimpleCookie sessionIdCookie) {
        SessionManager sessionManager=new SessionManager();
//        SessionManager sessionManager = new SessionManager();
        sessionManager.setSessionDAO(sessionDAO);
        sessionManager.setGlobalSessionTimeout(1800000);
        //定时清理失效会话, 清理用户直接关闭浏览器造成的孤立会话
        sessionManager.setSessionValidationInterval(120000);
        sessionManager.setSessionValidationSchedulerEnabled(true);
        sessionManager.setSessionIdCookie(sessionIdCookie);
        sessionManager.setSessionIdCookieEnabled(true);
        return sessionManager;
    }
 
开发者ID:egojit8,项目名称:easyweb,代码行数:16,代码来源:ShiroConfiguration.java

示例5: sessionValidationScheduler

import org.apache.shiro.web.session.mgt.DefaultWebSessionManager; //导入依赖的package包/类
@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;
}
 
开发者ID:johntostring,项目名称:spring-boot-shiro,代码行数:12,代码来源:ShiroAutoConfiguration.java

示例6: getSessionManager

import org.apache.shiro.web.session.mgt.DefaultWebSessionManager; //导入依赖的package包/类
@Bean
public SessionManager getSessionManager() {
    DefaultWebSessionManager sessionManager = new DefaultWebSessionManager();
    sessionManager.setGlobalSessionTimeout(180000);
    sessionManager.setDeleteInvalidSessions(true);
    return sessionManager;
}
 
开发者ID:sisyphsu,项目名称:server-boilerplate,代码行数:8,代码来源:ShiroConfig.java

示例7: sessionValidationScheduler

import org.apache.shiro.web.session.mgt.DefaultWebSessionManager; //导入依赖的package包/类
@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;
}
 
开发者ID:storezhang,项目名称:utils,代码行数:13,代码来源:ShiroAutoConfiguration.java

示例8: webSecurityManager

import org.apache.shiro.web.session.mgt.DefaultWebSessionManager; //导入依赖的package包/类
@Bean
public DefaultWebSecurityManager webSecurityManager(Realm realm,
                                                    CookieRememberMeManager rememberMeManager,
                                                    DefaultWebSessionManager sessionManager,
                                                    EhCacheManager ehCacheManager) {
    DefaultWebSecurityManager defaultWebSecurityManager = new DefaultWebSecurityManager();
    defaultWebSecurityManager.setRealm(realm);
    defaultWebSecurityManager.setRememberMeManager(rememberMeManager);
    defaultWebSecurityManager.setSessionManager(sessionManager);
    defaultWebSecurityManager.setCacheManager(ehCacheManager);
    return defaultWebSecurityManager;
}
 
开发者ID:izhangzhihao,项目名称:SpringMVCWithJavaConfig,代码行数:13,代码来源:ShiroConfig.java

示例9: defaultWebSessionManager

import org.apache.shiro.web.session.mgt.DefaultWebSessionManager; //导入依赖的package包/类
@Bean(name = "sessionManager")
public DefaultWebSessionManager defaultWebSessionManager(RedisSessionDao sessionDao, RedisCacheManager cacheManager, SimpleCookie simpleCookie) {
    LOGGER.info("register sessionManager...");

    DefaultWebSessionManager sessionManager = new DefaultWebSessionManager();
    sessionManager.setSessionDAO(sessionDao);
    // sessionManager.setCacheManager(cacheManager);
    sessionManager.setSessionIdCookie(simpleCookie);

    return sessionManager;
}
 
开发者ID:hadesvip,项目名称:ssm-shiro,代码行数:12,代码来源:ShiroConfig.java

示例10: initSecurityManager

import org.apache.shiro.web.session.mgt.DefaultWebSessionManager; //导入依赖的package包/类
private WebSecurityManager initSecurityManager() {
    AppDbRealm appDbRealm = new AppDbRealm();
    DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager(appDbRealm);
    final EhCacheManager cacheManager = new EhCacheManager();
    cacheManager.setCacheManagerConfigFile("classpath:goja/ehcache/shiro-ehcache.xml");
    securityManager.setCacheManager(cacheManager);
    final DefaultWebSessionManager defaultWebSessionManager = new DefaultWebSessionManager();
    defaultWebSessionManager.setSessionIdCookieEnabled(true);
    // 默认一年过期时间
    final String expiredTimes = shiroConfig.getProperty("session.expired", "10800000");
    defaultWebSessionManager.setGlobalSessionTimeout(MoreObjects.firstNonNull(Ints.tryParse(expiredTimes), 10800000));
    securityManager.setSessionManager(defaultWebSessionManager);
    return securityManager;
}
 
开发者ID:GojaFramework,项目名称:goja,代码行数:15,代码来源:GojaShiroFilter.java

示例11: sessionManager

import org.apache.shiro.web.session.mgt.DefaultWebSessionManager; //导入依赖的package包/类
@Bean
    public SessionManager sessionManager() {
        DefaultWebSessionManager defaultWebSessionManager = new DefaultWebSessionManager();
        defaultWebSessionManager.setGlobalSessionTimeout(Integer.valueOf(env.getProperty("session.max.age")) * 1000);
        defaultWebSessionManager.setSessionValidationSchedulerEnabled(false);

//        List<SessionListener> listenerList = new ArrayList<>();
//        listenerList.add(sessionListener());
//        defaultWebSessionManager.setSessionListeners(listenerList);
        return defaultWebSessionManager;
    }
 
开发者ID:qatang,项目名称:ctm,代码行数:12,代码来源:ShiroConfig.java

示例12: initialize

import org.apache.shiro.web.session.mgt.DefaultWebSessionManager; //导入依赖的package包/类
@Override
public boolean initialize(SilentGo me) throws AppBuildException {


    ShiroConfig config = (ShiroConfig) me.getConfig().getConfig(Name);

    me.getFactory(CacheFactory.class);
    PropKit prop = me.getConfig().getUserProp();

    RetryLimitHashedCredentialsMatcher retryLimitHashedCredentialsMatcher = new RetryLimitHashedCredentialsMatcher();
    retryLimitHashedCredentialsMatcher.setHashAlgorithmName(prop.getValue(Dict.SHIRO_CREDENTIALS_MATCHER_HASHALGORITHMNAME, "md5"));
    retryLimitHashedCredentialsMatcher.setHashIterations(prop.getInt(Dict.SHIRO_CREDENTIALS_MATCHER_HASHITERATIONS, 2));
    retryLimitHashedCredentialsMatcher.setStoredCredentialsHexEncoded(prop.getBool(Dict.SHIRO_CREDENTIALS_MATCHER_STOREDCREDENTIALSHEXENCODED, true));
    EhCacheManager ehCacheManager = new EhCacheManager();
    EhCache cache = (EhCache) me.getConfig().getCacheManager();
    ehCacheManager.setCacheManager(cache.getCacheManager());

    JavaUuidSessionIdGenerator sessionIdGenerator = new JavaUuidSessionIdGenerator();

    SimpleCookie sessionIdCookie = new SimpleCookie(prop.getValue(Dict.SHIRO_SESSION_COOKIENAME, "lc4e"));
    sessionIdCookie.setMaxAge(prop.getInt(Dict.SHIRO_SESSION_IDCOOKIE_MAXAGE, -1));
    sessionIdCookie.setHttpOnly(prop.getBool(Dict.SHIRO_SESSION_IDCOOKIE_HTTPONLY, true));

    SimpleCookie rememberMeCookie = new SimpleCookie(prop.getValue(Dict.SHIRO_SESSION_REMEMBER_COOKIENAME, "rlc4e"));
    rememberMeCookie.setHttpOnly(prop.getBool(Dict.SHIRO_SESSION_REMEMBER_ME_HTTPONLY, true));
    rememberMeCookie.setMaxAge(prop.getInt(Dict.SHIRO_SESSION_REMEMBER_ME_MAXAGE, 2592000));

    CookieRememberMeManager rememberMeManager = new CookieRememberMeManager();
    rememberMeManager.setCipherKey(Base64.decode(prop.getValue(Dict.SECURITY_KEY, "4AvVhmFLUs0KTA3Kprsdag==")));
    rememberMeManager.setCookie(rememberMeCookie);

    EnterpriseCacheSessionDAO sessionDAO = new EnterpriseCacheSessionDAO();
    sessionDAO.setActiveSessionsCacheName(prop.getValue(Dict.SHIRO_SESSION_ACTIVE_NAME, "shiro-activeSessionCache"));
    sessionDAO.setSessionIdGenerator(sessionIdGenerator);
    sessionDAO.setCacheManager(ehCacheManager);


    config.getRealm().setCredentialsMatcher(retryLimitHashedCredentialsMatcher);
    config.getRealm().setCachingEnabled(false);
    config.getRealm().setCacheManager(ehCacheManager);

    DefaultWebSessionManager sessionManager = new DefaultWebSessionManager();

    sessionValidationScheduler = new QuartzSessionValidationScheduler(sessionManager);
    sessionValidationScheduler.setSessionValidationInterval(prop.getLong(Dict.SHIRO_SESSION_VALIDATIONINTERVAL, 1800000L));

    sessionManager.setGlobalSessionTimeout(prop.getLong(Dict.SHIRO_SESSION_GLOBALSESSIONTIMEOUT, 1800000L));
    sessionManager.setSessionDAO(sessionDAO);
    sessionManager.setSessionValidationInterval(prop.getLong(Dict.SHIRO_SESSION_VALIDATIONINTERVAL, 360000L));
    sessionManager.setSessionValidationScheduler(sessionValidationScheduler);
    sessionManager.setSessionIdCookieEnabled(prop.getBool(Dict.SHIRO_SESSION_IDCOOKIEENABLED, true));
    sessionManager.setSessionIdCookie(sessionIdCookie);


    sessionValidationScheduler.setSessionManager(sessionManager);

    defaultWebSecurityManager = new DefaultWebSecurityManager(config.getRealm());
    defaultWebSecurityManager.setCacheManager(ehCacheManager);
    defaultWebSecurityManager.setRememberMeManager(rememberMeManager);
    defaultWebSecurityManager.setSessionManager(sessionManager);


    ServletContext servletContext = me.getContext();

    ShiroLoader shiroLoader = new ShiroLoader();

    shiroLoader.initEnvironment(servletContext);
    WebEnvironment environment = (WebEnvironment) servletContext.getAttribute(ShiroLoader.ENVIRONMENT_ATTRIBUTE_KEY);
    ((MutableWebEnvironment) environment).setWebSecurityManager(defaultWebSecurityManager);
    servletContext.setAttribute(ShiroLoader.ENVIRONMENT_ATTRIBUTE_KEY, environment);

    return false;
}
 
开发者ID:Teddy-Zhu,项目名称:SilentGo,代码行数:74,代码来源:ShiroFactory.java

示例13: bindSessionManager

import org.apache.shiro.web.session.mgt.DefaultWebSessionManager; //导入依赖的package包/类
@Override
protected void bindSessionManager(AnnotatedBindingBuilder<SessionManager> bind) {
    bind.to(DefaultWebSessionManager.class);
}
 
开发者ID:CIDARLAB,项目名称:clotho3crud,代码行数:5,代码来源:SecurityModule.java


注:本文中的org.apache.shiro.web.session.mgt.DefaultWebSessionManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。