【发布时间】:2019-02-07 07:21:00
【问题描述】:
我有一个使用 ntlm(Windows 集成身份验证)进行身份验证的托管 URL。我在 Windows 上并使用 java 1.8
URL url = new URL("someUrl");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
// con.setInstanceFollowRedirects(false);
con.setRequestProperty("Content-Type", "application/json");
con.setRequestMethod("GET");
int responseCode = con.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
// read response
...
in.close();
}else{
System.out.println("Error while fetching reponse, recieved response code " + responseCode);
}
上面的代码一直工作到 java 1.8.0_181 随着后续更新它开始失败,我用 191 和 201 进行了测试。 如果向后移植到 181,该代码仍然有效。 我也尝试使用 Authenticator,但它没有被调用(不知道为什么) 使用 java 的内部日志记录,我可以在日志中看到以下消息 “NegotiateAuthentication: java.io.IOException: 协商支持未启动” 我得到 401
我期待任何机制来帮助 java 自行协商以进行身份验证。
【问题讨论】:
标签: java java-8 windows-authentication ntlm