类 JwtAuthenticationFilterImpl
java.lang.Object
org.springframework.web.filter.GenericFilterBean
org.springframework.web.filter.OncePerRequestFilter
com.xumumi.filter.impl.JwtAuthenticationFilterImpl
- 所有已实现的接口:
JwtAuthenticationFilter,javax.servlet.Filter,org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanNameAware,org.springframework.beans.factory.DisposableBean,org.springframework.beans.factory.InitializingBean,org.springframework.context.EnvironmentAware,org.springframework.core.env.EnvironmentCapable,org.springframework.web.context.ServletContextAware
public final class JwtAuthenticationFilterImpl extends org.springframework.web.filter.OncePerRequestFilter implements JwtAuthenticationFilter
JWT 请求过滤器, 继承于 OncePerRequestFilter
可参考
BaseJwtSecurityConfigurerAdapter 进行配置- 从以下版本开始:
- 1.9
- 作者:
- XUMUMI
- 另请参阅:
BaseJwtSecurityConfigurerAdapter
-
字段概要
从类继承的字段 org.springframework.web.filter.OncePerRequestFilter
ALREADY_FILTERED_SUFFIX从类继承的字段 org.springframework.web.filter.GenericFilterBean
logger -
方法概要
修饰符和类型 方法 说明 static JwtAuthenticationFiltercreateJwtAuthenticationFilter(Function<? super javax.servlet.http.HttpServletRequest,String> secret)protected voiddoFilterInternal(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.FilterChain filterChain)执行验证voidsetRoleParameter(String parameter)自定义角色字段名voidsetTokenName(String name)自定义令牌名从类继承的方法 org.springframework.web.filter.OncePerRequestFilter
doFilter, doFilterNestedErrorDispatch, getAlreadyFilteredAttributeName, isAsyncDispatch, isAsyncStarted, shouldNotFilter, shouldNotFilterAsyncDispatch, shouldNotFilterErrorDispatch从类继承的方法 org.springframework.web.filter.GenericFilterBean
addRequiredProperty, afterPropertiesSet, createEnvironment, destroy, getEnvironment, getFilterConfig, getFilterName, getServletContext, init, initBeanWrapper, initFilterBean, setBeanName, setEnvironment, setServletContext从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait从接口继承的方法 javax.servlet.Filter
destroy, doFilter, init
-
方法详细资料
-
createJwtAuthenticationFilter
public static JwtAuthenticationFilter createJwtAuthenticationFilter(@NonNull Function<? super javax.servlet.http.HttpServletRequest,String> secret)- 参数:
secret- 用于生成密钥的回调函数- 返回:
JwtAuthenticationFilterImpl对象
-
doFilterInternal
protected void doFilterInternal(@NonNull javax.servlet.http.HttpServletRequest request, @NonNull javax.servlet.http.HttpServletResponse response, javax.servlet.FilterChain filterChain) throws javax.servlet.ServletException, IOException执行验证- 指定者:
doFilterInternal在类中org.springframework.web.filter.OncePerRequestFilter- 参数:
request- 请求response- 响应filterChain- 过滤链- 抛出:
javax.servlet.ServletException- Servlet 异常IOException- 读写异常
-
setTokenName
自定义令牌名- 指定者:
setTokenName在接口中JwtAuthenticationFilter- 参数:
name- 令牌名
-
setRoleParameter
自定义角色字段名- 指定者:
setRoleParameter在接口中JwtAuthenticationFilter- 参数:
parameter- 角色字段名
-