[jbosstools-commits] JBoss Tools SVN: r36013 - in branches/jbosstools-3.3.0.M4/as/plugins/org.jboss.tools.openshift.express.ui: src/org/jboss/tools/openshift/express/internal/ui/wizard and 1 other directory.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Wed Oct 26 11:39:24 EDT 2011


Author: adietish
Date: 2011-10-26 11:39:23 -0400 (Wed, 26 Oct 2011)
New Revision: 36013

Modified:
   branches/jbosstools-3.3.0.M4/as/plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF
   branches/jbosstools-3.3.0.M4/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPageModel.java
Log:
[JNIDE-10032] fixed loading ssh private keys from preferences

Modified: branches/jbosstools-3.3.0.M4/as/plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF
===================================================================
--- branches/jbosstools-3.3.0.M4/as/plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF	2011-10-26 14:16:49 UTC (rev 36012)
+++ branches/jbosstools-3.3.0.M4/as/plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF	2011-10-26 15:39:23 UTC (rev 36013)
@@ -10,6 +10,7 @@
  org.eclipse.egit.core;bundle-version="[1.1.0,2.0.0)",
  org.eclipse.jgit;bundle-version="[1.1.0,2.1.0)",
  com.jcraft.jsch;bundle-version="0.1.44",
+ org.eclipse.jsch.core;bundle-version="[1.1.300,2.0.0)",
  org.jboss.ide.eclipse.as.core;bundle-version="2.3.0",
  org.eclipse.m2e.core;bundle-version="1.0.100",
  org.eclipse.ui,

Modified: branches/jbosstools-3.3.0.M4/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPageModel.java
===================================================================
--- branches/jbosstools-3.3.0.M4/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPageModel.java	2011-10-26 14:16:49 UTC (rev 36012)
+++ branches/jbosstools-3.3.0.M4/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPageModel.java	2011-10-26 15:39:23 UTC (rev 36013)
@@ -14,6 +14,9 @@
 import java.io.FileNotFoundException;
 import java.io.IOException;
 
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.jsch.internal.core.IConstants;
+import org.eclipse.jsch.internal.core.JSchCorePlugin;
 import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
 import org.jboss.tools.common.ui.ssh.SshPrivateKeysPreferences;
 import org.jboss.tools.openshift.express.client.IDomain;
@@ -62,10 +65,25 @@
 	public void createSShKeyPair(String passPhrase) throws FileNotFoundException, OpenShiftException {
 		String sshKeysDirectory = SshPrivateKeysPreferences.getSshKeyDirectory();
 		SSHKeyPair keyPair = createSshKeyPair(passPhrase, sshKeysDirectory);
-		SshPrivateKeysPreferences.add(keyPair.getPrivateKeyPath());
+		addToPrivateKeysPreferences(keyPair);
 		setSshKey(keyPair.getPublicKeyPath());
 	}
 	
+	private void addToPrivateKeysPreferences(SSHKeyPair keyPair) {
+		Preferences preferences = JSchCorePlugin.getPlugin().getPluginPreferences();
+		String privateKeys = preferences.getString(IConstants.KEY_PRIVATEKEY);
+		if (privateKeys != null 
+				&& privateKeys.trim().length() > 0) {
+			privateKeys = privateKeys + ","	+ keyPair.getPrivateKeyPath();
+		} else {
+			privateKeys = keyPair.getPrivateKeyPath();
+		}
+		preferences.setValue(IConstants.KEY_PRIVATEKEY, privateKeys);
+		JSchCorePlugin.getPlugin().setNeedToLoadKnownHosts(true);
+	    JSchCorePlugin.getPlugin().setNeedToLoadKeys(true);
+	    JSchCorePlugin.getPlugin().savePluginPreferences();
+	}
+	
 	private SSHKeyPair createSshKeyPair(String passPhrase, String sshKeysDirectory) throws OpenShiftException {
 		String privateKeyPath = getKeyPairFileName(sshKeysDirectory);
 		String publicKeyPath = getPublicKeyPath(privateKeyPath);



More information about the jbosstools-commits mailing list