提交 27042bbc 编写于 作者: K kohsuke

[FIXED HUDSON-1920] Applied a patch. In 1.316.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@19683 71c3de6d-444a-0410-be80-ed276b4c234a
上级 da6ef815
......@@ -23,25 +23,34 @@
*/
package hudson;
import com.thoughtworks.xstream.XStream;
import hudson.model.Hudson;
import hudson.model.Saveable;
import hudson.util.XStream2;
import hudson.util.Scrambler;
import hudson.util.XStream2;
import java.io.File;
import java.io.IOException;
import java.net.Authenticator;
import java.net.InetSocketAddress;
import java.net.PasswordAuthentication;
import java.net.Proxy;
import java.net.URLConnection;
import java.net.URL;
import java.net.URLConnection;
import com.thoughtworks.xstream.XStream;
/**
* HTTP proxy configuration.
*
* <p>
* Use {@link #open(URL)} to open a connection with the proxy setting.
*
* <p>
* Proxy authentication (including NTLM) is implemented by setting a default
* {@link Authenticator} which provides a {@link PasswordAuthentication}
* (as described in the Java 6 tech note
* <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/http-auth.html">
* Http Authentication</a>).
*
* @see Hudson#proxy
*/
public final class ProxyConfiguration implements Saveable {
......@@ -101,8 +110,14 @@ public final class ProxyConfiguration implements Saveable {
URLConnection con = url.openConnection(p.createProxy());
if(p.getUserName()!=null) {
con.setRequestProperty("Proxy-Authorization","Basic "+
Scrambler.scramble(p.getUserName()+':'+p.getPassword()));
// Add an authenticator which provides the credentials for proxy authentication
Authenticator.setDefault(new Authenticator() {
public PasswordAuthentication getPasswordAuthentication() {
ProxyConfiguration p = Hudson.getInstance().proxy;
return new PasswordAuthentication(p.getUserName(),
p.getPassword().toCharArray());
}
});
}
return con;
}
......
......@@ -45,7 +45,7 @@ THE SOFTWARE.
<f:textbox name="proxy.port" value="${app.proxy.port}" />
</f:entry>
</f:block>
<f:entry title="${%User name}">
<f:entry title="${%User name}" help="/help/update-center/proxy-username.html>
<f:textbox name="proxy.userName" value="${app.proxy.userName}" />
</f:entry>
<f:entry title="${%Password}">
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册