クラス DaoAuthenticationProvider
- 実装されているすべてのインターフェース:
org.springframework.beans.factory.Aware、org.springframework.beans.factory.InitializingBean、org.springframework.context.MessageSourceAware、AuthenticationProvider
UserDetailsService からユーザーの詳細を取得する AuthenticationProvider 実装。フィールドのサマリー
クラス org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider から継承されたフィールド
hideUserNotFoundExceptions, logger, messagesコンストラクターの概要
コンストラクターコンストラクター説明使用すべきではありません。DaoAuthenticationProvider(UserDetailsService userDetailsService) DaoAuthenticationProvider(PasswordEncoder passwordEncoder) 使用すべきではありません。コンストラクターにUserDetailsServiceを指定し、その後にsetPasswordEncoder(PasswordEncoder)を指定してください。メソッドのサマリー
修飾子と型メソッド説明protected voidadditionalAuthenticationChecks(UserDetails userDetails, UsernamePasswordAuthenticationToken authentication) サブクラスが、特定の認証リクエストに対して返された(またはキャッシュされた)UserDetailsの追加チェックを実行できるようにします。protected AuthenticationcreateSuccessAuthentication(ObjectSE principal, Authentication authentication, UserDetails user) 成功したAuthenticationオブジェクトを作成します。protected voidprotected PasswordEncoderprotected UserDetailsServiceprotected final UserDetailsretrieveUser(StringSE username, UsernamePasswordAuthenticationToken authentication) サブクラスが実装固有の場所からUserDetailsを実際に取得できるようにします。提示された資格情報が正しくない場合、すぐにAuthenticationExceptionをスローするオプションがあります(これは、ユーザーとしてリソースにバインドする必要がある場合に特に役立ちます。UserDetailsを生成します)。voidsetCompromisedPasswordChecker(CompromisedPasswordChecker compromisedPasswordChecker) 認証を成功させる前に使用するCompromisedPasswordCheckerを設定します。voidsetPasswordEncoder(PasswordEncoder passwordEncoder) パスワードのエンコードと検証に使用される PasswordEncoder インスタンスを設定します。voidsetUserDetailsPasswordService(UserDetailsPasswordService userDetailsPasswordService) voidsetUserDetailsService(UserDetailsService userDetailsService) 使用すべきではありません。コンストラクターにUserDetailsServiceを指定してくださいクラス org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider から継承されたメソッド
afterPropertiesSet, authenticate, getPostAuthenticationChecks, getPreAuthenticationChecks, getUserCache, isForcePrincipalAsString, isHideUserNotFoundExceptions, setAuthoritiesMapper, setForcePrincipalAsString, setHideUserNotFoundExceptions, setMessageSource, setPostAuthenticationChecks, setPreAuthenticationChecks, setUserCache, supports
コンストラクターの詳細
DaoAuthenticationProvider
使用すべきではありません。コンストラクターにUserDetailsServiceを指定してくださいDaoAuthenticationProvider
DaoAuthenticationProvider
使用すべきではありません。コンストラクターにUserDetailsServiceを指定し、その後にsetPasswordEncoder(PasswordEncoder)を指定してください。提供されたPasswordEncoderを使用して新しいインスタンスを作成します- パラメーター:
passwordEncoder- 使用するPasswordEncoder。null にはできません。- 導入:
- 6.0.3
メソッドの詳細
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(StringSE 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(ObjectSE principal, Authentication authentication, UserDetails user) クラスからコピーされた説明:AbstractUserDetailsAuthenticationProvider成功したAuthenticationオブジェクトを作成します。サブクラスがオーバーライドできるように保護されています。
サブクラスは通常、返された
Authenticationオブジェクトにユーザーが提供した元の資格情報(ソルトまたはエンコードされたパスワードではない)を格納します。- オーバーライド:
- クラス
AbstractUserDetailsAuthenticationProviderのcreateSuccessAuthentication - パラメーター:
principal- それは返されたオブジェクトのプリンシパルでなければなりません (AbstractUserDetailsAuthenticationProvider.isForcePrincipalAsString()メソッドによって定義されます)authentication- 検証のためにプロバイダーに提示されたuser- 実装によってロードされた- 戻り値:
- 成功した認証トークン
setPasswordEncoder
パスワードのエンコードと検証に使用される PasswordEncoder インスタンスを設定します。設定されていない場合、PasswordEncoderFactories.createDelegatingPasswordEncoder()を使用してパスワードが比較されます- パラメーター:
passwordEncoder-PasswordEncoder型のいずれかのインスタンスでなければなりません。
getPasswordEncoder
setUserDetailsService
使用すべきではありません。コンストラクターにUserDetailsServiceを指定してください- パラメーター:
userDetailsService-
getUserDetailsService
setUserDetailsPasswordService
setCompromisedPasswordChecker
認証を成功させる前に使用するCompromisedPasswordCheckerを設定します。デフォルトはnullです。- パラメーター:
compromisedPasswordChecker- 使用するCompromisedPasswordChecker- 導入:
- 6.3
UserDetailsServiceを指定してください