クラス JaasAuthenticationProvider
- 実装されているすべてのインターフェース:
EventListenerSE、org.springframework.beans.factory.Aware、org.springframework.beans.factory.InitializingBean、org.springframework.context.ApplicationEventPublisherAware、org.springframework.context.ApplicationListener<SessionDestroyedEvent>、AuthenticationProvider
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 ログインモジュールを使用する場合は、時々 LoginContext は CallbackHandler 秒が必要になります。JaasAuthenticationProvider は内部 CallbackHandler を使用して、ApplicationContext で構成された JaasAuthenticationCallbackHandler をラップします。LoginContext が内部 CallbackHandler を呼び出すと、渡された各 Callback の各 JaasAuthenticationCallbackHandler に制御が渡されます。
JaasAuthenticationCallbackHandler は callbackHandlers プロパティを通じて 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) メソッドをオーバーライドします。フィールドのサマリー
フィールドコンストラクターの概要
コンストラクターメソッドのサマリー
修飾子と型メソッド説明void必要なプロパティが設定されていることを検証します。protected voidconfigureJaas(org.springframework.core.io.Resource loginConfig) Jaas を構成するためのフックメソッド。protected LoginContextSEcreateLoginContext(CallbackHandlerSE handler) 認証に使用する LoginContext を作成します。org.springframework.core.io.Resourceprotected voidJaasAuthenticationFailedEventを公開します。voidsetLoginConfig(org.springframework.core.io.Resource loginConfig) JAAS ログイン構成ファイルを設定します。voidsetRefreshConfigurationOnStartup(boolean refresh) 設定されている場合、Configuration#refresh()への呼び出しは#configureJaas(Resource)メソッドによって行われます。クラス org.springframework.security.authentication.jaas.AbstractJaasAuthenticationProvider から継承されたメソッド
authenticate, getApplicationEventPublisher, handleLogout, onApplicationEvent, publishSuccessEvent, setApplicationEventPublisher, setAuthorityGranters, setCallbackHandlers, setLoginContextName, setLoginExceptionResolver, supportsクラス java.lang.ObjectSE から継承されたメソッド
clone, equalsSE, finalize, getClass, hashCode, notify, notifyAll, toString, wait, waitSE, waitSEインターフェース org.springframework.context.ApplicationListener から継承されたメソッド
supportsAsyncExecution
フィールドの詳細
log
protected static final org.apache.commons.logging.Log log
コンストラクターの詳細
JaasAuthenticationProvider
public JaasAuthenticationProvider()
メソッドの詳細
afterPropertiesSet
クラスからコピーされた説明:AbstractJaasAuthenticationProvider必要なプロパティが設定されていることを検証します。さらに、AbstractJaasAuthenticationProvider.setCallbackHandlers(JaasAuthenticationCallbackHandler[])が有効なハンドラーで呼び出されていない場合は、JaasNameCallbackHandlerおよびJaasPasswordCallbackHandlerを使用するように初期化します。- 次で指定:
- インターフェース
org.springframework.beans.factory.InitializingBeanのafterPropertiesSet - オーバーライド:
- クラス
AbstractJaasAuthenticationProviderのafterPropertiesSet - 例外:
ExceptionSE
createLoginContext
クラスからコピーされた説明:AbstractJaasAuthenticationProvider認証に使用する LoginContext を作成します。- 次で指定:
- クラス
AbstractJaasAuthenticationProviderのcreateLoginContext - パラメーター:
handler- LoginContext に使用する必要がある CallbackHandler(非null)。- 戻り値:
- 認証に使用する LoginContext
- 例外:
LoginExceptionSE
configureJaas
Jaas を構成するためのフックメソッド。- パラメーター:
loginConfig- Jaas ログイン構成の URL- 例外:
IOExceptionSE- 構成リソースの読み取りに問題がある場合。
publishFailureEvent
protected void publishFailureEvent(UsernamePasswordAuthenticationToken token, AuthenticationException ase) JaasAuthenticationFailedEventを公開します。さまざまな機能のサブクラスによってオーバーライドできます- オーバーライド:
- クラス
AbstractJaasAuthenticationProviderのpublishFailureEvent - パラメーター:
token- 処理中の認証トークンase- 認証失敗の原因となった例外
getLoginConfig
public org.springframework.core.io.Resource getLoginConfig()setLoginConfig
public void setLoginConfig(org.springframework.core.io.Resource loginConfig) JAAS ログイン構成ファイルを設定します。- パラメーター:
loginConfig-- 関連事項:
setRefreshConfigurationOnStartup
public void setRefreshConfigurationOnStartup(boolean refresh) 設定されている場合、Configuration#refresh()への呼び出しは#configureJaas(Resource)メソッドによって行われます。デフォルトはtrueです。- パラメーター:
refresh-falseに設定すると、構成の再読み込みが無効になります。一部の環境で役立つ場合があります。- 関連事項: