【发布时间】:2010-10-06 05:46:07
【问题描述】:
我很困惑这应该如何工作。我试过使用这样的东西:
con = (HttpURLConnection) url2.openConnection();
con.setReadTimeout(10000);
con.setInstanceFollowRedirects(true);
con.setAllowUserInteraction(true);
con.setDoOutput(true);
con.setDoInput(true);
Authenticator.setDefault(new MyAuthenticator());
con.connect();
class MyAuthenticator extends Authenticator {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("myUser", "MyPassword".toCharArray());
}
}
我收到此方法返回的 401 错误,所以显然我没有抓住重点。根据这个chart NTLMv2 应该在 JRE 6 中得到支持。我的困惑在于它是在 Android 上运行的。在getOutputStream 引发的异常的堆栈跟踪中,我看到HttpURLConnection 的Apache 实现被引用。
根据我的研究发现,由于许可问题,Apache 无法包含 NTLMv2 协议。这就是它不能在android上运行的原因吗?
无论哪种方式,我都想知道这将如何在 Java 中完成,而不仅仅是 Android。
【问题讨论】:
标签: java android httpurlconnection ntlmv2