class OAuth::Signature::RSA::SHA1
Public Instance Methods
==(other)
click to toggle source
# File lib/oauth/signature/rsa/sha1.rb 11 def ==(other) 12 decoded = Base64.decode64(other.is_a?(Array) ? other.first : other) 13 public_key.verify(OpenSSL::Digest.new("SHA1"), decoded, signature_base_string) 14 end
body_hash()
click to toggle source
# File lib/oauth/signature/rsa/sha1.rb 27 def body_hash 28 # Use SHA1 body hash with compatibility across OpenSSL versions 29 data = request.body || "" 30 begin 31 digest_bytes = OpenSSL::Digest.digest("SHA1", data) 32 rescue StandardError 33 digest_bytes = ::Digest::SHA1.digest(data) 34 end 35 Base64.encode64(digest_bytes).chomp.delete("\n") 36 end
public_key()
click to toggle source
# File lib/oauth/signature/rsa/sha1.rb 16 def public_key 17 case consumer_secret 18 when String 19 decode_public_key 20 when OpenSSL::X509::Certificate 21 consumer_secret.public_key 22 else 23 consumer_secret 24 end 25 end
Private Instance Methods
decode_public_key()
click to toggle source
# File lib/oauth/signature/rsa/sha1.rb 40 def decode_public_key 41 case consumer_secret 42 when /-----BEGIN CERTIFICATE-----/ 43 OpenSSL::X509::Certificate.new(consumer_secret).public_key 44 else 45 OpenSSL::PKey::RSA.new(consumer_secret) 46 end 47 end
digest()
click to toggle source
# File lib/oauth/signature/rsa/sha1.rb 49 def digest 50 private_key = OpenSSL::PKey::RSA.new( 51 if options[:private_key_file] 52 File.read(options[:private_key_file]) 53 elsif options[:private_key] 54 options[:private_key] 55 else 56 consumer_secret 57 end, 58 ) 59 60 private_key.sign(OpenSSL::Digest.new("SHA1"), signature_base_string) 61 end