]> source.dussan.org Git - jgit.git/commitdiff
Ensure that stored credentials aren't reset too early 23/24923/1
authorMatthias Sohn <matthias.sohn@sap.com>
Wed, 26 Mar 2014 22:16:36 +0000 (23:16 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Sun, 13 Apr 2014 22:42:05 +0000 (00:42 +0200)
Some commands are started without showing a dialog allowing to enter
credentials if needed. Hence we need to tolerate one failing HTTP
authentication to trigger loading credentials from the secure store.
Hence we should not immediately reset the stored credentials if the
first attempt to authenticate fails.

Bug: 431209
Change-Id: I1b9fa34c3d70be226bb1c59c9ebe995998d29bc8
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java

index 5885e7b528617916f7e5a267196890a57df9558c..83ad971f787d27b4c51dde473fa9e391fcbeeb1b 100644 (file)
@@ -472,13 +472,13 @@ public class TransportHttp extends HttpTransport implements WalkTransport,
                                                throw new TransportException(uri, MessageFormat.format(
                                                                JGitText.get().authenticationNotSupported, uri));
                                        CredentialsProvider credentialsProvider = getCredentialsProvider();
+                                       if (authAttempts > 1)
+                                               credentialsProvider.reset(uri);
                                        if (3 < authAttempts
                                                        || !authMethod.authorize(uri, credentialsProvider)) {
-                                               credentialsProvider.reset(uri);
                                                throw new TransportException(uri,
                                                                JGitText.get().notAuthorized);
                                        }
-                                       credentialsProvider.reset(uri);
                                        authAttempts++;
                                        continue;