Class AbstractEdgeGridRequestSigner<RequestT,MutableRequestT>

java.lang.Object
com.akamai.edgegrid.signer.AbstractEdgeGridRequestSigner<RequestT,MutableRequestT>
Type Parameters:
RequestT - a type of HTTP client specific request.
MutableRequestT - a type of HTTP client request to update.

public abstract class AbstractEdgeGridRequestSigner<RequestT,MutableRequestT> extends Object

This is an abstract base class for implementing EdgeGrid request signing in a library-specific way. There are several HTTP client libraries available for Java, and this class offers a simple mechanism for supporting them.

This class uses a ClientCredentialProvider to select a ClientCredential appropriately for each request. This interface permits sharing a single instance of the class for a variety of API calls. It also offers a more configurable way to retrieve credentials any way the user wants.

Author:
[email protected], [email protected]
  • Constructor Details

  • Method Details

    • getClientCredentialProvider

      public final ClientCredentialProvider getClientCredentialProvider()
      Returns:
      ClientCredentialProvider
    • sign

      public void sign(RequestT request, MutableRequestT requestToUpdate) throws RequestSigningException
      Signs request with appropriate credentials using EdgeGrid signer algorithm and replaces request's host name with the one specified by the credential.
      Parameters:
      request - an HTTP request with data used to sign
      requestToUpdate - an HTTP request to update with signature
      Throws:
      RequestSigningException - if failed to sign a request
      NoMatchingCredentialException - if acquiring a ClientCredential throws NoMatchingCredentialException or returns null
    • requestUri

      protected abstract URI requestUri(RequestT request)
      Returns Request-URI of an original request.
      Parameters:
      request - an HTTP client-specific request
      Returns:
      a URI of request
    • map

      protected abstract Request map(RequestT request)
      Maps HTTP client-specific request to client-agnostic model of this request.
      Parameters:
      request - an HTTP client-specific request
      Returns:
      a Request representation of request
      Throws:
      IllegalArgumentException - if duplicate header definitions are found
    • setAuthorization

      protected abstract void setAuthorization(MutableRequestT request, String signature)
      Updates a given HTTP request by adding Authorization header with a value containing request signature.
      Parameters:
      request - HTTP request to update
      signature - HTTP request signature
    • setHost

      protected abstract void setHost(MutableRequestT request, String host, URI uri)
      Updates a given HTTP request by replacing the request hostname with host instead. Usually, it means updating Host header and Request-URI.
      Parameters:
      request - HTTP request to update
      host - an OPEN API hostname
      uri - request URI with OPEN API hostname