diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2010-11-10 14:15:50 -0800 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2010-11-10 14:58:45 -0800 |
commit | ce99b48384bd7a7ee42942653b5659787d3f1d48 (patch) | |
tree | 44d59023e04f787bbe84745556929220c043ded6 /org.eclipse.jgit | |
parent | 308e074f6570c6a12272db994b095b38a0c922f8 (diff) | |
download | jgit-ce99b48384bd7a7ee42942653b5659787d3f1d48.tar.gz jgit-ce99b48384bd7a7ee42942653b5659787d3f1d48.zip |
Define a default CredentialsProvider
This permits applications to set their preferred credentials UI
implementation once, rather than needing to define it on every
single Transport instance they open.
Change-Id: I010550de1a6becab27f7aa5a9901df5a1c7e74bd
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/transport/CredentialsProvider.java | 17 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java | 1 |
2 files changed, 18 insertions, 0 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/CredentialsProvider.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/CredentialsProvider.java index d2130ad30f..ca83c69042 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/CredentialsProvider.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/CredentialsProvider.java @@ -63,6 +63,23 @@ import org.eclipse.jgit.errors.UnsupportedCredentialItem; * @see UsernamePasswordCredentialsProvider */ public abstract class CredentialsProvider { + private static volatile CredentialsProvider defaultProvider; + + /** @return the default credentials provider, or null. */ + public static CredentialsProvider getDefault() { + return defaultProvider; + } + + /** + * Set the default credentials provider. + * + * @param p + * the new default provider, may be null to select no default. + */ + public static void setDefault(CredentialsProvider p) { + defaultProvider = p; + } + /** * Check if the provider can supply the necessary {@link CredentialItem}s. * diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java index 5895f7f37f..69eea0c223 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java @@ -577,6 +577,7 @@ public abstract class Transport { this.local = local; this.uri = uri; this.checkFetchedObjects = tc.isFsckObjects(); + this.credentialsProvider = CredentialsProvider.getDefault(); } /** |