`

<shrio学习>-扩展FormAuthenticationFilter实现动态改变LoginUrl

 
阅读更多

 

1.修改配置文件

<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">  
        ...  
        <property name="filters">  
            <util:map>  
                 <entry key="authc" value-ref="formAuthenticationFilter"/>  
            </util:map>  
        </property>  
...  
</bean>  
<!-- 自定义验证拦截器 -->  
    <bean id="formAuthenticationFilter" class="****.LZFormAuthenticationFilter"/>  

 

2.扩展FormAuthenticationFilter 

public class LZFormAuthenticationFilter extends  FormAuthenticationFilter {
	/**
	 * 重写登录地址
	 */
	protected void redirectToLogin(ServletRequest request,ServletResponse response) throws IOException {
		//request.getLocalAddr()
		HttpServletRequest req=(HttpServletRequest) request;
	String loginUrl = getLoginUrl();
	String url=req.getRequestURI();
	if(url.contains("/mine/")){
		loginUrl="/web/teacher/list.htm";
	}
	WebUtils.issueRedirect(request, response, loginUrl);
	}
}
3. 动态增加shiro的filter地址,可以继承DefaultFilterChainManager 
<property name="filterChainDefinitions">
			<value>
	/favicon.ico = anon
				/resources/**=anon
				/**/*.jpg = anon
</value>
		</property>
 
分享到:
评论

相关推荐

    springmvc+shiro配置教程

    &lt;artifactId&gt;shiro-core&lt;/artifactId&gt; &lt;/dependency&gt; &lt;!-- shiro-web --&gt; &lt;dependency&gt; &lt;groupId&gt;org.apache.shiro&lt;/groupId&gt; &lt;artifactId&gt;shiro-web&lt;/artifactId&gt; &lt;version&gt;${shiro.version}&lt;/version&gt; &lt;/...

    简单配置 shiro + spring +springMVC+hibernate简单框架

    &lt;artifactId&gt;shiro-core&lt;/artifactId&gt; &lt;version&gt;1.2.0&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.apache.shiro&lt;/groupId&gt; &lt;artifactId&gt;shiro-web&lt;/artifactId&gt; &lt;version&gt;1.2.0&lt;/version&gt; ...

    单点登录sso-shiro-cas-maven

    # sso-shiro-cas spring下使用shiro+cas配置单点登录,多个系统之间的访问,每次只需要登录一次 ## 系统模块说明 1. cas: 单点登录模块,这里直接拿的是cas的项目改了点样式而已 2. doc: 文档目录,里面有数据库...

    IDEA+SSM+Shiro(demo,包含数据库)

    &lt;artifactId&gt;shiro-core&lt;/artifactId&gt; &lt;version&gt;1.8.x&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.apache.shiro&lt;/groupId&gt; &lt;artifactId&gt;shiro-web&lt;/artifactId&gt; &lt;version&gt;1.8.x&lt;/version&gt; &lt;/...

    shiro(shiro-all-1.8.0.jar)

    shiro(shiro-all-1.8.0.jar)

    Spring Boot整合Shiro搭建权限管理系统

    &lt;artifactId&gt;shiro-spring&lt;/artifactId&gt; &lt;version&gt;1.7.2&lt;/version&gt; &lt;/dependency&gt; ``` 然后,我们需要配置Shiro的`WebSecurityManager`,并将其注入到Spring的bean中。这通常在`application.yml`或`application....

    自制验证码依赖.rar

    pom.xml中导入依赖 &lt;!--引入自制验证码依赖--&gt; &lt;dependency&gt; &lt;groupId&gt;cn.dsna.util.images&lt;/groupId&gt; &lt;artifactId&gt;... &lt;artifactId&gt;shiro-core&lt;/artifactId&gt; &lt;version&gt;1.2.3&lt;/version&gt; &lt;/dependency&gt;

    shiro-attack-4.7.0-SNAPSHOT-all.zip

    标题提到的"shiro-attack-4.7.0-SNAPSHOT-all.zip"很可能是针对Apache Shiro的安全测试工具或者漏洞利用工具包,其主要目的是帮助开发者检测和防范Shiro框架相关的安全问题。 描述中的"序列化验证工具"可能是指该...

    shiro-core-1.4.0-API文档-中文版.zip

    赠送jar包:shiro-core-1.4.0.jar; 赠送原API文档:shiro-core-1.4.0-javadoc.jar; 赠送源代码:shiro-core-1.4.0-sources.jar; 赠送Maven依赖信息文件:shiro-core-1.4.0.pom; 包含翻译后的API文档:shiro-core...

    shiro-jar-1.7.0.zip相关资源包

    解决:升級1.7后附件...shiro-cas-1.7.0.jar shiro-core-1.7.0.jar shiro-ehcache-1.7.0.jar shiro-spring-1.7.0.jar shiro-web-1.7.0.jar CustomShiroFilterFactoryBean.java spring-context-shiro.xml 修改说明.txt

    Shiro安装需要jar包

    &lt;artifactId&gt;shiro-all&lt;/artifactId&gt; &lt;version&gt;1.2.3&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.apache.shiro&lt;/groupId&gt; &lt;artifactId&gt;shiro-cas&lt;/artifactId&gt; &lt;version&gt;1.2.3&lt;/version&gt; &lt;/...

    shiro-config-core-1.4.0-API文档-中文版.zip

    赠送jar包:shiro-config-core-1.4.0.jar; 赠送原API文档:shiro-config-core-1.4.0-javadoc.jar; 赠送源代码:shiro-config-core-1.4.0-sources.jar; 赠送Maven依赖信息文件:shiro-config-core-1.4.0.pom; ...

    shiro认证.docx

    &lt;artifactId&gt;shiro-core&lt;/artifactId&gt; &lt;version&gt;1.3.2&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.apache.shiro&lt;/groupId&gt; &lt;artifactId&gt;shiro-web&lt;/artifactId&gt; &lt;version&gt;1.3.2&lt;/version&gt; &lt;/...

    shiro-jar.zip

    shiro-all-1.7.1.jar,shiro-aspectj-1.7.1.jar,shiro-cache-1.7.1.jar,shiro-config-core-1.7.1.jar,shiro-config-ogdl-1.7.1.jar,shiro-core-1.7.1.jar,shiro-crypto-cipher-1.7.1.jar,shiro-crypto-core-1.7.1.jar...

    Shiro-springBoot-mysql集成

    &lt;artifactId&gt;shiro-spring&lt;/artifactId&gt; &lt;version&gt;1.7.2&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;mysql&lt;/groupId&gt; &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt; &lt;scope&gt;runtime&lt;/scope&gt; &lt;/...

    springmvc shiro使用

    &lt;artifactId&gt;shiro-core&lt;/artifactId&gt; &lt;version&gt;${shiro.version}&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.apache.shiro&lt;/groupId&gt; &lt;artifactId&gt;shiro-spring&lt;/artifactId&gt; &lt;version&gt;${shiro....

    shiro-ehcache-1.4.0-API文档-中文版.zip

    赠送jar包:shiro-ehcache-1.4.0.jar; 赠送原API文档:shiro-ehcache-1.4.0-javadoc.jar; 赠送源代码:shiro-ehcache-1.4.0-sources.jar; 赠送Maven依赖信息文件:shiro-ehcache-1.4.0.pom; 包含翻译后的API文档...

    shiro-cas-1

    &lt;dependency&gt; &lt;groupId&gt;org.apache.shiro&lt;/groupId&gt; &lt;artifactId&gt;shiro-cas&lt;/artifactId&gt; &lt;version&gt;1.3.2&lt;/version&gt; &lt;/dependency&gt;

    shiro-crypto-core-1.4.0-API文档-中文版.zip

    赠送jar包:shiro-crypto-core-1.4.0.jar; 赠送原API文档:shiro-crypto-core-1.4.0-javadoc.jar; 赠送源代码:shiro-crypto-core-1.4.0-sources.jar; 赠送Maven依赖信息文件:shiro-crypto-core-1.4.0.pom; ...

    shiro-crypto-cipher-1.4.0-API文档-中文版.zip

    赠送jar包:shiro-crypto-cipher-1.4.0.jar; 赠送原API文档:shiro-crypto-cipher-1.4.0-javadoc.jar; 赠送源代码:shiro-crypto-cipher-1.4.0-sources.jar; 赠送Maven依赖信息文件:shiro-crypto-cipher-1.4.0....

Global site tag (gtag.js) - Google Analytics