Class: HTTPClient::NegotiateAuth
- Inherits:
-
Object
- Object
- HTTPClient::NegotiateAuth
- Defined in:
- lib/httpclient.rb
Overview
HTTPClient::NegotiateAuth
Instance Attribute Summary collapse
-
#scheme ⇒ Object
readonly
:nodoc:.
Instance Method Summary collapse
- #challenge(uri, param_str) ⇒ Object
- #get(req) ⇒ Object
-
#initialize ⇒ NegotiateAuth
constructor
A new instance of NegotiateAuth.
- #reset_challenge ⇒ Object
Constructor Details
#initialize ⇒ NegotiateAuth
Returns a new instance of NegotiateAuth.
520 521 522 523 |
# File 'lib/httpclient.rb', line 520 def initialize @challenge = {} @scheme = "Negotiate" end |
Instance Attribute Details
#scheme ⇒ Object (readonly)
:nodoc:
518 519 520 |
# File 'lib/httpclient.rb', line 518 def scheme @scheme end |
Instance Method Details
#challenge(uri, param_str) ⇒ Object
549 550 551 552 553 554 555 556 557 558 559 560 561 562 |
# File 'lib/httpclient.rb', line 549 def challenge(uri, param_str) return false unless SSPIEnabled if param_str.nil? or @challenge[uri].nil? c = @challenge[uri] = {} c[:state] = :init c[:authenticator] = nil c[:authphrase] = "" else c = @challenge[uri] c[:state] = :response c[:authphrase] = param_str end true end |
#get(req) ⇒ Object
529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 |
# File 'lib/httpclient.rb', line 529 def get(req) return nil unless SSPIEnabled target_uri = req.header.request_uri param = Util.hash_find_value(@challenge) { |uri, param| Util.uri_part_of(target_uri, uri) } return nil unless param state = param[:state] authenticator = param[:authenticator] authphrase = param[:authphrase] case state when :init authenticator = param[:authenticator] = Win32::SSPI::NegotiateAuth.new return authenticator.get_initial_token when :response return authenticator.complete_authentication(authphrase) end nil end |
#reset_challenge ⇒ Object
525 526 527 |
# File 'lib/httpclient.rb', line 525 def reset_challenge @challenge.clear end |