[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
This commit is contained in:
kohsuke committed 2009-07-14 03:55:43 +00:00
1 parent da6ef8151d
commit 27042bbc4a
2 files changed
+22 -7

No files matched your search

@@ -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;
}