Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

NTLM Authentication from Confluence plugin to third party application

Neha Sharma
Contributor
April 1, 2019

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 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events