使用HttpUrlConnection的NLTM auth失败

我正在尝试使用java.net的HttpUrlConnection对我的Java应用程序中支持NTLM身份validation的服务器进行身份validation。

问题是应用程序无法发送Authenticate响应。

我已将代理连接到http连接,以便通过fiddler路由流量。 在提琴手中,我可以看到正在发送的协商消息,并且收到服务器挑战。 但在此之后,应用程序停止说它有一个401,而没有发送type3身份validation消息。

有任何想法吗? 这是代码 –

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(); 

感谢任何帮助。 谢谢。