Class: HTTPAccess2::WWWAuth
- Inherits:
-
AuthFilterBase
- Object
- AuthFilterBase
- HTTPAccess2::WWWAuth
- Defined in:
- lib/rss-client/http-access2.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#basic_auth ⇒ Object
readonly
Returns the value of attribute basic_auth.
-
#digest_auth ⇒ Object
readonly
Returns the value of attribute digest_auth.
-
#negotiate_auth ⇒ Object
readonly
Returns the value of attribute negotiate_auth.
Instance Method Summary collapse
- #filter_request(req) ⇒ Object
- #filter_response(req, res) ⇒ Object
-
#initialize ⇒ WWWAuth
constructor
A new instance of WWWAuth.
- #reset_challenge ⇒ Object
- #set_auth(uri, user, passwd) ⇒ Object
Constructor Details
#initialize ⇒ WWWAuth
Returns a new instance of WWWAuth.
1075 1076 1077 1078 1079 1080 1081 |
# File 'lib/rss-client/http-access2.rb', line 1075 def initialize @basic_auth = BasicAuth.new @digest_auth = DigestAuth.new @negotiate_auth = NegotiateAuth.new # sort authenticators by priority @authenticator = [@negotiate_auth, @digest_auth, @basic_auth] end |
Instance Attribute Details
#basic_auth ⇒ Object (readonly)
Returns the value of attribute basic_auth.
1071 1072 1073 |
# File 'lib/rss-client/http-access2.rb', line 1071 def basic_auth @basic_auth end |
#digest_auth ⇒ Object (readonly)
Returns the value of attribute digest_auth.
1072 1073 1074 |
# File 'lib/rss-client/http-access2.rb', line 1072 def digest_auth @digest_auth end |
#negotiate_auth ⇒ Object (readonly)
Returns the value of attribute negotiate_auth.
1073 1074 1075 |
# File 'lib/rss-client/http-access2.rb', line 1073 def negotiate_auth @negotiate_auth end |
Instance Method Details
#filter_request(req) ⇒ Object
1094 1095 1096 1097 1098 1099 1100 1101 |
# File 'lib/rss-client/http-access2.rb', line 1094 def filter_request(req) @authenticator.each do |auth| if cred = auth.get(req) req.header.set('Authorization', auth.scheme + " " + cred) return end end end |
#filter_response(req, res) ⇒ Object
1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 |
# File 'lib/rss-client/http-access2.rb', line 1103 def filter_response(req, res) command = nil uri = req.header.request_uri if res.status == HTTP::Status::UNAUTHORIZED if challenge = parse_authentication_header(res, 'www-authenticate') challenge.each do |scheme, param_str| @authenticator.each do |auth| if scheme.downcase == auth.scheme.downcase challengeable = auth.challenge(uri, param_str) command = :retry if challengeable end end end # ignore unknown authentication scheme end end command end |
#reset_challenge ⇒ Object
1083 1084 1085 1086 1087 |
# File 'lib/rss-client/http-access2.rb', line 1083 def reset_challenge @authenticator.each do |auth| auth.reset_challenge end end |
#set_auth(uri, user, passwd) ⇒ Object
1089 1090 1091 1092 |
# File 'lib/rss-client/http-access2.rb', line 1089 def set_auth(uri, user, passwd) @basic_auth.set(uri, user, passwd) @digest_auth.set(uri, user, passwd) end |