]> source.dussan.org Git - jgit.git/commitdiff
UnsupportedCredentialItem with password authentication 29/5529/2
authorRobin Rosenberg <robin.rosenberg@dewire.com>
Thu, 5 Apr 2012 06:04:45 +0000 (08:04 +0200)
committerRobin Rosenberg <robin.rosenberg@dewire.com>
Mon, 9 Apr 2012 14:34:40 +0000 (16:34 +0200)
If the server prompts for password, it comes as a StringType prompt.

Bug: 360862
Change-Id: Ic758456c21c8d68d1b3d7f56228beb7535b11735

org.eclipse.jgit/src/org/eclipse/jgit/transport/UsernamePasswordCredentialsProvider.java

index 235e4b4b971ddcf3f50b6f5762626821e4b3ec4a..db4ac63851120dd0ab2ff99ee2b3ea72432ed831 100644 (file)
@@ -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;
        }