クラス ConcurrentSessionControlAuthenticationStrategy

  • 実装されたすべてのインターフェース:
    org.springframework.beans.factory.Awareorg.springframework.context.MessageSourceAwareSessionAuthenticationStrategy

    public class ConcurrentSessionControlAuthenticationStrategy
    extends java.lang.Object
    implements org.springframework.context.MessageSourceAware, SessionAuthenticationStrategy
    同時セッション制御を処理する戦略。

    認証後に呼び出されると、すでにアクティブなセッションの数と設定された maximumSessions 値を比較して、問題のユーザーが続行できるかどうかを確認します。SessionRegistry は、認証されたユーザーとセッションデータのソースとして使用されます。

    ユーザーが許可されたセッションの最大数に達した場合、動作は exceptionIfMaxExceeded プロパティに依存します。デフォルトの動作では、許可されたセッションの最大数を超えるセッションは、最近使用したセッションから順に期限切れになります。有効期限が切れたセッションは、再度アクセスされると ConcurrentSessionFilter によって無効化されます。ただし、 exceptionIfMaxExceeded true に設定されている場合、ユーザーは新しい認証セッションを開始できません。

    この戦略は、SessionManagementFilterAbstractAuthenticationProcessingFilter のインスタンス(通常 UsernamePasswordAuthenticationFilter)の両方に注入できますが、通常は CompositeSessionAuthenticationStrategy を使用して RegisterSessionAuthenticationStrategy と組み合わせます。

    導入:
    3.2
    関連事項:
    CompositeSessionAuthenticationStrategy
    • フィールドサマリー

      フィールド  
      修飾子と型 フィールド 説明
      protected org.springframework.context.support.MessageSourceAccessormessages
    • メソッドのサマリー

      すべてのメソッド   インスタンスメソッド   具象メソッド  
      修飾子と型 メソッド 説明
      protected voidallowableSessionsExceeded​(java.util.List<SessionInformation> sessions, int allowableSessions, SessionRegistry registry)
      検出されたセッションが多すぎる場合のサブクラスによる動作のカスタマイズを許可します。
      protected intgetMaximumSessionsForThisUser​(Authentication authentication)
      特定の認証に許可されるセッションの最大数をオーバーライドするために、サブクラスが使用するためのメソッド。
      voidonAuthentication​(Authentication authentication, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      スーパークラスの手順に加えて、sessionRegistry は新しいセッション情報で更新されます。
      voidsetExceptionIfMaximumExceeded​(boolean exceptionIfMaximumExceeded)
      exceptionIfMaximumExceeded プロパティを設定します。このプロパティは、ユーザーが許可されている以上のセッションを開くことを禁止するかどうかを決定します。
      voidsetMaximumSessions​(int maximumSessions)
      maxSessions プロパティを設定します。
      voidsetMessageSource​(org.springframework.context.MessageSource messageSource)
      ユーザーが認証の最大数を超えたときにユーザーにエラーを報告するために使用される MessageSource を設定します。
      • クラス java.lang.Object から継承されたメソッド

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • フィールドの詳細

      • messages

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

      • ConcurrentSessionControlAuthenticationStrategy

        public ConcurrentSessionControlAuthenticationStrategy​(SessionRegistry sessionRegistry)
        パラメーター:
        sessionRegistry - 認証されたセッションが変更されたときに更新されるセッションレジストリ。
    • メソッドの詳細

      • onAuthentication

        public void onAuthentication​(Authentication authentication,
                                     javax.servlet.http.HttpServletRequest request,
                                     javax.servlet.http.HttpServletResponse response)
        スーパークラスの手順に加えて、sessionRegistry は新しいセッション情報で更新されます。
        次で指定:
        インターフェース SessionAuthenticationStrategyonAuthentication 
      • getMaximumSessionsForThisUser

        protected int getMaximumSessionsForThisUser​(Authentication authentication)
        特定の認証に許可されるセッションの最大数をオーバーライドするために、サブクラスが使用するためのメソッド。デフォルトの実装は、Bean の maximumSessions 値を単に返します。
        パラメーター:
        authentication - の最大セッションを決定する
        戻り値:
        -1 は無制限を意味するか、制限する正の整数のいずれか (ゼロになることはありません)
      • allowableSessionsExceeded

        protected void allowableSessionsExceeded​(java.util.List<SessionInformation> sessions,
                                                 int allowableSessions,
                                                 SessionRegistry registry)
                                          throws SessionAuthenticationException
        検出されたセッションが多すぎる場合のサブクラスによる動作のカスタマイズを許可します。
        パラメーター:
        sessions - null またはプリンシパルに関連付けられたすべての期限切れでないセッション
        allowableSessions - ユーザーが保持できる同時セッションの数
        registry - サブクラス用の SessionRegistry のインスタンス
        例外:
        SessionAuthenticationException
      • setExceptionIfMaximumExceeded

        public void setExceptionIfMaximumExceeded​(boolean exceptionIfMaximumExceeded)
        exceptionIfMaximumExceeded プロパティを設定します。このプロパティは、ユーザーが許可されている以上のセッションを開くことを禁止するかどうかを決定します。 true に設定すると、 SessionAuthenticationException が発生します。これは、ユーザー認証が認証されないようにすることを意味します。 false に設定されている場合、すでに認証されているユーザーは強制的にログアウトされます。
        パラメーター:
        exceptionIfMaximumExceeded - デフォルトは false です。
      • setMaximumSessions

        public void setMaximumSessions​(int maximumSessions)
        maxSessions プロパティを設定します。デフォルト値は 1 です。無制限のセッションの場合は -1 を使用します。
        パラメーター:
        maximumSessions - ユーザーが同時に開くことができる許可されたセッションの最大数。
      • setMessageSource

        public void setMessageSource​(org.springframework.context.MessageSource messageSource)
        ユーザーが認証の最大数を超えたときにユーザーにエラーを報告するために使用される MessageSource を設定します。
        次で指定:
        インターフェース org.springframework.context.MessageSourceAwaresetMessageSource