]> source.dussan.org Git - jgit.git/commitdiff
[cli] Use chaining credentials provider to enable .netrc 99/33799/3
authorMatthias Sohn <matthias.sohn@sap.com>
Tue, 23 Sep 2014 22:06:48 +0000 (00:06 +0200)
committerMatthias Sohn <matthias.sohn@sap.com>
Wed, 24 Sep 2014 13:27:36 +0000 (15:27 +0200)
If available use credentials in .netrc otherwise prompt the user
if jgit command line needs credentials for remote operations.

Change-Id: Iea1f595618edfb87a37137db08bac8ca2d500ebc
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit.console/src/org/eclipse/jgit/console/ConsoleCredentialsProvider.java

index 91034fd2cc86d5130f39f423fb8d088f9cf8375e..a01fd86b4d28ca7360b02ed72a5cd41d68fe6068 100644 (file)
@@ -48,8 +48,10 @@ package org.eclipse.jgit.console;
 import java.io.Console;
 
 import org.eclipse.jgit.errors.UnsupportedCredentialItem;
+import org.eclipse.jgit.transport.ChainingCredentialsProvider;
 import org.eclipse.jgit.transport.CredentialItem;
 import org.eclipse.jgit.transport.CredentialsProvider;
+import org.eclipse.jgit.transport.NetRCCredentialsProvider;
 import org.eclipse.jgit.transport.URIish;
 
 /** Interacts with the user during authentication by using the text console. */
@@ -60,7 +62,9 @@ public class ConsoleCredentialsProvider extends CredentialsProvider {
                if (c.cons == null)
                        throw new NoClassDefFoundError(
                                        ConsoleText.get().noSystemConsoleAvailable);
-               CredentialsProvider.setDefault(c);
+               CredentialsProvider cp = new ChainingCredentialsProvider(
+                               new NetRCCredentialsProvider(), c);
+               CredentialsProvider.setDefault(cp);
        }
 
        private final Console cons = System.console();