クラス JwtIssuerAuthenticationManagerResolver
- java.lang.Object
-
- org.springframework.security.oauth2.server.resource.authentication.JwtIssuerAuthenticationManagerResolver
- 実装されたすべてのインターフェース:
AuthenticationManagerResolver<javax.servlet.http.HttpServletRequest>
public final class JwtIssuerAuthenticationManagerResolver extends java.lang.Object implements AuthenticationManagerResolver<javax.servlet.http.HttpServletRequest>
署名された JWT(JWS)の発行者に基づいて JWT ベースのAuthenticationManager
を解決するAuthenticationManagerResolver
の実装。使用するには、このクラスは `iss` クレームが信頼できるかどうかを判別できる必要があります。誰でも認証サーバーを立ち上げて、リソースサーバーに有効なトークンを発行できることを思い出してください。これを実現する最も簡単な方法は、コンストラクターで信頼できる発行者のリストを提供することです。このクラスは、HttpServletRequest
のベアラートークンにある `iss` クレームから発行者を派生させます。- 導入:
- 5.3
コンストラクターのサマリー
コンストラクター コンストラクター 説明 JwtIssuerAuthenticationManagerResolver(java.lang.String... trustedIssuers)
提供されたパラメーターを使用してJwtIssuerAuthenticationManagerResolver
を作成しますJwtIssuerAuthenticationManagerResolver(java.util.Collection<java.lang.String> trustedIssuers)
提供されたパラメーターを使用してJwtIssuerAuthenticationManagerResolver
を作成しますJwtIssuerAuthenticationManagerResolver(AuthenticationManagerResolver<java.lang.String> issuerAuthenticationManagerResolver)
提供されたパラメーターを使用してJwtIssuerAuthenticationManagerResolver
を作成するこのコンストラクターで提供されたAuthenticationManagerResolver
は、発行者が信頼できることを確認する必要があることに注意してください。
メソッドのサマリー
すべてのメソッド インスタンスメソッド 具象メソッド 修飾子と型 メソッド 説明 AuthenticationManager
resolve(javax.servlet.http.HttpServletRequest request)
リクエストのベアラートークンで見つかった `iss` クレームに基づいてAuthenticationManager
を返します
コンストラクターの詳細
JwtIssuerAuthenticationManagerResolver
public JwtIssuerAuthenticationManagerResolver(java.lang.String... trustedIssuers)
提供されたパラメーターを使用してJwtIssuerAuthenticationManagerResolver
を作成します- パラメーター:
trustedIssuers
- 信頼できる発行者のリスト
JwtIssuerAuthenticationManagerResolver
public JwtIssuerAuthenticationManagerResolver(java.util.Collection<java.lang.String> trustedIssuers)
提供されたパラメーターを使用してJwtIssuerAuthenticationManagerResolver
を作成します- パラメーター:
trustedIssuers
- 信頼できる発行者のリスト
JwtIssuerAuthenticationManagerResolver
public JwtIssuerAuthenticationManagerResolver(AuthenticationManagerResolver<java.lang.String> issuerAuthenticationManagerResolver)
提供されたパラメーターを使用してJwtIssuerAuthenticationManagerResolver
を構築するこのコンストラクターで提供されたAuthenticationManagerResolver
は、発行者が信頼されていることを確認する必要があることに注意してください。これは、許可リストを介して実行する必要があります。これを実現する 1 つの方法は、キーが既知の発行者であるMap
を使用することです。Map<String, AuthenticationManager> authenticationManagers = new HashMap<>(); authenticationManagers.put("https://issuerOne.example.org", managerOne); authenticationManagers.put("https://issuerTwo.example.org", managerTwo); JwtAuthenticationManagerResolver resolver = new JwtAuthenticationManagerResolver (authenticationManagers::get);
Map
のキーは、許可された発行者です。- パラメーター:
issuerAuthenticationManagerResolver
- 発行者がAuthenticationManager
を解決するための戦略
メソッドの詳細
resolve
public AuthenticationManager resolve(javax.servlet.http.HttpServletRequest request)
リクエストのベアラートークンで見つかった `iss` クレームに基づいてAuthenticationManager
を返します- 次で指定:
- インターフェース
AuthenticationManagerResolver<javax.servlet.http.HttpServletRequest>
のresolve
- 戻り値:
- 使用する
AuthenticationManager
- 例外:
OAuth2AuthenticationException
- ベアラートークンの形式が正しくない場合、またはAuthenticationManager
を発行者から取得できない場合