Class: OAuth::Signature::Base
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Helper
#escape, #generate_key, #generate_timestamp, #normalize, #normalize_nested_query, #parse_header, #stringify_keys, #unescape
Constructor Details
permalink
#initialize(request, options = {}, &block) ⇒ Base
Returns a new instance of Base.
[View source]
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# 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 = options[:consumer].secret if options[:consumer]
@consumer_secret = options[:consumer_secret] if options[:consumer_secret]
@token_secret = options[:token].secret if options[:token]
@token_secret = options[:token_secret] if options[:token_secret]
if block_given?
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
|
Instance Attribute Details
Returns the value of attribute consumer_secret.
11
12
13
|
# File 'lib/oauth/signature/base.rb', line 11
def consumer_secret
@consumer_secret
end
|
Returns the value of attribute options.
10
11
12
|
# File 'lib/oauth/signature/base.rb', line 10
def options
@options
end
|
Returns the value of attribute request.
11
12
13
|
# File 'lib/oauth/signature/base.rb', line 11
def request
@request
end
|
Returns the value of attribute token_secret.
11
12
13
|
# File 'lib/oauth/signature/base.rb', line 11
def token_secret
@token_secret
end
|
Class Method Details
permalink
.digest_class(digest_class = nil) ⇒ Object
[View source]
19
20
21
22
|
# 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
|
permalink
.digest_klass(digest_klass = nil) ⇒ Object
[View source]
24
25
26
27
|
# 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
|
permalink
.hash_class(hash_class = nil) ⇒ Object
[View source]
29
30
31
32
|
# 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
|
permalink
.implements(signature_method = nil) ⇒ Object
[View source]
13
14
15
16
17
|
# 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
|
Instance Method Details
[View source]
68
69
70
|
# File 'lib/oauth/signature/base.rb', line 68
def ==(cmp_signature)
Base64.decode64(signature) == Base64.decode64(cmp_signature)
end
|
[View source]
80
81
82
83
84
85
86
|
# 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 end
end
|
[View source]
64
65
66
|
# File 'lib/oauth/signature/base.rb', line 64
def signature
Base64.encode64(digest).chomp.gsub(/\n/,'')
end
|
[View source]
76
77
78
|
# File 'lib/oauth/signature/base.rb', line 76
def signature_base_string
request.signature_base_string
end
|
[View source]
72
73
74
|
# File 'lib/oauth/signature/base.rb', line 72
def verify
self == self.request.signature
end
|