summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorCarsten Pfeiffer2011-05-21 18:03:07 (EDT)
committer Matthias Sohn2011-05-21 18:04:28 (EDT)
commit9d983b781f5be94698fe5388c26df88b3bcc3801 (patch)
treea70b01ec2aaa302050050cf45920c0a9af567c27
parenta24f0036257215a848844e5170cda0ef5660e8ec (diff)
downloadegit-9d983b781f5be94698fe5388c26df88b3bcc3801.zip
egit-9d983b781f5be94698fe5388c26df88b3bcc3801.tar.gz
egit-9d983b781f5be94698fe5388c26df88b3bcc3801.tar.bz2
Fix reading of stored credentials by stripping the uri path on storerefs/changes/24/2724/3
When attempting to read the credentials from the secure storage, the uri has no path (simply not available in the session), so we better store it without the path as well. Otherwise we don't ever get our credentials back. Change-Id: I1eecd2ae6082068dc6e7c4214ee62cbaf2b0c3a7 Also-by: Matthias Sohn <matthias.sohn@sap.com> Signed-off-by: Carsten Pfeiffer <carsten.pfeiffer@gebit.de> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/securestorage/EGitSecureStoreTest.java15
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/securestorage/EGitSecureStore.java4
2 files changed, 9 insertions, 10 deletions
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/securestorage/EGitSecureStoreTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/securestorage/EGitSecureStoreTest.java
index dc44d9f..afd764a 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/securestorage/EGitSecureStoreTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/securestorage/EGitSecureStoreTest.java
@@ -22,7 +22,6 @@ import java.util.HashMap;
import javax.crypto.spec.PBEKeySpec;
import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.equinox.security.storage.EncodingUtils;
import org.eclipse.equinox.security.storage.ISecurePreferences;
import org.eclipse.equinox.security.storage.SecurePreferencesFactory;
import org.eclipse.equinox.security.storage.provider.IProviderHints;
@@ -56,8 +55,8 @@ public class EGitSecureStoreTest {
"agitter", "letmein");
store.putCredentials(uri, credentials);
- ISecurePreferences node = secureStoreForTest.node("/GIT/"
- + EncodingUtils.encodeSlashes(uri.toString()));
+ ISecurePreferences node = secureStoreForTest.node(EGitSecureStore
+ .calcNodePath(uri).toString());
assertEquals("agitter", node.get("user", null));
assertTrue(node.isEncrypted("password"));
assertEquals("letmein", node.get("password", null));
@@ -86,14 +85,14 @@ public class EGitSecureStoreTest {
@Test
public void testPutUserAndPasswordURIContainingUserAndPass()
throws Exception {
+ URIish uri = new URIish(
+ "http://user:pass@testRepo.example.com/testrepo");
UserPasswordCredentials credentials = new UserPasswordCredentials(
"agitter", "letmein");
- store.putCredentials(new URIish(
- "http://user:pass@testRepo.example.com/testrepo"), credentials);
+ store.putCredentials(uri, credentials);
- ISecurePreferences node = secureStoreForTest.node("/GIT/"
- + EncodingUtils
- .encodeSlashes("http://testRepo.example.com/testrepo"));
+ ISecurePreferences node = secureStoreForTest.node(EGitSecureStore
+ .calcNodePath(uri).toString());
assertEquals("agitter", node.get("user", null));
assertTrue(node.isEncrypted("password"));
assertEquals("letmein", node.get("password", null));
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/securestorage/EGitSecureStore.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/securestorage/EGitSecureStore.java
index f2482c9..ce34e8f 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/securestorage/EGitSecureStore.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/securestorage/EGitSecureStore.java
@@ -79,8 +79,8 @@ public class EGitSecureStore {
return new UserPasswordCredentials(user, password);
}
- private String calcNodePath(URIish uri) {
- URIish storedURI = uri.setUser(null).setPass(null);
+ static String calcNodePath(URIish uri) {
+ URIish storedURI = uri.setUser(null).setPass(null).setPath(null);
String pathName = GIT_PATH_PREFIX
+ EncodingUtils.encodeSlashes(storedURI.toString());
return pathName;