class OAuth::Signature::RSA::SHA1

Public Instance Methods

==(other) click to toggle source
# File lib/oauth/signature/rsa/sha1.rb, line 11
def ==(other)
  public_key.verify(OpenSSL::Digest.new("SHA1"),
                    Base64.decode64(other.is_a?(Array) ? other.first : other), signature_base_string)
end
body_hash() click to toggle source
# File lib/oauth/signature/rsa/sha1.rb, line 27
def body_hash
  Base64.encode64(OpenSSL::Digest.digest("SHA1", request.body || "")).chomp.delete("\n")
end
public_key() click to toggle source
# File lib/oauth/signature/rsa/sha1.rb, line 16
def public_key
  case consumer_secret
  when String
    decode_public_key
  when OpenSSL::X509::Certificate
    consumer_secret.public_key
  else
    consumer_secret
  end
end

Private Instance Methods

decode_public_key() click to toggle source
# File lib/oauth/signature/rsa/sha1.rb, line 33
def decode_public_key
  case consumer_secret
  when /-----BEGIN CERTIFICATE-----/
    OpenSSL::X509::Certificate.new(consumer_secret).public_key
  else
    OpenSSL::PKey::RSA.new(consumer_secret)
  end
end
digest() click to toggle source
# File lib/oauth/signature/rsa/sha1.rb, line 42
def digest
  private_key = OpenSSL::PKey::RSA.new(
    if options[:private_key_file]
      File.read(options[:private_key_file])
    elsif options[:private_key]
      options[:private_key]
    else
      consumer_secret
    end
  )

  private_key.sign(OpenSSL::Digest.new("SHA1"), signature_base_string)
end