Class: Rack::OAuth2::AccessToken::MAC::Verifier

Inherits:
Object
  • Object
show all
Includes:
AttrOptional, AttrRequired
Defined in:
lib/rack/oauth2/access_token/mac/verifier.rb

Direct Known Subclasses

Sha256HexVerifier, Signature

Defined Under Namespace

Classes: VerificationFailed

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Verifier



11
12
13
14
15
16
17
18
# File 'lib/rack/oauth2/access_token/mac/verifier.rb', line 11

def initialize(attributes = {})
  (required_attributes + optional_attributes).each do |key|
    self.send :#{key}=", attributes[key]
  end
  attr_missing!
rescue AttrRequired::AttrMissing => e
  raise VerificationFailed.new("#{self.class.name.demodulize} Invalid: #{e.message}")
end

Instance Method Details

#verify!(expected) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/rack/oauth2/access_token/mac/verifier.rb', line 20

def verify!(expected)
  if expected == self.calculate
    :verified
  else
    raise VerificationFailed.new("#{self.class.name.demodulize} Invalid")
  end
end