Class ClientAuthorization
java.lang.Object
com.linecorp.armeria.common.auth.oauth2.ClientAuthorization
Provides client authorization for the OAuth 2.0 requests,
as per [RFC6749], Section 2.3.
For example:
Authorization: Basic czZCaGRSa3F0Mzo3RmpmcDBaQnIxS3REUmJuZlZkbUl3
Fetches authorization source from the designated authorization or credentials supplier, which
might be facilitated by a secure Secret provider. Will fetch the authorization source for each
request. Therefore the designated supplier must cache the value in order to avoid unnecessary
network hops.
The authorization source might either provide complete authorization token or client credentials.-
Method Summary
Modifier and TypeMethodDescriptionvoid
addAsBodyParameters
(QueryParamsBuilder formBuilder) Fetches client credentials from the supplier and composes required body parameters, as per [RFC6749], Section 2.3:Fetches client credentials from the supplier and composes required body parameters, as per [RFC6749], Section 2.3:Fetches client authorization token or client credentials from the supplier and composes clientAuthorization
header value, as per [RFC6749], Section 2.3:static ClientAuthorization
ofAuthorization
(Supplier<String> authorizationSupplier, String authorizationType) Provides client authorization for the OAuth 2.0 requests based on encoded authorization token and authorization type, as per [RFC6749], Section 2.3.static ClientAuthorization
ofBasicAuthorization
(Supplier<String> authorizationSupplier) Provides client authorization for the OAuth 2.0 requests based on encoded authorization token andBasic
authorization type, as per [RFC6749], Section 2.3.static ClientAuthorization
ofCredentials
(Supplier<? extends Map.Entry<String, String>> credentialsSupplier) Provides client authorization for the OAuth 2.0 requests based on client credentials andBasic
authorization type, as per [RFC6749], Section 2.3.static ClientAuthorization
ofCredentials
(Supplier<? extends Map.Entry<String, String>> credentialsSupplier, String authorizationType) Provides client authorization for the OAuth 2.0 requests based on client credentials and authorization type, as per [RFC6749], Section 2.3.toString()
-
Method Details
-
ofAuthorization
public static ClientAuthorization ofAuthorization(Supplier<String> authorizationSupplier, String authorizationType) Provides client authorization for the OAuth 2.0 requests based on encoded authorization token and authorization type, as per [RFC6749], Section 2.3.- Parameters:
authorizationSupplier
- A supplier of encoded client authorization token.authorizationType
- One of the registered HTTP authentication schemes as per HTTP Authentication Scheme Registry.
-
ofBasicAuthorization
Provides client authorization for the OAuth 2.0 requests based on encoded authorization token andBasic
authorization type, as per [RFC6749], Section 2.3.- Parameters:
authorizationSupplier
- A supplier of encoded client authorization token.
-
ofCredentials
public static ClientAuthorization ofCredentials(Supplier<? extends Map.Entry<String, String>> credentialsSupplier, String authorizationType) Provides client authorization for the OAuth 2.0 requests based on client credentials and authorization type, as per [RFC6749], Section 2.3.- Parameters:
credentialsSupplier
- A supplier of client credentials.authorizationType
- One of the registered HTTP authentication schemes as per HTTP Authentication Scheme Registry.
-
ofCredentials
public static ClientAuthorization ofCredentials(Supplier<? extends Map.Entry<String, String>> credentialsSupplier) Provides client authorization for the OAuth 2.0 requests based on client credentials andBasic
authorization type, as per [RFC6749], Section 2.3.- Parameters:
credentialsSupplier
- A supplier of client credentials.
-
asHeaderValue
Fetches client authorization token or client credentials from the supplier and composes clientAuthorization
header value, as per [RFC6749], Section 2.3:
.Authorization: Basic czZCaGRSa3F0Mzo3RmpmcDBaQnIxS3REUmJuZlZkbUl3
- Returns:
- encoded client
Authorization
header value.
-
addAsBodyParameters
Fetches client credentials from the supplier and composes required body parameters, as per [RFC6749], Section 2.3:
. The client MAY omit theclient_id=s6BhdRkqt3&client_secret=7Fjfp0ZBr1KtDRbnfVdmIw
client_secret
parameter if the client secret is an empty string. -
asBodyParameters
Fetches client credentials from the supplier and composes required body parameters, as per [RFC6749], Section 2.3:
. The client MAY omit theclient_id=s6BhdRkqt3&client_secret=7Fjfp0ZBr1KtDRbnfVdmIw
client_secret
parameter if the client secret is an empty string.- Returns:
- encoded client credentials request body parameters as
QueryParams
.
-
toString
-