use of bndtools.bndplugins.repo.git.GitOBRRepo.Mapping in project bndtools by bndtools.
the class GitCredentialsProvider method get.
@Override
public boolean get(URIish uri, CredentialItem... items) throws UnsupportedCredentialItem {
Mapping mapping = repo.findMapping(uri.toString());
if (mapping != null) {
for (CredentialItem item : items) {
if (item instanceof CredentialItem.Username) {
((CredentialItem.Username) item).setValue(mapping.user);
continue;
}
if (item instanceof CredentialItem.Password) {
((CredentialItem.Password) item).setValue(mapping.pass);
continue;
}
// Usually Passphrase
if (item instanceof CredentialItem.StringType && item.isValueSecure()) {
((CredentialItem.StringType) item).setValue(new String(mapping.pass));
continue;
}
}
return true;
}
if (isInteractive()) {
JComponent[] inputs = getSwingUI(items);
int result = JOptionPane.showConfirmDialog(null, inputs, "Enter credentials for " + repo.getName(), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
if (result != JOptionPane.OK_OPTION) {
return false;
}
updateCredentialItems(inputs);
return true;
}
return false;
}
Aggregations