use of org.eclipse.jgit.errors.UnsupportedCredentialItem in project MGit by maks.
the class AndroidJschCredentialsProvider method get.
@Override
public boolean get(URIish uri, CredentialItem... items) throws UnsupportedCredentialItem {
Timber.w("get for uri %s", uri);
// FIXME: we will only handle the first *successfully* matched item
for (final CredentialItem item : items) {
if (item instanceof CredentialItem.StringType) {
Timber.w("need credential for: %s ", item.getPromptText());
// the getPromptText() will be "Passphrase for /.../files/ssh/key_file_name_rsa"
String prompt = item.getPromptText();
String keyfileName = prompt.substring(prompt.lastIndexOf("/") + 1, prompt.length());
String password = mSecPrefsHelper.get(keyfileName);
if (password != null) {
((CredentialItem.StringType) item).setValue(password);
return true;
}
}
}
return false;
}
Aggregations