|
org.netbeans.libs.git/1 1.1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.netbeans.libs.git.GitClientCallback
public abstract class GitClientCallback
Used as a callback to acquire user's credentials and ask caller about different questions during an inter-repository commands, e.g. fetch, push, clone. If an API client runs a git command that accesses a remote repository and the repository requires authentication then this is the class it should use to pass the credentials.
GitClient you want to run the fetch command with, see GitRepositoryGitClient.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); Listrefspecs = 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 Summary | |
|---|---|
GitClientCallback()
|
|
| Method Summary | |
|---|---|
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public GitClientCallback()
| Method Detail |
|---|
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 value
null 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 value
null 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 value
null if the authentication attempt should be halted.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 value
null 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 value
null if the authentication attempt should be halted.
|
org.netbeans.libs.git/1 1.1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||