Class: Cybersourcery::SignatureChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/cybersourcery/signature_checker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ SignatureChecker

Returns a new instance of SignatureChecker.



5
6
7
8
9
# File 'lib/cybersourcery/signature_checker.rb', line 5

def initialize(args = {})
  @profile = args[:profile]
  @params = args[:params]
  post_initialize(args)
end

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



3
4
5
# File 'lib/cybersourcery/signature_checker.rb', line 3

def params
  @params
end

#profileObject (readonly)

Returns the value of attribute profile.



3
4
5
# File 'lib/cybersourcery/signature_checker.rb', line 3

def profile
  @profile
end

Instance Method Details

#post_initialize(args) ⇒ Object

subclasses can override



12
13
14
# File 'lib/cybersourcery/signature_checker.rb', line 12

def post_initialize(args)
  nil
end

#runObject



16
17
18
# File 'lib/cybersourcery/signature_checker.rb', line 16

def run
  signature == Cybersourcery::CybersourceSigner::Signer.signature(signature_message, @profile.secret_key)
end

#run!Object



20
21
22
# File 'lib/cybersourcery/signature_checker.rb', line 20

def run!
  raise Cybersourcery::CybersourceryError, 'Detected possible data tampering. Signatures do not match.' unless run
end