Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn2014-03-15 20:45:27 -0400
committerMatthias Sohn2014-03-24 09:14:08 -0400
commitb5a2d497ae44fa7ba99a93bb31fc2f0c7c8b7304 (patch)
tree55fbd6f1eee47625959b282886d96f5649cbdbcc
parentbba4e7ff4321b0748d4687e0d40bbf23de5a81d3 (diff)
downloadegit-b5a2d497ae44fa7ba99a93bb31fc2f0c7c8b7304.tar.gz
egit-b5a2d497ae44fa7ba99a93bb31fc2f0c7c8b7304.tar.xz
egit-b5a2d497ae44fa7ba99a93bb31fc2f0c7c8b7304.zip
Always configure credentials provider for remote operations
This ensures that credentials are requested from the user or loaded from the secure store if the remote repository requires authentication for a remote operation. Bug: 338048 Bug: 339220 Bug: 342592 Bug: 427735 Change-Id: I8cbea42368d20657615b1b847e215eeb70290628 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/FetchOperation.java7
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/PullOperation.java18
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/PushOperation.java7
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/AbstractGitCloneWizard.java6
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/fetch/FetchOperationUI.java3
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/pull/PullOperationUI.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushOperationUI.java3
7 files changed, 44 insertions, 2 deletions
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/FetchOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/FetchOperation.java
index a99053482b..feaef70de9 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/FetchOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/FetchOperation.java
@@ -94,6 +94,13 @@ public class FetchOperation {
}
/**
+ * @return the operation's credentials provider
+ */
+ public CredentialsProvider getCredentialsProvider() {
+ return credentialsProvider;
+ }
+
+ /**
* @param tagOpt
*/
public void setTagOpt(TagOpt tagOpt) {
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/PullOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/PullOperation.java
index 14983a4f07..66107d074e 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/PullOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/PullOperation.java
@@ -42,6 +42,7 @@ import org.eclipse.jgit.api.errors.InvalidConfigurationException;
import org.eclipse.jgit.api.errors.JGitInternalException;
import org.eclipse.jgit.errors.TransportException;
import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.transport.CredentialsProvider;
import org.eclipse.osgi.util.NLS;
/**
@@ -54,6 +55,8 @@ public class PullOperation implements IEGitOperation {
private final int timeout;
+ private CredentialsProvider credentialsProvider;
+
/**
* @param repositories
* the repository
@@ -90,6 +93,7 @@ public class PullOperation implements IEGitOperation {
pull.setProgressMonitor(new EclipseGitProgressTransformer(
new SubProgressMonitor(mymonitor, 1)));
pull.setTimeout(timeout);
+ pull.setCredentialsProvider(credentialsProvider);
pullResult = pull.call();
results.put(repository, pullResult);
} catch (DetachedHeadException e) {
@@ -146,4 +150,18 @@ public class PullOperation implements IEGitOperation {
public ISchedulingRule getSchedulingRule() {
return RuleUtil.getRuleForRepositories(Arrays.asList(repositories));
}
+
+ /**
+ * @param credentialsProvider
+ */
+ public void setCredentialsProvider(CredentialsProvider credentialsProvider) {
+ this.credentialsProvider = credentialsProvider;
+ }
+
+ /**
+ * @return the operation's credentials provider
+ */
+ public CredentialsProvider getCredentialsProvider() {
+ return credentialsProvider;
+ }
}
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/PushOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/PushOperation.java
index a911d7ece6..d6150f1023 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/PushOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/PushOperation.java
@@ -106,6 +106,13 @@ public class PushOperation {
}
/**
+ * @return the operation's credentials provider
+ */
+ public CredentialsProvider getCredentialsProvider() {
+ return credentialsProvider;
+ }
+
+ /**
* @return push operation result
*/
public PushOperationResult getOperationResult() {
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/AbstractGitCloneWizard.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/AbstractGitCloneWizard.java
index 6324da1485..2fa2a531c3 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/AbstractGitCloneWizard.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/AbstractGitCloneWizard.java
@@ -46,6 +46,7 @@ import org.eclipse.egit.ui.internal.SecureStoreUtils;
import org.eclipse.egit.ui.internal.UIText;
import org.eclipse.egit.ui.internal.clone.GitCloneSourceProviderExtension.CloneSourceProvider;
import org.eclipse.egit.ui.internal.components.RepositorySelection;
+import org.eclipse.egit.ui.internal.credentials.EGitCredentialsProvider;
import org.eclipse.egit.ui.internal.provisional.wizards.GitRepositoryInfo;
import org.eclipse.egit.ui.internal.provisional.wizards.GitRepositoryInfo.PushInfo;
import org.eclipse.egit.ui.internal.provisional.wizards.GitRepositoryInfo.RepositoryConfigProperty;
@@ -60,7 +61,6 @@ import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.transport.URIish;
-import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
import org.eclipse.osgi.util.NLS;
import org.eclipse.ui.IWorkingSet;
@@ -245,8 +245,10 @@ public abstract class AbstractGitCloneWizard extends Wizard {
selectedBranches, workdir, ref != null ? ref.getName() : null,
remoteName, timeout);
if (credentials != null)
- op.setCredentialsProvider(new UsernamePasswordCredentialsProvider(
+ op.setCredentialsProvider(new EGitCredentialsProvider(
credentials.getUser(), credentials.getPassword()));
+ else
+ op.setCredentialsProvider(new EGitCredentialsProvider());
op.setCloneSubmodules(cloneDestination.isCloneSubmodules());
configureFetchSpec(op, gitRepositoryInfo, remoteName);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/fetch/FetchOperationUI.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/fetch/FetchOperationUI.java
index e3e437b891..135eefe0d7 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/fetch/FetchOperationUI.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/fetch/FetchOperationUI.java
@@ -25,6 +25,7 @@ import org.eclipse.egit.core.op.FetchOperation;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.JobFamilies;
import org.eclipse.egit.ui.internal.UIText;
+import org.eclipse.egit.ui.internal.credentials.EGitCredentialsProvider;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.transport.CredentialsProvider;
import org.eclipse.jgit.transport.FetchResult;
@@ -97,6 +98,8 @@ public class FetchOperationUI {
*/
public FetchResult execute(IProgressMonitor monitor) throws CoreException {
try {
+ if (op.getCredentialsProvider() == null)
+ op.setCredentialsProvider(new EGitCredentialsProvider());
op.run(monitor);
return op.getOperationResult();
} catch (InvocationTargetException e) {
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/pull/PullOperationUI.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/pull/PullOperationUI.java
index ac4cd09be0..8500fc36cf 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/pull/PullOperationUI.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/pull/PullOperationUI.java
@@ -30,6 +30,7 @@ import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.JobFamilies;
import org.eclipse.egit.ui.UIPreferences;
import org.eclipse.egit.ui.internal.UIText;
+import org.eclipse.egit.ui.internal.credentials.EGitCredentialsProvider;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jgit.api.PullResult;
@@ -61,6 +62,7 @@ public class PullOperationUI extends JobChangeAdapter {
int timeout = Activator.getDefault().getPreferenceStore().getInt(
UIPreferences.REMOTE_CONNECTION_TIMEOUT);
pullOperation = new PullOperation(repositories, timeout);
+ pullOperation.setCredentialsProvider(new EGitCredentialsProvider());
for (Repository repository : repositories)
results.put(repository, NOT_TRIED_STATUS);
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushOperationUI.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushOperationUI.java
index 9a9a94b858..5663f971fe 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushOperationUI.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushOperationUI.java
@@ -30,6 +30,7 @@ import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.JobFamilies;
import org.eclipse.egit.ui.UIPreferences;
import org.eclipse.egit.ui.internal.UIText;
+import org.eclipse.egit.ui.internal.credentials.EGitCredentialsProvider;
import org.eclipse.jgit.errors.NotSupportedException;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.transport.CredentialsProvider;
@@ -160,6 +161,8 @@ public class PushOperationUI {
createPushOperation();
if (credentialsProvider != null)
op.setCredentialsProvider(credentialsProvider);
+ else
+ op.setCredentialsProvider(new EGitCredentialsProvider());
try {
op.run(monitor);
return op.getOperationResult();

Back to the top