Class: HTTPClient::DigestAuth
- Inherits:
-
Object
- Object
- HTTPClient::DigestAuth
- Defined in:
- lib/httpclient.rb
Overview
HTTPClient::DigestAuth
Instance Attribute Summary collapse
-
#scheme ⇒ Object
readonly
:nodoc:.
Instance Method Summary collapse
- #challenge(uri, param_str) ⇒ Object
-
#get(req) ⇒ Object
send cred only when a given uri is; - child page of challengeable(got WWW-Authenticate before) uri and, - child page of defined credential.
-
#initialize ⇒ DigestAuth
constructor
A new instance of DigestAuth.
- #reset_challenge ⇒ Object
- #set(uri, user, passwd) ⇒ Object
Constructor Details
#initialize ⇒ DigestAuth
Returns a new instance of DigestAuth.
445 446 447 448 449 450 |
# File 'lib/httpclient.rb', line 445 def initialize @auth = {} @challenge = {} @nonce_count = 0 @scheme = "Digest" end |
Instance Attribute Details
#scheme ⇒ Object (readonly)
:nodoc:
443 444 445 |
# File 'lib/httpclient.rb', line 443 def scheme @scheme end |
Instance Method Details
#challenge(uri, param_str) ⇒ Object
478 479 480 481 |
# File 'lib/httpclient.rb', line 478 def challenge(uri, param_str) @challenge[uri] = Util.parse_challenge_param(param_str) true end |
#get(req) ⇒ Object
send cred only when a given uri is;
- child page of challengeable(got WWW-Authenticate before) uri and,
- child page of defined credential
464 465 466 467 468 469 470 471 472 473 474 475 476 |
# File 'lib/httpclient.rb', line 464 def get(req) target_uri = req.header.request_uri param = Util.hash_find_value(@challenge) { |uri, param| Util.uri_part_of(target_uri, uri) } return nil unless param user, passwd = Util.hash_find_value(@auth) { |uri, auth_data| Util.uri_part_of(target_uri, uri) } return nil unless user uri = req.header.request_uri calc_cred(req.header.request_method, uri, user, passwd, param) end |
#reset_challenge ⇒ Object
452 453 454 |
# File 'lib/httpclient.rb', line 452 def reset_challenge @challenge.clear end |
#set(uri, user, passwd) ⇒ Object
456 457 458 459 |
# File 'lib/httpclient.rb', line 456 def set(uri, user, passwd) uri = Util.uri_dirname(uri) @auth[uri] = [user, passwd] end |