Index: src/main/java/hudson/ProxyConfiguration.java =================================================================== --- src/main/java/hudson/ProxyConfiguration.java (revision 19358) +++ src/main/java/hudson/ProxyConfiguration.java (working copy) @@ -23,25 +23,34 @@ */ package hudson; -import com.thoughtworks.xstream.XStream; import hudson.model.Hudson; import hudson.model.Saveable; +import hudson.util.Scrambler; import hudson.util.XStream2; -import hudson.util.Scrambler; 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.URL; import java.net.URLConnection; -import java.net.URL; +import com.thoughtworks.xstream.XStream; + /** * HTTP proxy configuration. * *

* Use {@link #open(URL)} to open a connection with the proxy setting. - * + *

+ * 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 + * + * Http Authentication). + * * @see Hudson#proxy */ public final class ProxyConfiguration implements Saveable { @@ -101,8 +110,15 @@ 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; }