You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2017/01/03 20:35:35 UTC
[3/5] maven-wagon git commit: [WAGON-479] Preemptive auth with HTTP
Provider may fail because BasicScheme is added as completed=true to the
AuthCache
[WAGON-479] Preemptive auth with HTTP Provider may fail because BasicScheme is added as completed=true to the AuthCache
Project: http://git-wip-us.apache.org/repos/asf/maven-wagon/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-wagon/commit/bb77d508
Tree: http://git-wip-us.apache.org/repos/asf/maven-wagon/tree/bb77d508
Diff: http://git-wip-us.apache.org/repos/asf/maven-wagon/diff/bb77d508
Branch: refs/heads/jetty-8
Commit: bb77d50855498613874fea3d54317c75b745298c
Parents: 0ea3949
Author: Michael Osipov <mi...@apache.org>
Authored: Tue Dec 27 23:29:26 2016 +0100
Committer: Michael Osipov <mi...@apache.org>
Committed: Tue Jan 3 21:35:04 2017 +0100
----------------------------------------------------------------------
.../providers/http/AbstractHttpClientWagon.java | 45 +++++---------------
1 file changed, 11 insertions(+), 34 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven-wagon/blob/bb77d508/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/AbstractHttpClientWagon.java
----------------------------------------------------------------------
diff --git a/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/AbstractHttpClientWagon.java b/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/AbstractHttpClientWagon.java
index 7773d97..d38506f 100755
--- a/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/AbstractHttpClientWagon.java
+++ b/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/AbstractHttpClientWagon.java
@@ -25,10 +25,9 @@ import org.apache.http.HttpException;
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
-import org.apache.http.auth.AUTH;
import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.ChallengeState;
import org.apache.http.auth.Credentials;
-import org.apache.http.auth.MalformedChallengeException;
import org.apache.http.auth.NTCredentials;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.AuthCache;
@@ -460,9 +459,9 @@ public abstract class AbstractHttpClientWagon
creds = new UsernamePasswordCredentials( proxyUsername, proxyPassword );
}
- int port = proxyInfo.getPort();
+ int proxyPort = proxyInfo.getPort();
- AuthScope authScope = getProxyBasicAuthScope().getScope( proxyHost, port );
+ AuthScope authScope = getProxyBasicAuthScope().getScope( proxyHost, proxyPort );
credentialsProvider.setCredentials( authScope, creds );
}
}
@@ -576,15 +575,7 @@ public abstract class AbstractHttpClientWagon
if ( credentialsProvider.getCredentials( targetScope ) != null )
{
BasicScheme targetAuth = new BasicScheme();
- try
- {
- targetAuth.processChallenge( new BasicHeader( AUTH.WWW_AUTH, "BASIC preemptive" ) );
- authCache.put( targetHost, targetAuth );
- }
- catch ( MalformedChallengeException ignore )
- {
- // ignore
- }
+ authCache.put( targetHost, targetAuth );
}
HttpPut putMethod = new HttpPut( url );
@@ -807,7 +798,6 @@ public abstract class AbstractHttpClientWagon
if ( credentialsProvider.getCredentials( targetScope ) != null )
{
BasicScheme targetAuth = new BasicScheme();
- targetAuth.processChallenge( new BasicHeader( AUTH.WWW_AUTH, "BASIC preemptive" ) );
authCache.put( targetHost, targetAuth );
}
}
@@ -819,26 +809,13 @@ public abstract class AbstractHttpClientWagon
HttpHost proxyHost = new HttpHost( proxyInfo.getHost(), proxyInfo.getPort() );
AuthScope proxyScope = getProxyBasicAuthScope().getScope( proxyHost );
- String proxyUsername = proxyInfo.getUserName();
- String proxyPassword = proxyInfo.getPassword();
- String proxyNtlmHost = proxyInfo.getNtlmHost();
- String proxyNtlmDomain = proxyInfo.getNtlmDomain();
-
- if ( proxyUsername != null && proxyPassword != null )
+ if ( credentialsProvider.getCredentials( proxyScope ) != null )
{
- Credentials creds;
- if ( proxyNtlmHost != null || proxyNtlmDomain != null )
- {
- creds = new NTCredentials( proxyUsername, proxyPassword, proxyNtlmHost, proxyNtlmDomain );
- }
- else
- {
- creds = new UsernamePasswordCredentials( proxyUsername, proxyPassword );
- }
-
- credentialsProvider.setCredentials( proxyScope, creds );
- BasicScheme proxyAuth = new BasicScheme();
- proxyAuth.processChallenge( new BasicHeader( AUTH.PROXY_AUTH, "BASIC preemptive" ) );
+ /* This is extremely ugly because we need to set challengeState to PROXY, but
+ * the constructor is deprecated. Alternatively, we could subclass BasicScheme
+ * to ProxyBasicScheme and set the state internally in the constructor.
+ */
+ BasicScheme proxyAuth = new BasicScheme( ChallengeState.PROXY );
authCache.put( proxyHost, proxyAuth );
}
}
@@ -1158,4 +1135,4 @@ public abstract class AbstractHttpClientWagon
{
return MAX_BACKOFF_WAIT_SECONDS;
}
-}
\ No newline at end of file
+}