クラス OAuth2LoginAuthenticationProvider
- java.lang.Object
-
- org.springframework.security.oauth2.client.authentication.OAuth2LoginAuthenticationProvider
- 実装されているすべてのインターフェース:
AuthenticationProvider
public class OAuth2LoginAuthenticationProvider extends java.lang.Object implements AuthenticationProvider
OAuth 2.0 認証コード付与フローを活用する OAuth 2.0 ログイン用のAuthenticationProviderの実装。このAuthenticationProviderは、認証サーバーのトークンエンドポイントを使用して認証コードのクレデンシャルを認証し、有効な場合はアクセストークンのクレデンシャルと交換するロールを果たします。また、
OAuth2UserServiceを使用して UserInfo エンドポイントからエンドユーザー(リソース所有者)のユーザー属性を取得し、OAuth2Userの形式でPrincipalを作成します。次に、OAuth2UserがOAuth2LoginAuthenticationTokenに関連付けられ、認証が完了します。
コンストラクターの概要
コンストラクター コンストラクター 説明 OAuth2LoginAuthenticationProvider(OAuth2AccessTokenResponseClient<OAuth2AuthorizationCodeGrantRequest> accessTokenResponseClient, OAuth2UserService<OAuth2UserRequest,OAuth2User> userService)指定されたパラメーターを使用してOAuth2LoginAuthenticationProviderを構築します。
メソッドのサマリー
すべてのメソッド インスタンスメソッド 具象メソッド 修飾子と型 メソッド 説明 Authenticationauthenticate(Authentication authentication)AuthenticationManager.authenticate(Authentication)と同じ契約で認証を実行します。voidsetAuthoritiesMapper(GrantedAuthoritiesMapper authoritiesMapper)OAuth2AuthenticatedPrincipal.getAuthorities()をOAuth2LoginAuthenticationTokenに関連付けられる新しい権限のセットにマッピングするために使用されるGrantedAuthoritiesMapperを設定します。booleansupports(java.lang.Class<?> authentication)このAuthenticationProviderが指定されたAuthenticationオブジェクトをサポートする場合、trueを返します。
コンストラクターの詳細
OAuth2LoginAuthenticationProvider
public OAuth2LoginAuthenticationProvider(OAuth2AccessTokenResponseClient<OAuth2AuthorizationCodeGrantRequest> accessTokenResponseClient, OAuth2UserService<OAuth2UserRequest,OAuth2User> userService)
指定されたパラメーターを使用してOAuth2LoginAuthenticationProviderを構築します。- パラメーター:
accessTokenResponseClient- トークンエンドポイントからアクセストークンクレデンシャルをリクエストするために使用されるクライアントuserService- UserInfo エンドポイントからエンドユーザーのユーザー属性を取得するために使用されるサービス
メソッドの詳細
authenticate
public Authentication authenticate(Authentication authentication) throws AuthenticationException
インターフェースからコピーされた説明:AuthenticationProviderAuthenticationManager.authenticate(Authentication)と同じ契約で認証を実行します。- 次で指定:
- インターフェース
AuthenticationProviderのauthenticate - パラメーター:
authentication- 認証リクエストオブジェクト。- 戻り値:
- 資格情報を含む完全に認証されたオブジェクト。
AuthenticationProviderが、渡されたAuthenticationオブジェクトの認証をサポートできない場合、nullを返すことがあります。そのような場合、提示されたAuthenticationクラスをサポートする次のAuthenticationProviderが試行されます。 - 例外:
AuthenticationException- 認証が失敗した場合。
setAuthoritiesMapper
public final void setAuthoritiesMapper(GrantedAuthoritiesMapper authoritiesMapper)
OAuth2AuthenticatedPrincipal.getAuthorities()をOAuth2LoginAuthenticationTokenに関連付けられる新しい権限のセットにマッピングするために使用されるGrantedAuthoritiesMapperを設定します。- パラメーター:
authoritiesMapper- ユーザーの権限のマッピングに使用されるGrantedAuthoritiesMapper
supports
public boolean supports(java.lang.Class<?> authentication)
インターフェースからコピーされた説明:AuthenticationProviderこのAuthenticationProviderが指定されたAuthenticationオブジェクトをサポートする場合、trueを返します。trueを返すことは、AuthenticationProviderがAuthenticationクラスの提示されたインスタンスを認証できることを保証しません。それは、それがより詳細な評価をサポートできることを示しています。AuthenticationProviderは、AuthenticationProvider.authenticate(Authentication)メソッドからnullを返して、別のAuthenticationProviderを試す必要があることを示すことができます。認証を実行できる
AuthenticationProviderの選択は、実行時にProviderManagerで行われます。- 次で指定:
- インターフェース
AuthenticationProviderのsupports - 戻り値:
- 実装が提示された
Authenticationクラスをより厳密に評価できる場合はtrue