Lines 51-56
Link Here
|
51 |
import java.io.IOException; |
51 |
import java.io.IOException; |
52 |
import java.net.HttpURLConnection; |
52 |
import java.net.HttpURLConnection; |
53 |
import java.net.URL; |
53 |
import java.net.URL; |
|
|
54 |
import java.net.URLConnection; |
54 |
import java.util.logging.Level; |
55 |
import java.util.logging.Level; |
55 |
import java.util.logging.Logger; |
56 |
import java.util.logging.Logger; |
56 |
import javax.swing.JButton; |
57 |
import javax.swing.JButton; |
Lines 60-68
Link Here
|
60 |
import org.netbeans.modules.hudson.api.UI; |
61 |
import org.netbeans.modules.hudson.api.UI; |
61 |
import org.netbeans.modules.hudson.impl.HudsonInstanceImpl; |
62 |
import org.netbeans.modules.hudson.impl.HudsonInstanceImpl; |
62 |
import org.netbeans.modules.hudson.api.Utilities; |
63 |
import org.netbeans.modules.hudson.api.Utilities; |
|
|
64 |
import org.netbeans.modules.hudson.spi.ConnectionAuthenticator; |
63 |
import org.openide.DialogDescriptor; |
65 |
import org.openide.DialogDescriptor; |
64 |
import org.openide.DialogDisplayer; |
66 |
import org.openide.DialogDisplayer; |
65 |
import org.openide.NotifyDescriptor; |
67 |
import org.openide.NotifyDescriptor; |
|
|
68 |
import org.openide.util.Lookup; |
66 |
import org.openide.util.NbBundle; |
69 |
import org.openide.util.NbBundle; |
67 |
import org.openide.util.RequestProcessor; |
70 |
import org.openide.util.RequestProcessor; |
68 |
|
71 |
|
Lines 108-113
Link Here
|
108 |
try { |
111 |
try { |
109 |
URL u = new URL(panel.getUrl()); |
112 |
URL u = new URL(panel.getUrl()); |
110 |
HttpURLConnection connection = new ConnectionBuilder().homeURL(u).url(new URL(u, "?checking=redirects")).httpConnection(); // NOI18N |
113 |
HttpURLConnection connection = new ConnectionBuilder().homeURL(u).url(new URL(u, "?checking=redirects")).httpConnection(); // NOI18N |
|
|
114 |
for (ConnectionAuthenticator authenticator : Lookup.getDefault().lookupAll(ConnectionAuthenticator.class)) { // XXX conditionally! |
115 |
URLConnection retry = authenticator.forbidden(connection, u); |
116 |
if (retry != null) { |
117 |
connection = (HttpURLConnection) retry; |
118 |
authenticator.prepareRequest(retry, u); |
119 |
break; |
120 |
} |
121 |
} |
122 |
/* |
111 |
String sVersion = connection.getHeaderField("X-Hudson"); // NOI18N |
123 |
String sVersion = connection.getHeaderField("X-Hudson"); // NOI18N |
112 |
connection.disconnect(); |
124 |
connection.disconnect(); |
113 |
if (sVersion == null) { |
125 |
if (sVersion == null) { |
Lines 123-128
Link Here
|
123 |
problem(NbBundle.getMessage(InstanceDialog.class, "MSG_incorrect_redirects")); |
135 |
problem(NbBundle.getMessage(InstanceDialog.class, "MSG_incorrect_redirects")); |
124 |
return; |
136 |
return; |
125 |
} |
137 |
} |
|
|
138 |
*/ |
126 |
} catch (IOException x) { |
139 |
} catch (IOException x) { |
127 |
LOG.log(Level.INFO, null, x); |
140 |
LOG.log(Level.INFO, null, x); |
128 |
problem(NbBundle.getMessage(InstanceDialog.class, "MSG_FailedToConnect")); |
141 |
problem(NbBundle.getMessage(InstanceDialog.class, "MSG_FailedToConnect")); |