### Eclipse Workspace Patch 1.0
#P org.jboss.tools.openshift.express.ui
Index: src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPage.java
===================================================================
--- src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPage.java	(revision 41574)
+++ src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPage.java	(working copy)
@@ -54,6 +54,7 @@
 import org.jboss.tools.common.ui.ssh.SshPrivateKeysPreferences;
 import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
 import org.jboss.tools.openshift.express.internal.ui.utils.FileUtils;
+import org.jboss.tools.openshift.express.internal.ui.utils.SSHUserConfig;
 import org.jboss.tools.openshift.express.internal.ui.utils.StringUtils;
 
 import com.openshift.client.OpenShiftException;
@@ -153,7 +154,7 @@
 					if (pageModel.libraPublicKeyExists()) {
 						MessageDialog.openInformation(getShell(), 
 								"Libra Key already present", 
-								"You already have a key at \"" + pageModel.getLibraPublicKey() + "\". Please move it or use it.");
+								"You already have a key at \"" + pageModel.getPublicKey() + "\". Please move it or use it.");
 						return;
 					} 
 
@@ -220,7 +221,7 @@
 
 	@Override
 	protected void setupWizardPageSupport(DataBindingContext dbc) {
-		ParametrizableWizardPageSupport.create(IStatus.ERROR, this, dbc);
+		ParametrizableWizardPageSupport.create(IStatus.ERROR | IStatus.CANCEL, this, dbc);
 	}
 
 	private class SSHKeyValidator implements IValidator {
@@ -232,10 +233,14 @@
 					|| !FileUtils.canRead((String) value)) {
 				return ValidationStatus.error("You have to provide a valid ssh public key");
 			}
-			if (!isKeyKnownToSsh((String) value)) {
+			if (pageModel.hasConfiguredFixedPrivateKeys()) {
 				return ValidationStatus.warning(
-						NLS.bind("Could not find the private portion for your public key. "
-								+ "Make sure it is listed in the ssh2 preferences.", value));
+						NLS.bind("Your SSH config ({0}) contains fixed keys for OpenShift servers. " +
+								"This can override any Eclipse specific SSH key preferences.", new SSHUserConfig(pageModel.getSSH2Home()).getFile()));
+			} else if (!isKeyKnownToSsh((String) value)) {
+					return ValidationStatus.warning(
+							NLS.bind("Could not find the private portion for your public key in the preferences. "
+									+ "Make sure it is listed in the ssh2 preferences.", value));
 			}
 			return ValidationStatus.ok();
 		}
@@ -244,14 +249,15 @@
 			if (StringUtils.isEmpty(publicKeyPath)) {
 				return false;
 			}
-			for (String preferencesKey : SshPrivateKeysPreferences.getKeys()) {
+			for (String preferencesKey : pageModel.getPrivateKeysFromPreferences()) {
 				try {
 					File privateKey = SshPrivateKeysPreferences.getKeyFile(preferencesKey);
 					if (privateKey == null
 							|| !FileUtils.canRead(privateKey)) {
 						continue;
 					}
-					if (publicKeyPath.startsWith(privateKey.getAbsolutePath() + ".")) {
+					if (publicKeyPath.startsWith(privateKey.getAbsolutePath() + ".")
+							|| publicKeyPath.startsWith(privateKey.getPath() + ".")) {
 						return true;
 					}
 				} catch (FileNotFoundException e) {
Index: src/org/jboss/tools/openshift/express/internal/ui/utils/SSHUserConfig.java
===================================================================
--- src/org/jboss/tools/openshift/express/internal/ui/utils/SSHUserConfig.java	(revision 0)
+++ src/org/jboss/tools/openshift/express/internal/ui/utils/SSHUserConfig.java	(revision 0)
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.openshift.express.internal.ui.utils;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.jboss.ide.eclipse.as.core.util.StreamUtils;
+
+import com.openshift.client.OpenShiftException;
+
+/**
+ * A class that parses the user ssh configuration and retrieves the
+ * <tt>IdentityFile</tt> setting from a <tt>Host</tt> block that is configuring
+ * the OpenShift application (<tt>rhcloud.com</tt>) PaaS.
+ * 
+ * @author Andre Dietisheim
+ */
+public class SSHUserConfig {
+
+	private static final String VALUE_LIBRA_SSH_HOST = "rhcloud.com";
+	private static final String KEY_CONFIGBLOCK_HOST_START = "Host ";
+	private static final String KEY_CONFIGBLOCK_HOST_END = "\n";
+	private static final Pattern IDENTITYFILE_PATTERN = Pattern.compile(".+IdentityFile (.+)");
+	private static final String CONFIG_FILENAME = "config";
+	private File configFile;
+
+	public SSHUserConfig(String sshHome) {
+		this(new File(sshHome, CONFIG_FILENAME));
+	}
+
+	public SSHUserConfig(File configFile) {
+		this.configFile = configFile;
+	}
+
+	public boolean exists() {
+		return FileUtils.canRead(configFile);
+	}
+
+	public File getFile() {
+		return configFile;
+	}
+	
+	public boolean hasLibraIdentifyFile() throws OpenShiftException {
+		return getLibraIdentityFile() != null;
+	}
+
+	public String getLibraIdentityFile() throws OpenShiftException {
+		if (!exists()) {
+			return null;
+		}
+
+		BufferedReader reader = null;
+		try {
+			reader = new BufferedReader(new FileReader(configFile));
+			for (String data = reader.readLine(); data != null; data = reader.readLine()) {
+				if (!data.startsWith(KEY_CONFIGBLOCK_HOST_START)
+						|| !data.endsWith(VALUE_LIBRA_SSH_HOST)) {
+					continue;
+				}
+
+				for (data = reader.readLine(); data != null; reader.readLine()) {
+					if (data.equals(KEY_CONFIGBLOCK_HOST_END)) {
+						continue;
+					}
+
+					Matcher matcher = IDENTITYFILE_PATTERN.matcher(data);
+					if (!matcher.find()
+							|| matcher.groupCount() < 1) {
+						continue;
+					}
+
+					return matcher.group(1);
+				}
+			}
+			return null;
+		} catch (IOException e) {
+			throw new OpenShiftException("Could not read file {0}", configFile);
+		} finally {
+			StreamUtils.safeClose(reader);
+		}
+	}
+}
Index: src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPageModel.java
===================================================================
--- src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPageModel.java	(revision 41574)
+++ src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPageModel.java	(working copy)
@@ -22,6 +22,7 @@
 import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
 import org.jboss.tools.openshift.express.internal.core.console.UserDelegate;
 import org.jboss.tools.openshift.express.internal.ui.utils.FileUtils;
+import org.jboss.tools.openshift.express.internal.ui.utils.SSHUserConfig;
 
 import com.openshift.client.IDomain;
 import com.openshift.client.IOpenShiftSSHKey;
@@ -35,8 +36,10 @@
  */
 public class NewDomainWizardPageModel extends ObservableUIPojo {
 
-	public static final String LIBRA_KEY = "libra_id_rsa";
+	public static final String ID_RSA_FILENAME = "id_rsa";
+	public static final String LIBRA_ID_RSA_FILENAME = "libra_id_rsa";
 	private static final String PUBLIC_KEY_SUFFIX = ".pub";
+	private static final String KEYS_SEPARATOR = ",";
 
 	private static final String SSHKEY_DEFAULT_NAME = "jbosstools"; //$NON-NLS-1$
 
@@ -56,18 +59,19 @@
 		if (!libraPublicKeyExists()) {
 			return;
 		}
-		File libraPublicKey = getLibraPublicKey();
+		File libraPublicKey = getPublicKey();
 		setSshKey(libraPublicKey.getAbsolutePath());
 	}
 
+	
 	/**
 	 * Returns the file of the libra public key. It is not checking if the file exists.
 	 *  
 	 * @return the libra public key 
 	 * @throws OpenShiftException 
 	 */
-	public File getLibraPublicKey() throws OpenShiftException {
-		File libraPrivateKey = getLibraPrivateKey();
+	public File getPublicKey() throws OpenShiftException {
+		File libraPrivateKey = getPrivateKey();
 		return new File(libraPrivateKey.getParent(), getPublicKeyPath(libraPrivateKey.getName()));
 	}
 
@@ -75,30 +79,39 @@
 		return privateKeyPath + PUBLIC_KEY_SUFFIX;
 	}
 
-	public File getLibraPrivateKey() throws OpenShiftException {
-		String ssh2Home = getSSH2Home();
-		File ssh2HomeFile = new File(ssh2Home);
-		if (!FileUtils.canRead(ssh2HomeFile)) {
-			try {
-				ssh2HomeFile.createNewFile();
-			} catch(IOException e) {
-				throw new OpenShiftException("Could not create ssh2 home directory at {0}", ssh2Home);
-			}
+	public File getPrivateKey() throws OpenShiftException {
+		String ssh2Home = checkedGetSSH2Home();
+		ensureSSHHomeExists(ssh2Home);
+		if (hasConfiguredFixedPrivateKeys()) {
+			return new File(ssh2Home, LIBRA_ID_RSA_FILENAME);
+		} else {
+			return new File(ssh2Home, ID_RSA_FILENAME);
 		}
-		
-		return new File(ssh2Home, LIBRA_KEY);
 	}
 
-	private String getSSH2Home() throws OpenShiftException {
-		Preferences preferences = JSchCorePlugin.getPlugin().getPluginPreferences();
-		String ssh2Home = preferences.getString(IConstants.KEY_SSH2HOME);
+	private String checkedGetSSH2Home() throws OpenShiftException {
+		String ssh2Home = getSSH2Home();
 		if (ssh2Home == null 
 				|| ssh2Home.trim().length() == 0) {
 			throw new OpenShiftException("Could not determine your ssh2 home directory");
 		}
 		return ssh2Home;
 	}
+	
+	public String getSSH2Home() {
+		return JSchCorePlugin.getPlugin().getPluginPreferences().getString(IConstants.KEY_SSH2HOME);
+	}
+
+	public boolean hasConfiguredFixedPrivateKeys() {
+		try {
+			SSHUserConfig sshUserConfig = new SSHUserConfig(checkedGetSSH2Home());
+			return sshUserConfig.hasLibraIdentifyFile();
+		} catch (OpenShiftException e) {
+			return false;
+		}
+	}
 
+
 	public String getDomainId() {
 		return this.domainId;
 	}
@@ -124,24 +137,24 @@
 	}
 	
 	public boolean libraPublicKeyExists() throws OpenShiftException {
-		return FileUtils.canRead(getLibraPublicKey());
+		return FileUtils.canRead(getPublicKey());
 	}
 
 	public void createLibraKeyPair(String passPhrase) throws FileNotFoundException, OpenShiftException {
-		File libraPublicKey = getLibraPublicKey();
+		File libraPublicKey = getPublicKey();
 		if (libraPublicKey.canRead()) {
 			// key already exists
 			return;
 		}
-		createSSHHome(getSSH2Home());
-		File libraPrivateKey = getLibraPrivateKey();
+		ensureSSHHomeExists(checkedGetSSH2Home());
+		File libraPrivateKey = getPrivateKey();
 		SSHKeyPair keyPair = SSHKeyPair.create(passPhrase, libraPrivateKey.getAbsolutePath(), libraPublicKey.getAbsolutePath());
 		setFilePermissions(libraPrivateKey);
 		addToPrivateKeysPreferences(keyPair);
 		setSshKey(keyPair.getPublicKeyPath());
 	}
 	
-	private void createSSHHome(String ssh2Home)
+	private void ensureSSHHomeExists(String ssh2Home)
 			throws OpenShiftException {
 		File ssh2HomeFile = new File(ssh2Home);
 		if (FileUtils.canRead(ssh2HomeFile)) {
@@ -171,6 +184,17 @@
 		file.setWritable(true, true);
 	}
 
+	public String[] getPrivateKeysFromPreferences() {
+		String privateKeys = 
+				JSchCorePlugin.getPlugin().getPluginPreferences().getString(IConstants.KEY_PRIVATEKEY);
+		if (privateKeys != null 
+				&& privateKeys.trim().length() > 0) {
+			return privateKeys.split(KEYS_SEPARATOR);
+		} else {
+			return new String[0];
+		}
+	}
+	
 	private void addToPrivateKeysPreferences(SSHKeyPair keyPair) {
 		Preferences preferences = JSchCorePlugin.getPlugin().getPluginPreferences();
 		String privateKeys = preferences.getString(IConstants.KEY_PRIVATEKEY);
Index: src/org/jboss/tools/openshift/express/internal/ui/utils/FileUtils.java
===================================================================
--- src/org/jboss/tools/openshift/express/internal/ui/utils/FileUtils.java	(revision 41574)
+++ src/org/jboss/tools/openshift/express/internal/ui/utils/FileUtils.java	(working copy)
@@ -155,6 +155,7 @@
 
 	public static final void writeTo(String content, File destination) throws FileNotFoundException {
 		PrintWriter writer = new PrintWriter(destination);
+		writer.write(content);
 		writer.flush();
 		writer.close();
 	}
