Uploaded image for project: 'HttpComponents HttpClient'
  1. HttpComponents HttpClient
  2. HTTPCLIENT-1598

Native Windows Negotiate/NTLM via JNA + 407 Proxy Authentication Required

    XMLWordPrintableJSON

Details

    Description

      I'm trying to use the native Windows NTLM negotiation as described at http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/httpclient-win/src/examples/org/apache/http/examples/client/win/ClientWinAuth.java
      but I need to explicitly set a proxy.

      if (!WinHttpClients.isWinAuthAvailable()) {
      	System.out.println("Integrated Win auth is not supported!!!");
      }
      
      HttpClientBuilder httpClientBuilder = WinHttpClients.custom();
      
      HttpHost httpProxy = new HttpHost("proxyserver.example.com", 3128);
      
      httpClientBuilder.setProxy(httpProxy);
      CloseableHttpClient httpclient = httpClientBuilder.build();
      
      try {
      	HttpGet httpget = new HttpGet("http://www.google.it");
      
      	System.out.println("Executing request " + httpget.getRequestLine());
      	CloseableHttpResponse response = httpclient.execute(httpget);
      	try {
      		System.out.println("----------------------------------------");
      		System.out.println(response.getStatusLine());
      		EntityUtils.consume(response.getEntity());
      	} finally {
      		response.close();
      	}
      } finally {
      	httpclient.close();
      }
      

      The response contains the following line

      HTTP/1.0 407 Proxy Authentication Required

      In the attachments both the source code above and the complete log of the negotiation (I obviously changed the real proxy).

      What's wrong?

      Attachments

        1. curl7.40Output.txt
          7 kB
          Giacomo Boccardo
        2. curlOutput.txt
          9 kB
          Giacomo Boccardo
        3. log.txt
          59 kB
          Giacomo Boccardo
        4. sample.java
          0.8 kB
          Giacomo Boccardo

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jhack Giacomo Boccardo
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: