Class: HTTPAccess2::ProxyAuth

Inherits:
AuthFilterBase show all
Defined in:
lib/rss-client/http-access2.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeProxyAuth

Returns a new instance of ProxyAuth.



1128
1129
1130
1131
1132
1133
# File 'lib/rss-client/http-access2.rb', line 1128

def initialize
  @basic_auth = BasicAuth.new
  @negotiate_auth = NegotiateAuth.new
  # sort authenticators by priority
  @authenticator = [@negotiate_auth, @basic_auth]
end

Instance Attribute Details

#basic_authObject (readonly)

Returns the value of attribute basic_auth.



1125
1126
1127
# File 'lib/rss-client/http-access2.rb', line 1125

def basic_auth
  @basic_auth
end

#negotiate_authObject (readonly)

Returns the value of attribute negotiate_auth.



1126
1127
1128
# File 'lib/rss-client/http-access2.rb', line 1126

def negotiate_auth
  @negotiate_auth
end

Instance Method Details

#filter_request(req) ⇒ Object



1145
1146
1147
1148
1149
1150
1151
1152
# File 'lib/rss-client/http-access2.rb', line 1145

def filter_request(req)
  @authenticator.each do |auth|
    if cred = auth.get(req)
      req.header.set('Proxy-Authorization', auth.scheme + " " + cred)
      return
    end
  end
end

#filter_response(req, res) ⇒ Object



1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
# File 'lib/rss-client/http-access2.rb', line 1154

def filter_response(req, res)
  command = nil
  uri = req.header.request_uri
  if res.status == HTTP::Status::PROXY_AUTHENTICATE_REQUIRED
    if challenge = parse_authentication_header(res, 'proxy-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_challengeObject



1135
1136
1137
1138
1139
# File 'lib/rss-client/http-access2.rb', line 1135

def reset_challenge
  @authenticator.each do |auth|
    auth.reset_challenge
  end
end

#set_auth(user, passwd) ⇒ Object



1141
1142
1143
# File 'lib/rss-client/http-access2.rb', line 1141

def set_auth(user, passwd)
  @basic_auth.set(nil, user, passwd)
end