Author: adietish
Date: 2012-05-08 11:39:44 -0400 (Tue, 08 May 2012)
New Revision: 40854
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/OpenShiftPasswordStorageKey.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/SecurePasswordStore.java
Log:
[JBIDE-11634] corrected key that's used to store OpenShift password (removed
url-encoding, used proper path partitioning)
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/OpenShiftPasswordStorageKey.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/OpenShiftPasswordStorageKey.java 2012-05-08
15:03:30 UTC (rev 40853)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/OpenShiftPasswordStorageKey.java 2012-05-08
15:39:44 UTC (rev 40854)
@@ -10,6 +10,9 @@
******************************************************************************/
package org.jboss.tools.openshift.express.internal.ui.utils;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
import
org.jboss.tools.openshift.express.internal.ui.utils.SecurePasswordStore.IStorageKey;
@@ -23,25 +26,37 @@
public class OpenShiftPasswordStorageKey implements IStorageKey {
private static final char SEPARATOR = '/';
-
- private static final String PREFERNCES_BASEKEY =
OpenShiftUIActivator.PLUGIN_ID.replace('.', SEPARATOR);
+ private static final Pattern SCHEME_PATTERN = Pattern.compile(".+://(.*)");
+ private static final String PREFERNCES_BASEKEY = OpenShiftUIActivator.PLUGIN_ID;
+
private String platform;
private String userName;
public OpenShiftPasswordStorageKey(String platform, String userName) {
- this.platform = platform;
+ this.platform = stripScheme(platform);
this.userName = userName;
}
@Override
public String getKey() {
return new StringBuilder(PREFERNCES_BASEKEY)
+ .append(SEPARATOR)
.append(platform)
.append(SEPARATOR)
.append(userName)
.toString();
}
+ private String stripScheme(String value) {
+ Matcher matcher = SCHEME_PATTERN.matcher(value);
+ if (matcher.find()
+ && matcher.groupCount() == 1) {
+ return matcher.group(1);
+ } else {
+ return value;
+ }
+ }
+
@Override
public boolean equals(IStorageKey key) {
if (!key.getClass().isAssignableFrom(OpenShiftPasswordStorageKey.class)) {
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/SecurePasswordStore.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/SecurePasswordStore.java 2012-05-08
15:03:30 UTC (rev 40853)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/SecurePasswordStore.java 2012-05-08
15:39:44 UTC (rev 40854)
@@ -11,7 +11,6 @@
package org.jboss.tools.openshift.express.internal.ui.utils;
import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
import org.eclipse.equinox.security.storage.EncodingUtils;
import org.eclipse.equinox.security.storage.ISecurePreferences;
@@ -25,8 +24,6 @@
*/
public class SecurePasswordStore {
- private static final String ENCODING = "UTF-8";
-
public static interface IStorageKey {
public String getKey();
@@ -115,7 +112,6 @@
}
ISecurePreferences root = SecurePreferencesFactory.getDefault();
- String keyString = URLEncoder.encode(key.getKey(), ENCODING);
- return root.node(keyString);
+ return root.node(key.getKey());
}
}
Show replies by date