Class: OAuth::Signature::RSA::SHA1

Inherits:
Base show all
Defined in:
lib/oauth/signature/rsa/sha1.rb

Instance Attribute Summary

Attributes inherited from Base

#consumer_secret, #options, #request, #token_secret

Instance Method Summary collapse

Methods inherited from Base

implements, #initialize, #signature, #signature_base_string, #verify

Methods included from Helper

#escape, #generate_key, #generate_timestamp, #normalize, #normalize_nested_query, #parse_header, #stringify_keys, #unescape

Constructor Details

This class inherits a constructor from OAuth::Signature::Base

Instance Method Details

#==(cmp_signature) ⇒ Object



7
8
9
# File 'lib/oauth/signature/rsa/sha1.rb', line 7

def ==(cmp_signature)
  public_key.verify(OpenSSL::Digest::SHA1.new, Base64.decode64(cmp_signature.is_a?(Array) ? cmp_signature.first : cmp_signature), signature_base_string)
end

#body_hashObject



21
22
23
# File 'lib/oauth/signature/rsa/sha1.rb', line 21

def body_hash
  Base64.encode64(OpenSSL::Digest::SHA1.digest(request.body || '')).chomp.gsub(/\n/,'')
end

#public_keyObject



11
12
13
14
15
16
17
18
19
# File 'lib/oauth/signature/rsa/sha1.rb', line 11

def public_key
  if consumer_secret.is_a?(String)
    decode_public_key
  elsif consumer_secret.is_a?(OpenSSL::X509::Certificate)
    consumer_secret.public_key
  else
    consumer_secret
  end
end