title: NLTM auth using HttpUrlConnection failing
body: <p>I am trying to authenticate against a server supporting NTLM authentication in my Java application using java.net's HttpUrlConnection.</p>
  
  <p>The problem is that the application fails to send the Authenticate response.</p>
  
  <p>I have attached proxy to the http connection so that the traffic is routed via fiddler. In fiddler i can see Negotiate message being sent, and server Challenge is received. But after this, the application just stops saying it got a 401, without sending the type3 authenticate message.</p>
  
  <p>Any ideas? Here is the code - </p>
  
  <pre><code>Authenticator.setDefault(new Authenticator() {
      public PasswordAuthentication getPasswordAuthentication() {
          return new PasswordAuthentication("username",
                                            "password".toCharArray());
      }
  });
  URL url = new URL("https://service_url.svc");
  
  // Proxy for fiddler
  Proxy proxy = new Proxy(Proxy.Type.HTTP,
                    new InetSocketAddress("localhost", 8888));
  
  // Create a connection
  HttpURLConnection conn = (HttpURLConnection)url.openConnection(proxy);
  conn.setRequestMethod("GET");
  conn.setDoInput(true);
  conn.setDoOutput(true);
  conn.setUseCaches(false);
  
  InputStream is = conn.getInputStream();
  BufferedReader rd = new BufferedReader(new InputStreamReader(is));
  String line;
  while ((line = rd.readLine()) != null)
      System.out.println(line);
  
  rd.close();
  </code></pre>
  
  <p>Appreciate any help. Thanks.</p>