oauth 0.4.7 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of oauth might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/README.rdoc +21 -10
- data/bin/oauth +8 -2
- data/lib/oauth.rb +3 -5
- data/lib/oauth/cli.rb +37 -359
- data/lib/oauth/cli/authorize_command.rb +71 -0
- data/lib/oauth/cli/base_command.rb +208 -0
- data/lib/oauth/cli/help_command.rb +22 -0
- data/lib/oauth/cli/query_command.rb +25 -0
- data/lib/oauth/cli/sign_command.rb +81 -0
- data/lib/oauth/cli/version_command.rb +7 -0
- data/lib/oauth/client/action_controller_request.rb +1 -1
- data/lib/oauth/client/em_http.rb +0 -1
- data/lib/oauth/client/helper.rb +4 -0
- data/lib/oauth/client/net_http.rb +9 -8
- data/lib/oauth/consumer.rb +35 -8
- data/lib/oauth/helper.rb +11 -7
- data/lib/oauth/request_proxy/action_controller_request.rb +27 -3
- data/lib/oauth/request_proxy/action_dispatch_request.rb +7 -0
- data/lib/oauth/request_proxy/base.rb +7 -3
- data/lib/oauth/request_proxy/net_http.rb +1 -1
- data/lib/oauth/request_proxy/rest_client_request.rb +62 -0
- data/lib/oauth/request_proxy/typhoeus_request.rb +4 -3
- data/lib/oauth/signature/base.rb +9 -23
- data/lib/oauth/signature/hmac/sha1.rb +12 -4
- data/lib/oauth/signature/plaintext.rb +6 -0
- data/lib/oauth/signature/rsa/sha1.rb +7 -3
- data/lib/oauth/tokens/access_token.rb +12 -0
- data/lib/oauth/tokens/request_token.rb +6 -1
- data/lib/oauth/tokens/token.rb +1 -1
- data/lib/oauth/version.rb +3 -0
- metadata +147 -103
- data/.gemtest +0 -0
- data/Gemfile +0 -16
- data/Gemfile.lock +0 -47
- data/HISTORY +0 -173
- data/Rakefile +0 -37
- data/examples/yql.rb +0 -44
- data/lib/digest/hmac.rb +0 -104
- data/lib/oauth/core_ext.rb +0 -31
- data/lib/oauth/signature/hmac/base.rb +0 -15
- data/lib/oauth/signature/hmac/md5.rb +0 -8
- data/lib/oauth/signature/hmac/rmd160.rb +0 -8
- data/lib/oauth/signature/hmac/sha2.rb +0 -8
- data/lib/oauth/signature/md5.rb +0 -13
- data/lib/oauth/signature/sha1.rb +0 -13
- data/oauth.gemspec +0 -148
- data/tasks/deployment.rake +0 -34
- data/tasks/environment.rake +0 -7
- data/tasks/website.rake +0 -17
- data/test/cases/oauth_case.rb +0 -19
- data/test/cases/spec/1_0-final/test_construct_request_url.rb +0 -62
- data/test/cases/spec/1_0-final/test_normalize_request_parameters.rb +0 -88
- data/test/cases/spec/1_0-final/test_parameter_encodings.rb +0 -86
- data/test/cases/spec/1_0-final/test_signature_base_strings.rb +0 -77
- data/test/integration/consumer_test.rb +0 -307
- data/test/keys/rsa.cert +0 -11
- data/test/keys/rsa.pem +0 -16
- data/test/test_access_token.rb +0 -26
- data/test/test_action_controller_request_proxy.rb +0 -133
- data/test/test_consumer.rb +0 -220
- data/test/test_curb_request_proxy.rb +0 -77
- data/test/test_em_http_client.rb +0 -80
- data/test/test_em_http_request_proxy.rb +0 -115
- data/test/test_helper.rb +0 -28
- data/test/test_hmac_sha1.rb +0 -20
- data/test/test_net_http_client.rb +0 -292
- data/test/test_net_http_request_proxy.rb +0 -72
- data/test/test_oauth_helper.rb +0 -94
- data/test/test_rack_request_proxy.rb +0 -40
- data/test/test_request_token.rb +0 -51
- data/test/test_rsa_sha1.rb +0 -59
- data/test/test_server.rb +0 -40
- data/test/test_signature.rb +0 -22
- data/test/test_signature_base.rb +0 -32
- data/test/test_signature_plain_text.rb +0 -31
- data/test/test_token.rb +0 -14
- data/test/test_typhoeus_request_proxy.rb +0 -80
data/.gemtest
DELETED
File without changes
|
data/Gemfile
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
source :rubygems
|
2
|
-
|
3
|
-
|
4
|
-
group :development do
|
5
|
-
gem 'rake'
|
6
|
-
gem 'jeweler'
|
7
|
-
end
|
8
|
-
|
9
|
-
group :test do
|
10
|
-
gem 'actionpack', '~>2.3.8'
|
11
|
-
gem 'mocha', '>=0.9.8'
|
12
|
-
gem 'typhoeus', '>=0.1.13'
|
13
|
-
gem 'em-http-request', "0.2.11"
|
14
|
-
gem 'curb', ">= 0.6.6.0"
|
15
|
-
gem 'webmock'
|
16
|
-
end
|
data/Gemfile.lock
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: http://rubygems.org/
|
3
|
-
specs:
|
4
|
-
actionpack (2.3.14)
|
5
|
-
activesupport (= 2.3.14)
|
6
|
-
rack (~> 1.1.0)
|
7
|
-
activesupport (2.3.14)
|
8
|
-
addressable (2.2.7)
|
9
|
-
crack (0.3.1)
|
10
|
-
curb (0.8.0)
|
11
|
-
em-http-request (0.2.11)
|
12
|
-
addressable (>= 2.0.0)
|
13
|
-
eventmachine (>= 0.12.9)
|
14
|
-
eventmachine (0.12.10)
|
15
|
-
git (1.2.5)
|
16
|
-
jeweler (1.8.3)
|
17
|
-
bundler (~> 1.0)
|
18
|
-
git (>= 1.2.5)
|
19
|
-
rake
|
20
|
-
rdoc
|
21
|
-
json (1.6.6)
|
22
|
-
metaclass (0.0.1)
|
23
|
-
mime-types (1.18)
|
24
|
-
mocha (0.11.1)
|
25
|
-
metaclass (~> 0.0.1)
|
26
|
-
rack (1.1.3)
|
27
|
-
rake (0.9.2.2)
|
28
|
-
rdoc (3.12)
|
29
|
-
json (~> 1.4)
|
30
|
-
typhoeus (0.3.3)
|
31
|
-
mime-types
|
32
|
-
webmock (1.8.6)
|
33
|
-
addressable (>= 2.2.7)
|
34
|
-
crack (>= 0.1.7)
|
35
|
-
|
36
|
-
PLATFORMS
|
37
|
-
ruby
|
38
|
-
|
39
|
-
DEPENDENCIES
|
40
|
-
actionpack (~> 2.3.8)
|
41
|
-
curb (>= 0.6.6.0)
|
42
|
-
em-http-request (= 0.2.11)
|
43
|
-
jeweler
|
44
|
-
mocha (>= 0.9.8)
|
45
|
-
rake
|
46
|
-
typhoeus (>= 0.1.13)
|
47
|
-
webmock
|
data/HISTORY
DELETED
@@ -1,173 +0,0 @@
|
|
1
|
-
=== 0.4.7 2012-09-03
|
2
|
-
|
3
|
-
* Fix merging paths if the path is not empty
|
4
|
-
* Set a configurable timeout for all requests (Rick Olson)
|
5
|
-
* Fix nested hash params in Consumer#request (Ernie Miller)
|
6
|
-
|
7
|
-
=== 0.4.6 2012-04-21
|
8
|
-
|
9
|
-
* Fixed nested attributes in #normalize (Shaliko Usubov)
|
10
|
-
* Make use the path component of the :site parameter (Jonathon M. Abbott)
|
11
|
-
* Fixed post body's being dropped in 1.9 (Steven Hammond)
|
12
|
-
* Fixed PUT request handling (Anton Panasenko)
|
13
|
-
|
14
|
-
=== 0.4.5 2011-06-25
|
15
|
-
|
16
|
-
* Add explicit require for rsa/sha1 (Juris Galang)
|
17
|
-
* Use webmock to mock all http-requests in tests (Adrian Feldman)
|
18
|
-
* Add gemtest support (Adrian Feldman)
|
19
|
-
* Fix POST Requests with Typhoeus proxy (niedhui)
|
20
|
-
* Mention Typhoeus require in the README (Kim Ahlström)
|
21
|
-
* Fix incorrect hardcoded port (Ian Taylor)
|
22
|
-
* Use Net::HTTPGenericRequest (Jakub Kuźma)
|
23
|
-
|
24
|
-
=== 0.4.4 2010-10-31
|
25
|
-
|
26
|
-
* Fix LoadError rescue in tests: return can't be used in this context (Hans de Graaff)
|
27
|
-
* HTTP headers should be strings. (seancribbs)
|
28
|
-
* ensure consumer uri gets set back to original config even if an error occurs (Brian Finney)
|
29
|
-
* Yahoo uses & to split records in OAuth headers (Brian Finney)
|
30
|
-
* Added support for Rails 3 in client/action_controller_request (Pelle)
|
31
|
-
|
32
|
-
== 0.4.3 2010-09-01
|
33
|
-
|
34
|
-
* Fix for em-http proxy (ichverstehe)
|
35
|
-
|
36
|
-
== 0.4.2 2010-08-13
|
37
|
-
|
38
|
-
* Fixed compatibility with Ruby 1.9.2 (ecavazos)
|
39
|
-
* Fixed the em-http request proxy (Joshua Hull)
|
40
|
-
* Fix for oauth proxy string manipulation (Jakub Suder)
|
41
|
-
* Added Bundler (rc) Gemfile for easier dev/testing
|
42
|
-
|
43
|
-
== 0.4.1 2010-06-16
|
44
|
-
|
45
|
-
* Added support for using OAuth with proxies (Marsh Gardiner)
|
46
|
-
* Rails 3 Compatibility fixes (Pelle Braendgaard)
|
47
|
-
* Fixed load errors on tests for missing (non-required) libraries
|
48
|
-
|
49
|
-
== 0.4.0 2010-04-22
|
50
|
-
|
51
|
-
* Added computation of oauth_body_hash as per OAuth Request Body Hash 1.0
|
52
|
-
Draft 4 (Michael Reinsch)
|
53
|
-
* Added the optional `oauth_session_handle` parameter for the Yahoo implementation (Will Bailey)
|
54
|
-
* Better marshalling implementation (Yoan Blanc)
|
55
|
-
* Added optional block to OAuth::Consumer.get_*_token (Neill Pearman)
|
56
|
-
* Exclude `oauth_callback` with :exclude_callback (Neill Pearman)
|
57
|
-
* Strip extraneous spaces and line breaks from access_token responses
|
58
|
-
(observed in the wild with Yahoo!'s OAuth+OpenID hybrid) (Eric Hartmann)
|
59
|
-
* Stop double-escaping PLAINTEXT signatures (Jimmy Zimmerman)
|
60
|
-
* OAuth::Client::Helper won't override the specified `oauth_version`
|
61
|
-
(Philip Kromer)
|
62
|
-
* Support for Ruby 1.9 (Aaron Quint, Corey Donahoe, et al)
|
63
|
-
* Fixed an encoding / multibyte issue (成田 一生)
|
64
|
-
* Replaced hoe with Jeweler (Aaron Quint)
|
65
|
-
* Support for Typhoeus (Bill Kocik)
|
66
|
-
* Support for em-http (EventMachine) (Darcy Laycock)
|
67
|
-
* Support for curb (André Luis Leal Cardoso Junior)
|
68
|
-
* New website (Aaron Quint)
|
69
|
-
|
70
|
-
== 0.3.6 2009-09-14
|
71
|
-
|
72
|
-
* Added -B CLI option to use the :body authentication scheme (Seth)
|
73
|
-
* Respect `--method` in `authorize` CLI command (Seth)
|
74
|
-
* Support POST and PUT with raw bodies (Yu-Shan Fung et al)
|
75
|
-
* Test clean-up (Xavier Shay, Hannes Tydén)
|
76
|
-
* Added :ca_file consumer option to allow consumer specific certificate
|
77
|
-
override. (Pelle)
|
78
|
-
|
79
|
-
== 0.3.5 2009-06-03
|
80
|
-
|
81
|
-
* `query` CLI command to access protected resources (Seth)
|
82
|
-
* Added -H, -Q CLI options for specifying the authentication scheme (Seth)
|
83
|
-
* Added -O CLI option for specifying a file containing options (Seth)
|
84
|
-
* Support streamable body contents for large request bodies (Seth Cousins)
|
85
|
-
* Support for OAuth 1.0a (Seth)
|
86
|
-
* Added proxy support to OAuth::Consumer (Marshall Huss)
|
87
|
-
* Added --scope CLI option for Google's 'scope' parameter (Seth)
|
88
|
-
|
89
|
-
== 0.3.4 2009-05-06
|
90
|
-
|
91
|
-
* OAuth::Client::Helper uses OAuth::VERSION (chadisfaction)
|
92
|
-
* Fix OAuth::RequestProxy::ActionControllerRequest's handling of params
|
93
|
-
(Tristan Groléat)
|
94
|
-
|
95
|
-
== 0.3.3 2009-05-04
|
96
|
-
|
97
|
-
* Corrected OAuth XMPP namespace (Seth)
|
98
|
-
* Improved error handling for invalid Authorization headers (Matt Sanford)
|
99
|
-
* Fixed signatures for non-ASCII under $KCODE other than 'u' (Matt Sanford)
|
100
|
-
* Fixed edge cases in ActionControllerRequestProxy where params were being
|
101
|
-
incorrectly signed (Marcos Wright Kuhns)
|
102
|
-
* Support for arguments in OAuth::Consumer#get_access_token (Matt Sanford)
|
103
|
-
* Add gem version to user-agent header (Matt Sanford)
|
104
|
-
* Handle input from aggressive form encoding libraries (Matt Wood)
|
105
|
-
|
106
|
-
== 0.3.2 2009-03-23
|
107
|
-
|
108
|
-
* 2xx statuses should be treated as success (Anders Conbere)
|
109
|
-
* Support applications using the MethodOverride Rack middleware (László Bácsi)
|
110
|
-
* `authorize` command for `oauth` CLI (Seth)
|
111
|
-
* Initial support for Problem Reporting extension (Seth)
|
112
|
-
* Verify SSL certificates if CA certificates are available (Seth)
|
113
|
-
* Fixed ActionController parameter escaping behavior (Thiago Arrais, László
|
114
|
-
Bácsi, Brett Gibson, et al)
|
115
|
-
* Fixed signature calculation when both options and a block were provided to
|
116
|
-
OAuth::Signature::Base#initialize (Seth)
|
117
|
-
* Added help to the 'oauth' CLI (Seth)
|
118
|
-
* Fixed a problem when attempting to normalize MockRequest URIs (Seth)
|
119
|
-
|
120
|
-
== 0.3.1 2009-1-26
|
121
|
-
|
122
|
-
* Fixed a problem with relative and absolute token request paths. (Michael
|
123
|
-
Wood)
|
124
|
-
|
125
|
-
== 0.3.0 2009-1-25
|
126
|
-
|
127
|
-
* Support ActionController::Request from Edge Rails (László Bácsi)
|
128
|
-
* Correctly handle multi-valued parameters (Seth)
|
129
|
-
* Added #normalized_parameters to OAuth::RequestProxy::Base (Pelle)
|
130
|
-
* OAuth::Signature.sign and friends now yield the RequestProxy instead of the
|
131
|
-
token when the passed block's arity is 1. (Seth)
|
132
|
-
* Token requests are made to the configured URL rather than generating a
|
133
|
-
potentially incorrect one. (Kellan Elliott-McCrea)
|
134
|
-
* Command-line app for generating signatures. (Seth)
|
135
|
-
* Improved test-cases and compatibility for encoding issues. (Pelle)
|
136
|
-
|
137
|
-
== 0.2.7 2008-9-10 The lets fix the last release release
|
138
|
-
|
139
|
-
* Fixed plain text signatures (Andrew Arrow)
|
140
|
-
* Fixed RSA requests using OAuthTokens. (Philip Lipu Tsai)
|
141
|
-
|
142
|
-
== 0.2.6 2008-9-9 The lets RSA release
|
143
|
-
|
144
|
-
* Improved support for Ruby 1.8.7 (Bill Kocik)
|
145
|
-
* Fixed RSA verification to support RSA providers
|
146
|
-
now using Ruby and RSA
|
147
|
-
* Improved RSA testing
|
148
|
-
* Omit token when signing with RSA
|
149
|
-
* Added support for 'private_key_file' option for RSA signatures (Chris Mear)
|
150
|
-
* Fixed several edge cases where params were being incorrectly signed (Scott
|
151
|
-
Hill)
|
152
|
-
* Fixed RSA signing (choonkeat)
|
153
|
-
|
154
|
-
== 0.2.2 2008-2-22 Lets actually support SSL release
|
155
|
-
|
156
|
-
* Use HTTPS when required.
|
157
|
-
|
158
|
-
== 0.2 2008-1-19 All together now release
|
159
|
-
|
160
|
-
This is a big release, where we have merged the efforts of various parties into one common library.
|
161
|
-
This means there are definitely some API changes you should be aware of. They should be minimal
|
162
|
-
but please have a look at the unit tests.
|
163
|
-
|
164
|
-
== 0.1.2 2007-12-1
|
165
|
-
|
166
|
-
* Fixed checks for missing OAuth params to improve performance
|
167
|
-
* Includes Pat's fix for getting the realm out.
|
168
|
-
|
169
|
-
== 0.1.1 2007-11-26
|
170
|
-
|
171
|
-
* First release as a GEM
|
172
|
-
* Moved all non-Rails functionality from the Rails plugin:
|
173
|
-
http://code.google.com/p/oauth-plugin/
|
data/Rakefile
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
%w[rubygems rake rake/clean rake/testtask fileutils].each { |f| require f }
|
2
|
-
$LOAD_PATH << File.dirname(__FILE__) + '/lib'
|
3
|
-
require 'oauth'
|
4
|
-
|
5
|
-
begin
|
6
|
-
require 'jeweler'
|
7
|
-
Jeweler::Tasks.new do |s|
|
8
|
-
s.name = %q{oauth}
|
9
|
-
s.version = OAuth::VERSION
|
10
|
-
s.authors = ["Pelle Braendgaard", "Blaine Cook", "Larry Halff", "Jesse Clark", "Jon Crosby", "Seth Fitzsimmons", "Matt Sanford", "Aaron Quint"]
|
11
|
-
s.email = "oauth-ruby@googlegroups.com"
|
12
|
-
s.description = "OAuth Core Ruby implementation"
|
13
|
-
s.summary = s.description
|
14
|
-
s.rubyforge_project = %q{oauth}
|
15
|
-
s.add_development_dependency(%q<actionpack>, [">=2.3.5"])
|
16
|
-
s.add_development_dependency(%q<rack>, [">= 1.0.0"])
|
17
|
-
s.add_development_dependency(%q<mocha>, [">= 0.9.8"])
|
18
|
-
s.add_development_dependency(%q<typhoeus>, [">= 0.1.13"])
|
19
|
-
s.add_development_dependency(%q<em-http-request>, [">= 0.2.10"])
|
20
|
-
s.add_development_dependency(%q<curb>, [">= 0.6.6.0"])
|
21
|
-
|
22
|
-
s.files.include '.gemtest'
|
23
|
-
end
|
24
|
-
Jeweler::GemcutterTasks.new
|
25
|
-
rescue LoadError
|
26
|
-
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
27
|
-
end
|
28
|
-
|
29
|
-
Rake::TestTask.new do |t|
|
30
|
-
t.libs << "test"
|
31
|
-
t.test_files = FileList['test/**/*test*.rb']
|
32
|
-
t.verbose = true
|
33
|
-
end
|
34
|
-
|
35
|
-
Dir['tasks/**/*.rake'].each { |t| load t }
|
36
|
-
|
37
|
-
task :default => :test
|
data/examples/yql.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby -rubygems
|
2
|
-
|
3
|
-
# Sample queries:
|
4
|
-
# ./yql.rb --consumer-key <key> --consumer-secret <secret> "show tables"
|
5
|
-
# ./yql.rb --consumer-key <key> --consumer-secret <secret> "select * from flickr.photos.search where text='Cat' limit 10"
|
6
|
-
|
7
|
-
require 'oauth'
|
8
|
-
require 'optparse'
|
9
|
-
require 'json'
|
10
|
-
require 'pp'
|
11
|
-
|
12
|
-
options = {}
|
13
|
-
|
14
|
-
option_parser = OptionParser.new do |opts|
|
15
|
-
opts.banner = "Usage: #{$0} [options] <query>"
|
16
|
-
|
17
|
-
opts.on("--consumer-key KEY", "Specifies the consumer key to use.") do |v|
|
18
|
-
options[:consumer_key] = v
|
19
|
-
end
|
20
|
-
|
21
|
-
opts.on("--consumer-secret SECRET", "Specifies the consumer secret to use.") do |v|
|
22
|
-
options[:consumer_secret] = v
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
option_parser.parse!
|
27
|
-
query = ARGV.pop
|
28
|
-
query = STDIN.read if query == "-"
|
29
|
-
|
30
|
-
if options[:consumer_key].nil? || options[:consumer_secret].nil? || query.nil?
|
31
|
-
puts option_parser.help
|
32
|
-
exit 1
|
33
|
-
end
|
34
|
-
|
35
|
-
consumer = OAuth::Consumer.new \
|
36
|
-
options[:consumer_key],
|
37
|
-
options[:consumer_secret],
|
38
|
-
:site => "http://query.yahooapis.com"
|
39
|
-
|
40
|
-
access_token = OAuth::AccessToken.new(consumer)
|
41
|
-
|
42
|
-
response = access_token.request(:get, "/v1/yql?q=#{OAuth::Helper.escape(query)}&format=json")
|
43
|
-
rsp = JSON.parse(response.body)
|
44
|
-
pp rsp
|
data/lib/digest/hmac.rb
DELETED
@@ -1,104 +0,0 @@
|
|
1
|
-
# = digest/hmac.rb
|
2
|
-
#
|
3
|
-
# An implementation of HMAC keyed-hashing algorithm
|
4
|
-
#
|
5
|
-
# == Overview
|
6
|
-
#
|
7
|
-
# This library adds a method named hmac() to Digest classes, which
|
8
|
-
# creates a Digest class for calculating HMAC digests.
|
9
|
-
#
|
10
|
-
# == Examples
|
11
|
-
#
|
12
|
-
# require 'digest/hmac'
|
13
|
-
#
|
14
|
-
# # one-liner example
|
15
|
-
# puts Digest::HMAC.hexdigest("data", "hash key", Digest::SHA1)
|
16
|
-
#
|
17
|
-
# # rather longer one
|
18
|
-
# hmac = Digest::HMAC.new("foo", Digest::RMD160)
|
19
|
-
#
|
20
|
-
# buf = ""
|
21
|
-
# while stream.read(16384, buf)
|
22
|
-
# hmac.update(buf)
|
23
|
-
# end
|
24
|
-
#
|
25
|
-
# puts hmac.bubblebabble
|
26
|
-
#
|
27
|
-
# == License
|
28
|
-
#
|
29
|
-
# Copyright (c) 2006 Akinori MUSHA <knu@iDaemons.org>
|
30
|
-
#
|
31
|
-
# Documentation by Akinori MUSHA
|
32
|
-
#
|
33
|
-
# All rights reserved. You can redistribute and/or modify it under
|
34
|
-
# the same terms as Ruby.
|
35
|
-
#
|
36
|
-
# $Id: hmac.rb 14881 2008-01-04 07:26:14Z akr $
|
37
|
-
#
|
38
|
-
|
39
|
-
require 'digest'
|
40
|
-
|
41
|
-
unless defined?(Digest::HMAC)
|
42
|
-
module Digest
|
43
|
-
class HMAC < Digest::Class
|
44
|
-
def initialize(key, digester)
|
45
|
-
@md = digester.new
|
46
|
-
|
47
|
-
block_len = @md.block_length
|
48
|
-
|
49
|
-
if key.bytesize > block_len
|
50
|
-
key = @md.digest(key)
|
51
|
-
end
|
52
|
-
|
53
|
-
ipad = Array.new(block_len).fill(0x36)
|
54
|
-
opad = Array.new(block_len).fill(0x5c)
|
55
|
-
|
56
|
-
key.bytes.each_with_index { |c, i|
|
57
|
-
ipad[i] ^= c
|
58
|
-
opad[i] ^= c
|
59
|
-
}
|
60
|
-
|
61
|
-
@key = key.freeze
|
62
|
-
@ipad = ipad.inject('') { |s, c| s << c.chr }.freeze
|
63
|
-
@opad = opad.inject('') { |s, c| s << c.chr }.freeze
|
64
|
-
@md.update(@ipad)
|
65
|
-
end
|
66
|
-
|
67
|
-
def initialize_copy(other)
|
68
|
-
@md = other.instance_eval { @md.clone }
|
69
|
-
end
|
70
|
-
|
71
|
-
def update(text)
|
72
|
-
@md.update(text)
|
73
|
-
self
|
74
|
-
end
|
75
|
-
alias << update
|
76
|
-
|
77
|
-
def reset
|
78
|
-
@md.reset
|
79
|
-
@md.update(@ipad)
|
80
|
-
self
|
81
|
-
end
|
82
|
-
|
83
|
-
def finish
|
84
|
-
d = @md.digest!
|
85
|
-
@md.update(@opad)
|
86
|
-
@md.update(d)
|
87
|
-
@md.digest!
|
88
|
-
end
|
89
|
-
private :finish
|
90
|
-
|
91
|
-
def digest_length
|
92
|
-
@md.digest_length
|
93
|
-
end
|
94
|
-
|
95
|
-
def block_length
|
96
|
-
@md.block_length
|
97
|
-
end
|
98
|
-
|
99
|
-
def inspect
|
100
|
-
sprintf('#<%s: key=%s, digest=%s>', self.class.name, @key.inspect, @md.inspect.sub(/^\#<(.*)>$/) { $1 });
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
data/lib/oauth/core_ext.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
# these are to backport methods from 1.8.7/1.9.1 to 1.8.6
|
2
|
-
|
3
|
-
class Object
|
4
|
-
|
5
|
-
unless method_defined?(:tap)
|
6
|
-
def tap
|
7
|
-
yield self
|
8
|
-
self
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
end
|
13
|
-
|
14
|
-
class String
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
unless method_defined?(:bytesize)
|
19
|
-
def bytesize
|
20
|
-
self.size
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
unless method_defined?(:bytes)
|
25
|
-
def bytes
|
26
|
-
require 'enumerator'
|
27
|
-
Enumerable::Enumerator.new(self, :each_byte)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|