當前位置: 首頁>>代碼示例>>Java>>正文


Java ShiroFilterFactoryBean.setFilters方法代碼示例

本文整理匯總了Java中org.apache.shiro.spring.web.ShiroFilterFactoryBean.setFilters方法的典型用法代碼示例。如果您正苦於以下問題:Java ShiroFilterFactoryBean.setFilters方法的具體用法?Java ShiroFilterFactoryBean.setFilters怎麽用?Java ShiroFilterFactoryBean.setFilters使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.shiro.spring.web.ShiroFilterFactoryBean的用法示例。


在下文中一共展示了ShiroFilterFactoryBean.setFilters方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: shiroFilter

import org.apache.shiro.spring.web.ShiroFilterFactoryBean; //導入方法依賴的package包/類
@Bean
public ShiroFilterFactoryBean shiroFilter() {
	ShiroFilterFactoryBean factoryBean = new ShiroFilterFactoryBean();
	
	//設置Filter映射
	LinkedHashMap<String, Filter> filterMap = new LinkedHashMap<>();
	DefaultCasFilter casFilter = new DefaultCasFilter();
	casFilter.setFailureUrl(loginProperties.getFailureUrl()); //配置驗證錯誤時的失敗頁麵
	casFilter.setReloginUrl(loginProperties.getCasLogin() + "&msg={0}"); //驗證錯誤後顯示登錄頁麵,並提示錯誤信息。隻試用於ErrorContext異常
	casFilter.setLogoutUrl(loginProperties.getCasLogout());
	filterMap.put("casFilter", casFilter);
	LogoutFilter logoutFilter = new LogoutFilter();
	logoutFilter.setRedirectUrl(loginProperties.getCasLogout() + "?service=" + loginProperties.getCasLogoutCallback());
	filterMap.put("logoutFilter", logoutFilter);
	filterMap.put("perms", new DefaultPermissionsAuthorizationFilter());
	filterMap.put("authc", new DefaultFormAuthenticationFilter());
	filterMap.put("sense", new SenseLoginFilter());
	factoryBean.setFilters(filterMap);
	
	factoryBean.setSecurityManager(securityManager());
	factoryBean.setLoginUrl(loginProperties.getCasLogin());
	factoryBean.setUnauthorizedUrl(loginProperties.getUnauthorizedUrl());
	//加載權限配置
	Ini ini = new Ini();
	ini.loadFromPath(loginProperties.getShiroFilterFile());
	//did they explicitly state a 'urls' section?  Not necessary, but just in case:
	Ini.Section section = ini.getSection(IniFilterChainResolverFactory.URLS);
	if (MapUtils.isEmpty(section)) {
		//no urls section.  Since this _is_ a urls chain definition property, just assume the
		//default section contains only the definitions:
		section = ini.getSection(Ini.DEFAULT_SECTION_NAME);
	}
	factoryBean.setFilterChainDefinitionMap(section);
	return factoryBean;
}
 
開發者ID:easycodebox,項目名稱:easycode,代碼行數:36,代碼來源:ShiroConfig.java

示例2: getShiroFilterFactoryBean

import org.apache.shiro.spring.web.ShiroFilterFactoryBean; //導入方法依賴的package包/類
/**
 * ShiroFilter<br/>
 * 注意這裏參數中的 StudentService 和 IScoreDao 隻是一個例子,因為我們在這裏可以用這樣的方式獲取到相關訪問數據庫的對象,
 * 然後讀取數據庫相關配置,配置到 shiroFilterFactoryBean 的訪問規則中。實際項目中,請使用自己的Service來處理業務邏輯。
 *
 * @param securityManager
 * @param casFilter
 * @param userDao
 * @return
 * @author SHANHY
 * @create  2016年1月14日
 */
@Bean(name = "shiroFilter")
public ShiroFilterFactoryBean getShiroFilterFactoryBean(DefaultWebSecurityManager securityManager, CasFilter casFilter, UserDao userDao) {
    ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
    // 必須設置 SecurityManager
    shiroFilterFactoryBean.setSecurityManager(securityManager);
    // 如果不設置默認會自動尋找Web工程根目錄下的"/login.jsp"頁麵
    shiroFilterFactoryBean.setLoginUrl(loginUrl);
    // 登錄成功後要跳轉的連接
    shiroFilterFactoryBean.setSuccessUrl(loginSuccessUrl);
    shiroFilterFactoryBean.setUnauthorizedUrl(unauthorizedUrl);
    // 添加casFilter到shiroFilter中
    Map<String, Filter> filters = new HashMap<>();
    filters.put("casFilter", casFilter);
   // filters.put("logout",logoutFilter());
    shiroFilterFactoryBean.setFilters(filters);

    loadShiroFilterChain(shiroFilterFactoryBean, userDao);
    return shiroFilterFactoryBean;
}
 
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:32,代碼來源:ShiroCasConfiguration.java

示例3: getShiroFilterFactoryBean

import org.apache.shiro.spring.web.ShiroFilterFactoryBean; //導入方法依賴的package包/類
@Bean(name = "shiroFilter")
public ShiroFilterFactoryBean getShiroFilterFactoryBean() {
	ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
	// 必須設置 SecurityManager
	shiroFilterFactoryBean.setSecurityManager(securityManager());
	// 如果不設置默認會自動尋找Web工程根目錄下的"/login.jsp"頁麵
	shiroFilterFactoryBean.setLoginUrl("/login");
	// 登錄成功後要跳轉的連接
	shiroFilterFactoryBean.setSuccessUrl("/user");
	shiroFilterFactoryBean.setUnauthorizedUrl("/403");
	// 添加casFilter到shiroFilter中
	Map<String, Filter> filters = new HashMap<String, Filter>();
	filters.put("authc",new FormAuthenticationFilter());
	shiroFilterFactoryBean.setFilters(filters);

	Map<String,String> shiroFilterChainDefinitions = Maps.newHashMap();
	shiroFilterChainDefinitions.put("/static/**","anon");
	shiroFilterFactoryBean.setFilterChainDefinitionMap(shiroFilterChainDefinitions);
	return shiroFilterFactoryBean;
}
 
開發者ID:whatlookingfor,項目名稱:spring-boot-sample,代碼行數:21,代碼來源:ShiroConfiguration.java

示例4: shiroFilterFactoryBean

import org.apache.shiro.spring.web.ShiroFilterFactoryBean; //導入方法依賴的package包/類
/**
 * 對過濾器進行調整
 *
 * @param securityManager
 * @return
 */
@Bean(name = "shiroFilter")
protected ShiroFilterFactoryBean shiroFilterFactoryBean(DefaultWebSecurityManager securityManager, Config config) {
    ShiroFilterFactoryBean filterFactoryBean = super.shiroFilterFactoryBean();
    filterFactoryBean.setSecurityManager(securityManager);
    
    //過濾器設置
    Map<String, Filter> filters = new HashMap<>();
    SecurityFilter securityFilter = new SecurityFilter();
    securityFilter.setClients("cas,rest,jwt");
    securityFilter.setConfig(config);
    filters.put("casSecurityFilter", securityFilter);
    
    CallbackFilter callbackFilter = new CallbackFilter();
    callbackFilter.setConfig(config);
    filters.put("callbackFilter", callbackFilter);
    
    filterFactoryBean.setFilters(filters);
    

    return filterFactoryBean;
}
 
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:28,代碼來源:ShiroConfiguration.java

示例5: getShiroFilterFactoryBean

import org.apache.shiro.spring.web.ShiroFilterFactoryBean; //導入方法依賴的package包/類
@Bean(name = "shiroFilter")
public ShiroFilterFactoryBean getShiroFilterFactoryBean() {
    ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
    shiroFilterFactoryBean.setSecurityManager(securityManager());
    shiroFilterFactoryBean.setLoginUrl("/login.html");
    shiroFilterFactoryBean.setSuccessUrl("/overview/dashboard.html");
    Map<String, Filter> filters = new LinkedHashMap<String, Filter>();
    filters.put("authc", createLoginFilter());
    filters.put("forceLogout", new ForceLogoutFilter());
    shiroFilterFactoryBean.setFilters(filters);
    filterChainDefinitionMap.put("/static/**", "anon");
    filterChainDefinitionMap.put("/test/**", "anon");
    filterChainDefinitionMap.put("/logout", "logout");
    filterChainDefinitionMap.put("/authenticated", "authc");
    filterChainDefinitionMap.put("/login.json", "authc");
    filterChainDefinitionMap.put("/**", "user");
    shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);
    return shiroFilterFactoryBean;
}
 
開發者ID:liaojiacan,項目名稱:zkAdmin,代碼行數:20,代碼來源:ShiroConfiguration.java

示例6: getShiroFilterFactoryBean

import org.apache.shiro.spring.web.ShiroFilterFactoryBean; //導入方法依賴的package包/類
@Bean(name = "shiroFilter")
    public ShiroFilterFactoryBean getShiroFilterFactoryBean(
            DefaultWebSecurityManager securityManager,
            FormAuthenticationFilter formAuthenticationFilter) {

        ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
        // 必須設置 SecurityManager
        shiroFilterFactoryBean.setSecurityManager(securityManager);
        // 如果不設置默認會自動尋找Web工程根目錄下的"/login.jsp"頁麵
        shiroFilterFactoryBean.setLoginUrl("/oss/login");
        // 登錄成功後要跳轉的連接
        shiroFilterFactoryBean.setSuccessUrl("/admin/index");
        shiroFilterFactoryBean.setUnauthorizedUrl("/403");
        Map map=new HashMap<>();
//        map.put("authc",formAuthenticationFilter);
        shiroFilterFactoryBean.setFilters(map);
        loadShiroFilterChain(shiroFilterFactoryBean);
        return shiroFilterFactoryBean;
    }
 
開發者ID:egojit8,項目名稱:easyweb,代碼行數:20,代碼來源:ShiroConfiguration.java

示例7: shiroFilter

import org.apache.shiro.spring.web.ShiroFilterFactoryBean; //導入方法依賴的package包/類
@Bean(name = "shiroFilter")
public ShiroFilterFactoryBean shiroFilter() {
	ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
	shiroFilterFactoryBean.setSecurityManager(securityManager);
	shiroFilterFactoryBean.setLoginUrl("/admin");
	shiroFilterFactoryBean.setSuccessUrl("/admin");
	shiroFilterFactoryBean.setUnauthorizedUrl("/error");

	Map<String, Filter> filters = Application.getSecurityfilters();
	AjaxAuthenticationFilter ajaxAuthenticationFilter = new AjaxAuthenticationFilter();
	ajaxAuthenticationFilter.setRobotPrevention(new CaptchaRobotPrevention());
	filters.put(DefaultFilter.authc.name(), ajaxAuthenticationFilter);
	shiroFilterFactoryBean.setFilters(filters);

	shiroFilterFactoryBean.setFilterChainDefinitionMap(Application.getSecurityFilterChainDefinitionMap());
	return shiroFilterFactoryBean;
}
 
開發者ID:xiangxik,項目名稱:java-platform,代碼行數:18,代碼來源:ApplicationConfiguration.java

示例8: shiroFilter

import org.apache.shiro.spring.web.ShiroFilterFactoryBean; //導入方法依賴的package包/類
@Bean
public ShiroFilterFactoryBean shiroFilter() {
    final ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
    shiroFilterFactoryBean.setSecurityManager(securityManager());
    shiroFilterFactoryBean.setLoginUrl("/member/login");
    shiroFilterFactoryBean.setSuccessUrl("/home/index");
    shiroFilterFactoryBean.setUnauthorizedUrl("/error/401");

    final Map<String, Filter> filters = Maps.newHashMap();
    filters.put("authc", this.authcFilter());
    filters.put("membership", this.membershipFilter());
    shiroFilterFactoryBean.setFilters(filters);

    final Map<String, String> chains = Maps.newLinkedHashMap();
    chains.put("/member/logout", "logout");
    chains.put("/", this.configProperties.getShiro().getFilters());
    chains.put("/home/**", this.configProperties.getShiro().getFilters());
    chains.put("/views/**", this.configProperties.getShiro().getFilters());
    chains.put("/rest/**", this.configProperties.getShiro().getFilters());
    chains.put("/**", "anon");
    shiroFilterFactoryBean.setFilterChainDefinitionMap(chains);

    return shiroFilterFactoryBean;
}
 
開發者ID:xianrendzw,項目名稱:EasyReport,代碼行數:25,代碼來源:ShiroConfig.java

示例9: shiroFilterFactoryBean

import org.apache.shiro.spring.web.ShiroFilterFactoryBean; //導入方法依賴的package包/類
@Bean(name = "shiroFilter")
public ShiroFilterFactoryBean shiroFilterFactoryBean(DefaultWebSecurityManager securityManager, CasConfig casConfig, CasFilter casFilter){
	ShiroFilterFactoryBean factoryBean = new MyShiroFilterFactoryBean();
	factoryBean.setSecurityManager(securityManager);
	factoryBean.setLoginUrl(casConfig.getLocalServerLoginUrl());
	factoryBean.setSuccessUrl("/user");
	factoryBean.setUnauthorizedUrl("/403");
	// 添加casFilter到shiroFilter中
	Map<String, Filter> filterMap = new HashMap<String, Filter>(1);
	filterMap.put(CAS_FILTER, casFilter);
	factoryBean.setFilters(filterMap);

	loadShiroFilterChain(factoryBean, casConfig);
	return factoryBean;
}
 
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:16,代碼來源:ShiroCasConfig.java

示例10: shirFilter

import org.apache.shiro.spring.web.ShiroFilterFactoryBean; //導入方法依賴的package包/類
@Bean("shiroFilter")
public ShiroFilterFactoryBean shirFilter(SecurityManager securityManager) {
    ShiroFilterFactoryBean shiroFilter = new ShiroFilterFactoryBean();
    shiroFilter.setSecurityManager(securityManager);

    //oauth過濾
    Map<String, Filter> filters = new HashMap<>();
    filters.put("oauth2", new OAuth2Filter());
    shiroFilter.setFilters(filters);

    Map<String, String> filterMap = new LinkedHashMap<>();
    filterMap.put("/webjars/**", "anon");
    filterMap.put("/druid/**", "anon");
    filterMap.put("/api/**", "anon");

    //swagger配置
    filterMap.put("/swagger**", "anon");
    filterMap.put("/v2/api-docs", "anon");
    filterMap.put("/swagger-resources/configuration/ui", "anon");

    filterMap.put("/sys/login", "anon");
    filterMap.put("/**/*.css", "anon");
    filterMap.put("/**/*.js", "anon");
    filterMap.put("/**/*.html", "anon");
    filterMap.put("/fonts/**", "anon");
    filterMap.put("/plugins/**", "anon");
    filterMap.put("/favicon.ico", "anon");
    filterMap.put("/captcha.jpg", "anon");
    filterMap.put("/", "anon");
    filterMap.put("/**", "oauth2");
    shiroFilter.setFilterChainDefinitionMap(filterMap);

    return shiroFilter;
}
 
開發者ID:zhaoqicheng,項目名稱:renren-fast,代碼行數:35,代碼來源:ShiroConfig.java

示例11: shiroFilterFactoryBean

import org.apache.shiro.spring.web.ShiroFilterFactoryBean; //導入方法依賴的package包/類
/**
 * 對過濾器進行調整
 *
 * @param securityManager
 * @return
 */
@Bean
protected ShiroFilterFactoryBean shiroFilterFactoryBean(SecurityManager securityManager, SubjectFactory subjectFactory,@Qualifier("filters") Map<String, Filter> filters) {
    //把subject對象設為subjectFactory
    ((DefaultSecurityManager) securityManager).setSubjectFactory(subjectFactory);
    ShiroFilterFactoryBean filterFactoryBean = super.shiroFilterFactoryBean();
    filterFactoryBean.setSecurityManager(securityManager);

    filterFactoryBean.setFilters(filters);
    return filterFactoryBean;
}
 
開發者ID:kawhii,項目名稱:wolf,代碼行數:17,代碼來源:ShiroFilterConfiguration.java

示例12: shirFilter

import org.apache.shiro.spring.web.ShiroFilterFactoryBean; //導入方法依賴的package包/類
@Bean("shiroFilter")
public ShiroFilterFactoryBean shirFilter(SecurityManager securityManager) {
    ShiroFilterFactoryBean shiroFilter = new ShiroFilterFactoryBean();
    shiroFilter.setSecurityManager(securityManager);

    //oauth過濾
    Map<String, Filter> filters = new HashMap<>(16);
    filters.put("oauth2", new OAuth2Filter());
    shiroFilter.setFilters(filters);

    Map<String, String> filterMap = new LinkedHashMap<>();
    filterMap.put("/webjars/**", "anon");
    filterMap.put("/druid/**", "anon");
    filterMap.put("/api/**", "anon");

    //swagger配置
    filterMap.put("/swagger**", "anon");
    filterMap.put("/v2/api-docs", "anon");
    filterMap.put("/swagger-resources/configuration/ui", "anon");

    filterMap.put("/sys/login", "anon");
    filterMap.put("/**/*.css", "anon");
    filterMap.put("/**/*.js", "anon");
    filterMap.put("/**/*.html", "anon");
    filterMap.put("/fonts/**", "anon");
    filterMap.put("/plugins/**", "anon");
    filterMap.put("/favicon.ico", "anon");
    filterMap.put("/captcha.jpg", "anon");
    filterMap.put("/", "anon");
    filterMap.put("/**", "oauth2");
    shiroFilter.setFilterChainDefinitionMap(filterMap);

    return shiroFilter;
}
 
開發者ID:davichi11,項目名稱:my-spring-boot-project,代碼行數:35,代碼來源:ShiroConfig.java

示例13: shiroFilterFactoryBean

import org.apache.shiro.spring.web.ShiroFilterFactoryBean; //導入方法依賴的package包/類
/**
 * 對過濾器進行調整
 *
 * @return
 */
@Bean
protected ShiroFilterFactoryBean shiroFilterFactoryBean() {
    //把subject對象設為subjectFactory
    //由於cas代理了用戶,所以必須通過cas進行創建對象
    ((DefaultSecurityManager) securityManager).setSubjectFactory(new Pac4jSubjectFactory());

    ShiroFilterFactoryBean filterFactoryBean = super.shiroFilterFactoryBean();
    filterFactoryBean.setFilters(shiroFilters());
    return filterFactoryBean;
}
 
開發者ID:kawhii,項目名稱:sso,代碼行數:16,代碼來源:ShiroConfiguration.java

示例14: getShiroFilterFactoryBean

import org.apache.shiro.spring.web.ShiroFilterFactoryBean; //導入方法依賴的package包/類
public ShiroFilterFactoryBean getShiroFilterFactoryBean(SecurityManager securityManager) throws Exception {
    ShiroFilterFactoryBean shiroFilter = new ShiroFilterFactoryBean();
    shiroFilter.setSecurityManager(securityManager);
    shiroFilter.setLoginUrl(properties.getLoginUrl());
    shiroFilter.setSuccessUrl(properties.getSuccessUrl());
    shiroFilter.setUnauthorizedUrl(properties.getUnauthorizedUrl());

    Map<String, Filter> filterMap = new LinkedHashMap<String, Filter>();
    filterMap.put("authc", formSignInFilter());

    Map<String, Filter> filterClasses = instantiateFilterClasses(properties.getFilters());
    if (filterClasses != null) {
        filterMap.putAll(filterClasses);
    }

    if (shiroFilterCustomizer != null) {
        filterMap = shiroFilterCustomizer.customize(filterMap);
    }

    shiroFilter.setFilters(filterMap);

    Map<String, String> filterChains = new LinkedHashMap<>();
    if (jdbcPermissionDefinitionsLoader != null) {
        Map<String, String> permissionUrlMap = jdbcPermissionDefinitionsLoader.getObject();
        filterChains.putAll(permissionUrlMap);
    }
    if (properties.getFilterChainDefinitions() != null) {
        filterChains.putAll(properties.getFilterChainDefinitions());
    }
    shiroFilter.setFilterChainDefinitionMap(filterChains);
    return shiroFilter;
}
 
開發者ID:johntostring,項目名稱:spring-boot-shiro,代碼行數:33,代碼來源:ShiroAutoConfiguration.java

示例15: getShiroFilterFactoryBean

import org.apache.shiro.spring.web.ShiroFilterFactoryBean; //導入方法依賴的package包/類
public ShiroFilterFactoryBean getShiroFilterFactoryBean(SecurityManager securityManager) throws Exception {
    ShiroFilterFactoryBean shiroFilter = new ShiroFilterFactoryBean();
    shiroFilter.setSecurityManager(securityManager);
    shiroFilter.setLoginUrl(shiroProperties.getLoginUrl());
    shiroFilter.setSuccessUrl(shiroProperties.getSuccessUrl());
    shiroFilter.setUnauthorizedUrl(shiroProperties.getUnauthorizedUrl());

    Map<String, Filter> filterMap = new LinkedHashMap<String, Filter>();
    filterMap.put("authm", authFilter());

    Map<String, Filter> filterClasses = instantiateFilterClasses(shiroProperties.getFilters());
    if (filterClasses != null) {
        filterMap.putAll(filterClasses);
    }

    if (shiroFilterCustomizer != null) {
        filterMap = shiroFilterCustomizer.customize(filterMap);
    }

    shiroFilter.setFilters(filterMap);

    Map<String, String> filterChains = new LinkedHashMap<String, String>();
    if (jdbcPermissionDefinitionsLoader != null) {
        Map<String, String> permissionUrlMap = jdbcPermissionDefinitionsLoader.getObject();
        filterChains.putAll(permissionUrlMap);
    }
    if (shiroProperties.getFilterChainDefinitions() != null) {
        filterChains.putAll(shiroProperties.getFilterChainDefinitions());
    }
    shiroFilter.setFilterChainDefinitionMap(filterChains);

    return shiroFilter;
}
 
開發者ID:storezhang,項目名稱:utils,代碼行數:34,代碼來源:ShiroAutoConfiguration.java


注:本文中的org.apache.shiro.spring.web.ShiroFilterFactoryBean.setFilters方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。