# File lib/httparty/net_digest_auth.rb, line 13 def initialize(username, password, method, path, response_header) @username = username @password = password @method = method @path = path @response = parse(response_header) end
# File lib/httparty/net_digest_auth.rb, line 75 def a1 [@username, @response['realm'], @password].join(":") end
# File lib/httparty/net_digest_auth.rb, line 79 def a2 [@method, @path].join(":") end
# File lib/httparty/net_digest_auth.rb, line 71 def md5(str) Digest::MD5.hexdigest(str) end
# File lib/httparty/net_digest_auth.rb, line 53 def opaque_present? @response.has_key?('opaque') and not @response['opaque'].empty? end
# File lib/httparty/net_digest_auth.rb, line 46 def parse(response_header) response_header['www-authenticate'] =~ /^(\w+) (.*)/ params = {} $2.gsub(/(\w+)="(.*?)"/) { params[$1] = $2 } params end
# File lib/httparty/net_digest_auth.rb, line 57 def qop_present? @response.has_key?('qop') and not @response['qop'].empty? end
# File lib/httparty/net_digest_auth.rb, line 61 def random "%x" % (Time.now.to_i + rand(65535)) end
# File lib/httparty/net_digest_auth.rb, line 65 def request_digest a = [md5(a1), @response['nonce'], md5(a2)] a.insert(2, "00000001", @cnonce, @response['qop']) if qop_present? md5(a.join(":")) end