NTLMv2 HTTP认证Java

NTLMv2 HTTP认证Java,java,android,httpurlconnection,ntlmv2,Java,Android,Httpurlconnection,Ntlmv2,我很不明白这是怎么回事。我试过使用这样的东西: con = (HttpURLConnection) url2.openConnection(); con.setReadTimeout(10000); con.setInstanceFollowRedirects(true); con.setAllowUserInteraction(true); con.setDoOutput(true); con.setDoInput(true);

我很不明白这是怎么回事。我试过使用这样的东西:

    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
引发的异常的堆栈跟踪中,我看到引用了
HttpURLConnection
的Apache实现

根据我在研究中发现的情况,由于许可问题,Apache无法包含NTLMv2协议。这就是为什么它不能在android上工作的原因吗


无论哪种方式,我都想知道这将如何在Java中实现,而不仅仅是Android。

它没有实现。请查看此问题:。同时考虑Android不是JRE 6的事实,它是标准java的修改版本。请查看此问题:。还考虑Android不是JRE 6的事实,它是标准java的修改版本。

实际上可以使用JCIF库:实际上可以使用JCIF库: