クラス JaasAuthenticationProvider

java.lang.ObjectSE
org.springframework.security.authentication.jaas.AbstractJaasAuthenticationProvider
org.springframework.security.authentication.jaas.JaasAuthenticationProvider
実装されたすべてのインターフェース:
EventListenerSEorg.springframework.beans.factory.Awareorg.springframework.beans.factory.InitializingBeanorg.springframework.context.ApplicationEventPublisherAwareorg.springframework.context.ApplicationListener<SessionDestroyedEvent>AuthenticationProvider

public class JaasAuthenticationProvider extends AbstractJaasAuthenticationProvider
JAAS ログイン構成からユーザーの詳細を取得する AuthenticationProvider 実装。

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

この実装は、JAAS 構成によってサポートされています。loginConfig プロパティは、特定の JAAS 構成ファイルに設定する必要があります。この setter は、Spring Resource インスタンスを受け入れます。これは、loginContextName プロパティに一致するインデックスを含む JAAS 構成ファイルを指す必要があります。

次に例を示します: この JaasAuthenticationProvider が Spring WebApplicationContext で構成されている場合、loginConfiguration を設定するための xml は次のようになります...

 <property name="loginConfig">
   <value>/WEB-INF/login.conf</value>
 </property>
 

loginContextName は、指定された loginConfig 内の特定のインデックスと一致する必要があります。JUnit テストで使用される loginConfig ファイルは次のようになります。

 JAASTest {
   org.springframework.security.authentication.jaas.TestLoginModule required;
 };
 
上記のログイン構成の例を使用すると、loginContextName プロパティは JAASTest... として設定されます
  <property name="loginContextName"> <value>JAASTest</value> </property>
 

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

JaasAuthenticationCallbackHandlercallbackHandlers プロパティを通じて JaasAuthenticationProvider に渡されます。

 <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() を呼び出した後、JaasAuthenticationProvider はサブジェクト(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>
 
構成メモ: JaasAuthenticationProvider は、セキュリティプロパティ "login.config.url.X" を使用して jaas を構成します。Jaas の構成方法をカスタマイズする場合は、このサブクラスを作成し、configureJaas(Resource) メソッドをオーバーライドします。
  • フィールドの詳細

    • log

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

    • JaasAuthenticationProvider

      public JaasAuthenticationProvider()
  • メソッドの詳細