diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2015-11-27 11:46:21 +0100 |
---|---|---|
committer | Christian Halstrick <christian.halstrick@sap.com> | 2015-12-15 12:49:08 +0100 |
commit | 2647d024afe7aac427ab37bba1655f2e54b257d5 (patch) | |
tree | 650808b91961ebf7b9050fbe1e0b221c0717192d /org.eclipse.jgit.pgm/META-INF | |
parent | 741829f1775a199514af7ca05d35ba39fd934668 (diff) | |
download | jgit-2647d024afe7aac427ab37bba1655f2e54b257d5.tar.gz jgit-2647d024afe7aac427ab37bba1655f2e54b257d5.zip |
Fix push with jgit pgm failing with "unauthorized"
Pushing with JGit commandline to e.g. Github failed with "unauthorized"
since HttpUrlConnection calls the configured authenticator implicitly.
The problem is that during a push two requests are sent to the server,
first a GET and then a POST (containing the pack data). The first GET
request sent anonymously is rejected with 401 (unauthorized). When an
Authenticator is installed the java.net classes will use the
Authenticator to ask the user for credentials and retry the request.
But this happens under the hood and JGit level code doesn't see that
this happens.
The next request is the POST but since JGit thinks the first GET request
went through anonymously it doesn't add authentication headers to the
POST request. This POST of course also fails with 401 but since this
request contains a lot of body-data streamed from JGit (the pack file!)
the java.net classes can't simply retry the request with authorization
headers. The whole process fails.
Fix this by using Apache httpclient which doesn't use Authenticator to
retrieve credentials. Instead initialize TransportCommand to use the
default credential provider if no other credentials provider was set
explicitly. org.eclipse.jgit.pgm.Main sets this default for the JGit
command line client.
Change-Id: Ic4e0f8b60d4bd6e69d91eae0c7e1b44cdf851b00
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.pgm/META-INF')
-rw-r--r-- | org.eclipse.jgit.pgm/META-INF/MANIFEST.MF | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/org.eclipse.jgit.pgm/META-INF/MANIFEST.MF b/org.eclipse.jgit.pgm/META-INF/MANIFEST.MF index 567fd05750..bd09e4e748 100644 --- a/org.eclipse.jgit.pgm/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit.pgm/META-INF/MANIFEST.MF @@ -7,7 +7,8 @@ Bundle-Vendor: %provider_name Bundle-ActivationPolicy: lazy Bundle-Localization: plugin Bundle-RequiredExecutionEnvironment: JavaSE-1.7 -Import-Package: org.apache.commons.compress.archivers;version="[1.3,2.0)", +Import-Package: org.apache.commons.codec.binary;version="[1.6.0,2.0.0)", + org.apache.commons.compress.archivers;version="[1.3,2.0)", org.apache.commons.compress.archivers.tar;version="[1.3,2.0)", org.apache.commons.compress.archivers.zip;version="[1.3,2.0)", org.eclipse.jgit.api;version="[4.2.0,4.3.0)", @@ -31,6 +32,7 @@ Import-Package: org.apache.commons.compress.archivers;version="[1.3,2.0)", org.eclipse.jgit.storage.file;version="[4.2.0,4.3.0)", org.eclipse.jgit.storage.pack;version="[4.2.0,4.3.0)", org.eclipse.jgit.transport;version="[4.2.0,4.3.0)", + org.eclipse.jgit.transport.http.apache;version="[4.2.0,4.3.0)", org.eclipse.jgit.transport.resolver;version="[4.2.0,4.3.0)", org.eclipse.jgit.treewalk;version="[4.2.0,4.3.0)", org.eclipse.jgit.treewalk.filter;version="[4.2.0,4.3.0)", |