Shiro默认过滤器详解
一、过滤器种类
在shiro中,除过登录认证操作,最核心的就属一些列过滤器
shiro过滤器以及对应的类:过滤器

二、过滤器详解
以authc过滤器为例,对应的处理器类是FormAuthenticationFilter
1. 继承关系及结构

authc继承关系:
1.AbstractFilter > 2.NameableFilter > 3.OncePerRequestFilter > 4.AdviceFilter > 5.PathMatchingFilter > 6.AccessControlFilter > 7.AuthenticationFilter > 8.AuthenticatingFilter > 9.FormAuthenticationFilter
2. filter过滤器简介
tomcat中的自定义过滤器必需实现Filter接口,过滤器的实现方法为Filter中的
doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain),如果一个请求被该过滤器拦截,想要到达用户最后请求的地址,那么一定得有:filterChain.doFilter(request, response);这个方法的调用,表示通过过滤,请求可以到达用户的请求地址。否则用户的请求地址不会被调用,用户的请求被过滤器拦截
3. shiro过滤器分析
3.1 AbstractFilter
源码:
package org.apache.shiro.web.servlet;
public abstract class AbstractFilter extends ServletContextSupport implements Filter {
private static final transient Logger log = LoggerFactory.getLogger(AbstractFilter.class);
protected FilterConfig filterConfig;
public AbstractFilter()

最低0.47元/天 解锁文章
1275





