クラス DaoAuthenticationProvider
- java.lang.Object
-
- org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider
-
- org.springframework.security.authentication.dao.DaoAuthenticationProvider
- 実装されているすべてのインターフェース:
org.springframework.beans.factory.Aware、org.springframework.beans.factory.InitializingBean、org.springframework.context.MessageSourceAware、AuthenticationProvider
public class DaoAuthenticationProvider extends AbstractUserDetailsAuthenticationProvider
UserDetailsServiceからユーザーの詳細を取得するAuthenticationProvider実装。
フィールドのサマリー
クラス org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider から継承されたフィールド
hideUserNotFoundExceptions, logger, messages
コンストラクターの概要
コンストラクター コンストラクター 説明 DaoAuthenticationProvider()
方法の概要
すべてのメソッド インスタンスメソッド 具象メソッド 修飾子と型 メソッド 説明 protected voidadditionalAuthenticationChecks(UserDetails userDetails, UsernamePasswordAuthenticationToken authentication)サブクラスが、特定の認証リクエストに対して返された(またはキャッシュされた)UserDetailsの追加チェックを実行できるようにします。protected AuthenticationcreateSuccessAuthentication(java.lang.Object principal, Authentication authentication, UserDetails user)成功したAuthenticationオブジェクトを作成します。protected voiddoAfterPropertiesSet()protected PasswordEncodergetPasswordEncoder()protected UserDetailsServicegetUserDetailsService()protected UserDetailsretrieveUser(java.lang.String username, UsernamePasswordAuthenticationToken authentication)サブクラスが実装固有の場所からUserDetailsを実際に取得できるようにします。提示された資格情報が正しくない場合、すぐにAuthenticationExceptionをスローするオプションがあります(これは、ユーザーとしてリソースにバインドする必要がある場合に特に役立ちます。UserDetailsを生成します)。voidsetPasswordEncoder(PasswordEncoder passwordEncoder)パスワードのエンコードと検証に使用される PasswordEncoder インスタンスを設定します。voidsetUserDetailsPasswordService(UserDetailsPasswordService userDetailsPasswordService)voidsetUserDetailsService(UserDetailsService userDetailsService)クラス org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider から継承されたメソッド
afterPropertiesSet, authenticate, getPostAuthenticationChecks, getPreAuthenticationChecks, getUserCache, isForcePrincipalAsString, isHideUserNotFoundExceptions, setAuthoritiesMapper, setForcePrincipalAsString, setHideUserNotFoundExceptions, setMessageSource, setPostAuthenticationChecks, setPreAuthenticationChecks, setUserCache, supports
メソッドの詳細
additionalAuthenticationChecks
protected void additionalAuthenticationChecks(UserDetails userDetails, UsernamePasswordAuthenticationToken authentication) throws AuthenticationException
クラスからコピーされた説明:AbstractUserDetailsAuthenticationProviderサブクラスが、特定の認証リクエストに対して返された(またはキャッシュされた)UserDetailsの追加チェックを実行できるようにします。通常、サブクラスは少なくともAuthentication.getCredentials()とUserDetails.getPassword()を比較します。UserDetailsおよび / またはUsernamePasswordAuthenticationTokenの追加のプロパティを比較するためにカスタムロジックが必要な場合、これらもこのメソッドに表示されます。- 次で指定:
- クラス
AbstractUserDetailsAuthenticationProviderのadditionalAuthenticationChecks - パラメーター:
userDetails-AbstractUserDetailsAuthenticationProvider.retrieveUser(String, UsernamePasswordAuthenticationToken)またはUserCacheから取得したものauthentication- 認証が必要な現在のリクエスト- 例外:
AuthenticationException- 資格情報を検証できなかった場合は AuthenticationException (一般的にBadCredentialsException、AuthenticationServiceException)
doAfterPropertiesSet
protected void doAfterPropertiesSet()
- オーバーライド:
- クラス
AbstractUserDetailsAuthenticationProviderのdoAfterPropertiesSet
retrieveUser
protected final UserDetails retrieveUser(java.lang.String username, UsernamePasswordAuthenticationToken authentication) throws AuthenticationException
クラスからコピーされた説明:AbstractUserDetailsAuthenticationProviderサブクラスが実装固有の場所からUserDetailsを実際に取得できるようにします。提示された資格情報が正しくない場合、すぐにAuthenticationExceptionをスローするオプションがあります(これは、ユーザーとしてリソースにバインドする必要がある場合に特に役立ちます。UserDetailsを生成します)。AbstractUserDetailsAuthenticationProviderはデフォルトでUserDetailsをキャッシュするため、キャッシュを実行するためにサブクラスは必要ありません。UserDetailsのキャッシュは、このメソッドでバインディングベースの戦略を採用するサブクラスによって資格情報の正確性が保証されている場合でも、キャッシュに依存する後続のリクエストがまだ資格情報を検証する必要があるため、さらなる複雑さを示します。サブクラスがキャッシュを無効にすることが重要です(UserDetailsがキャッシュされないため、このメソッドがリクエストを認証できる唯一のメソッドであることを確認したい場合)、またはサブクラスがAbstractUserDetailsAuthenticationProvider.additionalAuthenticationChecks(UserDetails, UsernamePasswordAuthenticationToken)を実装してキャッシュされた資格情報を比較することを確認することUserDetailsと後続の認証リクエスト。ほとんどの場合、サブクラスはこのメソッドで資格情報インスペクションを実行せず、代わりに
AbstractUserDetailsAuthenticationProvider.additionalAuthenticationChecks(UserDetails, UsernamePasswordAuthenticationToken)で実行するため、資格情報の検証に関連するコードを 2 つのメソッド間で複製する必要はありません。- 次で指定:
- クラス
AbstractUserDetailsAuthenticationProviderのretrieveUser - パラメーター:
username- 取得するユーザー名authentication- サブクラスがUserDetailsのバインディングベースの検索を実行する必要があるかもしれない認証リクエスト- 戻り値:
- ユーザー情報 (非
null- 代わりに例外がスローされます) - 例外:
AuthenticationException- 資格情報を検証できなかった場合 (通常、BadCredentialsException、AuthenticationServiceExceptionまたはUsernameNotFoundException)
createSuccessAuthentication
protected Authentication createSuccessAuthentication(java.lang.Object principal, Authentication authentication, UserDetails user)
クラスからコピーされた説明:AbstractUserDetailsAuthenticationProvider成功したAuthenticationオブジェクトを作成します。サブクラスがオーバーライドできるように保護されています。
サブクラスは通常、返された
Authenticationオブジェクトにユーザーが提供した元の資格情報(ソルトまたはエンコードされたパスワードではない)を格納します。- オーバーライド:
- クラス
AbstractUserDetailsAuthenticationProviderのcreateSuccessAuthentication - パラメーター:
principal- それは返されたオブジェクトのプリンシパルでなければなりません (AbstractUserDetailsAuthenticationProvider.isForcePrincipalAsString()メソッドによって定義されます)authentication- 検証のためにプロバイダーに提示されたuser- 実装によってロードされた- 戻り値:
- 成功した認証トークン
setPasswordEncoder
public void setPasswordEncoder(PasswordEncoder passwordEncoder)
パスワードのエンコードと検証に使用される PasswordEncoder インスタンスを設定します。設定されていない場合、PasswordEncoderFactories.createDelegatingPasswordEncoder()を使用してパスワードが比較されます- パラメーター:
passwordEncoder-PasswordEncoder型のいずれかのインスタンスでなければなりません。
getPasswordEncoder
protected PasswordEncoder getPasswordEncoder()
setUserDetailsService
public void setUserDetailsService(UserDetailsService userDetailsService)
getUserDetailsService
protected UserDetailsService getUserDetailsService()
setUserDetailsPasswordService
public void setUserDetailsPasswordService(UserDetailsPasswordService userDetailsPasswordService)