Hi,
I have a requirement something similar to this. I'm developing a plugin in confluence in which I have to make api calls to our internal applications from the Java code. Our internal api applications accept only NTLM authentication (Windows Authentication). Below is the code that I'm using currently, but it seems that it is not working -
import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.net.*; public class NT { static final String kuser = "[USERNAME]"; static final String kpass = "[PASSWORD]"; static class MyAuthenticator extends Authenticator { public PasswordAuthentication getPasswordAuthentication() { return (new PasswordAuthentication(kuser, kpass.toCharArray())); } } public static void main(String[] args) throws Exception { CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL)); Authenticator.setDefault(new MyAuthenticator()); URL url = new URL("http://<api-url>/23234941/"); URLConnection connection = url.openConnection(); InputStream ins = connection.getInputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(ins)); String str; while((str = reader.readLine()) != null) System.out.println(str); } }
can someone suggest a get around for this please.
Thanks,
Neha
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.