[ 
https://issues.apache.org/jira/browse/WAGON-538?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16687621#comment-16687621
 ] 

ASF GitHub Bot commented on WAGON-538:
--------------------------------------

aleksgj closed pull request #52: [MNG-6514] Adding support for encoding basic 
auth credentials with UT…
URL: https://github.com/apache/maven-wagon/pull/52
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 9f294f7e..2ccc4793 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
@@ -19,12 +19,14 @@
  * under the License.
  */
 
+import org.apache.http.Consts;
 import org.apache.http.Header;
 import org.apache.http.HttpEntity;
 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.AuthSchemeProvider;
 import org.apache.http.auth.AuthScope;
 import org.apache.http.auth.ChallengeState;
 import org.apache.http.auth.Credentials;
@@ -33,6 +35,7 @@
 import org.apache.http.client.AuthCache;
 import org.apache.http.client.CredentialsProvider;
 import org.apache.http.client.HttpRequestRetryHandler;
+import org.apache.http.client.config.AuthSchemes;
 import org.apache.http.client.config.CookieSpecs;
 import org.apache.http.client.config.RequestConfig;
 import org.apache.http.client.methods.CloseableHttpResponse;
@@ -52,6 +55,7 @@
 import org.apache.http.conn.ssl.SSLInitializationException;
 import org.apache.http.entity.AbstractHttpEntity;
 import org.apache.http.impl.auth.BasicScheme;
+import org.apache.http.impl.auth.BasicSchemeFactory;
 import org.apache.http.impl.client.BasicAuthCache;
 import org.apache.http.impl.client.BasicCredentialsProvider;
 import org.apache.http.impl.client.CloseableHttpClient;
@@ -439,6 +443,13 @@ private static HttpRequestRetryHandler createRetryHandler()
         }
     }
 
+    private static Registry<AuthSchemeProvider> createAuthSchemeRegistry()
+    {
+        return RegistryBuilder.<AuthSchemeProvider>create()
+                .register( AuthSchemes.BASIC, new BasicSchemeFactory( 
Consts.UTF_8 ) )
+                .build();
+    }
+
     private static Collection<Class<? extends IOException>> 
getNonRetryableExceptions()
     {
         final List<Class<? extends IOException>> exceptions = new 
ArrayList<>();
@@ -466,6 +477,7 @@ private static CloseableHttpClient createClient()
             .disableConnectionState() //
             .setConnectionManager( httpClientConnectionManager ) //
             .setRetryHandler( createRetryHandler() )
+            .setDefaultAuthSchemeRegistry( createAuthSchemeRegistry() )
             .build();
     }
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> Basic authentication fails if the password contains non-ASCII characters
> ------------------------------------------------------------------------
>
>                 Key: WAGON-538
>                 URL: https://issues.apache.org/jira/browse/WAGON-538
>             Project: Maven Wagon
>          Issue Type: Bug
>          Components: wagon-http
>    Affects Versions: 3.2.0
>            Reporter: Aleksander Gjermundsen
>            Assignee: Michael Osipov
>            Priority: Major
>             Fix For: 3.3.0
>
>
> If the username and/or password used to authenticate to Nexus contains 
> non-ascii characters, the authentication fails with an access denied error. 
> After using Wireshark to investigate the headers being sent (in my case "Ø", 
> any non-ascii characters are replaced with "?".
> To test, I have used the following configuration:
> {code:java}
> <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0";
>  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 
> http://maven.apache.org/xsd/settings-1.0.0.xsd";>
> ...
>     <servers>
>         <server>
>             <id>artifactory</id>
>             <username>userØ</username>
>             <password>userØ</password>
>         </server>
>     </servers>
>     ...
>     <mirrors>
>         <mirror>
>             <id>nexus</id>
>             <mirrorOf>*</mirrorOf>
>             <name>Local Nexus</name>
>             <url>http://localhost:8081/repository/maven-public</url>
>         </mirror>
>     </mirrors>
> ...
> </settings>{code}
> The settings.xml file is saved using UTF-8 encoding and it appears that Maven 
> reads the username and passwords correctly into strings, but Apache 
> HttpClient do not encode the UTF-8 characters when encoding them into base64.
> I did a quick patch of Wagon to make it work for my use case, where 
> HttpClient is configured to encode as UTF-8. As is mentioned in MNG-5917, it 
> is not completely clear from the standards how these characters are supposed 
> to be handled, but on my system both wget and the Chrome web browser encode 
> the characters the same way as after my patch and are able to download files 
> from Nexus.
> Since Artifactory was used in MNG-5917, I also tested against that, but in 
> contrast to Maven it was not able to decode the username and password 
> correctly, however it would be broken without the patch anyway.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to