public abstract class AbstractJaasAuthenticationProvider extends java.lang.Object implements AuthenticationProvider, org.springframework.context.ApplicationEventPublisherAware, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationListener<SessionDestroyedEvent>
AuthenticationProvider 実装。 この AuthenticationProvider は、正しいユーザー名とパスワードを含む UsernamePasswordAuthenticationToken リクエストを検証できます。
この実装は、サブクラスの createLoginContext(CallbackHandler) 実装によって提供される JAAS 構成によってサポートされています。
JAAS ログインモジュールを認証ソースとして使用する場合、LoginContext は CallbackHandler を必要とする場合があります。AbstractJaasAuthenticationProvider は、ApplicationContext で設定された JaasAuthenticationCallbackHandler をラップするために内部 CallbackHandler を使用します。LoginContext が内部 CallbackHandler を呼び出すと、渡されたコールバックごとに制御が各 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 を返します。 |
public void afterPropertiesSet()
throws java.lang.ExceptionsetCallbackHandlers(JaasAuthenticationCallbackHandler[]) が有効なハンドラーで呼び出されていない場合は、JaasNameCallbackHandler および JaasPasswordCallbackHandler を使用するように初期化します。org.springframework.beans.factory.InitializingBean 内の afterPropertiesSet java.lang.Exceptionpublic Authentication authenticate(Authentication auth) throws AuthenticationException
AuthenticationProvider 内の authenticate auth - 認証される認証オブジェクト。AuthenticationException - この実装は、「ロックされた」アカウントまたは 'disabled' アカウントを処理しません。このメソッドは、loginContext.login() メソッドが失敗した場合にスローされる LoginException のメッセージとともに、AuthenticationServiceException のみをスローします。protected abstract javax.security.auth.login.LoginContext createLoginContext(javax.security.auth.callback.CallbackHandler handler)
throws javax.security.auth.login.LoginExceptionhandler - LoginContext に使用する必要がある CallbackHandler(非 null)。javax.security.auth.login.LoginExceptionprotected void handleLogout(SessionDestroyedEvent event)
JaasAuthenticationToken を含むすべてのセッションに対して LoginContext.logout() を呼び出すことにより、ログアウトを処理します。event - 現在のセッションを含むセッションイベント public void onApplicationEvent(SessionDestroyedEvent event)
org.springframework.context.ApplicationListener<SessionDestroyedEvent> 内の onApplicationEvent protected void publishFailureEvent(UsernamePasswordAuthenticationToken token, AuthenticationException ase)
JaasAuthenticationFailedEvent を公開します。さまざまな機能のサブクラスによってオーバーライドできます token - 処理中の認証トークン ase - 認証失敗の原因となった例外 protected void publishSuccessEvent(UsernamePasswordAuthenticationToken token)
JaasAuthenticationSuccessEvent を公開します。さまざまな機能のサブクラスによってオーバーライドできます。token - 処理中のトークン public void setAuthorityGranters(AuthorityGranter[] authorityGranters)
authorityGranters - AuthorityGranter 配列 JaasAuthenticationProviderpublic void setCallbackHandlers(JaasAuthenticationCallbackHandler[] callbackHandlers)
callbackHandlers - JAASAuthenticationCallbackHandlers の配列 public void setLoginContextName(java.lang.String loginContextName)
loginContextName -public void setLoginExceptionResolver(LoginExceptionResolver loginExceptionResolver)
public boolean supports(java.lang.Class<?> aClass)
AuthenticationProviderAuthenticationProvider が指定された Authentication オブジェクトをサポートする場合、true を返します。true を返すことは、AuthenticationProvider が Authentication クラスの提示されたインスタンスを認証できることを保証しません。それは、それがより詳細な評価をサポートできることを示しています。AuthenticationProvider は、AuthenticationProvider.authenticate(Authentication) メソッドから null を返して、別の AuthenticationProvider を試す必要があることを示すことができます。
認証を実行できる AuthenticationProvider の選択は、実行時に ProviderManager で行われます。
AuthenticationProvider 内の supports Authentication クラスをより厳密に評価できる場合は true public void setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher)
org.springframework.context.ApplicationEventPublisherAware 内の setApplicationEventPublisher protected org.springframework.context.ApplicationEventPublisher getApplicationEventPublisher()