Browse Source

[cli] Use chaining credentials provider to enable .netrc

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>
tags/v3.5.0.201409260305-r
Matthias Sohn 9 years ago
parent
commit
00802b6317

+ 5
- 1
org.eclipse.jgit.console/src/org/eclipse/jgit/console/ConsoleCredentialsProvider.java View File

import java.io.Console; import java.io.Console;


import org.eclipse.jgit.errors.UnsupportedCredentialItem; import org.eclipse.jgit.errors.UnsupportedCredentialItem;
import org.eclipse.jgit.transport.ChainingCredentialsProvider;
import org.eclipse.jgit.transport.CredentialItem; import org.eclipse.jgit.transport.CredentialItem;
import org.eclipse.jgit.transport.CredentialsProvider; import org.eclipse.jgit.transport.CredentialsProvider;
import org.eclipse.jgit.transport.NetRCCredentialsProvider;
import org.eclipse.jgit.transport.URIish; import org.eclipse.jgit.transport.URIish;


/** Interacts with the user during authentication by using the text console. */ /** Interacts with the user during authentication by using the text console. */
if (c.cons == null) if (c.cons == null)
throw new NoClassDefFoundError( throw new NoClassDefFoundError(
ConsoleText.get().noSystemConsoleAvailable); ConsoleText.get().noSystemConsoleAvailable);
CredentialsProvider.setDefault(c);
CredentialsProvider cp = new ChainingCredentialsProvider(
new NetRCCredentialsProvider(), c);
CredentialsProvider.setDefault(cp);
} }


private final Console cons = System.console(); private final Console cons = System.console();

Loading…
Cancel
Save