Class: NTLMServlet

Inherits:
WEBrick::HTTPServlet::AbstractServlet
  • Object
show all
Defined in:
lib/mechanize/test_case.rb

Instance Method Summary collapse

Instance Method Details

#do_GET(req, res) ⇒ Object



361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
# File 'lib/mechanize/test_case.rb', line 361

def do_GET(req, res)
  if req['Authorization'] =~ /^NTLM (.*)/ then
    authorization = $1.unpack('m*').first

    if authorization =~ /^NTLMSSP\000\001/ then
      type_2 = 'TlRMTVNTUAACAAAADAAMADAAAAABAoEAASNFZ4mr' \
        'ze8AAAAAAAAAAGIAYgA8AAAARABPAE0AQQBJAE4A' \
        'AgAMAEQATwBNAEEASQBOAAEADABTAEUAUgBWAEUA' \
        'UgAEABQAZABvAG0AYQBpAG4ALgBjAG8AbQADACIA' \
        'cwBlAHIAdgBlAHIALgBkAG8AbQBhAGkAbgAuAGMA' \
        'bwBtAAAAAAA='

      res['WWW-Authenticate'] = "NTLM #{type_2}"
      res.status = 401
    elsif authorization =~ /^NTLMSSP\000\003/ then
      res.body = 'ok'
    else
      res['WWW-Authenticate'] = 'NTLM'
      res.status = 401
    end
  else
    res['WWW-Authenticate'] = 'NTLM'
    res.status = 401
  end
end