クラス AbstractJaasAuthenticationProvider

java.lang.ObjectSE
org.springframework.security.authentication.jaas.AbstractJaasAuthenticationProvider
実装済みのインターフェース一覧:
EventListenerSE、org.springframework.beans.factory.Aware、org.springframework.beans.factory.InitializingBean、org.springframework.context.ApplicationEventPublisherAware、org.springframework.context.ApplicationListener<SessionDestroyedEvent>、AuthenticationProvider
既知の直属サブクラス
DefaultJaasAuthenticationProvider, JaasAuthenticationProvider

public abstract class AbstractJaasAuthenticationProvider extends ObjectSE implements AuthenticationProvider, org.springframework.context.ApplicationEventPublisherAware, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationListener<SessionDestroyedEvent>
JAAS ログイン構成からユーザーの詳細を取得する AuthenticationProvider 実装。

この AuthenticationProvider は、正しいユーザー名とパスワードを含む UsernamePasswordAuthenticationToken リクエストを検証できます。

この実装は、サブクラスの createLoginContext(CallbackHandler) の実装によって提供される JAAS 構成によってサポートされます。

認証ソースとして JAAS ログインモジュールを使用する場合は、時々 LoginContext は CallbackHandler 秒が必要になります。AbstractJaasAuthenticationProvider は内部 CallbackHandler を使用して、ApplicationContext で構成された JaasAuthenticationCallbackHandler をラップします。LoginContext が内部 CallbackHandler を呼び出すと、渡された各 Callback の各 JaasAuthenticationCallbackHandler に制御が渡されます。

JaasAuthenticationCallbackHandler は callbackHandlers プロパティを通じて AbstractJaasAuthenticationProvider に渡されます。

 <property name="callbackHandlers">
   <list>
     <bean class="org.springframework.security.authentication.jaas.TestCallbackHandler"/>
     <bean class="org.springframework.security.authentication.jaas.JaasNameCallbackHandler"/>
     <bean class="org.springframework.security.authentication.jaas.JaasPasswordCallbackHandler"/>
  </list>
 </property>
 

LoginContext.login() を呼び出した後、AbstractJaasAuthenticationProvider はサブジェクト(LoginContext.getSubject()。getPrincipals)から返されたプリンシパルを取得します。返された各プリンシパルは、構成された AuthorityGranter に渡されます。AuthorityGranter は、返されたプリンシパルとロール名の間のマッピングです。AuthorityGranter が Authorization にロールを付与したい場合は、AuthorityGranter.grant(java.security.Principal) メソッドからそのロール名を返します。返されたロールは、GrantedAuthority として Authorization オブジェクトに適用されます。

AuthorityGranters は次のように Spring XML で構成されています...

 <property name="authorityGranters">
   <list>
     <bean class="org.springframework.security.authentication.jaas.TestAuthorityGranter"/>
   </list>
  </property>
 
  • フィールドの詳細

    • log

      protected final org.apache.commons.logging.Log log
  • コンストラクターの詳細

    • AbstractJaasAuthenticationProvider

      public AbstractJaasAuthenticationProvider()
  • 方法の詳細

    • afterPropertiesSet

      public void afterPropertiesSet() throws ExceptionSE
      必要なプロパティが設定されていることを検証します。さらに、setCallbackHandlers(JaasAuthenticationCallbackHandler[]) が有効なハンドラーで呼び出されていない場合は、JaasNameCallbackHandler および JaasPasswordCallbackHandler を使用するように初期化します。
      次で指定:
      インターフェース org.springframework.beans.factory.InitializingBean 内の afterPropertiesSet 
      例外:
      ExceptionSE
    • authenticate

      public Authentication authenticate(Authentication auth) throws AuthenticationException
      認証オブジェクトのプリンシパルとクレデンシャルを指定してユーザーにログインしようとします
      次で指定:
      インターフェース AuthenticationProvider 内の authenticate 
      パラメーター:
      auth - 認証される認証オブジェクト。
      戻り値:
      grantedAuthorities が設定された、認証された Authentication オブジェクト。
      例外:
      AuthenticationException - この実装は、「ロックされた」アカウントまたは 'disabled' アカウントを処理しません。このメソッドは、loginContext.login() メソッドが失敗した場合にスローされる LoginException のメッセージとともに、AuthenticationServiceException のみをスローします。
    • createLoginContext

      protected abstract LoginContextSE createLoginContext(CallbackHandlerSE handler) throws LoginExceptionSE
      認証に使用する LoginContext を作成します。
      パラメーター:
      handler - LoginContext に使用する必要がある CallbackHandler(非 null)。
      戻り値:
      認証に使用する LoginContext
      例外:
      LoginExceptionSE
    • handleLogout

      protected void handleLogout(SessionDestroyedEvent event)
      破棄されたセッションのセキュリティコンテキストを取得し、JaasAuthenticationToken を含むすべてのセッションに対して LoginContext.logout() を呼び出すことにより、ログアウトを処理します。
      パラメーター:
      event - 現在のセッションを含むセッションイベント
    • onApplicationEvent

      public void onApplicationEvent(SessionDestroyedEvent event)
      次で指定:
      インターフェース org.springframework.context.ApplicationListener<SessionDestroyedEvent> 内の onApplicationEvent 
    • publishFailureEvent

      protected void publishFailureEvent(UsernamePasswordAuthenticationToken token, AuthenticationException ase)
      JaasAuthenticationFailedEvent を公開します。さまざまな機能のサブクラスによってオーバーライドできます
      パラメーター:
      token - 処理中の認証トークン
      ase - 認証失敗の原因となった例外
    • publishSuccessEvent

      protected void publishSuccessEvent(UsernamePasswordAuthenticationToken token)
      JaasAuthenticationSuccessEvent を公開します。さまざまな機能のサブクラスによってオーバーライドできます。
      パラメーター:
      token - 処理中のトークン
    • setAuthorityGranters

      public void setAuthorityGranters(AuthorityGranter[] authorityGranters)
      認証に付与されるロール名について調べられる AuthorityGranters を設定します。
      パラメーター:
      authorityGranters - AuthorityGranter 配列
      関連事項:
    • setCallbackHandlers

      public void setCallbackHandlers(JaasAuthenticationCallbackHandler[] callbackHandlers)
      LoginContext.login メソッドによって生成されたコールバックオブジェクトを処理するように JAASAuthenticationCallbackHandler 配列を設定します。
      パラメーター:
      callbackHandlers - JAASAuthenticationCallbackHandlers の配列
    • setLoginContextName

      public void setLoginContextName(StringSE loginContextName)
      loginContextName を設定します。この名前は、loginConfig プロパティで指定された構成へのインデックスとして使用されます。
      パラメーター:
      loginContextName -
    • setLoginExceptionResolver

      public void setLoginExceptionResolver(LoginExceptionResolver loginExceptionResolver)
    • supports

      public boolean supports(ClassSE<?> aClass)
      インターフェースからコピーされた説明: AuthenticationProvider
      この AuthenticationProvider が指定された Authentication オブジェクトをサポートする場合、true を返します。

      true を返しても、AuthenticationProvider が提示された Authentication オブジェクトを認証できることは保証されません。これは単に、より詳細な評価をサポートできることを示しているだけです。AuthenticationProvider は、AuthenticationProvider.authenticate(Authentication) メソッドから null を返して、別の AuthenticationProvider を試す必要があることを示すことができます。

      認証を実行できる AuthenticationProvider の選択は、実行時に ProviderManager で行われます。

      次で指定:
      インターフェース AuthenticationProvider 内の supports 
      戻り値:
      実装が提示された Authentication クラスをより厳密に評価できる場合は true 
    • setApplicationEventPublisher

      public void setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher)
      次で指定:
      インターフェース org.springframework.context.ApplicationEventPublisherAware 内の setApplicationEventPublisher 
    • getApplicationEventPublisher

      protected org.springframework.context.ApplicationEventPublisher getApplicationEventPublisher()