Class: SignatureParameter
- Inherits:
-
Object
- Object
- SignatureParameter
- Defined in:
- lib/AuthenticationSDK/authentication/http/GetSignatureParameter.rb
Overview
This ID can be found on EBC portal*/
Instance Method Summary collapse
- #generateSignatureParameter(merchantconfig_obj, gmtdatetime) ⇒ Object
-
#gettargetUrlForGetDelete(request_type, merchantconfig_obj) ⇒ Object
puts ‘Check log for more details.’ exit!.
- #gettargetUrlForPutPost(request_type, merchantconfig_obj) ⇒ Object
Instance Method Details
#generateSignatureParameter(merchantconfig_obj, gmtdatetime) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/AuthenticationSDK/authentication/http/GetSignatureParameter.rb', line 18 def generateSignatureParameter(merchantconfig_obj, gmtdatetime) @log_obj = Log.new merchantconfig_obj.log_config, "GetSignatureParameter" request_type = merchantconfig_obj.requestType.upcase merchantSecretKey = merchantconfig_obj.merchantSecretKey signatureString = Constants::HOST + ': ' + merchantconfig_obj.requestHost signatureString << "\n"+ Constants::DATE + ': ' + gmtdatetime signatureString << "\n(request-target): " if request_type == Constants::GET_REQUEST_TYPE || request_type == Constants::DELETE_REQUEST_TYPE targetUrl=gettargetUrlForGetDelete(request_type,merchantconfig_obj) signatureString << targetUrl + "\n" elsif request_type == Constants::POST_REQUEST_TYPE || request_type == Constants::PUT_REQUEST_TYPE || request_type == Constants::PATCH_REQUEST_TYPE targetUrl=gettargetUrlForPutPost(request_type,merchantconfig_obj) signatureString << targetUrl + "\n" payload = merchantconfig_obj.requestJsonData digest = DigestGeneration.new.generateDigest(payload) digest_payload = Constants::SHA256 + digest signatureString << Constants::DIGEST + ': ' + digest_payload + "\n" end if merchantconfig_obj.useMetaKey signatureString << Constants::V_C_MERCHANT_ID + ': ' + merchantconfig_obj.portfolioID else signatureString << Constants::V_C_MERCHANT_ID + ': ' + merchantconfig_obj.merchantId end encodedSignatureString = signatureString.force_encoding(Encoding::UTF_8) decodedKey = Base64.decode64(merchantSecretKey) base64EncodedSignature = Base64.strict_encode64(OpenSSL::HMAC.digest('sha256', decodedKey, encodedSignatureString)) return base64EncodedSignature rescue StandardError => err @log_obj.logger.error(err.) @log_obj.logger.error(err.backtrace) raise err # puts 'Check log for more details.' # exit! end |
#gettargetUrlForGetDelete(request_type, merchantconfig_obj) ⇒ Object
puts ‘Check log for more details.’ exit!
55 56 57 58 59 60 61 62 63 |
# File 'lib/AuthenticationSDK/authentication/http/GetSignatureParameter.rb', line 55 def gettargetUrlForGetDelete(request_type, merchantconfig_obj) targetUrlForGetDelete = '' if request_type == Constants::DELETE_REQUEST_TYPE targetUrlForGetDelete = Constants::DELETE_REQUEST_TYPE_LOWER + ' ' + merchantconfig_obj.requestTarget elsif request_type == Constants::GET_REQUEST_TYPE targetUrlForGetDelete = Constants::GET_REQUEST_TYPE_LOWER + ' ' + merchantconfig_obj.requestTarget end return targetUrlForGetDelete end |
#gettargetUrlForPutPost(request_type, merchantconfig_obj) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/AuthenticationSDK/authentication/http/GetSignatureParameter.rb', line 64 def gettargetUrlForPutPost(request_type, merchantconfig_obj) targetUrlForPutPost = '' if request_type == Constants::POST_REQUEST_TYPE targetUrlForPutPost = Constants::POST_REQUEST_TYPE_LOWER + ' ' + merchantconfig_obj.requestTarget elsif request_type == Constants::PUT_REQUEST_TYPE targetUrlForPutPost = Constants::PUT_REQUEST_TYPE_LOWER + ' ' + merchantconfig_obj.requestTarget elsif request_type == Constants::PATCH_REQUEST_TYPE targetUrlForPutPost = Constants::PATCH_REQUEST_TYPE_LOWER + ' ' + merchantconfig_obj.requestTarget end return targetUrlForPutPost end |