Author: adietish
Date: 2011-01-27 10:07:51 -0500 (Thu, 27 Jan 2011)
New Revision: 28655
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/SshPrivateKeysPreferences.java
Log:
[JBIDE-8253] checking relative ssh private key entries now, too
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2011-01-27 13:49:55
UTC (rev 28654)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2011-01-27 15:07:51
UTC (rev 28655)
@@ -1,6 +1,12 @@
2011-01-27 André Dietisheim <André Dietisheim@adietisheim-thinkpad>
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/SshPrivateKeysPreferences.java
+ (contains):
+ (getAbsoluteKeyPath):
* src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java
+ (KeyValidator.isKeyKnowToSsh):
+ [JBIDE-8253] checking relative ssh private key entries now, too
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java
(KeyValidator.validate):
(KeyValidator.isKeyKnowToSsh):
* src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java
(performFinish):
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java 2011-01-27
13:49:55 UTC (rev 28654)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java 2011-01-27
15:07:51 UTC (rev 28655)
@@ -437,7 +437,7 @@
private boolean isKeyKnowToSsh(String keyId) {
try {
File file = PemFileManager.getFile(keyId,
SshPrivateKeysPreferences.getSshKeyDirectory());
- return SshPrivateKeysPreferences.contains(file.getAbsolutePath());
+ return SshPrivateKeysPreferences.contains(file);
} catch (FileNotFoundException e) {
return false;
}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/SshPrivateKeysPreferences.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/SshPrivateKeysPreferences.java 2011-01-27
13:49:55 UTC (rev 28654)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/SshPrivateKeysPreferences.java 2011-01-27
15:07:51 UTC (rev 28655)
@@ -51,20 +51,38 @@
}
/**
- * Adds the given keyName to the ssh-preferences
+ * Checks if the given key is cotained in the ssh-preferences
*
* @param keyName
* the name of the key to add
*/
- public static boolean contains(String keyName) {
+ public static boolean contains(File key) {
+ if (key == null) {
+ return false;
+ }
+
+ String keyPath = key.getAbsolutePath();
for (String privateKey : sshPrivateKeyPreference.get()) {
- if (privateKey.equals(keyName)) {
+ if (keyPath.equals(getAbsoluteKeyPath(privateKey))) {
return true;
}
}
return false;
}
-
+
+ private static String getAbsoluteKeyPath(String keyName) {
+ try {
+ if (keyName != null && !keyName.startsWith(File.separator)) {
+ StringBuilder builder = new StringBuilder(getSshKeyDirectory());
+ builder.append(File.separatorChar).append(keyName);
+ return builder.toString();
+ }
+ } catch (FileNotFoundException e) {
+ // ignore
+ }
+ return keyName;
+ }
+
/**
* Removes the given keyName from the ssh-preferences
*
Show replies by date