Class: Ebay::NotificationApi::Verifier::MessageValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/ebay/notification_api/verifier/message_validator.rb

Defined Under Namespace

Classes: WrongAlgorithm

Instance Method Summary collapse

Constructor Details

#initialize(message, signature_header) ⇒ MessageValidator

Returns a new instance of MessageValidator.

[View source]

9
10
11
12
# File 'lib/ebay/notification_api/verifier/message_validator.rb', line 9

def initialize(message, signature_header)
  @signature_header = signature_header
  @message = message
end

Instance Method Details

#valid_message?Boolean

Returns:

  • (Boolean)
[View source]

14
15
16
17
18
# File 'lib/ebay/notification_api/verifier/message_validator.rb', line 14

def valid_message?
  verifier = OpenSSL::PKey::EC.new(format_key(public_key_response["key"]))
  signature_base64 = Base64.decode64(signature_json["signature"])
  verifier.verify(OpenSSL::Digest.new(DIGEST), signature_base64, @message.to_json)
end