Class: OAuth::Signature::Base

### Home Classes Methods

### In Files

- lib/oauth/signature/base.rb

### Parent

Object

### Methods

- ::digest_class
- ::digest_klass
- ::hash_class
- ::implements
- ::new
- #==
- #body_hash
- #signature
- #signature_base_string
- #verify

### Included Modules

- OAuth::Helper

### Files

- LICENSE
- README.rdoc
- TODO

### Class/Module Index

Quicksearch

- OAuth
- OAuth::AccessToken
- OAuth::CLI
- OAuth::Client
- OAuth::Client::Helper
- OAuth::Consumer
- OAuth::ConsumerToken
- OAuth::Error
- OAuth::Helper
- OAuth::OAuthTestHelper
- OAuth::Problem
- OAuth::RequestProxy
- OAuth::RequestProxy::ActionControllerRequest
- OAuth::RequestProxy::Base
- OAuth::RequestProxy::Curl
- OAuth::RequestProxy::Curl::Easy
- OAuth::RequestProxy::EventMachine
- OAuth::RequestProxy::EventMachine::HttpRequest
- OAuth::RequestProxy::JabberRequest
- OAuth::RequestProxy::MockRequest
- OAuth::RequestProxy::Net
- OAuth::RequestProxy::Net::HTTP
- OAuth::RequestProxy::Net::HTTP::HTTPRequest
- OAuth::RequestProxy::RackRequest
- OAuth::RequestProxy::Typhoeus
- OAuth::RequestProxy::Typhoeus::Request
- OAuth::RequestProxy::UnknownRequestType
- OAuth::RequestToken
- OAuth::Server
- OAuth::ServerToken
- OAuth::Signature
- OAuth::Signature::Base
- OAuth::Signature::HMAC
- OAuth::Signature::HMAC::Base
- OAuth::Signature::HMAC::MD5
- OAuth::Signature::HMAC::RMD160
- OAuth::Signature::HMAC::SHA1
- OAuth::Signature::HMAC::SHA2
- OAuth::Signature::MD5
- OAuth::Signature::PLAINTEXT
- OAuth::Signature::RSA
- OAuth::Signature::RSA::SHA1
- OAuth::Signature::SHA1
- OAuth::Signature::UnknownSignatureMethod
- OAuth::Token
- OAuth::Unauthorized
- ActionController
- ActionController::Base
- ActionController::TestRequest
- Digest
- Digest::HMAC
- EventMachine
- EventMachine::HttpClient
- Net
- Net::HTTPGenericRequest
- Object
- String

No matching classes.

# OAuth::Signature::Base

### Attributes

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

### Public Class Methods

digest_class(digest_class = nil) click to toggle source

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

digest_klass(digest_klass = nil) click to toggle source

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

hash_class(hash_class = nil) click to toggle source

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

implements(signature_method = nil) click to toggle source

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

new(request, options = {}, &block) click to toggle source

    # File lib/oauth/signature/base.rb, line 34
    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

==(cmp_signature) click to toggle source

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

body_hash() click to toggle source

    # File lib/oauth/signature/base.rb, line 80
    def body_hash
      if self.class.hash_class
        Base64.encode64(self.class.hash_class.digest(request.body || '')).chomp.gsub(/\n/,'')
      else
        nil # no body hash algorithm defined, so don't generate one
      end
    end

signature() click to toggle source

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

signature_base_string() click to toggle source

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

verify() click to toggle source

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

[Validate]

Generated with the Darkfish Rdoc Generator 2.