lib/winrm/http/auth.rb
# Filter API implementation.  Traps HTTP response and parses
# 'WWW-Authenticate' header.
#
# This remembers the challenges for all authentication methods
# available to the client. On the subsequent retry of the request,
# filter_request will select the strongest method.
Filter API implementation.  Traps HTTP response and parses
'WWW-Authenticate' header.

This remembers the challenges for all authentication methods
available to the client. On the subsequent retry of the request,
filter_request will select the strongest method.
Filter API implementation . Traps HTTP response and parses ' WWW - Authenticate ' header . This remembers the challenges for all authentication methods available to the client . On the subsequent retry of the request filter_request will select the strongest method .
def filter_response(req, res)
      command = nil
      if res.status == HTTP::Status::UNAUTHORIZED
        if challenge = parse_authentication_header(res, 'www-authenticate')
          uri = req.header.request_uri
          challenge.each do |scheme, param_str|
            @authenticator.each do |auth|
              next unless auth.set? 
              if scheme.downcase == auth.scheme.downcase
                challengeable = auth.challenge(uri, param_str)
                command = :retry if challengeable
              end
            end
          end
        end
      else
        decrypted_content = res.content
        @authenticator.each do |auth|
          next unless auth.set? 
          decrypted_content = auth.decrypt_payload(res.content) if auth.respond_to?(:encrypted_channel?) && auth.encrypted_channel? && encrypted_content?(res.content)
        end
        res.content.replace(decrypted_content) if res.content and !res.content.empty?
      end
      command
    end
def filter_response ( req , res ) command = nil if res . status == HTTP :: Status :: UNAUTHORIZED if challenge = parse_authentication_header ( res , 'www-authenticate' ) uri = req . header . request_uri challenge . each do | scheme , param_str | @authenticator . each do | auth | next unless auth . set? if scheme . downcase == auth . scheme . downcase challengeable = auth . challenge ( uri , param_str ) command = :retry if challengeable end end end end else decrypted_content = res . content @authenticator . each do | auth | next unless auth . set? decrypted_content = auth . decrypt_payload ( res . content ) if auth . respond_to? ( :encrypted_channel? ) && auth . encrypted_channel? && encrypted_content? ( res . content ) end res . content . replace ( decrypted_content ) if res . content and ! res . content . empty? end command end
Filter API implementation.
Filter API implementation .
# hasn't be set, don't use it # ignore unknown authentication scheme # hasn't be set, don't use it # update with decrypted content
req
res