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