Java 仅在Windows上的NTLM连接期间IOException身份验证失败
我有一段简单的代码试图通过NTLM身份验证连接到Windows Server。它可以在Linux、MacOS上运行,但不能在Windows 10上运行。在Windows上,它总是抛出java.io.IOException身份验证失败Java 仅在Windows上的NTLM连接期间IOException身份验证失败,java,windows,ntlm,Java,Windows,Ntlm,我有一段简单的代码试图通过NTLM身份验证连接到Windows Server。它可以在Linux、MacOS上运行,但不能在Windows 10上运行。在Windows上,它总是抛出java.io.IOException身份验证失败 public static void main(String[] args) throws IOException { Authenticator myAuth = new Authenticator() { @Override
public static void main(String[] args) throws IOException {
Authenticator myAuth = new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("domain\\myusername", "password".toCharArray());
}
};
Authenticator.setDefault(myAuth);
URL url = new URL("http://url.to.server");
InputStream ins = url.openConnection().getInputStream();
System.out.println("done");
}
这在url.openConnection()期间发生,并引发以下异常:
Exception in thread "main" java.io.IOException: Authentication failure
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1696)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1440)
at de.agentes.soap.client.demo.SoapClientDemoApp.main(SoapClientDemoApp.java:24)
有没有人有过这方面的经验?您找到答案了吗?我也在想同样的。。。