josephholsten-rets4r 1.1.17 → 1.1.18
Sign up to get free protection for your applications and to get access to all the features.
- metadata +44 -84
- data/CHANGELOG +0 -336
- data/CONTRIBUTORS +0 -7
- data/GPL +0 -340
- data/LICENSE +0 -29
- data/NEWS +0 -183
- data/README.rdoc +0 -45
- data/RUBYS +0 -56
- data/Rakefile +0 -57
- data/TODO +0 -29
- data/VERSION.yml +0 -5
- data/examples/client_get_object.rb +0 -47
- data/examples/client_login.rb +0 -37
- data/examples/client_metadata.rb +0 -40
- data/examples/client_parser.rb +0 -10
- data/examples/client_search.rb +0 -47
- data/examples/settings.yml +0 -12
- data/lib/rets4r.rb +0 -9
- data/lib/rets4r/auth.rb +0 -73
- data/lib/rets4r/client.rb +0 -723
- data/lib/rets4r/client/data.rb +0 -14
- data/lib/rets4r/client/dataobject.rb +0 -20
- data/lib/rets4r/client/metadata.rb +0 -15
- data/lib/rets4r/client/parsers/compact.rb +0 -42
- data/lib/rets4r/client/parsers/compact_nokogiri.rb +0 -81
- data/lib/rets4r/client/parsers/metadata.rb +0 -92
- data/lib/rets4r/client/parsers/response_parser.rb +0 -100
- data/lib/rets4r/client/transaction.rb +0 -31
- data/lib/rets4r/core_ext/array/extract_options.rb +0 -15
- data/lib/rets4r/core_ext/class/attribute_accessors.rb +0 -58
- data/lib/rets4r/core_ext/hash/keys.rb +0 -46
- data/lib/rets4r/core_ext/hash/slice.rb +0 -39
- data/lib/rets4r/listing_mapper.rb +0 -17
- data/lib/rets4r/listing_service.rb +0 -35
- data/lib/rets4r/loader.rb +0 -8
- data/lib/tasks/annotations.rake +0 -20
- data/lib/tasks/coverage.rake +0 -13
- data/test/compact_nokogiri_test.rb +0 -35
- data/test/data/1.5/bad_compact.xml +0 -7
- data/test/data/1.5/count_only_compact.xml +0 -3
- data/test/data/1.5/error.xml +0 -1
- data/test/data/1.5/invalid_compact.xml +0 -4
- data/test/data/1.5/login.xml +0 -16
- data/test/data/1.5/metadata.xml +0 -0
- data/test/data/1.5/search_compact.xml +0 -8
- data/test/data/1.5/search_compact_big.xml +0 -136
- data/test/data/1.5/search_unescaped_compact.xml +0 -8
- data/test/data/listing_service.yml +0 -36
- data/test/listing_mapper_test.rb +0 -112
- data/test/loader_test.rb +0 -24
- data/test/test_auth.rb +0 -68
- data/test/test_client.rb +0 -315
- data/test/test_helper.rb +0 -12
- data/test/test_parser.rb +0 -96
data/README.rdoc
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
= RETS4R
|
2
|
-
|
3
|
-
RETS4R provides a native Ruby interface to the RETS (Real Estate
|
4
|
-
Transaction Standard). It currently is built for the 1.5 specification,
|
5
|
-
but support for 1.7 and 2.0 are planned. It does not currently implement
|
6
|
-
all of the specification, but the most commonly used portions.
|
7
|
-
Specifically, there is no support for Update transactions.
|
8
|
-
|
9
|
-
While this is the only "native" Ruby RETS library currently available
|
10
|
-
(to my knowledge), there is another client written in C++ with Ruby
|
11
|
-
bindings available from the Center for Realtor� Technology
|
12
|
-
(http://www.crt.realtors.org/projects/rets/librets/).
|
13
|
-
|
14
|
-
== Links
|
15
|
-
|
16
|
-
* Source: http://github.com/josephholsten/rets4r
|
17
|
-
* Documentation: http://rdoc.info/projects/josephholsten/rets4r
|
18
|
-
* Continuous Integration: http://runcoderun.com/josephholsten/rets4r
|
19
|
-
* Code Metrics: http://devver.net/caliper/project?repo=git%3A%2F%2Fgithub.com%2Fjosephholsten%2Frets4r.git
|
20
|
-
|
21
|
-
== Requirements
|
22
|
-
|
23
|
-
* Ruby 1.8.4
|
24
|
-
|
25
|
-
== License
|
26
|
-
|
27
|
-
Please see the LICENSE file.
|
28
|
-
|
29
|
-
== Acknowledgments
|
30
|
-
|
31
|
-
This project was made possible in part by the Contra Costa Association of
|
32
|
-
Realtors� (http://www.ccartoday.com).
|
33
|
-
|
34
|
-
== Getting Started
|
35
|
-
|
36
|
-
Take a look at the examples directory. You'll find it more helpful than
|
37
|
-
the unit tests because the unit tests work off of local files and mock
|
38
|
-
objects, rather than making real transaction calls.
|
39
|
-
|
40
|
-
Due to the nature of this library, it is HIGHLY recommended that you
|
41
|
-
have at least a basic understanding of the RETS protocol. The official
|
42
|
-
RETS website is http://www.rets.org.
|
43
|
-
|
44
|
-
Most of the time, you will be either searching for resources or getting
|
45
|
-
objects, so begin there.
|
data/RUBYS
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
|
2
|
-
You can redistribute it and/or modify it under either the terms of the GPL
|
3
|
-
(see the file GPL), or the conditions below:
|
4
|
-
|
5
|
-
1. You may make and give away verbatim copies of the source form of the
|
6
|
-
software without restriction, provided that you duplicate all of the
|
7
|
-
original copyright notices and associated disclaimers.
|
8
|
-
|
9
|
-
2. You may modify your copy of the software in any way, provided that
|
10
|
-
you do at least ONE of the following:
|
11
|
-
|
12
|
-
a) place your modifications in the Public Domain or otherwise
|
13
|
-
make them Freely Available, such as by posting said
|
14
|
-
modifications to Usenet or an equivalent medium, or by allowing
|
15
|
-
the author to include your modifications in the software.
|
16
|
-
|
17
|
-
b) use the modified software only within your corporation or
|
18
|
-
organization.
|
19
|
-
|
20
|
-
c) give non-standard binaries non-standard names, with
|
21
|
-
instructions on where to get the original software distribution.
|
22
|
-
|
23
|
-
d) make other distribution arrangements with the author.
|
24
|
-
|
25
|
-
3. You may distribute the software in object code or binary form,
|
26
|
-
provided that you do at least ONE of the following:
|
27
|
-
|
28
|
-
a) distribute the binaries and library files of the software,
|
29
|
-
together with instructions (in the manual page or equivalent)
|
30
|
-
on where to get the original distribution.
|
31
|
-
|
32
|
-
b) accompany the distribution with the machine-readable source of
|
33
|
-
the software.
|
34
|
-
|
35
|
-
c) give non-standard binaries non-standard names, with
|
36
|
-
instructions on where to get the original software distribution.
|
37
|
-
|
38
|
-
d) make other distribution arrangements with the author.
|
39
|
-
|
40
|
-
4. You may modify and include the part of the software into any other
|
41
|
-
software (possibly commercial). But some files in the distribution
|
42
|
-
are not written by the author, so that they are not under these terms.
|
43
|
-
|
44
|
-
For the list of those files and their copying conditions, see the
|
45
|
-
file LEGAL.
|
46
|
-
|
47
|
-
5. The scripts and library files supplied as input to or produced as
|
48
|
-
output from the software do not automatically fall under the
|
49
|
-
copyright of the software, but belong to whomever generated them,
|
50
|
-
and may be sold commercially, and may be aggregated with this
|
51
|
-
software.
|
52
|
-
|
53
|
-
6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
54
|
-
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
55
|
-
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
56
|
-
PURPOSE.
|
data/Rakefile
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'rake'
|
3
|
-
require 'rake/clean'
|
4
|
-
require 'rake/packagetask'
|
5
|
-
require 'rake/gempackagetask'
|
6
|
-
require 'rake/contrib/rubyforgepublisher'
|
7
|
-
require 'fileutils'
|
8
|
-
include FileUtils
|
9
|
-
|
10
|
-
# impart all tasks in lib/tasks/
|
11
|
-
Dir['lib/tasks/*.rake'].each { |task| import task }
|
12
|
-
|
13
|
-
begin
|
14
|
-
require 'jeweler'
|
15
|
-
Jeweler::Tasks.new do |gem|
|
16
|
-
gem.name = "rets4r"
|
17
|
-
gem.summary = 'A native Ruby implementation of RETS (Real Estate Transaction Standard).'
|
18
|
-
gem.authors = ['Scott Patterson', 'John Wulff', 'bgetting', "Jacob Basham"]
|
19
|
-
gem.email = ['scott.patterson@digitalaun.com', 'john@johnwulff.com', 'brian@terra-firma-design.com','jacob@paperpigeons.net']
|
20
|
-
gem.homepage = 'http://rets4r.rubyforge.org/'
|
21
|
-
gem.files = FileList["[A-Z]*", "{examples,lib,test}/**/*"]
|
22
|
-
gem.rubyforge_project = 'rets4r'
|
23
|
-
gem.extra_rdoc_files = ['CONTRIBUTORS', 'README.rdoc', 'LICENSE', 'RUBYS', 'GPL',
|
24
|
-
'CHANGELOG', 'TODO' ]
|
25
|
-
gem.rdoc_options << '--main' << 'README.rdoc'
|
26
|
-
gem.test_files = FileList['test/test_*.rb']
|
27
|
-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
28
|
-
end
|
29
|
-
Jeweler::GemcutterTasks.new
|
30
|
-
rescue LoadError
|
31
|
-
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
32
|
-
end
|
33
|
-
|
34
|
-
require 'rake/testtask'
|
35
|
-
Rake::TestTask.new(:test) do |test|
|
36
|
-
test.libs << "test"
|
37
|
-
test.pattern = ["test/test_*.rb", "test/*_test.rb"]
|
38
|
-
test.verbose = true
|
39
|
-
end
|
40
|
-
|
41
|
-
task :default => :test
|
42
|
-
|
43
|
-
require 'rake/rdoctask'
|
44
|
-
Rake::RDocTask.new do |rdoc|
|
45
|
-
if File.exist?('VERSION.yml')
|
46
|
-
config = YAML.load(File.read('VERSION.yml'))
|
47
|
-
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
48
|
-
else
|
49
|
-
version = ""
|
50
|
-
end
|
51
|
-
|
52
|
-
rdoc.rdoc_dir = 'rdoc'
|
53
|
-
rdoc.title = "rets4r #{version}"
|
54
|
-
rdoc.options << '--line-numbers' << '--inline-source'
|
55
|
-
rdoc.rdoc_files.include('README.rdoc')
|
56
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
57
|
-
end
|
data/TODO
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
Fix
|
2
|
-
* Unit Tests (We need METADATA!)
|
3
|
-
|
4
|
-
Add support for
|
5
|
-
* Standard (non-compact) XML
|
6
|
-
|
7
|
-
Add
|
8
|
-
* More Examples
|
9
|
-
* More Documentation
|
10
|
-
* Reply Codes (Readable Meaning)
|
11
|
-
* A search convenience method that makes subsequent requests if maxrows is true.
|
12
|
-
* Extend examples so they are useful replacements for SimpleRETS
|
13
|
-
* Shared configuration between examples
|
14
|
-
|
15
|
-
Verify
|
16
|
-
* 1.7 Compliance and support
|
17
|
-
|
18
|
-
Check
|
19
|
-
* GetMetadata
|
20
|
-
|
21
|
-
Possible To-do Items
|
22
|
-
* RETS 1.0
|
23
|
-
* RETS 2.0 (May not be necessary since it is now SOAP based, but it would be nice to have a consistent API)
|
24
|
-
* Running a RETS Server
|
25
|
-
* Update Actions
|
26
|
-
* Password Change Transaction
|
27
|
-
* Get Transaction
|
28
|
-
* HTTPS Support
|
29
|
-
* Simple mapping to ActiveRecord
|
data/VERSION.yml
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby
|
2
|
-
#
|
3
|
-
# This is an example of how to use the RETS client to retrieve an objet.
|
4
|
-
#
|
5
|
-
# You will need to set the necessary variables below.
|
6
|
-
#
|
7
|
-
#############################################################################################
|
8
|
-
# Settings
|
9
|
-
|
10
|
-
require 'yaml'
|
11
|
-
settings_file = File.expand_path(File.join(File.dirname(__FILE__), "settings.yml"))
|
12
|
-
settings = YAML.load_file(settings_file)['settings']
|
13
|
-
|
14
|
-
#############################################################################################
|
15
|
-
$:.unshift 'lib'
|
16
|
-
|
17
|
-
require 'rets4r'
|
18
|
-
require 'logger'
|
19
|
-
|
20
|
-
def handle_object(object)
|
21
|
-
case object.info['Content-Type']
|
22
|
-
when 'image/jpeg' then extension = 'jpg'
|
23
|
-
when 'image/gif' then extension = 'gif'
|
24
|
-
when 'image/png' then extension = 'png'
|
25
|
-
else extension = 'unknown'
|
26
|
-
end
|
27
|
-
|
28
|
-
File.open("#{object.info['Content-ID']}_#{object.info['Object-ID']}.#{extension}", 'w') do |f|
|
29
|
-
f.write(object.data)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
client = RETS4R::Client.new(settings[:url])
|
34
|
-
|
35
|
-
client.login(settings[:username], settings[:password]) do |login_result|
|
36
|
-
|
37
|
-
if login_result.success?
|
38
|
-
## Method 1
|
39
|
-
# Get objects using a block
|
40
|
-
client.get_object(settings[:resource], settings[:object_type], settings[:resource_id]) do |object|
|
41
|
-
handle_object(object)
|
42
|
-
end
|
43
|
-
else
|
44
|
-
puts "We were unable to log into the RETS server."
|
45
|
-
puts "Please check that you have set the login variables correctly."
|
46
|
-
end
|
47
|
-
end
|
data/examples/client_login.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby
|
2
|
-
#
|
3
|
-
# This is an example of how to use the RETS client to log in and out of a server.
|
4
|
-
#
|
5
|
-
# You will need to set the necessary variables below.
|
6
|
-
#
|
7
|
-
#############################################################################################
|
8
|
-
# Settings
|
9
|
-
|
10
|
-
require 'yaml'
|
11
|
-
settings_file = File.expand_path(File.join(File.dirname(__FILE__), "settings.yml"))
|
12
|
-
settings = YAML.load_file(settings_file)['settings']
|
13
|
-
|
14
|
-
#############################################################################################
|
15
|
-
$:.unshift 'lib'
|
16
|
-
|
17
|
-
require 'rets4r'
|
18
|
-
require 'logger'
|
19
|
-
|
20
|
-
client = RETS4R::Client.new(settings[:url])
|
21
|
-
client.logger = Logger.new(STDOUT)
|
22
|
-
|
23
|
-
login_result = client.login(settings[:username], settings[:password])
|
24
|
-
|
25
|
-
if login_result.success?
|
26
|
-
puts "We successfully logged into the RETS server!"
|
27
|
-
|
28
|
-
# Print the action URL results (if any)
|
29
|
-
puts login_result.secondary_response
|
30
|
-
|
31
|
-
client.logout
|
32
|
-
|
33
|
-
puts "We just logged out of the server."
|
34
|
-
else
|
35
|
-
puts "We were unable to log into the RETS server."
|
36
|
-
puts "Please check that you have set the login variables correctly."
|
37
|
-
end
|
data/examples/client_metadata.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby
|
2
|
-
#
|
3
|
-
# This is an example of how to use the RETS client to login to a server and retrieve metadata. It
|
4
|
-
# also makes use of passing blocks to client methods and demonstrates how to set the output format.
|
5
|
-
#
|
6
|
-
# You will need to set the necessary variables below.
|
7
|
-
#
|
8
|
-
#############################################################################################
|
9
|
-
# Settings
|
10
|
-
|
11
|
-
require 'yaml'
|
12
|
-
settings_file = File.expand_path(File.join(File.dirname(__FILE__), "settings.yml"))
|
13
|
-
settings = YAML.load_file(settings_file)['settings']
|
14
|
-
|
15
|
-
#############################################################################################
|
16
|
-
$:.unshift 'lib'
|
17
|
-
|
18
|
-
require 'rets4r'
|
19
|
-
|
20
|
-
RETS4R::Client.new(settings[:url]) do |client|
|
21
|
-
client.login(settings[:username], settings[:password]) do |login_result|
|
22
|
-
if login_result.success?
|
23
|
-
puts "Logged in successfully!"
|
24
|
-
|
25
|
-
metadata = ''
|
26
|
-
|
27
|
-
begin
|
28
|
-
metadata = client.get_metadata
|
29
|
-
rescue
|
30
|
-
puts "Unable to get metadata: '#{$!}'"
|
31
|
-
end
|
32
|
-
|
33
|
-
File.open('metadata.xml', 'w') do |file|
|
34
|
-
file.write metadata
|
35
|
-
end
|
36
|
-
else
|
37
|
-
puts "Unable to login: '#{login_result.reply_text}'."
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
data/examples/client_parser.rb
DELETED
data/examples/client_search.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby
|
2
|
-
#
|
3
|
-
# This is an example of how to use the RETS client to perform a basic search.
|
4
|
-
#
|
5
|
-
# You will need to set the necessary variables below.
|
6
|
-
#
|
7
|
-
#############################################################################################
|
8
|
-
# Settings
|
9
|
-
|
10
|
-
require 'yaml'
|
11
|
-
settings_file = File.expand_path(File.join(File.dirname(__FILE__), "settings.yml"))
|
12
|
-
settings = YAML.load_file(settings_file)['settings']
|
13
|
-
|
14
|
-
#############################################################################################
|
15
|
-
$:.unshift 'lib'
|
16
|
-
|
17
|
-
require 'rets4r'
|
18
|
-
|
19
|
-
client = RETS4R::Client.new(settings[:url])
|
20
|
-
|
21
|
-
logger = Logger.new($stdout)
|
22
|
-
logger.level = Logger::WARN
|
23
|
-
client.logger = logger
|
24
|
-
|
25
|
-
login_result = client.login(settings[:username], settings[:password])
|
26
|
-
|
27
|
-
if login_result.success?
|
28
|
-
puts "We successfully logged into the RETS server!"
|
29
|
-
|
30
|
-
options = {'Limit' => settings[:limit]}
|
31
|
-
|
32
|
-
client.search(settings[:resource], settings[:class], settings[:query], options) do |result|
|
33
|
-
result.response.each do |row|
|
34
|
-
puts row.inspect
|
35
|
-
puts
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
client.logout
|
40
|
-
|
41
|
-
puts "We just logged out of the server."
|
42
|
-
else
|
43
|
-
puts "We were unable to log into the RETS server."
|
44
|
-
puts "Please check that you have set the login variables correctly."
|
45
|
-
end
|
46
|
-
|
47
|
-
logger.close
|
data/examples/settings.yml
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
settings:
|
2
|
-
:url: http://demo.crt.realtors.org:6103/rets/login
|
3
|
-
:username: Joe
|
4
|
-
:password: Schmoe
|
5
|
-
:resource: Property
|
6
|
-
:class: RES
|
7
|
-
:query: (MODIFIED=2009-11-14-TODAY)
|
8
|
-
:object_type: Photo
|
9
|
-
:resource_id: '11003049:*'
|
10
|
-
:limit: 400
|
11
|
-
#:query: (LISTPRICE=0+)
|
12
|
-
#:query: (MODIFIED=2009-11-14-TODAY)
|
data/lib/rets4r.rb
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
# Add lib/rets4r as a default load path.
|
2
|
-
dir = File.join File.dirname(__FILE__), 'rets4r'
|
3
|
-
$:.unshift(dir) unless $:.include?(dir) || $:.include?(File.expand_path(dir))
|
4
|
-
|
5
|
-
require 'client'
|
6
|
-
require 'loader'
|
7
|
-
require 'client/parsers/compact_nokogiri'
|
8
|
-
require 'rets4r/listing_service'
|
9
|
-
require 'rets4r/listing_mapper'
|
data/lib/rets4r/auth.rb
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
require 'digest/md5'
|
2
|
-
|
3
|
-
module RETS4R
|
4
|
-
class Auth
|
5
|
-
# This is the primary method that would normally be used, and while it
|
6
|
-
def Auth.authenticate(response, username, password, uri, method, requestId, useragent, nc = 0)
|
7
|
-
if response['www-authenticate'].nil? || response['www-authenticate'].empty?
|
8
|
-
raise "Missing required header 'www-authenticate'. Got: #{response}"
|
9
|
-
end
|
10
|
-
|
11
|
-
authHeader = Auth.parse_header(response['www-authenticate'])
|
12
|
-
|
13
|
-
cnonce = cnonce(useragent, password, requestId, authHeader['nonce'])
|
14
|
-
|
15
|
-
authHash = calculate_digest(username, password, authHeader['realm'], authHeader['nonce'], method, uri, authHeader['qop'], cnonce, nc)
|
16
|
-
|
17
|
-
header = ''
|
18
|
-
header << "Digest username=\"#{username}\", "
|
19
|
-
header << "realm=\"#{authHeader['realm']}\", "
|
20
|
-
header << "qop=\"#{authHeader['qop']}\", "
|
21
|
-
header << "uri=\"#{uri}\", "
|
22
|
-
header << "nonce=\"#{authHeader['nonce']}\", "
|
23
|
-
header << "nc=#{('%08x' % nc)}, "
|
24
|
-
header << "cnonce=\"#{cnonce}\", "
|
25
|
-
header << "response=\"#{authHash}\", "
|
26
|
-
header << "opaque=\"#{authHeader['opaque']}\""
|
27
|
-
|
28
|
-
return header
|
29
|
-
end
|
30
|
-
|
31
|
-
def Auth.calculate_digest(username, password, realm, nonce, method, uri, qop = false, cnonce = false, nc = 0)
|
32
|
-
a1 = "#{username}:#{realm}:#{password}"
|
33
|
-
a2 = "#{method}:#{uri}"
|
34
|
-
|
35
|
-
response = '';
|
36
|
-
|
37
|
-
requestId = Auth.request_id unless requestId
|
38
|
-
|
39
|
-
if (qop)
|
40
|
-
throw ArgumentException, 'qop requires a cnonce to be provided.' unless cnonce
|
41
|
-
|
42
|
-
response = Digest::MD5.hexdigest("#{Digest::MD5.hexdigest(a1)}:#{nonce}:#{('%08x' % nc)}:#{cnonce}:#{qop}:#{Digest::MD5.hexdigest(a2)}")
|
43
|
-
else
|
44
|
-
response = Digest::MD5.hexdigest("#{Digest::MD5.hexdigest(a1)}:#{nonce}:#{Digest::MD5.hexdigest(a2)}")
|
45
|
-
end
|
46
|
-
|
47
|
-
return response
|
48
|
-
end
|
49
|
-
|
50
|
-
def Auth.parse_header(header)
|
51
|
-
type = header[0, header.index(' ')]
|
52
|
-
args = header[header.index(' '), header.length].strip.split(',')
|
53
|
-
|
54
|
-
parts = {'type' => type}
|
55
|
-
|
56
|
-
args.each do |arg|
|
57
|
-
name, value = arg.split('=')
|
58
|
-
|
59
|
-
parts[name.downcase.strip] = value.tr('"', '').strip
|
60
|
-
end
|
61
|
-
|
62
|
-
return parts
|
63
|
-
end
|
64
|
-
|
65
|
-
def Auth.request_id
|
66
|
-
Digest::MD5.hexdigest(Time.new.to_f.to_s)
|
67
|
-
end
|
68
|
-
|
69
|
-
def Auth.cnonce(useragent, password, requestId, nonce)
|
70
|
-
Digest::MD5.hexdigest("#{useragent}:#{password}:#{requestId}:#{nonce}")
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|