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 2020/02/23 18:50:49 UTC

[maven-wagon] branch WAGON-579 created (now 96118c9)

This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a change to branch WAGON-579
in repository https://gitbox.apache.org/repos/asf/maven-wagon.git.


      at 96118c9  [WAGON-579] Handle SC_UNAUTHORIZED and SC_PROXY_AUTHENTICATION_REQUIRED in all methods

This branch includes the following new commits:

     new 96118c9  [WAGON-579] Handle SC_UNAUTHORIZED and SC_PROXY_AUTHENTICATION_REQUIRED in all methods

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[maven-wagon] 01/01: [WAGON-579] Handle SC_UNAUTHORIZED and SC_PROXY_AUTHENTICATION_REQUIRED in all methods

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch WAGON-579
in repository https://gitbox.apache.org/repos/asf/maven-wagon.git

commit 96118c996e0f868f79294b6355ddba5c0c279639
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Sun Feb 23 19:50:25 2020 +0100

    [WAGON-579] Handle SC_UNAUTHORIZED and SC_PROXY_AUTHENTICATION_REQUIRED in all methods
---
 .../main/java/org/apache/maven/wagon/http/HttpWagonTestCase.java   | 4 ++--
 .../apache/maven/wagon/providers/http/LightweightHttpWagon.java    | 7 +++++--
 .../apache/maven/wagon/shared/http/AbstractHttpClientWagon.java    | 4 +++-
 3 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/wagon-provider-test/src/main/java/org/apache/maven/wagon/http/HttpWagonTestCase.java b/wagon-provider-test/src/main/java/org/apache/maven/wagon/http/HttpWagonTestCase.java
index a90f8f4..4680416 100644
--- a/wagon-provider-test/src/main/java/org/apache/maven/wagon/http/HttpWagonTestCase.java
+++ b/wagon-provider-test/src/main/java/org/apache/maven/wagon/http/HttpWagonTestCase.java
@@ -1810,7 +1810,7 @@ public abstract class HttpWagonTestCase
             runTestSecuredPut( null );
             fail();
         }
-        catch ( TransferFailedException e )
+        catch ( AuthorizationException e )
         {
             assertTrue( true );
         }
@@ -1827,7 +1827,7 @@ public abstract class HttpWagonTestCase
             runTestSecuredPut( authInfo );
             fail();
         }
-        catch ( TransferFailedException e )
+        catch ( AuthorizationException e )
         {
             assertTrue( true );
         }
diff --git a/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagon.java b/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagon.java
index d0f32eb..82981c9 100644
--- a/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagon.java
+++ b/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagon.java
@@ -170,7 +170,8 @@ public class LightweightHttpWagon
                 String reasonPhrase = urlConnection.getResponseMessage();
 
                 if ( responseCode == HttpURLConnection.HTTP_FORBIDDEN
-                        || responseCode == HttpURLConnection.HTTP_UNAUTHORIZED )
+                        || responseCode == HttpURLConnection.HTTP_UNAUTHORIZED
+                        || responseCode == HttpURLConnection.HTTP_PROXY_AUTH )
                 {
                     throw new AuthorizationException( formatAuthorizationMessage( buildUrl( resource ),
                             responseCode, reasonPhrase, getProxyInfo() ) );
@@ -276,8 +277,9 @@ public class LightweightHttpWagon
                 case HttpURLConnection.HTTP_NO_CONTENT: // 204
                     break;
 
-                // TODO: handle 401 explicitly?
                 case HttpURLConnection.HTTP_FORBIDDEN:
+                case HttpURLConnection.HTTP_UNAUTHORIZED:
+                case HttpURLConnection.HTTP_PROXY_AUTH:
                     throw new AuthorizationException( formatAuthorizationMessage( buildUrl( resource ), statusCode,
                             reasonPhrase, getProxyInfo() ) );
 
@@ -453,6 +455,7 @@ public class LightweightHttpWagon
                     return false;
 
                 case HttpURLConnection.HTTP_UNAUTHORIZED:
+                case HttpURLConnection.HTTP_PROXY_AUTH:
                     throw new AuthorizationException( "Access denied to: " + url );
 
                 default:
diff --git a/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/AbstractHttpClientWagon.java b/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/AbstractHttpClientWagon.java
index 4927525..81d56d5 100755
--- a/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/AbstractHttpClientWagon.java
+++ b/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/AbstractHttpClientWagon.java
@@ -793,8 +793,10 @@ public abstract class AbstractHttpClientWagon
                     case HttpStatus.SC_ACCEPTED: // 202
                     case HttpStatus.SC_NO_CONTENT:  // 204
                         break;
-                    //case HttpStatus.SC_UNAUTHORIZED:
+
                     case HttpStatus.SC_FORBIDDEN:
+                    case HttpStatus.SC_UNAUTHORIZED:
+                    case HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED:
                         EntityUtils.consumeQuietly( response.getEntity() );
                         fireSessionConnectionRefused();
                         throw new AuthorizationException( formatAuthorizationMessage( url,