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>
This commit is contained in:
parent
308e074f65
commit
ce99b48384
|
@ -63,6 +63,23 @@
|
||||||
* @see UsernamePasswordCredentialsProvider
|
* @see UsernamePasswordCredentialsProvider
|
||||||
*/
|
*/
|
||||||
public abstract class CredentialsProvider {
|
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.
|
* Check if the provider can supply the necessary {@link CredentialItem}s.
|
||||||
*
|
*
|
||||||
|
|
|
@ -577,6 +577,7 @@ protected Transport(final Repository local, final URIish uri) {
|
||||||
this.local = local;
|
this.local = local;
|
||||||
this.uri = uri;
|
this.uri = uri;
|
||||||
this.checkFetchedObjects = tc.isFsckObjects();
|
this.checkFetchedObjects = tc.isFsckObjects();
|
||||||
|
this.credentialsProvider = CredentialsProvider.getDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue