From: Robin Rosenberg Date: Thu, 5 Apr 2012 06:04:45 +0000 (+0200) Subject: UnsupportedCredentialItem with password authentication X-Git-Tag: v2.0.0.201205301645-rc2~37^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2047eaa4c2206782bf07550cde435e5e4b3721c8;p=jgit.git UnsupportedCredentialItem with password authentication If the server prompts for password, it comes as a StringType prompt. Bug: 360862 Change-Id: Ic758456c21c8d68d1b3d7f56228beb7535b11735 --- diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UsernamePasswordCredentialsProvider.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UsernamePasswordCredentialsProvider.java index 235e4b4b97..db4ac63851 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UsernamePasswordCredentialsProvider.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UsernamePasswordCredentialsProvider.java @@ -100,14 +100,23 @@ public class UsernamePasswordCredentialsProvider extends CredentialsProvider { public boolean get(URIish uri, CredentialItem... items) throws UnsupportedCredentialItem { for (CredentialItem i : items) { - if (i instanceof CredentialItem.Username) + if (i instanceof CredentialItem.Username) { ((CredentialItem.Username) i).setValue(username); - - else if (i instanceof CredentialItem.Password) + continue; + } + if (i instanceof CredentialItem.Password) { ((CredentialItem.Password) i).setValue(password); - - else - throw new UnsupportedCredentialItem(uri, i.getPromptText()); + continue; + } + if (i instanceof CredentialItem.StringType) { + if (i.getPromptText().equals("Password: ")) { + ((CredentialItem.StringType) i).setValue(new String( + password)); + continue; + } + } + throw new UnsupportedCredentialItem(uri, i.getClass().getName() + + ":" + i.getPromptText()); } return true; }