Class OAuth::Signature::Base
In: lib/oauth/signature/base.rb
Parent: Object

Methods

Included Modules

OAuth::Helper

Attributes

consumer_secret  [R] 
options  [RW] 
request  [R] 
token_secret  [R] 

Public Class methods

[Source]

# File lib/oauth/signature/base.rb, line 17
    def self.digest_class(digest_class = nil)
      return @digest_class if digest_class.nil?
      @digest_class = digest_class
    end

[Source]

# File lib/oauth/signature/base.rb, line 13
    def self.implements(signature_method)
      OAuth::Signature.available_methods[signature_method] = self
    end

[Source]

# File lib/oauth/signature/base.rb, line 22
    def initialize(request, options = {}, &block)
      raise TypeError unless request.kind_of?(OAuth::RequestProxy::Base)
      @request = request
      @options = options

      ## consumer secret was determined beforehand

      @consumer_secret = options[:consumer].secret if options[:consumer]

      # presence of :consumer_secret option will override any Consumer that's provided
      @consumer_secret = options[:consumer_secret] if options[:consumer_secret]

      ## token secret was determined beforehand

      @token_secret = options[:token].secret if options[:token]

      # presence of :token_secret option will override any Token that's provided
      @token_secret = options[:token_secret] if options[:token_secret]


      # override secrets based on the values returned from the block (if any)
      if block_given?
        # consumer secret and token secret need to be looked up based on pieces of the request
        secrets = yield block.arity == 1 ? request : [token, consumer_key, nonce, request.timestamp]
        if secrets.is_a?(Array) && secrets.size == 2
          @token_secret = secrets[0]
          @consumer_secret = secrets[1]
        end
      end
    end

Public Instance methods

[Source]

# File lib/oauth/signature/base.rb, line 57
    def ==(cmp_signature)
      Base64.decode64(signature) == Base64.decode64(cmp_signature)
    end

[Source]

# File lib/oauth/signature/base.rb, line 53
    def signature
      Base64.encode64(digest).chomp.gsub(/\n/,'')
    end

[Source]

# File lib/oauth/signature/base.rb, line 65
    def signature_base_string
      request.signature_base_string
    end

[Source]

# File lib/oauth/signature/base.rb, line 61
    def verify
      self == self.request.signature
    end

[Validate]