Search in sources :

Example 1 with Mapping

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;
}
Also used : JComponent(javax.swing.JComponent) CredentialItem(org.eclipse.jgit.transport.CredentialItem) UnsupportedCredentialItem(org.eclipse.jgit.errors.UnsupportedCredentialItem) Mapping(bndtools.bndplugins.repo.git.GitOBRRepo.Mapping)

Aggregations

Mapping (bndtools.bndplugins.repo.git.GitOBRRepo.Mapping)1 JComponent (javax.swing.JComponent)1 UnsupportedCredentialItem (org.eclipse.jgit.errors.UnsupportedCredentialItem)1 CredentialItem (org.eclipse.jgit.transport.CredentialItem)1