Author: rob.stryker(a)jboss.com
Date: 2012-01-24 02:21:01 -0500 (Tue, 24 Jan 2012)
New Revision: 38071
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerUtil.java
Log:
https://issues.jboss.org/browse/JBIDE-10490 - secure passwords for app servers (NOT
openshift) - fix to use the default storage location
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerUtil.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerUtil.java 2012-01-24
06:44:13 UTC (rev 38070)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerUtil.java 2012-01-24
07:21:01 UTC (rev 38071)
@@ -11,10 +11,8 @@
package org.jboss.ide.eclipse.as.core.util;
import java.io.File;
-import java.io.IOError;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
-import java.net.URL;
import java.net.URLEncoder;
import org.eclipse.core.runtime.CoreException;
@@ -177,7 +175,6 @@
}
- private static final String SECURE = "secure"; //$NON-NLS-1$
/**
* @since 2.3
*/
@@ -196,6 +193,8 @@
}
}
+ private static final String PREFERNCES_BASEKEY =
JBossServerCorePlugin.PLUGIN_ID.replace('.', Path.SEPARATOR);
+
/**
* @since 2.3
*/
@@ -212,17 +211,13 @@
}
private static ISecurePreferences getNode(IServer server) throws
UnsupportedEncodingException {
- try {
- IPath p = JBossServerCorePlugin.getServerStateLocation(server).append(SECURE);
- if( !p.toFile().exists())
- p.toFile().mkdirs();
-
- URL url = p.toFile().toURI().toURL();
- ISecurePreferences root = SecurePreferencesFactory.open(url, null);
- return root;
- } catch(IOException ioe ) {
- return null;
- }
+ String secureKey = new StringBuilder(PREFERNCES_BASEKEY)
+ .append(server.getName())
+ .append(Path.SEPARATOR).toString();
+
+ ISecurePreferences root = SecurePreferencesFactory.getDefault();
+ String encoded = URLEncoder.encode(secureKey, "UTF-8"); //$NON-NLS-1$
+ return root.node(encoded);
}
}