クラス AbstractJaasAuthenticationProvider
- java.lang.Object
-
- org.springframework.security.authentication.jaas.AbstractJaasAuthenticationProvider
- 実装済みのインターフェース一覧:
java.util.EventListener、org.springframework.beans.factory.Aware、org.springframework.beans.factory.InitializingBean、org.springframework.context.ApplicationEventPublisherAware、org.springframework.context.ApplicationListener<SessionDestroyedEvent>、AuthenticationProvider
public abstract class AbstractJaasAuthenticationProvider extends java.lang.Object 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>
フィールド概要
フィールド 修飾子と型 フィールド 説明 protected org.apache.commons.logging.Loglog
コンストラクター概要
コンストラクター コンストラクター 説明 AbstractJaasAuthenticationProvider()
方法の概要
すべてのメソッド インスタンスメソッド 抽象メソッド 具象メソッド 修飾子と型 メソッド 説明 voidafterPropertiesSet()必要なプロパティが設定されていることを検証します。Authenticationauthenticate(Authentication auth)認証オブジェクトのプリンシパルとクレデンシャルを指定してユーザーにログインしようとしますprotected abstract javax.security.auth.login.LoginContextcreateLoginContext(javax.security.auth.callback.CallbackHandler handler)認証に使用する LoginContext を作成します。protected org.springframework.context.ApplicationEventPublishergetApplicationEventPublisher()protected voidhandleLogout(SessionDestroyedEvent event)破棄されたセッションのセキュリティコンテキストを取得し、JaasAuthenticationTokenを含むすべてのセッションに対してLoginContext.logout()を呼び出すことにより、ログアウトを処理します。voidonApplicationEvent(SessionDestroyedEvent event)protected voidpublishFailureEvent(UsernamePasswordAuthenticationToken token, AuthenticationException ase)JaasAuthenticationFailedEventを公開します。protected voidpublishSuccessEvent(UsernamePasswordAuthenticationToken token)JaasAuthenticationSuccessEventを公開します。voidsetApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher)voidsetAuthorityGranters(AuthorityGranter[] authorityGranters)認証に付与されるロール名について調べられる AuthorityGranters を設定します。voidsetCallbackHandlers(JaasAuthenticationCallbackHandler[] callbackHandlers)JAASAuthentcationCallbackHandler 配列を設定して、LoginContext.login メソッドによって生成されたコールバックオブジェクトを処理します。voidsetLoginContextName(java.lang.String loginContextName)loginContextName を設定します。この名前は、loginConfig プロパティで指定された構成へのインデックスとして使用されます。voidsetLoginExceptionResolver(LoginExceptionResolver loginExceptionResolver)booleansupports(java.lang.Class<?> aClass)このAuthenticationProviderが指定されたAuthenticationオブジェクトをサポートする場合、trueを返します。
メソッドの詳細
afterPropertiesSet
public void afterPropertiesSet() throws java.lang.Exception必要なプロパティが設定されていることを検証します。さらに、setCallbackHandlers(JaasAuthenticationCallbackHandler[])が有効なハンドラーで呼び出されていない場合は、JaasNameCallbackHandlerおよびJaasPasswordCallbackHandlerを使用するように初期化します。- 次で指定:
- インターフェース
org.springframework.beans.factory.InitializingBean内のafterPropertiesSet - 例外:
java.lang.Exception
authenticate
public Authentication authenticate(Authentication auth) throws AuthenticationException
認証オブジェクトのプリンシパルとクレデンシャルを指定してユーザーにログインしようとします- 次で指定:
- インターフェース
AuthenticationProvider内のauthenticate - パラメーター:
auth- 認証される認証オブジェクト。- 戻り値:
- grantedAuthorities が設定された、認証された Authentication オブジェクト。
- 例外:
AuthenticationException- この実装は、「ロックされた」アカウントまたは 'disabled' アカウントを処理しません。このメソッドは、loginContext.login() メソッドが失敗した場合にスローされる LoginException のメッセージとともに、AuthenticationServiceException のみをスローします。
createLoginContext
protected abstract javax.security.auth.login.LoginContext createLoginContext(javax.security.auth.callback.CallbackHandler handler) throws javax.security.auth.login.LoginException認証に使用する LoginContext を作成します。- パラメーター:
handler- LoginContext に使用する必要がある CallbackHandler(非null)。- 戻り値:
- 認証に使用する LoginContext
- 例外:
javax.security.auth.login.LoginException
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 配列- 関連事項:
JaasAuthenticationProvider
setCallbackHandlers
public void setCallbackHandlers(JaasAuthenticationCallbackHandler[] callbackHandlers)
JAASAuthentcationCallbackHandler 配列を設定して、LoginContext.login メソッドによって生成されたコールバックオブジェクトを処理します。- パラメーター:
callbackHandlers- JAASAuthenticationCallbackHandlers の配列
setLoginContextName
public void setLoginContextName(java.lang.String loginContextName)
loginContextName を設定します。この名前は、loginConfig プロパティで指定された構成へのインデックスとして使用されます。- パラメーター:
loginContextName-
setLoginExceptionResolver
public void setLoginExceptionResolver(LoginExceptionResolver loginExceptionResolver)
supports
public boolean supports(java.lang.Class<?> 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()