Class: HTTPAccess2::DigestAuth
- Inherits:
-
Object
- Object
- HTTPAccess2::DigestAuth
- Defined in:
- lib/rss-client/http-access2.rb
Overview
HTTPAccess2::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.
927 928 929 930 931 932 |
# File 'lib/rss-client/http-access2.rb', line 927 def initialize @auth = {} @challenge = {} @nonce_count = 0 @scheme = "Digest" end |
Instance Attribute Details
#scheme ⇒ Object (readonly)
:nodoc:
925 926 927 |
# File 'lib/rss-client/http-access2.rb', line 925 def scheme @scheme end |
Instance Method Details
#challenge(uri, param_str) ⇒ Object
960 961 962 963 |
# File 'lib/rss-client/http-access2.rb', line 960 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
946 947 948 949 950 951 952 953 954 955 956 957 958 |
# File 'lib/rss-client/http-access2.rb', line 946 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
934 935 936 |
# File 'lib/rss-client/http-access2.rb', line 934 def reset_challenge @challenge.clear end |
#set(uri, user, passwd) ⇒ Object
938 939 940 941 |
# File 'lib/rss-client/http-access2.rb', line 938 def set(uri, user, passwd) uri = Util.uri_dirname(uri) @auth[uri] = [user, passwd] end |