Class V1HmacAuthenticator

java.lang.Object
com.onlinepayments.authentication.V1HmacAuthenticator
All Implemented Interfaces:
Authenticator

public class V1HmacAuthenticator extends Object implements Authenticator
V1HMAC Authenticator implementation.
  • Constructor Details

    • V1HmacAuthenticator

      public V1HmacAuthenticator(CommunicatorConfiguration communicatorConfiguration)
      Constructs a new V1HmacAuthenticator instance using the provided CommunicatorConfiguration.
      Parameters:
      communicatorConfiguration - The configuration object containing the API key, and API key secret, connect timeout, and socket timeout. None of these can be null or empty, and the timeout values must be positive.
      Throws:
      IllegalArgumentException - If the API key, and API key secret from the communicator configuration is null or empty, or if the connect timeout or socket timeout is non-positive.
    • V1HmacAuthenticator

      public V1HmacAuthenticator(String apiKeyId, String secretApiKey)
      Parameters:
      apiKeyId - An identifier for the secret API key. This identifier is visible in the HTTP request and is also used to identify the correct account.
      secretApiKey - A shared secret. An apiKeyId and secretApiKey always go hand-in-hand, the difference is that secretApiKey is never visible in the HTTP request. This secret is used as input for the HMAC algorithm.
    • V1HmacAuthenticator

      public V1HmacAuthenticator(String apiKeyId, String secretApiKey, AuthorizationType authorizationType)
      Parameters:
      apiKeyId - An identifier for the secret API key. This identifier is visible in the HTTP request and is also used to identify the correct account.
      secretApiKey - A shared secret. An apiKeyId and secretApiKey always go hand-in-hand, the difference is that secretApiKey is never visible in the HTTP request. This secret is used as input for the HMAC algorithm.
      authorizationType - Based on this value both the Online Payments platform and the merchant know which security implementation is used. A version number is used for backward compatibility in the future.
  • Method Details

    • getAuthorization

      public String getAuthorization(String httpMethod, URI resourceUri, List<RequestHeader> httpHeaders)
      Description copied from interface: Authenticator
      Returns a value that can be used for the "Authorization" header.
      Specified by:
      getAuthorization in interface Authenticator
      Parameters:
      httpMethod - The HTTP method.
      resourceUri - The URI of the resource.
      httpHeaders - A list of RequestHeaders. This list may not be modified and may not contain headers with the same name.