类 AbstractJsonAuthenticationFilter
java.lang.Object
org.springframework.web.filter.GenericFilterBean
org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter
com.xumumi.filter.AbstractJsonAuthenticationFilter
- 所有已实现的接口:
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.ApplicationEventPublisherAware,org.springframework.context.EnvironmentAware,org.springframework.context.MessageSourceAware,org.springframework.core.env.EnvironmentCapable,org.springframework.web.context.ServletContextAware
- 直接已知子类:
JwtLoginFilterImpl
public abstract class AbstractJsonAuthenticationFilter
extends org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter
Json 请求过滤器, 继承于
AbstractAuthenticationProcessingFilter
参考 BaseJwtSecurityConfigurerAdapter 和 JwtLoginFilterImpl 进行配置- 从以下版本开始:
- 1.9
- 作者:
- XUMUMI
- 另请参阅:
BaseJwtSecurityConfigurerAdapter
-
字段概要
从类继承的字段 org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter
authenticationDetailsSource, eventPublisher, messages从类继承的字段 org.springframework.web.filter.GenericFilterBean
logger -
构造器概要
构造器 限定符 构造器 说明 protectedAbstractJsonAuthenticationFilter(org.springframework.security.authentication.AuthenticationManager manager, String loginProcessingUrl)构造器 -
方法概要
修饰符和类型 方法 说明 org.springframework.security.core.AuthenticationattemptAuthentication(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)对读取到的请求信息进行处理protected List<javax.servlet.http.Cookie>getCookies(javax.servlet.http.HttpServletRequest request, org.springframework.security.core.Authentication authResult)获取登录成功时存入响应头的 cookies 内容,可以为空voidsetCookiesCallback(CookiesCallback cookies)自定义成功时 cookies 的内容voidsetFailureCallback(ResultCallback<? super org.springframework.security.core.AuthenticationException> failure)自定义失败时返回的内容voidsetGuardCallback(GuardCallback guard)自定义守卫拦截方式,比如验证码,频繁登录拦截等等voidsetPasswordParameter(String parameter)修改密码字段名voidsetSuccessCallback(ResultCallback<? super org.springframework.security.core.Authentication> success)自定义成功时返回的内容voidsetUsernameParameter(String parameter)修改用户字段名protected voidsuccessfulAuthentication(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.FilterChain chain, org.springframework.security.core.Authentication authResult)重写登录成功逻辑protected voidunsuccessfulAuthentication(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.security.core.AuthenticationException failed)重写登录失败逻辑从类继承的方法 org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter
afterPropertiesSet, doFilter, getAllowSessionCreation, getAuthenticationManager, getFailureHandler, getRememberMeServices, getSuccessHandler, requiresAuthentication, setAllowSessionCreation, setApplicationEventPublisher, setAuthenticationDetailsSource, setAuthenticationFailureHandler, setAuthenticationManager, setAuthenticationSuccessHandler, setContinueChainBeforeSuccessfulAuthentication, setFilterProcessesUrl, setMessageSource, setRememberMeServices, setRequiresAuthenticationRequestMatcher, setSessionAuthenticationStrategy从类继承的方法 org.springframework.web.filter.GenericFilterBean
addRequiredProperty, createEnvironment, destroy, getEnvironment, getFilterConfig, getFilterName, getServletContext, init, initBeanWrapper, initFilterBean, setBeanName, setEnvironment, setServletContext
-
构造器详细资料
-
AbstractJsonAuthenticationFilter
protected AbstractJsonAuthenticationFilter(@NonNull org.springframework.security.authentication.AuthenticationManager manager, @NonNull String loginProcessingUrl)构造器- 参数:
manager- 必须传入认证管理器以供使用loginProcessingUrl- 登录请求地址
-
-
方法详细资料
-
setUsernameParameter
修改用户字段名- 参数:
parameter- 字段名
-
setPasswordParameter
修改密码字段名- 参数:
parameter- 字段名
-
attemptAuthentication
public final org.springframework.security.core.Authentication attemptAuthentication(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException对读取到的请求信息进行处理- 指定者:
attemptAuthentication在类中org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter- 参数:
request- 接收到的消息response- 返回的内容- 返回:
- Authentication 处理完毕的 token
- 抛出:
org.springframework.security.core.AuthenticationException- 登录异常IOException- 读写异常- 另请参阅:
Authentication
-
successfulAuthentication
protected final void successfulAuthentication(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.FilterChain chain, org.springframework.security.core.Authentication authResult) throws IOException重写登录成功逻辑- 覆盖:
successfulAuthentication在类中org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter- 参数:
request- 请求内容response- 响应内容chain- 过滤链authResult- 具体的身份信息- 抛出:
IOException- 读写异常
-
setSuccessCallback
public final void setSuccessCallback(ResultCallback<? super org.springframework.security.core.Authentication> success)自定义成功时返回的内容- 参数:
success- 处理Authentication并返回一个可序列化对象的回调函数 该回调函数原型如下 Object success(String path, Authentication authResult) 传入的是调用页面和认证信息,返回一个可序列化的对象- 另请参阅:
ResultCallback
-
unsuccessfulAuthentication
protected final void unsuccessfulAuthentication(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.security.core.AuthenticationException failed) throws IOException重写登录失败逻辑- 覆盖:
unsuccessfulAuthentication在类中org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter- 参数:
request- 请求内容response- 响应内容failed- 错误细节- 抛出:
IOException- 读写异常
-
setFailureCallback
public final void setFailureCallback(ResultCallback<? super org.springframework.security.core.AuthenticationException> failure)自定义失败时返回的内容- 参数:
failure- 处理AuthenticationException并返回一个可序列化对象的回调函数 该回调函数原型如下 Object failure(String path, AuthenticationException exception) 传入的是调用页面和错误细节,返回一个可序列化对象- 另请参阅:
ResultCallback
-
getCookies
protected List<javax.servlet.http.Cookie> getCookies(javax.servlet.http.HttpServletRequest request, org.springframework.security.core.Authentication authResult)获取登录成功时存入响应头的 cookies 内容,可以为空- 参数:
request- 请求内容authResult- 认证细节- 返回:
- cookies 列表
-
setCookiesCallback
自定义成功时 cookies 的内容- 参数:
cookies- 处理Authentication并返回一个 cookies 列表
-
setGuardCallback
自定义守卫拦截方式,比如验证码,频繁登录拦截等等- 参数:
guard- 一个回调函数,该回调函数需要接受一个HttpServletRequest并对其进行分析,根据抛出异常以中断登录过程- 另请参阅:
GuardCallback
-