0

Recently I have been working with a Netbeans plugin that makes a http basic authentication. So in order to verify that the password is correct I have the following code.

String url = "http://someurl.com";
URLConnection conn = (new URL(url)).openConnection();
HttpURLConnection hconn = (HttpURLConnection) conn;
hconn.setUseCaches(false);
String input = username.getText() + ":" + password.getText();
String output = Base64.encode(input.getBytes());
hconn.setRequestProperty("Authorization", "Basic " + output);
hconn.connect();
int code = hconn.getResponseCode();
boolean connectionOk = (code == HttpURLConnection.HTTP_OK);

In a normal swing application the previous code helps to show if the connetion is ok, but when I put it in a Netbeans platform plugin and the connection is not ok it brings me the following dialog. enter image description here

What can I do to disable this dialog?

troy_frommer
  • 102
  • 1
  • 21
Nestor Hernandez Loli
  • 1,412
  • 3
  • 21
  • 26

1 Answers1

1

Have you tried the following:

conn.setAllowUserInteraction(false);