Class: HTTPAccess2::BasicAuth

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

Overview

HTTPAccess2::BasicAuth – BasicAuth repository.

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ BasicAuth

:nodoc:



716
717
718
719
# File 'lib/http-access2.rb', line 716

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

Instance Method Details

#get(uri) ⇒ Object



728
729
730
731
732
733
734
735
736
737
738
# File 'lib/http-access2.rb', line 728

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



721
722
723
724
725
726
# File 'lib/http-access2.rb', line 721

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