类 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 参考 BaseJwtSecurityConfigurerAdapterJwtLoginFilterImpl 进行配置
从以下版本开始:
1.9
作者:
XUMUMI
另请参阅:
BaseJwtSecurityConfigurerAdapter
  • 字段概要

    从类继承的字段 org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter

    authenticationDetailsSource, eventPublisher, messages

    从类继承的字段 org.springframework.web.filter.GenericFilterBean

    logger
  • 构造器概要

    构造器
    限定符 构造器 说明
    protected AbstractJsonAuthenticationFilter​(org.springframework.security.authentication.AuthenticationManager manager, String loginProcessingUrl)
    构造器
  • 方法概要

    修饰符和类型 方法 说明
    org.springframework.security.core.Authentication attemptAuthentication​(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 内容,可以为空
    void setCookiesCallback​(CookiesCallback cookies)
    自定义成功时 cookies 的内容
    void setFailureCallback​(ResultCallback<? super org.springframework.security.core.AuthenticationException> failure)
    自定义失败时返回的内容
    void setGuardCallback​(GuardCallback guard)
    自定义守卫拦截方式,比如验证码,频繁登录拦截等等
    void setPasswordParameter​(String parameter)
    修改密码字段名
    void setSuccessCallback​(ResultCallback<? super org.springframework.security.core.Authentication> success)
    自定义成功时返回的内容
    void setUsernameParameter​(String parameter)
    修改用户字段名
    protected void successfulAuthentication​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.FilterChain chain, org.springframework.security.core.Authentication authResult)
    重写登录成功逻辑
    protected void unsuccessfulAuthentication​(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

    从类继承的方法 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 构造器详细资料

    • AbstractJsonAuthenticationFilter

      protected AbstractJsonAuthenticationFilter​(@NonNull org.springframework.security.authentication.AuthenticationManager manager, @NonNull String loginProcessingUrl)
      构造器
      参数:
      manager - 必须传入认证管理器以供使用
      loginProcessingUrl - 登录请求地址
  • 方法详细资料

    • setUsernameParameter

      public final void setUsernameParameter​(String parameter)
      修改用户字段名
      参数:
      parameter - 字段名
    • setPasswordParameter

      public final void setPasswordParameter​(String parameter)
      修改密码字段名
      参数:
      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

      public final void setCookiesCallback​(CookiesCallback cookies)
      自定义成功时 cookies 的内容
      参数:
      cookies - 处理 Authentication 并返回一个 cookies 列表
    • setGuardCallback

      public final void setGuardCallback​(GuardCallback guard)
      自定义守卫拦截方式,比如验证码,频繁登录拦截等等
      参数:
      guard - 一个回调函数,该回调函数需要接受一个 HttpServletRequest 并对其进行分析,根据抛出异常以中断登录过程
      另请参阅:
      GuardCallback