class HTTPClient::BasicAuth
Used in WWWAuth and ProxyAuth.
Authentication filter for handling BasicAuth negotiation.
def challenge(uri, param_str = nil)
def challenge(uri, param_str = nil) synchronize { @challenge[urify(uri)] = true true } end
def get(req)
* child page of challengeable(got *Authenticate before) uri and,
It sends cred only when a given uri is;
Response handler: returns credential.
def get(req) target_uri = req.header.request_uri synchronize { return nil if !@force_auth and !@challenge.any? { |uri, ok| Util.uri_part_of(target_uri, uri) and ok } return @cred if @cred Util.hash_find_value(@auth) { |uri, cred| Util.uri_part_of(target_uri, uri) } } end
def initialize
def initialize super('Basic') @cred = nil @auth = {} @force_auth = false end
def set(uri, user, passwd)
Set authentication credential.
def set(uri, user, passwd) synchronize do if uri.nil? @cred = ["#{user}:#{passwd}"].pack('m').tr("\n", '') else uri = Util.uri_dirname(uri) @auth[uri] = ["#{user}:#{passwd}"].pack('m').tr("\n", '') end end end
def set?
def set? @cred || @auth.any? end