Class: Net::HTTPHeader::DigestAuthenticator
- Inherits:
-
Object
- Object
- Net::HTTPHeader::DigestAuthenticator
- Defined in:
- lib/httparty/net_digest_auth.rb
Instance Method Summary collapse
- #authorization_header ⇒ Object
-
#initialize(username, password, method, path, response_header) ⇒ DigestAuthenticator
constructor
A new instance of DigestAuthenticator.
Constructor Details
#initialize(username, password, method, path, response_header) ⇒ DigestAuthenticator
Returns a new instance of DigestAuthenticator.
13 14 15 16 17 18 19 |
# 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 |
Instance Method Details
#authorization_header ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/httparty/net_digest_auth.rb', line 21 def @cnonce = md5(random) header = [ %Q(Digest username="#{@username}"), %Q(realm="#{@response['realm']}"), %Q(nonce="#{@response['nonce']}"), %Q(uri="#{@path}"), %Q(response="#{request_digest}"), ] if qop_present? fields = [ %Q(cnonce="#{@cnonce}"), %Q(qop="#{@response['qop']}"), %Q(nc=00000001) ] fields.each { |field| header << field } end header << %Q(opaque="#{@response['opaque']}") if opaque_present? header end |