クラス ExceptionTranslationFilter

java.lang.ObjectSE
org.springframework.web.filter.GenericFilterBean
org.springframework.security.web.access.ExceptionTranslationFilter
実装されたすべてのインターフェース:
jakarta.servlet.Filterorg.springframework.beans.factory.Awareorg.springframework.beans.factory.BeanNameAwareorg.springframework.beans.factory.DisposableBeanorg.springframework.beans.factory.InitializingBeanorg.springframework.context.EnvironmentAwareorg.springframework.context.MessageSourceAwareorg.springframework.core.env.EnvironmentCapableorg.springframework.web.context.ServletContextAware

public class ExceptionTranslationFilter extends org.springframework.web.filter.GenericFilterBean implements org.springframework.context.MessageSourceAware
フィルターチェーン内でスローされた AccessDeniedException および AuthenticationException を処理します。

このフィルターは、Java 例外と HTTP レスポンス間のブリッジを提供するために必要です。ユーザーインターフェースの維持にのみ関係します。このフィルターは、実際のセキュリティ実施を行いません。

AuthenticationException が検出された場合、フィルターは authenticationEntryPoint を起動します。これにより、AbstractSecurityInterceptor の任意のサブクラスに起因する認証失敗の一般的な処理が可能になります。

AccessDeniedException が検出された場合、フィルターはユーザーが匿名ユーザーであるかどうかを判別します。匿名ユーザーの場合、authenticationEntryPoint が起動します。それらが匿名ユーザーでない場合、フィルターは AccessDeniedHandler に委譲します。デフォルトでは、フィルターは AccessDeniedHandlerImpl を使用します。

このフィルターを使用するには、次のプロパティを指定する必要があります。

  • authenticationEntryPoint は、AuthenticationException が検出された場合に認証プロセスを開始するハンドラーを示します。これにより、SSL ログインのために現在のプロトコルが http から https に切り替わることもあります。
  • requestCache は、ユーザーが認証されたらリクエストを取得して再利用できるように、認証プロセス中にリクエストを保存するために使用される戦略を決定します。デフォルトの実装は HttpSessionRequestCache です。
  • フィールドの詳細

    • messages

      protected org.springframework.context.support.MessageSourceAccessor messages
  • コンストラクターの詳細

  • メソッドの詳細

    • afterPropertiesSet

      public void afterPropertiesSet()
      次で指定:
      インターフェース org.springframework.beans.factory.InitializingBeanafterPropertiesSet 
      オーバーライド:
      クラス org.springframework.web.filter.GenericFilterBeanafterPropertiesSet 
    • doFilter

      public void doFilter(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, jakarta.servlet.FilterChain chain) throws IOExceptionSE, jakarta.servlet.ServletException
      次で指定:
      インターフェース jakarta.servlet.FilterdoFilter 
      例外:
      IOExceptionSE
      jakarta.servlet.ServletException
    • getAuthenticationEntryPoint

      public AuthenticationEntryPoint getAuthenticationEntryPoint()
    • getAuthenticationTrustResolver

      protected AuthenticationTrustResolver getAuthenticationTrustResolver()
    • sendStartAuthentication

      protected void sendStartAuthentication(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, jakarta.servlet.FilterChain chain, AuthenticationException reason) throws jakarta.servlet.ServletException, IOExceptionSE
      例外:
      jakarta.servlet.ServletException
      IOExceptionSE
    • setAccessDeniedHandler

      public void setAccessDeniedHandler(AccessDeniedHandler accessDeniedHandler)
    • setAuthenticationTrustResolver

      public void setAuthenticationTrustResolver(AuthenticationTrustResolver authenticationTrustResolver)
    • setThrowableAnalyzer

      public void setThrowableAnalyzer(ThrowableAnalyzer throwableAnalyzer)
    • setMessageSource

      public void setMessageSource(org.springframework.context.MessageSource messageSource)
      次で指定:
      インターフェース org.springframework.context.MessageSourceAwaresetMessageSource 
      導入:
      5.5
    • setSecurityContextHolderStrategy

      public void setSecurityContextHolderStrategy(SecurityContextHolderStrategy securityContextHolderStrategy)
      使用する SecurityContextHolderStrategy を設定します。デフォルトのアクションは、SecurityContextHolder に格納されている SecurityContextHolderStrategy を使用することです。
      導入:
      5.8