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


Java ShiroFilterFactoryBean.setUnauthorizedUrl方法代碼示例

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


在下文中一共展示了ShiroFilterFactoryBean.setUnauthorizedUrl方法的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: 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

示例5: shirFilter

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

    Map<String, String> filterMap = new LinkedHashMap<>();
    filterMap.put("/public/**", "anon");
    filterMap.put("/webjars/**", "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("/login.html", "anon");
    filterMap.put("/sys/login", "anon");
    filterMap.put("/captcha.jpg", "anon");
    filterMap.put("/**", "authc");
    shiroFilter.setFilterChainDefinitionMap(filterMap);

    return shiroFilter;
}
 
開發者ID:guolf,項目名稱:pds,代碼行數:27,代碼來源:ShiroConfig.java

示例6: getShiroFilterFactoryBean

import org.apache.shiro.spring.web.ShiroFilterFactoryBean; //導入方法依賴的package包/類
@Bean(name = "shiroFilter")
@DependsOn("securityManager")
@ConditionalOnMissingBean
public ShiroFilterFactoryBean getShiroFilterFactoryBean(DefaultSecurityManager securityManager, Realm realm, ShiroFilterRegistry registry) {
	securityManager.setRealm(realm);

       Map<String, String> filterDef = swapKeyValue(properties.getFilterChainDefinitions());
       log.info("過慮器配置: {}", filterDef);
       log.info("自定義過慮器: {}", registry.getFilterMap());

	ShiroFilterFactoryBean shiroFilter = new ShiroFilterFactoryBean();
	shiroFilter.setSecurityManager(securityManager);
	shiroFilter.setLoginUrl(properties.getLoginUrl());
	shiroFilter.setSuccessUrl(properties.getSuccessUrl());
	shiroFilter.setUnauthorizedUrl(properties.getUnauthorizedUrl());

	shiroFilter.setFilterChainDefinitionMap(filterDef);
       shiroFilter.getFilters().putAll(registry.getFilterMap());

	return shiroFilter;
}
 
開發者ID:wanghongfei,項目名稱:shiro-spring-boot-starter,代碼行數:22,代碼來源:ShiroAutoConfiguration.java

示例7: getShiroFilterFactoryBean

import org.apache.shiro.spring.web.ShiroFilterFactoryBean; //導入方法依賴的package包/類
/**
 * ShiroFilter<br/>
 * 注意這裏參數中的 StudentService 和 IScoreDao 隻是一個例子,因為我們在這裏可以用這樣的方式獲取到相關訪問數據庫的對象,
 * 然後讀取數據庫相關配置,配置到 shiroFilterFactoryBean 的訪問規則中。實際項目中,請使用自己的Service來處理業務邏輯。
 *
 * @param myShiroRealm
 * @param stuService
 * @param scoreDao
 * @return
 * @author SHANHY
 * @create  2016年1月14日
 */
@Bean(name = "shiroFilter")
public ShiroFilterFactoryBean getShiroFilterFactoryBean(DefaultWebSecurityManager securityManager, StudentService stuService,UserDao userDao) {

    ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
    // 必須設置 SecurityManager  
    shiroFilterFactoryBean.setSecurityManager(securityManager);
    // 如果不設置默認會自動尋找Web工程根目錄下的"/login.jsp"頁麵
    shiroFilterFactoryBean.setLoginUrl("/login");
    // 登錄成功後要跳轉的連接
    shiroFilterFactoryBean.setSuccessUrl("/user");
    shiroFilterFactoryBean.setUnauthorizedUrl("/403");

    loadShiroFilterChain(shiroFilterFactoryBean, stuService, userDao);
    return shiroFilterFactoryBean;
}
 
開發者ID:seagrape,項目名稱:kekoa,代碼行數:28,代碼來源:ShiroConfiguration.java

示例8: getShiroFilterFactoryBean

import org.apache.shiro.spring.web.ShiroFilterFactoryBean; //導入方法依賴的package包/類
/**
 * ShiroFilter<br/>
 * 注意這裏參數中的 StudentService 和 IScoreDao 隻是一個例子,因為我們在這裏可以用這樣的方式獲取到相關訪問數據庫的對象,
 * 然後讀取數據庫相關配置,配置到 shiroFilterFactoryBean 的訪問規則中。實際項目中,請使用自己的Service來處理業務邏輯。
 *
 * @param myShiroRealm
 * @param stuService
 * @param scoreDao
 * @return
 * @author SHANHY
 * @create 2016年1月14日
 */
@Bean(name = "shiroFilter")
public ShiroFilterFactoryBean getShiroFilterFactoryBean(
		DefaultWebSecurityManager securityManager,
		StudentService stuService, UserDao userDao) {

	ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
	// 必須設置 SecurityManager
	shiroFilterFactoryBean.setSecurityManager(securityManager);
	// 如果不設置默認會自動尋找Web工程根目錄下的"/login.jsp"頁麵
	shiroFilterFactoryBean.setLoginUrl("/login");
	// 登錄成功後要跳轉的連接
	shiroFilterFactoryBean.setSuccessUrl("/user");
	shiroFilterFactoryBean.setUnauthorizedUrl("/403");
	// shiroFilterFactoryBean.setFilters(filters);

	loadShiroFilterChain(shiroFilterFactoryBean, stuService, userDao);
	return shiroFilterFactoryBean;
}
 
開發者ID:seagrape,項目名稱:kekoa,代碼行數:31,代碼來源:KekoaShiroConfiguration.java

示例9: 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

示例10: 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

示例11: shiroFilter

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

    StringBuilder sb = new StringBuilder();
    sb.append("/api/** = anon").append("\n");
    sb.append("/resources/** = anon").append("\n");
    sb.append("/signin = anon").append("\n");
    sb.append("/signup = anon").append("\n");
    sb.append("/user/password/forget = anon").append("\n");
    sb.append("/kaptcha = anon").append("\n");
    sb.append("/signout = logout").append("\n");
    sb.append("/dashboard = user").append("\n");
    sb.append("/** = user");
    shiroFilterFactoryBean.setFilterChainDefinitions(sb.toString());
    return shiroFilterFactoryBean;
}
 
開發者ID:qatang,項目名稱:ctm,代碼行數:21,代碼來源:ShiroConfig.java

示例12: shiroFilter

import org.apache.shiro.spring.web.ShiroFilterFactoryBean; //導入方法依賴的package包/類
@Bean
public ShiroFilterFactoryBean shiroFilter(SecurityManager securityManager, LogoutFilter logoutFilter) {
    ShiroFilterFactoryBean sffb = new ShiroFilterFactoryBean();
    sffb.setSecurityManager(securityManager);
    //
    sffb.getFilters().put("logout", logoutFilter);
    //
    sffb.setLoginUrl(WebappPath.getWebappPath() + "/a/user/loginForm");
    // TODO: ?? sffb.setSuccessUrl("/");
    sffb.setUnauthorizedUrl(WebappPath.getWebappPath() + "/a/error/unauthorized");
    //
    sffb.setFilterChainDefinitionMap(ImmutableMap.<String, String>builder()
            .put(WebappPath.getWebappPath() + "/a/user/loginForm", "authc")
            .put(WebappPath.getWebappPath() + "/a/user/logout", "logout")
            .put(WebappPath.getWebappPath() + "/a/shiro/restricted", "user")
            .put(WebappPath.getWebappPath() + "/a/shiro/privileged", "user, roles[never_given_permission]")
            .build());
    //
    LOG.debug(ObjectUtils.toString(sffb.getFilters()));
    //
    return sffb;
}
 
開發者ID:ageldama,項目名稱:glados-wiki,代碼行數:23,代碼來源:ShiroContext.java

示例13: shiroFilterFactoryBean

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

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

示例14: 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

示例15: shirFilter

import org.apache.shiro.spring.web.ShiroFilterFactoryBean; //導入方法依賴的package包/類
/**
 * 處理攔截資源文件問題。
 *
 * @param securityManager
 * @return
 */
@Bean
public ShiroFilterFactoryBean shirFilter(SecurityManager securityManager) {
    ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();

    // 設置 SecurityManager
    shiroFilterFactoryBean.setSecurityManager(securityManager);

    // 如果不設置默認會自動尋找Web工程根目錄下的"/login.html"頁麵
    shiroFilterFactoryBean.setLoginUrl("/login");
    // 登錄成功後要跳轉的鏈接
    shiroFilterFactoryBean.setSuccessUrl("/initPage");
    //未授權界麵
    shiroFilterFactoryBean.setUnauthorizedUrl("/403");
    //攔截器.
    Map<String, String> filterChainDefinitionMap = new LinkedHashMap<>();
    filterChainDefinitionMap.put("/favicon.png","anon");//解決彈出favicon.ico下載
    filterChainDefinitionMap.put("/logout", "logout");
    filterChainDefinitionMap.put("/css/**", "anon");
    filterChainDefinitionMap.put("/js/**", "anon");
    filterChainDefinitionMap.put("/img/**", "anon");
    filterChainDefinitionMap.put("/font-awesome/**", "anon");

    //自定義加載權限資源關係
    List<Permission> list = permissionService.findAll();
    for (Permission p : list) {
        if (!p.getPerurl().isEmpty()) {
            String permission = "perms[" + p.getPerurl() + "]";
            filterChainDefinitionMap.put(p.getPerurl(), permission);
        }
    }


    //過濾鏈定義,從上向下順序執行,一般將 /**放在最為下邊
    filterChainDefinitionMap.put("/**", "authc");
    shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);
    return shiroFilterFactoryBean;
}
 
開發者ID:ChinaLHR,項目名稱:JavaQuarkBBS,代碼行數:44,代碼來源:ShiroConfig.java


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