クラス 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.Log
log
コンストラクターの概要
コンストラクター コンストラクター 説明 AbstractJaasAuthenticationProvider()
メソッドのサマリー
すべてのメソッド インスタンスメソッド 抽象メソッド 具象メソッド 修飾子と型 メソッド 説明 void
afterPropertiesSet()
必要なプロパティが設定されていることを検証します。Authentication
authenticate(Authentication auth)
認証オブジェクトのプリンシパルとクレデンシャルを指定してユーザーにログインしようとしますprotected abstract javax.security.auth.login.LoginContext
createLoginContext(javax.security.auth.callback.CallbackHandler handler)
認証に使用する LoginContext を作成します。protected org.springframework.context.ApplicationEventPublisher
getApplicationEventPublisher()
protected void
handleLogout(SessionDestroyedEvent event)
破棄されたセッションのセキュリティコンテキストを取得し、JaasAuthenticationToken
を含むすべてのセッションに対してLoginContext.logout()
を呼び出すことにより、ログアウトを処理します。void
onApplicationEvent(SessionDestroyedEvent event)
protected void
publishFailureEvent(UsernamePasswordAuthenticationToken token, AuthenticationException ase)
JaasAuthenticationFailedEvent
を公開します。protected void
publishSuccessEvent(UsernamePasswordAuthenticationToken token)
JaasAuthenticationSuccessEvent
を公開します。void
setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher)
void
setAuthorityGranters(AuthorityGranter[] authorityGranters)
認証に付与されるロール名について調べられる AuthorityGranters を設定します。void
setCallbackHandlers(JaasAuthenticationCallbackHandler[] callbackHandlers)
JAASAuthentcationCallbackHandler 配列を設定して、LoginContext.login メソッドによって生成されたコールバックオブジェクトを処理します。void
setLoginContextName(java.lang.String loginContextName)
loginContextName を設定します。この名前は、loginConfig プロパティで指定された構成へのインデックスとして使用されます。void
setLoginExceptionResolver(LoginExceptionResolver loginExceptionResolver)
boolean
supports(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()