クラス JwtAuthenticationProvider

java.lang.ObjectSE
org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationProvider
実装されたすべてのインターフェース:
AuthenticationProvider

public final class JwtAuthenticationProvider extends ObjectSE implements AuthenticationProvider
OAuth 2.0 リソースサーバーを保護するための Jwt -encoded ベアラートークンAuthenticationProvider 実装。

この AuthenticationProvider は、Jwt -encoded アクセストークンのデコードと検証を行い、Authentication ステートメントの一部としてそのクレームセットを返します。

スコープは、次のアルゴリズムに従って GrantedAuthority に変換されます。1. 「スコープ」または "scp" 属性 がある場合、StringSE の場合はスペースで分割して返すか、CollectionSE の場合は単に返す 2. 結果の CollectionSE を取得します。StringSE の先頭に "SCOPE_" キーワードを追加し、GrantedAuthority として追加します。

導入:
5.1
関連事項:
  • コンストラクターの詳細

    • JwtAuthenticationProvider

      public JwtAuthenticationProvider(JwtDecoder jwtDecoder)
  • メソッドの詳細

    • authenticate

      public Authentication authenticate(Authentication authentication) throws AuthenticationException
      ベアラートークンをデコードして検証します。
      次で指定:
      インターフェース AuthenticationProviderauthenticate 
      パラメーター:
      authentication - 認証リクエストオブジェクト。
      戻り値:
      成功した認証
      例外:
      AuthenticationException - 何らかの理由で認証に失敗した場合
    • supports

      public boolean supports(ClassSE<?> authentication)
      インターフェースからコピーされた説明: AuthenticationProvider
      この AuthenticationProvider が指定された Authentication オブジェクトをサポートする場合、true を返します。

      true を返しても、AuthenticationProvider が提示された Authentication オブジェクトを認証できることは保証されません。これは単に、より詳細な評価をサポートできることを示しているだけです。AuthenticationProvider は、AuthenticationProvider.authenticate(Authentication) メソッドから null を返して、別の AuthenticationProvider を試す必要があることを示すことができます。

      認証を実行できる AuthenticationProvider の選択は、実行時に ProviderManager で行われます。

      次で指定:
      インターフェース AuthenticationProvidersupports 
      戻り値:
      実装が提示された Authentication クラスをより厳密に評価できる場合は true 
    • setJwtAuthenticationConverter

      public void setJwtAuthenticationConverter(org.springframework.core.convert.converter.Converter<Jwt,? extends AbstractAuthenticationToken> jwtAuthenticationConverter)