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.
444 445 446 447 448 449 |
# File 'lib/httpclient.rb', line 444 def initialize @auth = {} @challenge = {} @nonce_count = 0 @scheme = "Digest" end |
Instance Attribute Details
#scheme ⇒ Object (readonly)
:nodoc:
442 443 444 |
# File 'lib/httpclient.rb', line 442 def scheme @scheme end |
Instance Method Details
#challenge(uri, param_str) ⇒ Object
477 478 479 480 |
# File 'lib/httpclient.rb', line 477 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
463 464 465 466 467 468 469 470 471 472 473 474 475 |
# File 'lib/httpclient.rb', line 463 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
451 452 453 |
# File 'lib/httpclient.rb', line 451 def reset_challenge @challenge.clear end |
#set(uri, user, passwd) ⇒ Object
455 456 457 458 |
# File 'lib/httpclient.rb', line 455 def set(uri, user, passwd) uri = Util.uri_dirname(uri) @auth[uri] = [user, passwd] end |