Class: HTTPAccess2::BasicAuth

Inherits:
Object
  • Object
show all
Defined in:
lib/reap/vendor/http-access2.rb

Overview

HTTPAccess2::BasicAuth – BasicAuth repository.

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ BasicAuth

:nodoc:



718
719
720
721
# File 'lib/reap/vendor/http-access2.rb', line 718

def initialize(client)
  @client = client
  @auth = {}
end

Instance Method Details

#get(uri) ⇒ Object



730
731
732
733
734
735
736
737
738
739
740
# File 'lib/reap/vendor/http-access2.rb', line 730

def get(uri)
  @auth.each do |realm_uri, cred|
    if ((realm_uri.host == uri.host) and
 (realm_uri.scheme == uri.scheme) and
	  (realm_uri.port == uri.port) and
	  uri.path.upcase.index(realm_uri.path.upcase) == 0)
	return cred
    end
  end
  nil
end

#set(uri, user_id, passwd) ⇒ Object



723
724
725
726
727
728
# File 'lib/reap/vendor/http-access2.rb', line 723

def set(uri, user_id, passwd)
  uri = uri.clone
  uri.path = uri.path.sub(/\/[^\/]*$/, '/')
  @auth[uri] = ["#{user_id}:#{passwd}"].pack('m').strip
  @client.reset_all
end