Author: adietish
Date: 2011-09-16 09:08:14 -0400 (Fri, 16 Sep 2011)
New Revision: 34815
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/ISSHPublicKey.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/SSHKeyPair.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/SSHPublicKey.java
Removed:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/SSHKey.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/IOpenshiftJsonConstants.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/IOpenshiftService.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/User.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/OpenshiftService.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/request/AbstractDomainRequest.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/request/ChangeDomainRequest.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/request/CreateDomainRequest.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/request/marshalling/DomainRequestJsonMarshaller.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/response/UserInfoResponseUnmarshaller.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/DomainIntegrationTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/DomainTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/SSHKeyTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/UserInfoTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/fakes/NoopOpenshiftServiceFake.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/fakes/TestSSHKey.java
Log:
[JBIDE-9510] implementing IOpenshiftService#getUserInfo
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/IOpenshiftJsonConstants.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/IOpenshiftJsonConstants.java 2011-09-16
13:07:25 UTC (rev 34814)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/IOpenshiftJsonConstants.java 2011-09-16
13:08:14 UTC (rev 34815)
@@ -38,5 +38,6 @@
public static final String PROPERTY_EMBEDDED = "embedded";
public static final String PROPERTY_FRAMEWORK = "framework";
public static final String PROPERTY_CREATION_TIME = "creation_time";
+ public static final String PROPERTY_SSH_KEY = "ssh_key";
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/IOpenshiftService.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/IOpenshiftService.java 2011-09-16
13:07:25 UTC (rev 34814)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/IOpenshiftService.java 2011-09-16
13:08:14 UTC (rev 34815)
@@ -33,11 +33,11 @@
public String getStatus(String name, Cartridge cartridge) throws OpenshiftException;
- public Domain changeDomain(String domainName, SSHKey sshKey) throws OpenshiftException;
+ public Domain changeDomain(String domainName, SSHKeyPair sshKey) throws
OpenshiftException;
- public Domain createDomain(String name, SSHKey keyPair) throws OpenshiftException;
+ public Domain createDomain(String name, SSHKeyPair sshKey) throws OpenshiftException;
- public SSHKey createKey(String passPhrase, String privateKeyPath, String publicKeyPath)
throws OpenshiftException;
+ public SSHKeyPair createKey(String passPhrase, String privateKeyPath, String
publicKeyPath) throws OpenshiftException;
- public SSHKey loadKey(String privateKeyPath, String publicKeyPath) throws
OpenshiftException;
+ public SSHKeyPair loadKey(String privateKeyPath, String publicKeyPath) throws
OpenshiftException;
}
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/ISSHPublicKey.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/ISSHPublicKey.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/ISSHPublicKey.java 2011-09-16
13:08:14 UTC (rev 34815)
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.ide.eclipse.as.openshift.core;
+
+/**
+ * @author André Dietisheim
+ */
+public interface ISSHPublicKey {
+
+ /**
+ * Returns the content of the public key (key content without ssh-rsa
+ * identifier nor comment) of the ssh key
+ *
+ * @return the content of the public key (without signature, without
+ * comment)
+ * @throws OpenshiftException
+ */
+ public String getPublicKey() throws OpenshiftException;
+
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/ISSHPublicKey.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Deleted:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/SSHKey.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/SSHKey.java 2011-09-16
13:07:25 UTC (rev 34814)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/SSHKey.java 2011-09-16
13:08:14 UTC (rev 34815)
@@ -1,111 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.ide.eclipse.as.openshift.core;
-
-import org.jboss.ide.eclipse.as.openshift.core.internal.OpenshiftCoreActivator;
-import org.jboss.ide.eclipse.as.openshift.core.internal.utils.Base64Encoder;
-
-import com.jcraft.jsch.JSch;
-import com.jcraft.jsch.JSchException;
-import com.jcraft.jsch.KeyPair;
-
-/**
- * @author André Dietisheim
- */
-public class SSHKey {
-
- /**
- * the length of the key that is created when using #create. ssh-keygen uses
- * a default of 2048
- *
- * @see #create(String, String, String)
- * @see
http://en.wikipedia.org/wiki/Ssh-keygen
- */
- private static final int KEYLENGTH = 2048;
-
- private KeyPair keyPair;
- private String privateKeyPath;
- private String publicKeyPath;
-
- private SSHKey(KeyPair keyPair, String privateKeyPath, String publicKeyPath) throws
OpenshiftException {
- this.keyPair = keyPair;
- this.privateKeyPath = privateKeyPath;
- this.publicKeyPath = publicKeyPath;
- }
-
- /**
- * Creates private and public ssh-rsa keys and stores them to the given
- * paths. The key is created while using the given pass phrase.
- *
- * @param passPhrase
- * the pass phrase to set to the new key
- * @param privateKeyPath
- * the path where the new private key gets stored
- * @param publicKeyPath
- * the path where the new public key gets stored
- * @return
- * @throws OpenshiftException
- * if the key could not be created
- */
- public static SSHKey create(String passPhrase, String privateKeyPath, String
publicKeyPath)
- throws OpenshiftException {
- try {
- KeyPair keyPair = KeyPair.genKeyPair(new JSch(), KeyPair.RSA, KEYLENGTH);
- keyPair.setPassphrase(passPhrase);
- keyPair.writePublicKey(publicKeyPath, "created by " +
OpenshiftCoreActivator.PLUGIN_ID);
- keyPair.writePrivateKey(privateKeyPath);
- return new SSHKey(keyPair, privateKeyPath, publicKeyPath);
- } catch (Exception e) {
- throw new OpenshiftException(e, "Could not create new rsa key", e);
- }
- }
-
- /**
- * Loads existing private and public ssh key from the given paths.
- *
- * @param privateKeyPath
- * the path to the private key
- * @param publicKeyPath
- * the path to the public key
- * @return
- * @throws OpenshiftException
- */
- public static SSHKey load(String privateKeyPath, String publicKeyPath)
- throws OpenshiftException {
- try {
- KeyPair keyPair = KeyPair.load(new JSch(), privateKeyPath, publicKeyPath);
- return new SSHKey(keyPair, privateKeyPath, publicKeyPath);
- } catch (JSchException e) {
- throw new OpenshiftException(e, "Could not create new rsa key");
- }
- }
-
- /**
- * Returns the content of the public key (key content without ssh-rsa
- * identifier nor comment) of the ssh key
- *
- * @return the content of the public key (without signature, without
- * comment)
- * @throws OpenshiftException
- */
- public String getPublicKeyContent() throws OpenshiftException {
- return new String(Base64Encoder.encode(keyPair.getPublicKeyBlob()));
- }
-
- protected String getPublicKeyPath() {
- return publicKeyPath;
- }
-
- protected String getPrivateKeyPath() {
- return privateKeyPath;
- }
-
-}
Copied:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/SSHKeyPair.java
(from rev 34809,
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/SSHKey.java)
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/SSHKeyPair.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/SSHKeyPair.java 2011-09-16
13:08:14 UTC (rev 34815)
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.ide.eclipse.as.openshift.core;
+
+import org.jboss.ide.eclipse.as.openshift.core.internal.OpenshiftCoreActivator;
+import org.jboss.ide.eclipse.as.openshift.core.internal.utils.Base64Encoder;
+
+import com.jcraft.jsch.JSch;
+import com.jcraft.jsch.JSchException;
+import com.jcraft.jsch.KeyPair;
+
+/**
+ * @author André Dietisheim
+ */
+public class SSHKeyPair implements ISSHPublicKey {
+
+ /**
+ * the length of the key that is created when using #create. ssh-keygen uses
+ * a default of 2048
+ *
+ * @see #create(String, String, String)
+ * @see
http://en.wikipedia.org/wiki/Ssh-keygen
+ */
+ private static final int KEYLENGTH = 2048;
+
+ private KeyPair keyPair;
+ private String privateKeyPath;
+
+ private String publicKeyPath;
+
+ private SSHKeyPair(KeyPair keyPair, String privateKeyPath, String publicKeyPath) throws
OpenshiftException {
+ this.keyPair = keyPair;
+ this.privateKeyPath = privateKeyPath;
+ this.publicKeyPath = publicKeyPath;
+ }
+
+ /**
+ * Creates private and public ssh-rsa keys and stores them to the given
+ * paths. The key is created while using the given pass phrase.
+ *
+ * @param passPhrase
+ * the pass phrase to set to the new key
+ * @param privateKeyPath
+ * the path where the new private key gets stored
+ * @param publicKeyPath
+ * the path where the new public key gets stored
+ * @return
+ * @throws OpenshiftException
+ * if the key could not be created
+ */
+ public static SSHKeyPair create(String passPhrase, String privateKeyPath, String
publicKeyPath)
+ throws OpenshiftException {
+ try {
+ KeyPair keyPair = KeyPair.genKeyPair(new JSch(), KeyPair.RSA, KEYLENGTH);
+ keyPair.setPassphrase(passPhrase);
+ keyPair.writePublicKey(publicKeyPath, "created by " +
OpenshiftCoreActivator.PLUGIN_ID);
+ keyPair.writePrivateKey(privateKeyPath);
+ return new SSHKeyPair(keyPair, privateKeyPath, publicKeyPath);
+ } catch (Exception e) {
+ throw new OpenshiftException(e, "Could not create new rsa key", e);
+ }
+ }
+
+ /**
+ * Loads existing private and public ssh key from the given paths.
+ *
+ * @param privateKeyPath
+ * the path to the private key
+ * @param publicKeyPath
+ * the path to the public key
+ * @return
+ * @throws OpenshiftException
+ */
+ public static SSHKeyPair load(String privateKeyPath, String publicKeyPath)
+ throws OpenshiftException {
+ try {
+ KeyPair keyPair = KeyPair.load(new JSch(), privateKeyPath, publicKeyPath);
+ return new SSHKeyPair(keyPair, privateKeyPath, publicKeyPath);
+ } catch (JSchException e) {
+ throw new OpenshiftException(e, "Could not create new rsa key");
+ }
+ }
+
+ public String getPublicKey() throws OpenshiftException {
+ return new String(Base64Encoder.encode(keyPair.getPublicKeyBlob()));
+ }
+
+ protected String getPrivateKeyPath() {
+ return privateKeyPath;
+ }
+
+ protected String getPublicKeyPath() {
+ return publicKeyPath;
+ }
+
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/SSHKeyPair.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/SSHPublicKey.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/SSHPublicKey.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/SSHPublicKey.java 2011-09-16
13:08:14 UTC (rev 34815)
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.ide.eclipse.as.openshift.core;
+
+/**
+ * @author André Dietisheim
+ */
+public class SSHPublicKey implements ISSHPublicKey {
+
+ private String publicKey;
+
+ public SSHPublicKey(String publicKey) {
+ this.publicKey = publicKey;
+ }
+
+ public String getPublicKey() throws OpenshiftException {
+ return publicKey;
+ }
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/SSHPublicKey.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/User.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/User.java 2011-09-16
13:07:25 UTC (rev 34814)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/User.java 2011-09-16
13:08:14 UTC (rev 34815)
@@ -17,14 +17,14 @@
private String rhlogin;
private String uuid;
- private SSHKey sshKey;
+ private ISSHPublicKey sshKey;
private Domain domain;
public User(String rhlogin, String uuid, Domain domain) {
this(rhlogin, uuid, null, domain);
}
- public User(String rhlogin, String uuid, SSHKey sshKey, Domain domain) {
+ public User(String rhlogin, String uuid, ISSHPublicKey sshKey, Domain domain) {
this.rhlogin = rhlogin;
this.uuid = uuid;
this.sshKey = sshKey;
@@ -35,7 +35,7 @@
return domain;
}
- public SSHKey getSshKey() {
+ public ISSHPublicKey getSshKey() {
return sshKey;
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/OpenshiftService.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/OpenshiftService.java 2011-09-16
13:07:25 UTC (rev 34814)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/OpenshiftService.java 2011-09-16
13:08:14 UTC (rev 34815)
@@ -22,7 +22,7 @@
import org.jboss.ide.eclipse.as.openshift.core.InvalidCredentialsOpenshiftException;
import org.jboss.ide.eclipse.as.openshift.core.OpenshiftEndpointException;
import org.jboss.ide.eclipse.as.openshift.core.OpenshiftException;
-import org.jboss.ide.eclipse.as.openshift.core.SSHKey;
+import org.jboss.ide.eclipse.as.openshift.core.SSHKeyPair;
import org.jboss.ide.eclipse.as.openshift.core.UserInfo;
import org.jboss.ide.eclipse.as.openshift.core.internal.httpclient.HttpClientException;
import
org.jboss.ide.eclipse.as.openshift.core.internal.httpclient.UnauthorizedException;
@@ -109,22 +109,22 @@
}
@Override
- public SSHKey createKey(String passPhrase, String privateKeyPath, String publicKeyPath)
throws OpenshiftException {
- return SSHKey.create(passPhrase, privateKeyPath, publicKeyPath);
+ public SSHKeyPair createKey(String passPhrase, String privateKeyPath, String
publicKeyPath) throws OpenshiftException {
+ return SSHKeyPair.create(passPhrase, privateKeyPath, publicKeyPath);
}
@Override
- public SSHKey loadKey(String privateKeyPath, String publicKeyPath) throws
OpenshiftException {
- return SSHKey.load(privateKeyPath, publicKeyPath);
+ public SSHKeyPair loadKey(String privateKeyPath, String publicKeyPath) throws
OpenshiftException {
+ return SSHKeyPair.load(privateKeyPath, publicKeyPath);
}
@Override
- public Domain createDomain(String name, SSHKey sshKey) throws OpenshiftException {
+ public Domain createDomain(String name, SSHKeyPair sshKey) throws OpenshiftException {
return requestDomainAction(new CreateDomainRequest(name, sshKey, username, true));
}
@Override
- public Domain changeDomain(String newName, SSHKey sshKey) throws OpenshiftException {
+ public Domain changeDomain(String newName, SSHKeyPair sshKey) throws OpenshiftException
{
return requestDomainAction(new ChangeDomainRequest(newName, sshKey, username, true));
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/request/AbstractDomainRequest.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/request/AbstractDomainRequest.java 2011-09-16
13:07:25 UTC (rev 34814)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/request/AbstractDomainRequest.java 2011-09-16
13:08:14 UTC (rev 34815)
@@ -10,7 +10,7 @@
******************************************************************************/
package org.jboss.ide.eclipse.as.openshift.core.internal.request;
-import org.jboss.ide.eclipse.as.openshift.core.SSHKey;
+import org.jboss.ide.eclipse.as.openshift.core.SSHKeyPair;
/**
@@ -19,13 +19,13 @@
public abstract class AbstractDomainRequest extends AbstractOpenshiftRequest {
private String name;
- private SSHKey sshKey;
+ private SSHKeyPair sshKey;
- public AbstractDomainRequest(String name, SSHKey sshKey, String username) {
+ public AbstractDomainRequest(String name, SSHKeyPair sshKey, String username) {
this(name, sshKey, username, false);
}
- public AbstractDomainRequest(String name, SSHKey sshKey, String username, boolean debug)
{
+ public AbstractDomainRequest(String name, SSHKeyPair sshKey, String username, boolean
debug) {
super(username, debug);
this.name = name;
this.sshKey = sshKey;
@@ -35,7 +35,7 @@
return name;
}
- public SSHKey getSshKey() {
+ public SSHKeyPair getSshKey() {
return sshKey;
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/request/ChangeDomainRequest.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/request/ChangeDomainRequest.java 2011-09-16
13:07:25 UTC (rev 34814)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/request/ChangeDomainRequest.java 2011-09-16
13:08:14 UTC (rev 34815)
@@ -10,7 +10,7 @@
******************************************************************************/
package org.jboss.ide.eclipse.as.openshift.core.internal.request;
-import org.jboss.ide.eclipse.as.openshift.core.SSHKey;
+import org.jboss.ide.eclipse.as.openshift.core.SSHKeyPair;
/**
@@ -18,11 +18,11 @@
*/
public class ChangeDomainRequest extends AbstractDomainRequest {
- public ChangeDomainRequest(String name, SSHKey sshKey, String username) {
+ public ChangeDomainRequest(String name, SSHKeyPair sshKey, String username) {
this(name, sshKey, username, false);
}
- public ChangeDomainRequest(String name, SSHKey sshKey, String username, boolean debug)
{
+ public ChangeDomainRequest(String name, SSHKeyPair sshKey, String username, boolean
debug) {
super(name, sshKey, username, debug);
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/request/CreateDomainRequest.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/request/CreateDomainRequest.java 2011-09-16
13:07:25 UTC (rev 34814)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/request/CreateDomainRequest.java 2011-09-16
13:08:14 UTC (rev 34815)
@@ -10,7 +10,7 @@
******************************************************************************/
package org.jboss.ide.eclipse.as.openshift.core.internal.request;
-import org.jboss.ide.eclipse.as.openshift.core.SSHKey;
+import org.jboss.ide.eclipse.as.openshift.core.SSHKeyPair;
/**
@@ -18,11 +18,11 @@
*/
public class CreateDomainRequest extends AbstractDomainRequest {
- public CreateDomainRequest(String name, SSHKey sshKey, ApplicationAction action, String
username) {
+ public CreateDomainRequest(String name, SSHKeyPair sshKey, ApplicationAction action,
String username) {
this(name, sshKey, username, false);
}
- public CreateDomainRequest(String name, SSHKey sshKey, String username, boolean debug)
{
+ public CreateDomainRequest(String name, SSHKeyPair sshKey, String username, boolean
debug) {
super(name, sshKey, username, debug);
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/request/marshalling/DomainRequestJsonMarshaller.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/request/marshalling/DomainRequestJsonMarshaller.java 2011-09-16
13:07:25 UTC (rev 34814)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/request/marshalling/DomainRequestJsonMarshaller.java 2011-09-16
13:08:14 UTC (rev 34815)
@@ -24,6 +24,6 @@
protected void setJsonDataProperties(ModelNode node, AbstractDomainRequest request)
throws OpenshiftException {
node.get(IOpenshiftJsonConstants.PROPERTY_NAMESPACE).set(request.getName());
node.get(IOpenshiftJsonConstants.PROPERTY_ALTER).set(String.valueOf(request.isAlter()));
- node.get(IOpenshiftJsonConstants.PROPERTY_SSH).set(request.getSshKey().getPublicKeyContent());
+ node.get(IOpenshiftJsonConstants.PROPERTY_SSH).set(request.getSshKey().getPublicKey());
}
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/response/UserInfoResponseUnmarshaller.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/response/UserInfoResponseUnmarshaller.java 2011-09-16
13:07:25 UTC (rev 34814)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/response/UserInfoResponseUnmarshaller.java 2011-09-16
13:08:14 UTC (rev 34815)
@@ -22,6 +22,8 @@
import org.jboss.ide.eclipse.as.openshift.core.Domain;
import org.jboss.ide.eclipse.as.openshift.core.IOpenshiftJsonConstants;
import org.jboss.ide.eclipse.as.openshift.core.IOpenshiftService;
+import org.jboss.ide.eclipse.as.openshift.core.ISSHPublicKey;
+import org.jboss.ide.eclipse.as.openshift.core.SSHPublicKey;
import org.jboss.ide.eclipse.as.openshift.core.User;
import org.jboss.ide.eclipse.as.openshift.core.UserInfo;
@@ -42,29 +44,36 @@
if (!isSet(dataNode)) {
return null;
}
+
ModelNode userInfoNode = dataNode.get(IOpenshiftJsonConstants.PROPERTY_USER_INFO);
if (!isSet(userInfoNode)) {
return null;
}
- User user = createUser(userInfoNode, createDomain(userInfoNode));
- return new UserInfo(
- user,
- createApplications(dataNode.get(IOpenshiftJsonConstants.PROPERTY_APP_INFO)));
+
+ ISSHPublicKey sshKey = createSSHKey(userInfoNode);
+ User user = createUser(userInfoNode, sshKey, createDomain(userInfoNode));
+ List<Application> applications =
createApplications(dataNode.get(IOpenshiftJsonConstants.PROPERTY_APP_INFO));
+
+ return new UserInfo(user, applications);
}
- private List<Application> createApplications(ModelNode appInfoNode) throws
DatatypeConfigurationException {
+ private ISSHPublicKey createSSHKey(ModelNode userInfoNode) {
+ String sshPublicKey = getString(IOpenshiftJsonConstants.PROPERTY_SSH_KEY,
userInfoNode);
+ return new SSHPublicKey(sshPublicKey);
+ }
+
+ private List<Application> createApplications(ModelNode appInfoNode) throws
DatatypeConfigurationException {
List<Application> applications = new ArrayList<Application>();
if (!isSet(appInfoNode)) {
return applications;
}
- for(String name : appInfoNode.keys()) {
+ for (String name : appInfoNode.keys()) {
applications.add(createApplication(name, appInfoNode.get(name)));
}
return applications;
}
-
private Application createApplication(String name, ModelNode appNode) throws
DatatypeConfigurationException {
String embedded = getString(IOpenshiftJsonConstants.PROPERTY_EMBEDDED, appNode);
String uuid = getString(IOpenshiftJsonConstants.PROPERTY_UUID, appNode);
@@ -73,16 +82,15 @@
return new Application(name, uuid, cartrdige, embedded, creationTime.getTime(),
service);
}
- protected User createUser(ModelNode userInfoNode, Domain domain) {
+ private User createUser(ModelNode userInfoNode, ISSHPublicKey sshKey, Domain domain) {
String rhlogin = getString(IOpenshiftJsonConstants.PROPERTY_RHLOGIN, userInfoNode);
- String uuid = getString(IOpenshiftJsonConstants.PROPERTY_RHLOGIN, userInfoNode);
- return new User(rhlogin, uuid, domain);
+ String uuid = getString(IOpenshiftJsonConstants.PROPERTY_UUID, userInfoNode);
+ return new User(rhlogin, uuid, sshKey, domain);
}
- protected Domain createDomain(ModelNode userInfoNode) {
+ private Domain createDomain(ModelNode userInfoNode) {
String namespace = getString(IOpenshiftJsonConstants.PROPERTY_NAMESPACE,
userInfoNode);
String rhcDomain = getString(IOpenshiftJsonConstants.PROPERTY_RHC_DOMAIN,
userInfoNode);
return new Domain(namespace, rhcDomain);
}
-
}
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/DomainIntegrationTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/DomainIntegrationTest.java 2011-09-16
13:07:25 UTC (rev 34814)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/DomainIntegrationTest.java 2011-09-16
13:08:14 UTC (rev 34815)
@@ -14,7 +14,7 @@
import static org.junit.Assert.assertNotNull;
import org.jboss.ide.eclipse.as.openshift.core.Domain;
-import org.jboss.ide.eclipse.as.openshift.core.SSHKey;
+import org.jboss.ide.eclipse.as.openshift.core.SSHKeyPair;
import org.jboss.ide.eclipse.as.openshift.core.internal.OpenshiftService;
import org.jboss.ide.eclipse.as.openshift.test.internal.core.fakes.TestSSHKey;
import org.junit.Before;
@@ -36,7 +36,7 @@
public void canCreateDomain() throws Exception {
String domainName = createRandomString();
- SSHKey sshKey = TestSSHKey.create();
+ SSHKeyPair sshKey = TestSSHKey.create();
Domain domain = openshiftService.createDomain(domainName, sshKey);
assertNotNull(domain);
@@ -47,7 +47,7 @@
public void canChangeDomain() throws Exception {
String domainName = createRandomString();
- SSHKey sshKey = TestSSHKey.create();
+ SSHKeyPair sshKey = TestSSHKey.create();
Domain domain = openshiftService.changeDomain(domainName, sshKey);
assertNotNull(domain);
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/DomainTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/DomainTest.java 2011-09-16
13:07:25 UTC (rev 34814)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/DomainTest.java 2011-09-16
13:08:14 UTC (rev 34815)
@@ -19,7 +19,7 @@
import org.jboss.ide.eclipse.as.openshift.core.Domain;
import org.jboss.ide.eclipse.as.openshift.core.OpenshiftException;
-import org.jboss.ide.eclipse.as.openshift.core.SSHKey;
+import org.jboss.ide.eclipse.as.openshift.core.SSHKeyPair;
import org.jboss.ide.eclipse.as.openshift.core.internal.request.ChangeDomainRequest;
import org.jboss.ide.eclipse.as.openshift.core.internal.request.CreateDomainRequest;
import
org.jboss.ide.eclipse.as.openshift.core.internal.request.OpenshiftEnvelopeFactory;
@@ -41,9 +41,9 @@
@Test
public void canMarshallDomainCreateRequest() throws IOException, OpenshiftException {
- SSHKey sshKey = TestSSHKey.create();
+ SSHKeyPair sshKey = TestSSHKey.create();
String expectedRequestString = createDomainRequestString(PASSWORD, USERNAME, true,
"myDomain", false,
- sshKey.getPublicKeyContent());
+ sshKey.getPublicKey());
CreateDomainRequest request = new CreateDomainRequest("myDomain", sshKey,
USERNAME, true);
String requestString =
@@ -69,9 +69,9 @@
@Test
public void canMarshallDomainAlterRequest() throws IOException, OpenshiftException {
- SSHKey sshKey = TestSSHKey.create();
+ SSHKeyPair sshKey = TestSSHKey.create();
String expectedRequestString = createDomainRequestString(PASSWORD, USERNAME, true,
"myDomain", true,
- sshKey.getPublicKeyContent());
+ sshKey.getPublicKey());
ChangeDomainRequest request = new ChangeDomainRequest("myDomain", sshKey,
USERNAME, true);
String requestString =
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/SSHKeyTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/SSHKeyTest.java 2011-09-16
13:07:25 UTC (rev 34814)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/SSHKeyTest.java 2011-09-16
13:08:14 UTC (rev 34815)
@@ -16,7 +16,7 @@
import java.io.File;
import java.io.IOException;
-import org.jboss.ide.eclipse.as.openshift.core.SSHKey;
+import org.jboss.ide.eclipse.as.openshift.core.SSHKeyPair;
import org.junit.Test;
public class SSHKeyTest {
@@ -27,8 +27,8 @@
public void canCreatePublicKey() throws Exception {
String publicKeyPath = createTempFile().getAbsolutePath();
String privateKeyPath = createTempFile().getAbsolutePath();
- SSHKey sshKey = SSHKey.create(PASSPHRASE, privateKeyPath, publicKeyPath);
- String publicKey = sshKey.getPublicKeyContent();
+ SSHKeyPair sshKey = SSHKeyPair.create(PASSPHRASE, privateKeyPath, publicKeyPath);
+ String publicKey = sshKey.getPublicKey();
assertNotNull(publicKey);
assertTrue(!publicKey.contains("ssh-rsa")); // no identifier
@@ -39,10 +39,10 @@
public void canLoadPublicKey() throws Exception {
String publicKeyPath = createTempFile().getAbsolutePath();
String privateKeyPath = createTempFile().getAbsolutePath();
- SSHKey.create(PASSPHRASE, privateKeyPath, publicKeyPath);
+ SSHKeyPair.create(PASSPHRASE, privateKeyPath, publicKeyPath);
- SSHKey sshKey = SSHKey.load(privateKeyPath, publicKeyPath);
- String publicKey = sshKey.getPublicKeyContent();
+ SSHKeyPair sshKey = SSHKeyPair.load(privateKeyPath, publicKeyPath);
+ String publicKey = sshKey.getPublicKey();
assertNotNull(publicKey);
assertTrue(!publicKey.contains("ssh-rsa")); // no identifier
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/UserInfoTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/UserInfoTest.java 2011-09-16
13:07:25 UTC (rev 34814)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/UserInfoTest.java 2011-09-16
13:08:14 UTC (rev 34815)
@@ -10,11 +10,13 @@
******************************************************************************/
package org.jboss.ide.eclipse.as.openshift.test.internal.core;
-import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import java.net.URLEncoder;
+import org.jboss.ide.eclipse.as.openshift.core.Domain;
+import org.jboss.ide.eclipse.as.openshift.core.ISSHPublicKey;
import org.jboss.ide.eclipse.as.openshift.core.User;
import org.jboss.ide.eclipse.as.openshift.core.UserInfo;
import
org.jboss.ide.eclipse.as.openshift.core.internal.request.OpenshiftEnvelopeFactory;
@@ -37,7 +39,12 @@
private static final String RHC_DOMAIN = "rhcloud.com";
private static final String NAMESPACE = "1315839296868";
private static final String UUID = "5f34b742db754cc9ab70fd1db2c9a2bd";
-
+ private static final String SSH_KEY =
+ "AAAAB3NzaC1yc2EAAAADAQABAAAAgQC6BGRDydfGsQHhnZgo43dEfLz"
+ + "SJBke/hE8MLBBG1+5ZwktsrE+f2VdVt0McRLVAO6rdJRyMUX0rTbm7"
+ + "SABRVSX+zeQjlfqbbUtYFc7TIfd4RQc3GaISG1rS3C4svRSjdWaG36"
+ + "vDY2KxowdFvpKj8i8IYNPlLoRA/7EzzyneS6iyw==";
+
private static final String userInfoRespose =
"{"
+ " \"messages\":\"\","
@@ -50,8 +57,8 @@
+ " \\\"rhc_domain\\\":\\\"" + RHC_DOMAIN +
"\\\"," //
+ " \\\"rhlogin\\\":\\\"" + USERNAME +
"\\\","
+ " \\\"namespace\\\":\\\"" + NAMESPACE +
"\\\","
- + " \\\"uuid\\\":\\\"" + UUID +"\\\","
- +
" \\\"ssh_key\\\":\\\"AAAAB3NzaC1yc2EAAAADAQABAAAAgQC6BGRDydfGsQHhnZgo43dEfLzSJBke/hE8MLBBG1+5ZwktsrE+f2VdVt0McRLVAO6rdJRyMUX0rTbm7SABRVSX+zeQjlfqbbUtYFc7TIfd4RQc3GaISG1rS3C4svRSjdWaG36vDY2KxowdFvpKj8i8IYNPlLoRA/7EzzyneS6iyw==\\\""
+ + " \\\"uuid\\\":\\\"" + UUID + "\\\","
+ + " \\\"ssh_key\\\":\\\"" + SSH_KEY +
"\\\""
+ " },"
+ " \\\"app_info\\\":"
+ " {"
@@ -114,10 +121,18 @@
UserInfo userInfo = response.getOpenshiftObject();
assertNotNull(userInfo);
+
User user = userInfo.getUser();
assertNotNull(user);
assertEquals(USERNAME, user.getRhlogin());
assertEquals(UUID, user.getUuid());
+ ISSHPublicKey sshKey = user.getSshKey();
+ assertNotNull(sshKey);
+ assertEquals(SSH_KEY,sshKey.getPublicKey());
+
+ Domain domain = user.getDomain();
+ assertEquals(NAMESPACE, domain.getNamespace());
+ assertEquals(RHC_DOMAIN, domain.getRhcDomain());
+
}
-
}
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/fakes/NoopOpenshiftServiceFake.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/fakes/NoopOpenshiftServiceFake.java 2011-09-16
13:07:25 UTC (rev 34814)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/fakes/NoopOpenshiftServiceFake.java 2011-09-16
13:08:14 UTC (rev 34815)
@@ -17,7 +17,7 @@
import org.jboss.ide.eclipse.as.openshift.core.Domain;
import org.jboss.ide.eclipse.as.openshift.core.IOpenshiftService;
import org.jboss.ide.eclipse.as.openshift.core.OpenshiftException;
-import org.jboss.ide.eclipse.as.openshift.core.SSHKey;
+import org.jboss.ide.eclipse.as.openshift.core.SSHKeyPair;
import org.jboss.ide.eclipse.as.openshift.core.UserInfo;
/**
@@ -66,22 +66,22 @@
}
@Override
- public Domain changeDomain(String domainName, SSHKey sshKey) throws OpenshiftException
{
+ public Domain changeDomain(String domainName, SSHKeyPair sshKey) throws
OpenshiftException {
throw new UnsupportedOperationException();
}
@Override
- public Domain createDomain(String name, SSHKey keyPair) throws OpenshiftException {
+ public Domain createDomain(String name, SSHKeyPair keyPair) throws OpenshiftException {
throw new UnsupportedOperationException();
}
@Override
- public SSHKey createKey(String passPhrase, String privateKeyPath, String publicKeyPath)
throws OpenshiftException {
+ public SSHKeyPair createKey(String passPhrase, String privateKeyPath, String
publicKeyPath) throws OpenshiftException {
throw new UnsupportedOperationException();
}
@Override
- public SSHKey loadKey(String privateKeyPath, String publicKeyPath) throws
OpenshiftException {
+ public SSHKeyPair loadKey(String privateKeyPath, String publicKeyPath) throws
OpenshiftException {
throw new UnsupportedOperationException();
}
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/fakes/TestSSHKey.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/fakes/TestSSHKey.java 2011-09-16
13:07:25 UTC (rev 34814)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/fakes/TestSSHKey.java 2011-09-16
13:08:14 UTC (rev 34815)
@@ -14,7 +14,7 @@
import java.io.IOException;
import org.jboss.ide.eclipse.as.openshift.core.OpenshiftException;
-import org.jboss.ide.eclipse.as.openshift.core.SSHKey;
+import org.jboss.ide.eclipse.as.openshift.core.SSHKeyPair;
import org.jboss.ide.eclipse.as.openshift.test.internal.core.utils.StreamUtils;
/**
@@ -50,14 +50,14 @@
"1rS3C4svRSjdWaG36vDY2KxowdFvpKj8i8IYNPlLoRA/7EzzyneS6iyw" +
"== created by org.jboss.ide.eclipse.as.openshift.core";
- public static SSHKey create() throws IOException, OpenshiftException {
+ public static SSHKeyPair create() throws IOException, OpenshiftException {
File privateKeyFile = File.createTempFile(createRandomString(), null);
StreamUtils.writeTo(privateKey, privateKeyFile);
File publicKeyFile = File.createTempFile(createRandomString(), null);
StreamUtils.writeTo(publicKey, publicKeyFile);
- return SSHKey.load(privateKeyFile.getAbsolutePath(), publicKeyFile.getAbsolutePath());
+ return SSHKeyPair.load(privateKeyFile.getAbsolutePath(),
publicKeyFile.getAbsolutePath());
}
private static String createRandomString() {