diff options
| author | Carsten Pfeiffer | 2011-05-21 22:03:07 +0000 |
|---|---|---|
| committer | Matthias Sohn | 2011-05-21 22:04:28 +0000 |
| commit | 9d983b781f5be94698fe5388c26df88b3bcc3801 (patch) | |
| tree | a70b01ec2aaa302050050cf45920c0a9af567c27 | |
| parent | a24f0036257215a848844e5170cda0ef5660e8ec (diff) | |
| download | egit-9d983b781f5be94698fe5388c26df88b3bcc3801.tar.gz egit-9d983b781f5be94698fe5388c26df88b3bcc3801.tar.xz egit-9d983b781f5be94698fe5388c26df88b3bcc3801.zip | |
Fix reading of stored credentials by stripping the uri path on store
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.java | 15 | ||||
| -rw-r--r-- | org.eclipse.egit.core/src/org/eclipse/egit/core/securestorage/EGitSecureStore.java | 4 |
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 dc44d9f800..afd764a2de 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 f2482c9679..ce34e8f387 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; |
