Class GrantTypeHandler

java.lang.Object
org.forgerock.secrets.oauth2.GrantTypeHandler
Direct Known Subclasses:
AuthorizationCodeGrantTypeHandler, ClientCredentialsGrantTypeHandler, JwtBearerGrantTypeHandler, RefreshTokenGrantTypeHandler, ResourceOwnerPasswordGrantTypeHandler

public abstract class GrantTypeHandler extends Object
Abstract base class for OAuth 2 grant type handlers for calling the token endpoint. Each handler can add additional parameters to the token request.
  • Constructor Details

    • GrantTypeHandler

      protected GrantTypeHandler(String grantType, String clientId, Collection<String> scope)
      Initialises the grant type handler with the given grant type name and client id.
      Parameters:
      grantType - the grant type name such as "client_credentials".
      clientId - the client id. May be null.
      scope - the scope to add to the request. May not be null. Represents the scope of the authorization grant being requested, as per RFC 6749.
    • GrantTypeHandler

      protected GrantTypeHandler(String grantType, String clientId)
      Initialises the grant type handler with the given grant type name and client id.
      Parameters:
      grantType - the grant type name such as "client_credentials".
      clientId - the client id. May be null.
  • Method Details

    • handle

      protected Promise<Form,NoSuchSecretException> handle(Request tokenEndpointRequest, Form form)
      Handles the request by adding appropriate parameters to the OAuth 2.0 token endpoint request.
      Parameters:
      tokenEndpointRequest - the original token endpoint request.
      form - the POST body to add parameters to.
      Returns:
      a promise for the token endpoint request with parameters appropriate for this grant type.
    • getGrantType

      public String getGrantType()
      The name of the grant type implemented by this handler.
      Returns:
      the name of the grant type.
    • getClientId

      public String getClientId()
      The client id of the client using this grant type.
      Returns:
      the client id.
    • getScope

      protected Collection<String> getScope()
      The requested scopes.
      Returns:
      the scopes.
    • toString

      public String toString()
      Overrides:
      toString in class Object