4

I have got this simple snippet of code trying to connect to Windows Server with NTLM authentication. It works on Linux, MacOS but not on Windows 10. On Windows it always throws java.io.IOException Authentication Failure.

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");
}

This is happening during url.openConnection() and it throws this exception:

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)

Does anyone have any experience with this issue?

sovanegger
  • 121
  • 4

0 Answers0