クラス JaasAuthenticationProvider
- java.lang.Object
-
- org.springframework.security.authentication.jaas.AbstractJaasAuthenticationProvider
-
- org.springframework.security.authentication.jaas.JaasAuthenticationProvider
- 実装済みのインターフェース一覧:
java.util.EventListener、org.springframework.beans.factory.Aware、org.springframework.beans.factory.InitializingBean、org.springframework.context.ApplicationEventPublisherAware、org.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 ログインモジュールを使用する場合は、時々 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)メソッドをオーバーライドします。
フィールド概要
フィールド 修飾子と型 フィールド 説明 protected static org.apache.commons.logging.Loglog
コンストラクター概要
コンストラクター コンストラクター 説明 JaasAuthenticationProvider()
方法の概要
すべてのメソッド インスタンスメソッド 具象メソッド 修飾子と型 メソッド 説明 voidafterPropertiesSet()必要なプロパティが設定されていることを検証します。protected voidconfigureJaas(org.springframework.core.io.Resource loginConfig)Jaas を構成するためのフックメソッド。protected javax.security.auth.login.LoginContextcreateLoginContext(javax.security.auth.callback.CallbackHandler handler)認証に使用する LoginContext を作成します。org.springframework.core.io.ResourcegetLoginConfig()protected voidpublishFailureEvent(UsernamePasswordAuthenticationToken token, AuthenticationException ase)JaasAuthenticationFailedEventを公開します。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
メソッドの詳細
afterPropertiesSet
public void afterPropertiesSet() throws java.lang.Exceptionクラスからコピーされた説明:AbstractJaasAuthenticationProvider必要なプロパティが設定されていることを検証します。さらに、AbstractJaasAuthenticationProvider.setCallbackHandlers(JaasAuthenticationCallbackHandler[])が有効なハンドラーで呼び出されていない場合は、JaasNameCallbackHandlerおよびJaasPasswordCallbackHandlerを使用するように初期化します。- 次で指定:
- インターフェース
org.springframework.beans.factory.InitializingBean内のafterPropertiesSet - オーバーライド:
- クラス
AbstractJaasAuthenticationProviderのafterPropertiesSet - 例外:
java.lang.Exception
createLoginContext
protected javax.security.auth.login.LoginContext createLoginContext(javax.security.auth.callback.CallbackHandler handler) throws javax.security.auth.login.LoginExceptionクラスからコピーされた説明:AbstractJaasAuthenticationProvider認証に使用する LoginContext を作成します。- 次で指定:
- クラス
AbstractJaasAuthenticationProviderのcreateLoginContext - パラメーター:
handler- LoginContext に使用する必要がある CallbackHandler(非null)。- 戻り値:
- 認証に使用する LoginContext
- 例外:
javax.security.auth.login.LoginException
configureJaas
protected void configureJaas(org.springframework.core.io.Resource loginConfig) throws java.io.IOExceptionJaas を構成するためのフックメソッド。- パラメーター:
loginConfig- Jaas ログイン構成の URL- 例外:
java.io.IOException- 構成リソースの読み取りに問題がある場合。
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-- 関連事項:
- JAAS リファレンス
setRefreshConfigurationOnStartup
public void setRefreshConfigurationOnStartup(boolean refresh)
設定されている場合、Configuration#refresh()への呼び出しは#configureJaas(Resource)メソッドによって行われます。デフォルトはtrueです。- パラメーター:
refresh-falseに設定すると、構成の再読み込みが無効になります。一部の環境で役立つ場合があります。- 関連事項:
- SEC-1320