continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From och...@apache.org
Subject svn commit: r1124681 - in /continuum/trunk: continuum-core/src/main/java/org/apache/maven/continuum/project/builder/AbstractContinuumProjectBuilder.java pom.xml
Date Thu, 19 May 2011 10:49:18 GMT
Author: oching
Date: Thu May 19 10:49:18 2011
New Revision: 1124681

URL: http://svn.apache.org/viewvc?rev=1124681&view=rev
Log:
[CONTINUUM-2627] 
o upgrade httpclient and httpcore to 4.1.1 and use pre-emptive authn if initial attempt to
get the pom metadata during project add failed

Modified:
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/AbstractContinuumProjectBuilder.java
    continuum/trunk/pom.xml

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/AbstractContinuumProjectBuilder.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/AbstractContinuumProjectBuilder.java?rev=1124681&r1=1124680&r2=1124681&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/AbstractContinuumProjectBuilder.java
(original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/AbstractContinuumProjectBuilder.java
Thu May 19 10:49:18 2011
@@ -32,22 +32,28 @@ import java.net.UnknownHostException;
 
 import org.apache.commons.io.IOUtils;
 import org.apache.http.HttpException;
+import org.apache.http.HttpHost;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpVersion;
 import org.apache.http.auth.AuthScope;
 import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.client.AuthCache;
 import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.protocol.ClientContext;
 import org.apache.http.conn.ClientConnectionManager;
 import org.apache.http.conn.params.ConnManagerPNames;
 import org.apache.http.conn.params.ConnPerRouteBean;
 import org.apache.http.conn.scheme.PlainSocketFactory;
 import org.apache.http.conn.scheme.Scheme;
 import org.apache.http.conn.scheme.SchemeRegistry;
+import org.apache.http.impl.auth.BasicScheme;
+import org.apache.http.impl.client.BasicAuthCache;
 import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
 import org.apache.http.params.BasicHttpParams;
 import org.apache.http.params.HttpParams;
 import org.apache.http.params.HttpProtocolParams;
+import org.apache.http.protocol.BasicHttpContext;
 import org.apache.http.util.EntityUtils;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
@@ -119,11 +125,31 @@ public abstract class AbstractContinuumP
                                                                                         
            password ) );
             }
 
+            // basic auth
             HttpResponse httpResponse = httpClient.execute( httpGet );
 
-            // basic auth 
+            // CONTINUUM-2627
+            if( httpResponse.getStatusLine().getStatusCode() != 200 )
+            {
+                log.debug( "Initial attempt did not return a 200 status code. Trying pre-emptive
authentication.." );
+
+                HttpHost targetHost = new HttpHost( uri.getHost(), uri.getPort(), uri.getScheme()
);
+
+                // Create AuthCache instance
+                AuthCache authCache = new BasicAuthCache();
+                // Generate BASIC scheme object and add it to the local auth cache
+                BasicScheme basicAuth = new BasicScheme();
+                authCache.put(targetHost, basicAuth);
+
+                // Add AuthCache to the execution context
+                BasicHttpContext localcontext = new BasicHttpContext();
+                localcontext.setAttribute( ClientContext.AUTH_CACHE, authCache);
+
+                httpResponse = httpClient.execute( targetHost, httpGet, localcontext );
+            }
 
             int res = httpResponse.getStatusLine().getStatusCode();
+
             switch ( res )
             {
                 case 200:

Modified: continuum/trunk/pom.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/pom.xml?rev=1124681&r1=1124680&r2=1124681&view=diff
==============================================================================
--- continuum/trunk/pom.xml (original)
+++ continuum/trunk/pom.xml Thu May 19 10:49:18 2011
@@ -977,12 +977,12 @@ under the License.
       <dependency>
         <groupId>org.apache.httpcomponents</groupId>
         <artifactId>httpcore</artifactId>
-        <version>4.0-beta3</version>
+        <version>4.1.1</version>
       </dependency>    
       <dependency>
         <groupId>org.apache.httpcomponents</groupId>
         <artifactId>httpclient</artifactId>
-        <version>4.0-beta2</version>
+        <version>4.1.1</version>
         <exclusions>
           <exclusion>
             <groupId>commons-logging</groupId>



Mime
View raw message