You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by ma...@apache.org on 2010/05/27 23:56:55 UTC
svn commit: r949015 - in /ant/ivy/core/trunk: CHANGES.txt
src/java/org/apache/ivy/util/url/HttpClientHandler.java
Author: maartenc
Date: Thu May 27 21:56:54 2010
New Revision: 949015
URL: http://svn.apache.org/viewvc?rev=949015&view=rev
Log:
FIX: Proxy authentication could fail when using commons-httpclient
Modified:
ant/ivy/core/trunk/CHANGES.txt
ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/HttpClientHandler.java
Modified: ant/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=949015&r1=949014&r2=949015&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Thu May 27 21:56:54 2010
@@ -125,6 +125,7 @@ for detailed view of each issue, please
- IMPROVEMENT: Trace a message when a property file referenced from the settings doesn't exixts (IVY-1074)
- IMPROVEMENT: use defaultconf in combination with defaultconfmapping (IVY-1135) (thanks to Jon Schneider)
+- FIX: Proxy authentication could fail when using commons-httpclient
- FIX: Packager resolver always extracts all files from archives even when the packaging instructions contains include tags (IVY-1179) (thanks to Stefan De Boey)
- FIX: Ivy cannot connect to URLs with '_' in their hostname
- FIX: Transitive dependencies resolutions issue when eviction is triggered (IVY-1178)
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/HttpClientHandler.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/HttpClientHandler.java?rev=949015&r1=949014&r2=949015&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/HttpClientHandler.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/HttpClientHandler.java Thu May 27 21:56:54 2010
@@ -62,8 +62,6 @@ public class HttpClientHandler extends A
// proxy configuration: obtain from system properties
private int proxyPort;
- private String proxyRealm = null;
-
private String proxyHost = null;
private String proxyUserName = null;
@@ -79,8 +77,6 @@ public class HttpClientHandler extends A
}
private void configureProxy() {
- proxyRealm = System.getProperty("http.auth.ntlm.domain");
- // no equivalent for realm in jdk proxy support ?
proxyHost = System.getProperty("http.proxyHost");
// TODO constant is better ...
if (useProxy()) {
@@ -285,19 +281,17 @@ public class HttpClientHandler extends A
if (useProxyAuthentication()) {
httpClient.getState().setProxyCredentials(
new AuthScope(proxyHost, proxyPort, AuthScope.ANY_REALM),
- new NTCredentials(proxyUserName, proxyPasswd,
- HostUtil.getLocalHostName(), proxyRealm));
+ createCredentials(proxyUserName, proxyPasswd));
}
}
// user-agent
httpClient.getParams().setParameter("http.useragent",
"Apache Ivy/" + Ivy.getIvyVersion());
- }
- if (useAuthentication(url)) {
+ // authentication
httpClient.getParams().setParameter(CredentialsProvider.PROVIDER,
- new IvyCredentialsProvider());
+ new IvyCredentialsProvider());
}
return httpClient;
@@ -434,12 +428,26 @@ public class HttpClientHandler extends A
org.apache.ivy.util.Credentials c = (org.apache.ivy.util.Credentials)
CredentialsStore.INSTANCE.getCredentials(realm, host);
if (c != null) {
- return new NTCredentials(c.getUserName(), c.getPasswd(),
- HostUtil.getLocalHostName(), c.getRealm());
+ return createCredentials(c.getUserName(), c.getPasswd());
}
return null;
}
-
+ }
+
+ private static Credentials createCredentials(String username, String password) {
+ String user;
+ String domain;
+
+ int backslashIndex = username.indexOf('\\');
+ if (backslashIndex >= 0) {
+ user = username.substring(backslashIndex + 1);
+ domain = username.substring(0, backslashIndex);
+ } else {
+ user = username;
+ domain = System.getProperty("http.auth.ntlm.domain", "");
+ }
+
+ return new NTCredentials(user, password, HostUtil.getLocalHostName(), domain);
}
}