Class ClientAuthorization

java.lang.Object
com.linecorp.armeria.common.auth.oauth2.ClientAuthorization

@UnstableApi
public final class ClientAuthorization
extends Object
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 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

      public static ClientAuthorization ofBasicAuthorization​(Supplier<String> authorizationSupplier)
      Provides client authorization for the OAuth 2.0 requests based on encoded authorization token and Basic 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 and Basic authorization type, as per [RFC6749], Section 2.3.
      Parameters:
      credentialsSupplier - A supplier of client credentials.
    • asHeaderValue

      public String asHeaderValue()
      Fetches client authorization token or client credentials from the supplier and composes client Authorization header value, as per [RFC6749], Section 2.3:
      
       Authorization: Basic czZCaGRSa3F0Mzo3RmpmcDBaQnIxS3REUmJuZlZkbUl3
       
      .
      Returns:
      encoded client Authorization header value.
    • addAsBodyParameters

      public void addAsBodyParameters​(QueryParamsBuilder formBuilder)
      Fetches client credentials from the supplier and composes required body parameters, as per [RFC6749], Section 2.3:
      
       client_id=s6BhdRkqt3&client_secret=7Fjfp0ZBr1KtDRbnfVdmIw
       
      . The client MAY omit the client_secret parameter if the client secret is an empty string.
    • asBodyParameters

      public QueryParams asBodyParameters()
      Fetches client credentials from the supplier and composes required body parameters, as per [RFC6749], Section 2.3:
      
       client_id=s6BhdRkqt3&client_secret=7Fjfp0ZBr1KtDRbnfVdmIw
       
      . The client MAY omit the client_secret parameter if the client secret is an empty string.
      Returns:
      encoded client credentials request body parameters as QueryParams.
    • toString

      public String toString()
      Overrides:
      toString in class Object