Reputation: 1832
I have created an Eclipse Plugin, and within that I have created a Wizard by extending org.eclipse.jface.wizard.Wizard. In that I am using java.net.URLConnection to perform Basic Authentication with a server, like so:
String auth = new String(Base64.encodeBase64((username + ":" + password).getBytes()));
log(auth);
URL url = new URL(server);
URLConnection conn = url.openConnection();
// this fails -- can't stop the auth window when the username/password are invalid
conn.setAllowUserInteraction(false);
conn.setRequestProperty("Authorization", "Basic " + auth);
monitor.beginTask("Authenticating: ", IProgressMonitor.UNKNOWN);
InputStream in = conn.getInputStream();
If the username & password are valid, then everything works fine. But if the username & password do not authenticate, Eclipse pops up its own "Password Required" window (which I don't want -- I want to manage the failed authentication myself). I would have thought that URLConnection.setAllowUserInteraction would stop this, but it has no effect.
Upvotes: 1
Views: 251