class Net::HTTPHeader::DigestAuthenticator
Public Class Methods
Source
# File lib/httparty/net_digest_auth.rb, line 27 def initialize(username, password, method, path, response_header) @username = username @password = password @method = method @path = path @response = parse(response_header) @cookies = parse_cookies(response_header) end
Public Instance Methods
Private Instance Methods
Source
# File lib/httparty/net_digest_auth.rb, line 121 def a1 a1_user_realm_pwd = [@username, @response['realm'], @password].join(':') if use_md5_sess? [ md5(a1_user_realm_pwd), @response['nonce'], @cnonce ].join(':') else a1_user_realm_pwd end end
Source
# File lib/httparty/net_digest_auth.rb, line 113 def algorithm_present? @response.key?('algorithm') && !@response['algorithm'].empty? end
Source
# File lib/httparty/net_digest_auth.rb, line 109 def md5(str) Digest::MD5.hexdigest(str) end
Source
# File lib/httparty/net_digest_auth.rb, line 91 def opaque_present? @response.key?('opaque') && !@response['opaque'].empty? end
Source
# File lib/httparty/net_digest_auth.rb, line 64 def parse(response_header) header = response_header['www-authenticate'] header = header.gsub(/qop=(auth(?:-int)?)/, 'qop="\\1"') header =~ /Digest (.*)/ params = {} if $1 non_quoted = $1.gsub(/(\w+)="(.*?)"/) { params[$1] = $2 } non_quoted.gsub(/(\w+)=([^,]*)/) { params[$1] = $2 } end params end
Source
# File lib/httparty/net_digest_auth.rb, line 95 def qop_present? @response.key?('qop') && !@response['qop'].empty? end
Source
# File lib/httparty/net_digest_auth.rb, line 99 def random format '%x', (Time.now.to_i + rand(65535)) end
Source
# File lib/httparty/net_digest_auth.rb, line 103 def request_digest a = [md5(a1), @response['nonce'], md5(a2)] a.insert(2, '00000001', @cnonce, @response['qop']) if qop_present? md5(a.join(':')) end
Source
# File lib/httparty/net_digest_auth.rb, line 117 def use_md5_sess? algorithm_present? && @response['algorithm'] == 'MD5-sess' end