[jbosstools-commits] JBoss Tools SVN: r43925 - branches/jbosstools-3.3.x/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Fri Sep 21 09:14:47 EDT 2012


Author: adietish
Date: 2012-09-21 09:14:46 -0400 (Fri, 21 Sep 2012)
New Revision: 43925

Modified:
   branches/jbosstools-3.3.x/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPageModel.java
Log:
[JBIDE-10118] adding key with name only, if it's stored in ssh2 home, full path otherwise

Modified: branches/jbosstools-3.3.x/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPageModel.java
===================================================================
--- branches/jbosstools-3.3.x/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPageModel.java	2012-09-21 12:18:14 UTC (rev 43924)
+++ branches/jbosstools-3.3.x/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPageModel.java	2012-09-21 13:14:46 UTC (rev 43925)
@@ -198,17 +198,33 @@
 	private void addToPrivateKeysPreferences(SSHKeyPair keyPair) {
 		Preferences preferences = JSchCorePlugin.getPlugin().getPluginPreferences();
 		String privateKeys = preferences.getString(IConstants.KEY_PRIVATEKEY);
-		if (privateKeys != null 
+		String privateKeyPath = getKeyPath(new File(keyPair.getPrivateKeyPath()));
+		
+		if (privateKeys != null
 				&& privateKeys.trim().length() > 0) {
-			privateKeys = privateKeys + ","	+ keyPair.getPrivateKeyPath();
+			privateKeys = privateKeys + "," + privateKeyPath;
 		} else {
-			privateKeys = keyPair.getPrivateKeyPath();
+			privateKeys = privateKeyPath;
 		}
 		preferences.setValue(IConstants.KEY_PRIVATEKEY, privateKeys);
-	    JSchCorePlugin.getPlugin().setNeedToLoadKeys(true);
-	    JSchCorePlugin.getPlugin().savePluginPreferences();
+		JSchCorePlugin.getPlugin().setNeedToLoadKeys(true);
+		JSchCorePlugin.getPlugin().savePluginPreferences();
 	}
+
+	private String getKeyPath(File privateKey) {
+		String ssh2Home = checkedGetSSH2Home();
+		if (ssh2Home == null
+				|| ssh2Home.isEmpty()) {
+			return privateKey.getAbsolutePath();
+		}
 		
+		if (!privateKey.getAbsolutePath().startsWith(ssh2Home)) {
+			return privateKey.getAbsolutePath(); 
+		}
+		
+		return privateKey.getName();
+	}
+		
 	public void setSshKey(String sshKey) {
 		firePropertyChange(PROPERTY_SSHKEY, this.sshKey, this.sshKey = sshKey);
 	}



More information about the jbosstools-commits mailing list