org.apache.shiro.mgt.DefaultSessionStorageEvaluator Java Examples

The following examples show how to use org.apache.shiro.mgt.DefaultSessionStorageEvaluator. 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: ShiroAuthConfig.java    From Moss with Apache License 2.0 6 votes vote down vote up
@Bean("securityManager")
public DefaultWebSecurityManager getManager(UserService userService) {
    DefaultWebSecurityManager manager = new DefaultWebSecurityManager();
    List<Realm> realms = Lists.newArrayList();
    realms.add(new DBRealm(userService));
    manager.setRealms(realms);

    /*
     * 关闭shiro自带的session,详情见文档
     * http://shiro.apache.org/session-management.html#SessionManagement-StatelessApplications%28Sessionless%29
     */
    DefaultSubjectDAO subjectDAO = new DefaultSubjectDAO();
    DefaultSessionStorageEvaluator defaultSessionStorageEvaluator = new DefaultSessionStorageEvaluator();
    defaultSessionStorageEvaluator.setSessionStorageEnabled(false);
    subjectDAO.setSessionStorageEvaluator(defaultSessionStorageEvaluator);
    manager.setSubjectDAO(subjectDAO);

    return manager;
}
 
Example #2
Source File: ShiroConfig.java    From web-flash with MIT License 6 votes vote down vote up
@Bean("securityManager")
public DefaultWebSecurityManager getManager(ApiRealm realm) {
    DefaultWebSecurityManager manager = new DefaultWebSecurityManager();
    // 使用自己的realm
    manager.setRealm(realm);

    /*
     * 关闭shiro自带的session,详情见文档
     * http://shiro.apache.org/session-management.html#SessionManagement-StatelessApplications%28Sessionless%29
     */
    DefaultSubjectDAO subjectDAO = new DefaultSubjectDAO();
    DefaultSessionStorageEvaluator defaultSessionStorageEvaluator = new DefaultSessionStorageEvaluator();
    defaultSessionStorageEvaluator.setSessionStorageEnabled(false);
    subjectDAO.setSessionStorageEvaluator(defaultSessionStorageEvaluator);
    manager.setSubjectDAO(subjectDAO);

    return manager;
}
 
Example #3
Source File: ShiroConfig.java    From flash-waimai with MIT License 6 votes vote down vote up
@Bean("securityManager")
public DefaultWebSecurityManager getManager(ApiRealm realm) {
    DefaultWebSecurityManager manager = new DefaultWebSecurityManager();
    // 使用自己的realm
    manager.setRealm(realm);

    /*
     * 关闭shiro自带的session,详情见文档
     * http://shiro.apache.org/session-management.html#SessionManagement-StatelessApplications%28Sessionless%29
     */
    DefaultSubjectDAO subjectDAO = new DefaultSubjectDAO();
    DefaultSessionStorageEvaluator defaultSessionStorageEvaluator = new DefaultSessionStorageEvaluator();
    defaultSessionStorageEvaluator.setSessionStorageEnabled(false);
    subjectDAO.setSessionStorageEvaluator(defaultSessionStorageEvaluator);
    manager.setSubjectDAO(subjectDAO);

    return manager;
}
 
Example #4
Source File: ShiroManager.java    From shiro-spring-boot-starter with Apache License 2.0 6 votes vote down vote up
@Bean(name = "securityManager")
	@ConditionalOnMissingBean
	public DefaultSecurityManager securityManager(CacheManager shiroCacheManager) {
        DefaultWebSecurityManager dwsm = new DefaultWebSecurityManager();

        // 用自己的Factory实现替换默认
        // 用于关闭session功能
        dwsm.setSubjectFactory(new StatelessSubjectFactory());
        dwsm.setSessionManager(defaultSessionManager());
        // 关闭session存储
        ((DefaultSessionStorageEvaluator) ((DefaultSubjectDAO)dwsm.getSubjectDAO()).getSessionStorageEvaluator()).setSessionStorageEnabled(false);

//      <!-- 用户授权/认证信息Cache, 采用EhCache 缓存 -->
        dwsm.setCacheManager(shiroCacheManager);

        SecurityUtils.setSecurityManager(dwsm);
        return dwsm;
	}
 
Example #5
Source File: ShiroConfig.java    From fastdep with Apache License 2.0 5 votes vote down vote up
/**
 * securityManager
 *
 * @param authorizingRealm AuthorizingRealm bean
 * @return securityManager
 */
@Bean("securityManager")
@ConditionalOnMissingBean(SecurityManager.class)
public DefaultWebSecurityManager getManager(AuthorizingRealm authorizingRealm) {
    DefaultWebSecurityManager manager = new DefaultWebSecurityManager();
    manager.setRealm(authorizingRealm);
    DefaultSubjectDAO subjectDAO = new DefaultSubjectDAO();
    DefaultSessionStorageEvaluator defaultSessionStorageEvaluator = new DefaultSessionStorageEvaluator();
    defaultSessionStorageEvaluator.setSessionStorageEnabled(false);
    subjectDAO.setSessionStorageEvaluator(defaultSessionStorageEvaluator);
    manager.setSubjectDAO(subjectDAO);
    return manager;
}
 
Example #6
Source File: ShiroConfiguration.java    From watchdog-framework with MIT License 5 votes vote down vote up
@Bean
public SecurityManager securityManager(RedisCacheManager RedisCacheManager){
    DefaultWebSecurityManager manager =  new DefaultWebSecurityManager();
    manager.setRealm(myRealm());
    manager.setCacheManager(RedisCacheManager);
    /*
    * 关闭session存储,禁用Session作为存储策略的实现,
    * 但它没有完全地禁用Session所以需要配合SubjectFactory中的context.setSessionCreationEnabled(false)
    */
    //manager.setSessionManager(sessionManager());
    ((DefaultSessionStorageEvaluator) ((DefaultSubjectDAO)manager.getSubjectDAO())
            .getSessionStorageEvaluator()).setSessionStorageEnabled(false);
    manager.setSubjectFactory(new AgileSubjectFactory());
    return manager;
}
 
Example #7
Source File: JsetsSubjectFactory.java    From jsets-shiro-spring-boot-starter with Apache License 2.0 4 votes vote down vote up
/**
 * DefaultSessionStorageEvaluator是否持久化SESSION的开关 
 */
public JsetsSubjectFactory(DefaultSessionStorageEvaluator storageEvaluator){
	this.storageEvaluator = storageEvaluator;
}