Class: RoadForest::HTTP::PreparedCredentialSource
- Inherits:
-
CredentialSource
- Object
- CredentialSource
- RoadForest::HTTP::PreparedCredentialSource
- Defined in:
- lib/roadforest/http/keychain.rb
Instance Method Summary collapse
- #add(url, user, secret) ⇒ Object
- #add_credentials(url, creds) ⇒ Object
-
#initialize ⇒ PreparedCredentialSource
constructor
A new instance of PreparedCredentialSource.
- #respond_to_challenge(url, realm, attempt) ⇒ Object
Methods inherited from CredentialSource
Constructor Details
#initialize ⇒ PreparedCredentialSource
Returns a new instance of PreparedCredentialSource.
28 29 30 |
# File 'lib/roadforest/http/keychain.rb', line 28 def initialize @for_url = Hash.new{|h,k| h[k] = []} end |
Instance Method Details
#add(url, user, secret) ⇒ Object
32 33 34 35 |
# File 'lib/roadforest/http/keychain.rb', line 32 def add(url, user, secret) creds = BasicCredentials.new(user, secret) add_credentials(url, creds) end |
#add_credentials(url, creds) ⇒ Object
37 38 39 |
# File 'lib/roadforest/http/keychain.rb', line 37 def add_credentials(url, creds) @for_url[canonical_root(url)] << creds end |
#respond_to_challenge(url, realm, attempt) ⇒ Object
41 42 43 44 45 |
# File 'lib/roadforest/http/keychain.rb', line 41 def respond_to_challenge(url, realm, attempt) @for_url[canonical_root(url)].fetch(attempt) rescue IndexError nil end |