8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/switchvox/net_http_digest_auth.rb', line 8
def digest_auth(user, password, response)
@@nonce_count += 1
response['www-authenticate'] =~ /^(\w+) (.*)/
params = {}
$2.gsub(/(\w+)="(.*?)"/) { params[$1] = $2 }
a_1 = "#{user}:#{params['realm']}:#{password}"
a_2 = "#{@method}:#{@path}"
request_digest = ''
request_digest << Digest::MD5.new.update(a_1).hexdigest
request_digest << ':' << params['nonce']
request_digest << ':' << Digest::MD5.new.update(a_2).hexdigest
= []
<< "Digest username=\"#{user}\""
<< "realm=\"#{params['realm']}\""
<< "uri=\"#{@path}\""
<< "nonce=\"#{params['nonce']}\""
<< "response=\"#{Digest::MD5.new.update(request_digest).hexdigest}\""
@header['Authorization'] =
end
|