NTLMV2 HTTP身份验证Java
-
28-09-2019 - |
题
我对应该如何工作非常困惑。我尝试使用这样的东西:
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错误,因此显然我缺少这一点。根据这个 图表 NTLMV2应在JRE 6中支持。我的混乱在于这是在Android上运行的事实。在堆栈痕迹中,异常被抛出 getOutputStream
我看到Apache的实现 HttpURLConnection
被引用。
据我在研究中发现的Apache所发现的原因是由于许可问题而无法包括NTLMV2协议。这就是为什么它不适用于Android?
无论哪种方式,我都想知道在Java中如何做到这一点,而不仅仅是Android。
解决方案
它没有实现。查看此问题: http://code.google.com/p/android/issues/detail?id=4962. 。还要考虑一个事实,即Android不是JRE 6,它是标准Java的修改版本。
不隶属于 StackOverflow