クラス ExceptionTranslationFilter
java.lang.ObjectSE
org.springframework.web.filter.GenericFilterBean
org.springframework.security.web.access.ExceptionTranslationFilter
- 実装されたすべてのインターフェース:
jakarta.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.context.MessageSourceAware
、org.springframework.core.env.EnvironmentCapable
、org.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
です。
フィールドサマリー
フィールドクラス org.springframework.web.filter.GenericFilterBean から継承されたフィールド
logger
コンストラクターのサマリー
コンストラクターコンストラクター説明ExceptionTranslationFilter
(AuthenticationEntryPoint authenticationEntryPoint) ExceptionTranslationFilter
(AuthenticationEntryPoint authenticationEntryPoint, RequestCache requestCache) メソッドのサマリー
修飾子と型メソッド説明void
void
doFilter
(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, jakarta.servlet.FilterChain chain) protected AuthenticationTrustResolver
protected void
sendStartAuthentication
(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, jakarta.servlet.FilterChain chain, AuthenticationException reason) void
setAccessDeniedHandler
(AccessDeniedHandler accessDeniedHandler) void
setAuthenticationTrustResolver
(AuthenticationTrustResolver authenticationTrustResolver) void
setMessageSource
(org.springframework.context.MessageSource messageSource) void
setSecurityContextHolderStrategy
(SecurityContextHolderStrategy securityContextHolderStrategy) 使用するSecurityContextHolderStrategy
を設定します。void
setThrowableAnalyzer
(ThrowableAnalyzer throwableAnalyzer) クラス org.springframework.web.filter.GenericFilterBean から継承されたメソッド
addRequiredProperty, createEnvironment, destroy, getEnvironment, getFilterConfig, getFilterName, getServletContext, init, initBeanWrapper, initFilterBean, setBeanName, setEnvironment, setServletContext
フィールドの詳細
messages
protected org.springframework.context.support.MessageSourceAccessor messages
コンストラクターの詳細
ExceptionTranslationFilter
ExceptionTranslationFilter
public ExceptionTranslationFilter(AuthenticationEntryPoint authenticationEntryPoint, RequestCache requestCache)
メソッドの詳細
afterPropertiesSet
public void afterPropertiesSet()- 次で指定:
- インターフェース
org.springframework.beans.factory.InitializingBean
のafterPropertiesSet
- オーバーライド:
- クラス
org.springframework.web.filter.GenericFilterBean
のafterPropertiesSet
doFilter
public void doFilter(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, jakarta.servlet.FilterChain chain) throws IOExceptionSE, jakarta.servlet.ServletException - 次で指定:
- インターフェース
jakarta.servlet.Filter
のdoFilter
- 例外:
IOExceptionSE
jakarta.servlet.ServletException
getAuthenticationEntryPoint
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
setAuthenticationTrustResolver
setThrowableAnalyzer
setMessageSource
public void setMessageSource(org.springframework.context.MessageSource messageSource) - 次で指定:
- インターフェース
org.springframework.context.MessageSourceAware
のsetMessageSource
- 導入:
- 5.5
setSecurityContextHolderStrategy
public void setSecurityContextHolderStrategy(SecurityContextHolderStrategy securityContextHolderStrategy) 使用するSecurityContextHolderStrategy
を設定します。デフォルトのアクションは、SecurityContextHolder
に格納されているSecurityContextHolderStrategy
を使用することです。- 導入:
- 5.8