クラス SecurityContextPersistenceFilter

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

@DeprecatedSE public class SecurityContextPersistenceFilter extends org.springframework.web.filter.GenericFilterBean
使用すべきではありません。
リクエストの前に構成済みの SecurityContextRepository から取得した情報を SecurityContextHolder に入力し、リクエストが完了してコンテキストホルダーをクリアすると、それをリポジトリに保存します。デフォルトでは HttpSessionSecurityContextRepository を使用します。 HttpSession 関連の設定オプションについては、このクラスを参照してください。

このフィルターはリクエストごとに 1 回だけ実行され、サーブレットコンテナー(特に Weblogic)の非互換性を解決します。

このフィルターは、認証処理メカニズムの前に実行する必要があります。認証処理メカニズム(BASIC、CAS 処理フィルターなど)は、SecurityContextHolder が実行されるまでに SecurityContextHolder に有効な SecurityContext が含まれることを期待しています。

これは基本的に古い HttpSessionContextIntegrationFilter のリファクタリングであり、ストレージの課題を別の戦略に委譲し、リクエスト間でセキュリティコンテキストを維持する方法をさらにカスタマイズできるようにします。

forceEagerSessionCreation プロパティを使用して、フィルターチェーンが実行される前にセッションが常に使用可能であることを確認できます(デフォルトは false です。これはリソースを大量に消費するため、推奨されません)。

導入:
3.0
  • フィールドサマリー

    クラス org.springframework.web.filter.GenericFilterBean から継承されたフィールド

    logger
  • コンストラクターのサマリー

    コンストラクター
    コンストラクター
    説明
    使用すべきではありません。
    使用すべきではありません。
  • メソッドのサマリー

    修飾子と型
    メソッド
    説明
    void
    doFilter(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, jakarta.servlet.FilterChain chain)
    使用すべきではありません。
    void
    setForceEagerSessionCreation(boolean forceEagerSessionCreation)
    使用すべきではありません。
    void
    使用すべきではありません。
    使用する SecurityContextHolderStrategy を設定します。

    クラス org.springframework.web.filter.GenericFilterBean から継承されたメソッド

    addRequiredProperty, afterPropertiesSet, createEnvironment, destroy, getEnvironment, getFilterConfig, getFilterName, getServletContext, init, initBeanWrapper, initFilterBean, setBeanName, setEnvironment, setServletContext

    クラス java.lang.ObjectSE から継承されたメソッド

    clone, equalsSE, finalize, getClass, hashCode, notify, notifyAll, toString, wait, waitSE, waitSE
  • コンストラクターの詳細

    • SecurityContextPersistenceFilter

      public SecurityContextPersistenceFilter()
      使用すべきではありません。
    • SecurityContextPersistenceFilter

      public SecurityContextPersistenceFilter(SecurityContextRepository repo)
      使用すべきではありません。
  • メソッドの詳細

    • doFilter

      public void doFilter(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, jakarta.servlet.FilterChain chain) throws IOExceptionSE, jakarta.servlet.ServletException
      使用すべきではありません。
      例外:
      IOExceptionSE
      jakarta.servlet.ServletException
    • setForceEagerSessionCreation

      public void setForceEagerSessionCreation(boolean forceEagerSessionCreation)
      使用すべきではありません。
    • setSecurityContextHolderStrategy

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