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

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

Agile BoardAttach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    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. log.txt
          59 kB
          Giacomo Boccardo
        2. sample.java
          0.8 kB
          Giacomo Boccardo
        3. curlOutput.txt
          9 kB
          Giacomo Boccardo
        4. curl7.40Output.txt
          7 kB
          Giacomo Boccardo

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

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

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment