From afd167a1f26d140b7023972ddf85d12f3c9f9d8d Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Tue, 8 Dec 2015 14:11:43 +0100 Subject: [PATCH] NetRCCredentialsProvider should return false if any item is missing Change-Id: I894d1621aaccd71dfe100fe83a1bd9d50a1e0808 --- .../transport/ChainingCredentialsProvider.java | 7 ------- .../jgit/transport/CredentialsProvider.java | 14 ++++++++++++++ .../jgit/transport/NetRCCredentialsProvider.java | 3 +-- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ChainingCredentialsProvider.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ChainingCredentialsProvider.java index 5e1eb3c49..3941d3c55 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ChainingCredentialsProvider.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ChainingCredentialsProvider.java @@ -127,11 +127,4 @@ public class ChainingCredentialsProvider extends CredentialsProvider { } return false; } - - private boolean isAnyNull(CredentialItem... items) { - for (CredentialItem i : items) - if (i == null) - return true; - return false; - } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/CredentialsProvider.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/CredentialsProvider.java index 464d0f9ee..4800f6826 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/CredentialsProvider.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/CredentialsProvider.java @@ -80,6 +80,20 @@ public abstract class CredentialsProvider { defaultProvider = p; } + /** + * @param items + * credential items to check + * @return {@code true} if any of the passed items is null, {@code false} + * otherwise + * @since 4.2 + */ + protected static boolean isAnyNull(CredentialItem... items) { + for (CredentialItem i : items) + if (i == null) + return true; + return false; + } + /** * Check if the provider is interactive with the end-user. * diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/NetRCCredentialsProvider.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/NetRCCredentialsProvider.java index 74909998c..4037545e9 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/NetRCCredentialsProvider.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/NetRCCredentialsProvider.java @@ -105,12 +105,11 @@ public class NetRCCredentialsProvider extends CredentialsProvider { throw new UnsupportedCredentialItem(uri, i.getClass().getName() + ":" + i.getPromptText()); //$NON-NLS-1$ } - return true; + return !isAnyNull(items); } @Override public boolean isInteractive() { return false; } - }