Author: adietish
Date: 2011-01-31 10:22:32 -0500 (Mon, 31 Jan 2011)
New Revision: 28767
Modified:
branches/jbosstools-3.2.x/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java
branches/jbosstools-3.2.x/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java
branches/jbosstools-3.2.x/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/SshPrivateKeysPreferences.java
Log:
[JBIDE-8253][JBUIDE-8254]
Modified:
branches/jbosstools-3.2.x/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java
===================================================================
---
branches/jbosstools-3.2.x/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java 2011-01-31
14:33:47 UTC (rev 28766)
+++
branches/jbosstools-3.2.x/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java 2011-01-31
15:22:32 UTC (rev 28767)
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.jboss.tools.internal.deltacloud.ui.wizards;
+import java.io.File;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
@@ -403,12 +404,10 @@
WidgetProperties.text(SWT.Modify).observeDelayed(KEY_CHECK_DELAY, text),
BeanProperties.value(NewInstancePageModel.class,
NewInstancePageModel.PROPERTY_KEYID).observe(model),
new UpdateValueStrategy()
- .setBeforeSetValidator(
+ .setAfterGetValidator(
new MandatoryStringValidator(WizardMessages.getString(MUST_ENTER_A_KEYNAME)))
.setBeforeSetValidator(
new KeyValidator()),
- // TODO: internationalize strings
-
null);
ControlDecorationSupport.create(textBinding, SWT.LEFT | SWT.TOP);
}
@@ -420,6 +419,11 @@
if (value instanceof String
&& ((String) value).length() > 0) {
if (doesKeyExist((String) value)) {
+ if (!isKeyKnownToSsh((String) value)) {
+ return ValidationStatus
+ .warning(
+ "Key not found under SSH preferences, might be needed for login after
launch.");
+ }
return ValidationStatus.ok();
}
}
@@ -427,6 +431,20 @@
"The key is not known to cloud \"{0}\"", cloud.getName()));
}
+ private boolean isKeyKnownToSsh(String keyName) {
+ if (keyName == null) {
+ return false;
+ }
+ for (String key :SshPrivateKeysPreferences.getKeys()) {
+ File file = new File(key);
+ if (file.getName().equals(keyName)
+ || file.getName().startsWith(keyName + ".")) {
+ return true;
+ }
+ }
+ return false;
+ }
+
private boolean doesKeyExist(String keyId) {
try {
return cloud.getKey(keyId) != null;
Modified:
branches/jbosstools-3.2.x/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java
===================================================================
---
branches/jbosstools-3.2.x/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java 2011-01-31
14:33:47 UTC (rev 28766)
+++
branches/jbosstools-3.2.x/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java 2011-01-31
15:22:32 UTC (rev 28767)
@@ -10,13 +10,9 @@
*******************************************************************************/
package org.jboss.tools.internal.deltacloud.ui.wizards;
-import java.io.File;
-import java.io.FileNotFoundException;
-
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
import org.eclipse.jface.wizard.Wizard;
import org.jboss.tools.common.jobs.ChainedJob;
@@ -107,7 +103,6 @@
Exception e = null;
try {
if (isProceed()) {
- warnSshPrivateKey(keyId);
instance = cloud.createInstance(name, imageId, realmId, profileId, keyId, memory,
storage);
if (instance != null) {
result = true;
@@ -130,23 +125,6 @@
return result;
}
- private void warnSshPrivateKey(String keyId) {
- try {
- File file = PemFileManager.getFile(keyId,
SshPrivateKeysPreferences.getSshKeyDirectory());
- boolean isKnowPrivateKey =
SshPrivateKeysPreferences.contains(file.getAbsolutePath());
-
- if (!isKnowPrivateKey) {
- MessageDialog
- .openWarning(
- getShell(),
- "Instance key is not private key",
- "The instance key you have chosen is not known to the ssh subsystem. If you
need this key to connect to your instance, you'll have to download it and add it to
the private keys in the SSH preferences.");
- }
- } catch (FileNotFoundException e) {
-
- }
- }
-
private void scheduleJobs() {
ChainedJob first =
new InstanceStateJob(
Modified:
branches/jbosstools-3.2.x/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/SshPrivateKeysPreferences.java
===================================================================
---
branches/jbosstools-3.2.x/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/SshPrivateKeysPreferences.java 2011-01-31
14:33:47 UTC (rev 28766)
+++
branches/jbosstools-3.2.x/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/SshPrivateKeysPreferences.java 2011-01-31
15:22:32 UTC (rev 28767)
@@ -49,20 +49,9 @@
public static void add(String keyName) {
sshPrivateKeyPreference.add(keyName);
}
-
- /**
- * Adds the given keyName to the ssh-preferences
- *
- * @param keyName
- * the name of the key to add
- */
- public static boolean contains(String keyName) {
- for (String privateKey : sshPrivateKeyPreference.get()) {
- if (privateKey.equals(keyName)) {
- return true;
- }
- }
- return false;
+
+ public static String[] getKeys() {
+ return sshPrivateKeyPreference.get();
}
/**
Show replies by date