diff --git a/hudson/src/org/netbeans/modules/hudson/ui/wizard/InstanceDialog.java b/hudson/src/org/netbeans/modules/hudson/ui/wizard/InstanceDialog.java --- a/hudson/src/org/netbeans/modules/hudson/ui/wizard/InstanceDialog.java +++ b/hudson/src/org/netbeans/modules/hudson/ui/wizard/InstanceDialog.java @@ -51,6 +51,7 @@ import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; +import java.net.URLConnection; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JButton; @@ -60,9 +61,11 @@ import org.netbeans.modules.hudson.api.UI; import org.netbeans.modules.hudson.impl.HudsonInstanceImpl; import org.netbeans.modules.hudson.api.Utilities; +import org.netbeans.modules.hudson.spi.ConnectionAuthenticator; import org.openide.DialogDescriptor; import org.openide.DialogDisplayer; import org.openide.NotifyDescriptor; +import org.openide.util.Lookup; import org.openide.util.NbBundle; import org.openide.util.RequestProcessor; @@ -108,6 +111,15 @@ try { URL u = new URL(panel.getUrl()); HttpURLConnection connection = new ConnectionBuilder().homeURL(u).url(new URL(u, "?checking=redirects")).httpConnection(); // NOI18N + for (ConnectionAuthenticator authenticator : Lookup.getDefault().lookupAll(ConnectionAuthenticator.class)) { // XXX conditionally! + URLConnection retry = authenticator.forbidden(connection, u); + if (retry != null) { + connection = (HttpURLConnection) retry; + authenticator.prepareRequest(retry, u); + break; + } + } + /* String sVersion = connection.getHeaderField("X-Hudson"); // NOI18N connection.disconnect(); if (sVersion == null) { @@ -123,6 +135,7 @@ problem(NbBundle.getMessage(InstanceDialog.class, "MSG_incorrect_redirects")); return; } + */ } catch (IOException x) { LOG.log(Level.INFO, null, x); problem(NbBundle.getMessage(InstanceDialog.class, "MSG_FailedToConnect"));