class GenerateHttpSignature

SignatureHeader return SignatureHeader Value that contains following paramters

Public Instance Methods

getToken(merchantconfig_obj, gmtdatetime, log_obj) click to toggle source

Generates Signature based on the requestType

# File lib/AuthenticationSDK/authentication/http/HttpSignatureHeader.rb, line 19
def getToken(merchantconfig_obj, gmtdatetime, log_obj)
  request_type = merchantconfig_obj.requestType.upcase
  signatureHeaderValue =''
  signatureHeaderValue << Constants::KEY_ID + merchantconfig_obj.merchantKeyId + "\""
  # Algorithm should be always HmacSHA256 for http signature
  signatureHeaderValue << ', ' + Constants::ALGORITHM + Constants::SIGNATURE_ALGORITHM + "\""
  # Headers - list is choosen based on HTTP method
  signatureheader=getsignatureHeader(request_type)
  signatureHeaderValue << ', ' + Constants::HEADERS_PARAM + signatureheader + "\""
  # Get Value for parameter 'Signature' to be passed to Signature Header
  signature_value = SignatureParameter.new.generateSignatureParameter(merchantconfig_obj, gmtdatetime, log_obj)
  signatureHeaderValue << ', ' + Constants::SIGNATURE_PARAM + signature_value + "\""
  return signatureHeaderValue
rescue StandardError => err
  ApiException.new.apiexception(err,log_obj)
  exit!
end
getsignatureHeader(request_type) click to toggle source
# File lib/AuthenticationSDK/authentication/http/HttpSignatureHeader.rb, line 36
def getsignatureHeader(request_type)
  headers = ''
  if request_type == Constants::POST_REQUEST_TYPE
    headers = 'host date (request-target) digest ' + Constants::V_C_MERCHANT_ID
  elsif request_type == Constants::GET_REQUEST_TYPE || request_type == Constants::DELETE_REQUEST_TYPE
    headers = 'host date (request-target)' + ' ' + Constants::V_C_MERCHANT_ID
  elsif request_type == Constants::PUT_REQUEST_TYPE
    headers = 'host date (request-target) digest ' + Constants::V_C_MERCHANT_ID
  elsif request_type == Constants::PATCH_REQUEST_TYPE
    headers = 'host date (request-target) digest ' + Constants::V_C_MERCHANT_ID
  else
    raise StandardError.new(Constants::ERROR_PREFIX + Constants::INVALID_REQUEST_TYPE_METHOD)
  end
  return headers
end