public abstract class GitClientCallback extends Object
How to use this class
GitClient
you want to run the fetch command with, see GitRepository
GitClient.setCallback(org.netbeans.libs.git.GitClientCallback)
GitClient.fetch(java.lang.String, org.netbeans.libs.git.progress.ProgressMonitor)
getUsername
and getPassword
will be called from within the client
so make sure they return the correct credentialsGitClient client =GitRepository.getInstance(myLocalReposiry)
.createClient()
; GitClientCallback myCallback =new GitClientCallback ()
{ public String askQuestion (String uri, String prompt) { return null; } public String getUsername (String uri, String prompt) { return "username"; } public char[] getPassword (String uri, String prompt) { return "password".toCharArray(); } public char[] getPassphrase (String uri, String prompt) { return null; } public String getIdentityFile (String uri, String prompt); public Boolean askYesNoQuestion (String uri, String prompt); }; client.setCallback(myCallback)
;List<String>
refspecs = Arrays.asList("refs/heads/*:refs/remotes/origin/*"); client.fetch("http://myrepositoryhost/path", refspecs, pm);}
Also note that returning null
from the implemented methods means that you want to cancel the authentication attempt.
Constructor and Description |
---|
GitClientCallback() |
Modifier and Type | Method and Description |
---|---|
abstract String |
askQuestion(String uri,
String prompt)
Through this method you are asked a question you should answer.
|
abstract Boolean |
askYesNoQuestion(String uri,
String prompt)
Through this method you are asked a question you should answer Yes or No.
|
abstract String |
getIdentityFile(String uri,
String prompt)
If the authentication should be done via a private/public key pair instead of usual username/password,
implement this method and return the absolute path to the file with the private key.
|
abstract char[] |
getPassphrase(String uri,
String prompt)
Implement this to pass the passphrase to unlock the private key.
|
abstract char[] |
getPassword(String uri,
String prompt)
Implement this to pass the user's password to the authentication process.
|
abstract String |
getUsername(String uri,
String prompt)
You should implement this to pass a username required by the authentication process.
|
public abstract String askQuestion(String uri, String prompt)
uri
- URI of a host you are trying to connect to.prompt
- a question asked by the system that needs answering.null
if the authentication attempt should be halted.public abstract String getUsername(String uri, String prompt)
uri
- URI of a host you are trying to connect to.prompt
- explanation of what is expected as the return valuenull
if the authentication attempt should be halted.public abstract char[] getPassword(String uri, String prompt)
uri
- URI of a host you are trying to connect to.prompt
- explanation of what is expected as the return valuenull
if the authentication attempt should be halted.public abstract char[] getPassphrase(String uri, String prompt)
uri
- URI of a host you are trying to connect to.prompt
- explanation of what is expected as the return valuenull
if the authentication attempt should be halted.GitClientCallback.getIdentityFile(java.lang.String, java.lang.String)
public abstract String getIdentityFile(String uri, String prompt)
uri
- URI of a host you are trying to connect to.prompt
- explanation of what is expected as the return valuenull
if the authentication attempt should be halted.public abstract Boolean askYesNoQuestion(String uri, String prompt)
uri
- URI of a host you are trying to connect to.prompt
- explanation of what is expected as the return valuenull
if the authentication attempt should be halted.