airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ami...@apache.org
Subject svn commit: r1529280 - in /airavata/sandbox/gsissh/src: main/java/com/jcraft/jsch/ main/java/org/apache/airavata/gsi/ssh/api/ main/java/org/apache/airavata/gsi/ssh/api/authentication/ main/java/org/apache/airavata/gsi/ssh/impl/ main/java/org/apache/air...
Date Fri, 04 Oct 2013 20:22:52 GMT
Author: amilaj
Date: Fri Oct  4 20:22:51 2013
New Revision: 1529280

URL: http://svn.apache.org/r1529280
Log:
Modified GSI-SSH to work with vanilla SSH. Support Key based and password based authentication mechanism

Added:
    airavata/sandbox/gsissh/src/main/java/com/jcraft/jsch/GSISSHIdentityFile.java
    airavata/sandbox/gsissh/src/main/java/com/jcraft/jsch/GSISSHIdentityRepository.java
    airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/authentication/
    airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/authentication/AuthenticationInfo.java
    airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/authentication/GSIAuthenticationInfo.java
      - copied, changed from r1525044, airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/AuthenticationInfo.java
    airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/authentication/SSHKeyAuthentication.java
    airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/authentication/SSHPasswordAuthentication.java
    airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/authentication/SSHPublicKeyAuthentication.java
    airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/authentication/SSHPublicKeyFileAuthentication.java
    airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/SSHUserInfo.java
    airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/authentication/
    airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/authentication/DefaultPasswordAuthenticationInfo.java
    airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/authentication/DefaultPublicKeyAuthentication.java
    airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/authentication/DefaultPublicKeyFileAuthentication.java
    airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/authentication/MyProxyAuthenticationInfo.java
      - copied, changed from r1525044, airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/MyProxyAuthenticationInfo.java
    airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/util/SSHAPIUIKeyboardInteractive.java
    airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/util/SSHKeyPasswordHandler.java
    airavata/sandbox/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/VanilaSSHTest.java
Removed:
    airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/AuthenticationInfo.java
    airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/MyProxyAuthenticationInfo.java
Modified:
    airavata/sandbox/gsissh/src/main/java/com/jcraft/jsch/ExtendedSession.java
    airavata/sandbox/gsissh/src/main/java/com/jcraft/jsch/UserAuthGSSAPIWithMICGSSCredentials.java
    airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/CommandExecutor.java
    airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/PBSCluster.java
    airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/jsch/ExtendedJSch.java
    airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/util/SSHUtils.java
    airavata/sandbox/gsissh/src/test/java/org/apache/airavata/gsi/ssh/config/SCPToTest.java
    airavata/sandbox/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/DefaultSSHApiTest.java

Modified: airavata/sandbox/gsissh/src/main/java/com/jcraft/jsch/ExtendedSession.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/com/jcraft/jsch/ExtendedSession.java?rev=1529280&r1=1529279&r2=1529280&view=diff
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/com/jcraft/jsch/ExtendedSession.java (original)
+++ airavata/sandbox/gsissh/src/main/java/com/jcraft/jsch/ExtendedSession.java Fri Oct  4 20:22:51 2013
@@ -21,10 +21,7 @@
 
 package com.jcraft.jsch;
 
-import com.jcraft.jsch.JSch;
-import com.jcraft.jsch.JSchException;
-import com.jcraft.jsch.Session;
-import org.apache.airavata.gsi.ssh.api.AuthenticationInfo;
+import org.apache.airavata.gsi.ssh.api.authentication.GSIAuthenticationInfo;
 
 /**
  * User: AmilaJ (amilaj@apache.org)
@@ -34,17 +31,17 @@ import org.apache.airavata.gsi.ssh.api.A
 
 public class ExtendedSession extends Session {
 
-    private AuthenticationInfo authenticationInfo;
+    private GSIAuthenticationInfo authenticationInfo;
 
     public ExtendedSession(JSch jsch, String username, String host, int port) throws JSchException {
         super(jsch, username, host, port);
     }
 
-    public AuthenticationInfo getAuthenticationInfo() {
+    public GSIAuthenticationInfo getAuthenticationInfo() {
         return authenticationInfo;
     }
 
-    public void setAuthenticationInfo(AuthenticationInfo authenticationInfo) {
+    public void setAuthenticationInfo(GSIAuthenticationInfo authenticationInfo) {
         this.authenticationInfo = authenticationInfo;
     }
 }

Added: airavata/sandbox/gsissh/src/main/java/com/jcraft/jsch/GSISSHIdentityFile.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/com/jcraft/jsch/GSISSHIdentityFile.java?rev=1529280&view=auto
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/com/jcraft/jsch/GSISSHIdentityFile.java (added)
+++ airavata/sandbox/gsissh/src/main/java/com/jcraft/jsch/GSISSHIdentityFile.java Fri Oct  4 20:22:51 2013
@@ -0,0 +1,128 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+
+package com.jcraft.jsch;
+
+import java.io.*;
+
+/**
+ * NOTE : This is class is directly created using com.jcraft.jsch.IdentityFile
+ * IdentityFile has private access. Therefore to suit our requirements we modify IdentityFile
+ * with public access.
+ */
+public class GSISSHIdentityFile implements Identity{
+    private JSch jsch;
+    private KeyPair kpair;
+    private String identity;
+
+    public static GSISSHIdentityFile newInstance(String prvfile, String pubfile, JSch jsch) throws JSchException{
+        KeyPair kpair = KeyPair.load(jsch, prvfile, pubfile);
+        return new GSISSHIdentityFile(jsch, prvfile, kpair);
+    }
+
+    public static GSISSHIdentityFile newInstance(String name, byte[] prvkey, byte[] pubkey, JSch jsch) throws JSchException{
+        KeyPair kpair = KeyPair.load(jsch, prvkey, pubkey);
+        return new GSISSHIdentityFile(jsch, name, kpair);
+    }
+
+    private GSISSHIdentityFile(JSch jsch, String name, KeyPair kpair) throws JSchException{
+        this.jsch = jsch;
+        this.identity = name;
+        this.kpair = kpair;
+    }
+
+    /**
+     * Decrypts this identity with the specified pass-phrase.
+     * @param passphrase the pass-phrase for this identity.
+     * @return <tt>true</tt> if the decryption is succeeded
+     * or this identity is not cyphered.
+     */
+    public boolean setPassphrase(byte[] passphrase) throws JSchException{
+        return kpair.decrypt(passphrase);
+    }
+
+    /**
+     * Returns the public-key blob.
+     * @return the public-key blob
+     */
+    public byte[] getPublicKeyBlob(){
+        return kpair.getPublicKeyBlob();
+    }
+
+    /**
+     * Signs on data with this identity, and returns the result.
+     * @param data data to be signed
+     * @return the signature
+     */
+    public byte[] getSignature(byte[] data){
+        return kpair.getSignature(data);
+    }
+
+    /**
+     * @deprecated This method should not be invoked.
+     * @see #setPassphrase(byte[] passphrase)
+     */
+    public boolean decrypt(){
+        throw new RuntimeException("not implemented");
+    }
+
+    /**
+     * Returns the name of the key algorithm.
+     * @return "ssh-rsa" or "ssh-dss"
+     */
+    public String getAlgName(){
+        return new String(kpair.getKeyTypeName());
+    }
+
+    /**
+     * Returns the name of this identity.
+     * It will be useful to identify this object in the {@link IdentityRepository}.
+     */
+    public String getName(){
+        return identity;
+    }
+
+    /**
+     * Returns <tt>true</tt> if this identity is cyphered.
+     * @return <tt>true</tt> if this identity is cyphered.
+     */
+    public boolean isEncrypted(){
+        return kpair.isEncrypted();
+    }
+
+    /**
+     * Disposes internally allocated data, like byte array for the private key.
+     */
+    public void clear(){
+        kpair.dispose();
+        kpair = null;
+    }
+
+    /**
+     * Returns an instance of {@link KeyPair} used in this {@link Identity}.
+     * @return an instance of {@link KeyPair} used in this {@link Identity}.
+     */
+    public KeyPair getKeyPair(){
+        return kpair;
+    }
+}
+

Added: airavata/sandbox/gsissh/src/main/java/com/jcraft/jsch/GSISSHIdentityRepository.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/com/jcraft/jsch/GSISSHIdentityRepository.java?rev=1529280&view=auto
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/com/jcraft/jsch/GSISSHIdentityRepository.java (added)
+++ airavata/sandbox/gsissh/src/main/java/com/jcraft/jsch/GSISSHIdentityRepository.java Fri Oct  4 20:22:51 2013
@@ -0,0 +1,35 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package com.jcraft.jsch;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 10/4/13
+ * Time: 12:37 PM
+ */
+
+public class GSISSHIdentityRepository extends LocalIdentityRepository {
+
+    public GSISSHIdentityRepository(JSch jsch) {
+        super(jsch);
+    }
+}

Modified: airavata/sandbox/gsissh/src/main/java/com/jcraft/jsch/UserAuthGSSAPIWithMICGSSCredentials.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/com/jcraft/jsch/UserAuthGSSAPIWithMICGSSCredentials.java?rev=1529280&r1=1529279&r2=1529280&view=diff
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/com/jcraft/jsch/UserAuthGSSAPIWithMICGSSCredentials.java (original)
+++ airavata/sandbox/gsissh/src/main/java/com/jcraft/jsch/UserAuthGSSAPIWithMICGSSCredentials.java Fri Oct  4 20:22:51 2013
@@ -5,7 +5,7 @@ import java.util.Iterator;
 import java.util.List;
 
 import org.apache.airavata.gsi.ssh.GSSContextX509;
-import org.apache.airavata.gsi.ssh.api.AuthenticationInfo;
+import org.apache.airavata.gsi.ssh.api.authentication.GSIAuthenticationInfo;
 import org.globus.gsi.gssapi.GSSConstants;
 import org.ietf.jgss.GSSException;
 import org.ietf.jgss.Oid;
@@ -170,7 +170,7 @@ public class UserAuthGSSAPIWithMICGSSCre
         // Get the credentials and set them
         // Not a good way, but we dont have any choice
         if (session instanceof ExtendedSession) {
-            AuthenticationInfo authenticationInfo = ((ExtendedSession) session).getAuthenticationInfo();
+            GSIAuthenticationInfo authenticationInfo = ((ExtendedSession) session).getAuthenticationInfo();
 
             if (context instanceof GSSContextX509) {
                 ((GSSContextX509) context).setCredential(authenticationInfo.getCredentials());

Modified: airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/CommandExecutor.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/CommandExecutor.java?rev=1529280&r1=1529279&r2=1529280&view=diff
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/CommandExecutor.java (original)
+++ airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/CommandExecutor.java Fri Oct  4 20:22:51 2013
@@ -20,15 +20,15 @@
 */
 package org.apache.airavata.gsi.ssh.api;
 
-import com.jcabi.aspects.RetryOnFailure;
 import com.jcraft.jsch.*;
+import org.apache.airavata.gsi.ssh.api.authentication.*;
 import org.apache.airavata.gsi.ssh.config.ConfigReader;
 import org.apache.airavata.gsi.ssh.jsch.ExtendedJSch;
+import org.apache.airavata.gsi.ssh.util.SSHAPIUIKeyboardInteractive;
+import org.apache.airavata.gsi.ssh.util.SSHKeyPasswordHandler;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.*;
-
 /**
  * This is a generic class which take care of command execution
  * in a shell, this is used through out the other places of the API.
@@ -51,7 +51,6 @@ public class CommandExecutor {
      * @param commandOutput
      * @throws SSHApiException
      */
-    @RetryOnFailure(attempts = 3, delay = 1000, verbose = true)
     public static Session executeCommand(CommandInfo commandInfo, Session session,
                                          CommandOutput commandOutput) throws SSHApiException {
 
@@ -102,7 +101,13 @@ public class CommandExecutor {
     public static void executeCommand(CommandInfo commandInfo, ServerInfo serverInfo,
                                       AuthenticationInfo authenticationInfo,
                                       CommandOutput commandOutput, ConfigReader configReader) throws SSHApiException {
-        System.setProperty(X509_CERT_DIR, (String) authenticationInfo.getProperties().get("X509_CERT_DIR"));
+
+        if (authenticationInfo instanceof GSIAuthenticationInfo) {
+            System.setProperty(X509_CERT_DIR, (String) ((GSIAuthenticationInfo)authenticationInfo).getProperties().
+                    get("X509_CERT_DIR"));
+        }
+
+
         JSch jsch = new ExtendedJSch();
 
         log.debug("Connecting to server - " + serverInfo.getHost() + ":" + serverInfo.getPort() + " with user name - "
@@ -122,9 +127,98 @@ public class CommandExecutor {
         java.util.Properties config = configReader.getProperties();
         session.setConfig(config);
 
+        //=============================================================
+        // Handling vanilla SSH pieces
+        //=============================================================
+        if (authenticationInfo instanceof SSHPasswordAuthentication) {
+            String password = ((SSHPasswordAuthentication) authenticationInfo).
+                    getPassword(serverInfo.getUserName(), serverInfo.getHost());
+
+            session.setUserInfo(new SSHAPIUIKeyboardInteractive(password));
+
+            // TODO figure out why we need to set password to session
+            session.setPassword(password);
+
+        } else if (authenticationInfo instanceof SSHPublicKeyFileAuthentication) {
+            SSHPublicKeyFileAuthentication sshPublicKeyFileAuthentication
+                    = (SSHPublicKeyFileAuthentication)authenticationInfo;
+
+            String privateKeyFile = sshPublicKeyFileAuthentication.
+                    getPrivateKeyFile(serverInfo.getUserName(), serverInfo.getHost());
+
+            logDebug("The private key file for vanilla SSH " + privateKeyFile);
+
+            String publicKeyFile = sshPublicKeyFileAuthentication.
+                    getPrivateKeyFile(serverInfo.getUserName(), serverInfo.getHost());
+
+            logDebug("The public key file for vanilla SSH " + publicKeyFile);
+
+            Identity identityFile;
+
+            try {
+                identityFile = GSISSHIdentityFile.newInstance(privateKeyFile, null, jsch);
+            } catch (JSchException e) {
+                throw new SSHApiException("An exception occurred while initializing keys using files. " +
+                        "(private key and public key)." +
+                        "Connecting server - " + serverInfo.getHost() + ":" + serverInfo.getPort() +
+                        " connecting user name - "
+                        + serverInfo.getUserName() + " private key file - " + privateKeyFile + ", public key file - " +
+                        publicKeyFile, e);
+            }
+
+            // Add identity to identity repository
+            GSISSHIdentityRepository identityRepository = new GSISSHIdentityRepository(jsch);
+            identityRepository.add(identityFile);
+
+            // Set repository to session
+            session.setIdentityRepository(identityRepository);
+
+            // Set the user info
+            SSHKeyPasswordHandler sshKeyPasswordHandler
+                    = new SSHKeyPasswordHandler((SSHKeyAuthentication)authenticationInfo);
+
+            session.setUserInfo(sshKeyPasswordHandler);
+
+        } else if (authenticationInfo instanceof SSHPublicKeyAuthentication) {
+
+            SSHPublicKeyAuthentication sshPublicKeyAuthentication
+                    = (SSHPublicKeyAuthentication)authenticationInfo;
+
+            Identity identityFile;
+
+            try {
+                String name = serverInfo.getUserName() + "_" + serverInfo.getHost();
+                identityFile = GSISSHIdentityFile.newInstance(name,
+                        sshPublicKeyAuthentication.getPrivateKey(serverInfo.getUserName(), serverInfo.getHost()),
+                        sshPublicKeyAuthentication.getPublicKey(serverInfo.getUserName(), serverInfo.getHost()), jsch);
+            } catch (JSchException e) {
+                throw new SSHApiException("An exception occurred while initializing keys using byte arrays. " +
+                        "(private key and public key)." +
+                        "Connecting server - " + serverInfo.getHost() + ":" + serverInfo.getPort() +
+                        " connecting user name - "
+                        + serverInfo.getUserName(), e);
+            }
+
+            // Add identity to identity repository
+            GSISSHIdentityRepository identityRepository = new GSISSHIdentityRepository(jsch);
+            identityRepository.add(identityFile);
+
+            // Set repository to session
+            session.setIdentityRepository(identityRepository);
+
+            // Set the user info
+            SSHKeyPasswordHandler sshKeyPasswordHandler
+                    = new SSHKeyPasswordHandler((SSHKeyAuthentication)authenticationInfo);
+
+            session.setUserInfo(sshKeyPasswordHandler);
+
+        }
+
         // Not a good way, but we dont have any choice
         if (session instanceof ExtendedSession) {
-            ((ExtendedSession) session).setAuthenticationInfo(authenticationInfo);
+            if (authenticationInfo instanceof GSIAuthenticationInfo) {
+                ((ExtendedSession) session).setAuthenticationInfo((GSIAuthenticationInfo)authenticationInfo);
+            }
         }
 
         try {
@@ -173,4 +267,12 @@ public class CommandExecutor {
         channel.disconnect();
         session.disconnect();
     }
+
+    private static void logDebug(String message) {
+        if (log.isDebugEnabled()) {
+            log.debug(message);
+        }
+    }
+
+
 }

Added: airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/authentication/AuthenticationInfo.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/authentication/AuthenticationInfo.java?rev=1529280&view=auto
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/authentication/AuthenticationInfo.java (added)
+++ airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/authentication/AuthenticationInfo.java Fri Oct  4 20:22:51 2013
@@ -0,0 +1,32 @@
+package org.apache.airavata.gsi.ssh.api.authentication;/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 10/4/13
+ * Time: 11:25 AM
+ */
+
+/**
+ * An empty interface that represents authentication data to the API.
+ */
+public interface AuthenticationInfo {
+}

Copied: airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/authentication/GSIAuthenticationInfo.java (from r1525044, airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/AuthenticationInfo.java)
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/authentication/GSIAuthenticationInfo.java?p2=airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/authentication/GSIAuthenticationInfo.java&p1=airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/AuthenticationInfo.java&r1=1525044&r2=1529280&rev=1529280&view=diff
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/AuthenticationInfo.java (original)
+++ airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/authentication/GSIAuthenticationInfo.java Fri Oct  4 20:22:51 2013
@@ -1,4 +1,4 @@
-package org.apache.airavata.gsi.ssh.api;/*
+package org.apache.airavata.gsi.ssh.api.authentication;/*
  *
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -27,7 +27,7 @@ import java.util.Properties;
  * Authentication data. Could be MyProxy user name, password, could be GSSCredentials
  * or could be SSH keys.
  */
-public abstract class AuthenticationInfo {
+public abstract class GSIAuthenticationInfo implements AuthenticationInfo {
 
     public Properties properties = new Properties();
 

Added: airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/authentication/SSHKeyAuthentication.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/authentication/SSHKeyAuthentication.java?rev=1529280&view=auto
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/authentication/SSHKeyAuthentication.java (added)
+++ airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/authentication/SSHKeyAuthentication.java Fri Oct  4 20:22:51 2013
@@ -0,0 +1,46 @@
+package org.apache.airavata.gsi.ssh.api.authentication;/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 10/4/13
+ * Time: 2:39 PM
+ */
+
+/**
+ * Abstracts out common methods for SSH key authentication.
+ */
+public interface SSHKeyAuthentication extends AuthenticationInfo {
+
+    /**
+     * This is needed only if private key and public keys are encrypted.
+     * If they are not encrypted we can just return null.
+     * @return User should return pass phrase if keys are encrypted. If not null.
+     */
+    String getPassPhrase();
+
+    /**
+     * Callback with the banner message. API user can get hold of banner message
+     * by implementing this method.
+     * @param message The banner message.
+     */
+    void bannerMessage(String message);
+}

Added: airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/authentication/SSHPasswordAuthentication.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/authentication/SSHPasswordAuthentication.java?rev=1529280&view=auto
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/authentication/SSHPasswordAuthentication.java (added)
+++ airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/authentication/SSHPasswordAuthentication.java Fri Oct  4 20:22:51 2013
@@ -0,0 +1,43 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.gsi.ssh.api.authentication;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 10/4/13
+ * Time: 11:22 AM
+ */
+
+/**
+ * Password authentication for vanilla SSH.
+ */
+public interface SSHPasswordAuthentication extends AuthenticationInfo {
+
+    /**
+     * Gets the password for given host name and given user name.
+     * @param userName The connecting user name name.
+     * @param hostName The connecting host.
+     * @return Password for the given user.
+     */
+    String getPassword(String userName, String hostName);
+
+}

Added: airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/authentication/SSHPublicKeyAuthentication.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/authentication/SSHPublicKeyAuthentication.java?rev=1529280&view=auto
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/authentication/SSHPublicKeyAuthentication.java (added)
+++ airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/authentication/SSHPublicKeyAuthentication.java Fri Oct  4 20:22:51 2013
@@ -0,0 +1,54 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.gsi.ssh.api.authentication;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 10/4/13
+ * Time: 9:48 AM
+ */
+
+
+/**
+ * Public key authentication for vanilla SSH.
+ * The public key and private key are returned as byte arrays. Useful when we store private key/public key
+ * in a secure storage such as credential store. API user should implement this.
+ */
+public interface SSHPublicKeyAuthentication extends SSHKeyAuthentication {
+
+    /**
+     * Gets the public key as byte array.
+     * @param userName The user who is trying to SSH
+     * @param hostName The host which user wants to connect to.
+     * @return The public key as a byte array.
+     */
+    byte[] getPrivateKey(String userName, String hostName);
+
+    /**
+     * Gets the private key as byte array.
+     * @param userName The user who is trying to SSH
+     * @param hostName The host which user wants to connect to.
+     * @return The private key as a byte array.
+     */
+    byte[] getPublicKey(String userName, String hostName);
+
+}

Added: airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/authentication/SSHPublicKeyFileAuthentication.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/authentication/SSHPublicKeyFileAuthentication.java?rev=1529280&view=auto
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/authentication/SSHPublicKeyFileAuthentication.java (added)
+++ airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/authentication/SSHPublicKeyFileAuthentication.java Fri Oct  4 20:22:51 2013
@@ -0,0 +1,52 @@
+package org.apache.airavata.gsi.ssh.api.authentication;/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 10/4/13
+ * Time: 9:52 AM
+ */
+
+/**
+ * Public key authentication for vanilla SSH.
+ * The public key and private key stored files are returned. API user should implement this.
+ */
+public interface SSHPublicKeyFileAuthentication extends SSHKeyAuthentication {
+
+    /**
+     * The file which contains the public key.
+     * @param userName The user who is trying to SSH
+     * @param hostName The host which user wants to connect to.
+     * @return The name of the file which contains the public key.
+     */
+    String getPublicKeyFile(String userName, String hostName);
+
+    /**
+     * The file which contains the public key.
+     * @param userName The user who is trying to SSH
+     * @param hostName The host which user wants to connect to.
+     * @return The name of the file which contains the private key.
+     */
+    String getPrivateKeyFile(String userName, String hostName);
+
+
+}

Modified: airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/PBSCluster.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/PBSCluster.java?rev=1529280&r1=1529279&r2=1529280&view=diff
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/PBSCluster.java (original)
+++ airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/PBSCluster.java Fri Oct  4 20:22:51 2013
@@ -22,10 +22,13 @@ package org.apache.airavata.gsi.ssh.impl
 
 import com.jcraft.jsch.*;
 import org.apache.airavata.gsi.ssh.api.*;
+import org.apache.airavata.gsi.ssh.api.authentication.*;
 import org.apache.airavata.gsi.ssh.api.job.JobDescriptor;
 import org.apache.airavata.gsi.ssh.config.ConfigReader;
 import org.apache.airavata.gsi.ssh.jsch.ExtendedJSch;
 import org.apache.airavata.gsi.ssh.util.CommonUtils;
+import org.apache.airavata.gsi.ssh.util.SSHAPIUIKeyboardInteractive;
+import org.apache.airavata.gsi.ssh.util.SSHKeyPasswordHandler;
 import org.apache.airavata.gsi.ssh.util.SSHUtils;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.FilenameUtils;
@@ -75,7 +78,8 @@ public class PBSCluster implements Clust
 
         this.authenticationInfo = authenticationInfo;
 
-        System.setProperty(X509_CERT_DIR, (String) authenticationInfo.getProperties().get(X509_CERT_DIR));
+        System.setProperty(X509_CERT_DIR, (String) ((GSIAuthenticationInfo)authenticationInfo).getProperties().
+                get(X509_CERT_DIR));
 
         if(installedPath.endsWith("/")){
             this.installedPath = installedPath;
@@ -106,9 +110,97 @@ public class PBSCluster implements Clust
         java.util.Properties config = this.configReader.getProperties();
         session.setConfig(config);
 
+
+        //=============================================================
+        // Handling vanilla SSH pieces
+        //=============================================================
+        if (authenticationInfo instanceof SSHPasswordAuthentication) {
+            String password = ((SSHPasswordAuthentication) authenticationInfo).
+                    getPassword(serverInfo.getUserName(), serverInfo.getHost());
+
+            session.setUserInfo(new SSHAPIUIKeyboardInteractive(password));
+
+            // TODO figure out why we need to set password to session
+            session.setPassword(password);
+
+        } else if (authenticationInfo instanceof SSHPublicKeyFileAuthentication) {
+            SSHPublicKeyFileAuthentication sshPublicKeyFileAuthentication
+                    = (SSHPublicKeyFileAuthentication)authenticationInfo;
+
+            String privateKeyFile = sshPublicKeyFileAuthentication.
+                    getPrivateKeyFile(serverInfo.getUserName(), serverInfo.getHost());
+
+            logDebug("The private key file for vanilla SSH " + privateKeyFile);
+
+            String publicKeyFile = sshPublicKeyFileAuthentication.
+                    getPrivateKeyFile(serverInfo.getUserName(), serverInfo.getHost());
+
+            logDebug("The public key file for vanilla SSH " + publicKeyFile);
+
+            Identity identityFile;
+
+            try {
+                identityFile = GSISSHIdentityFile.newInstance(privateKeyFile, null, jSch);
+            } catch (JSchException e) {
+                throw new SSHApiException("An exception occurred while initializing keys using files. " +
+                        "(private key and public key)." +
+                        "Connecting server - " + serverInfo.getHost() + ":" + serverInfo.getPort() +
+                        " connecting user name - "
+                        + serverInfo.getUserName() + " private key file - " + privateKeyFile + ", public key file - " +
+                        publicKeyFile, e);
+            }
+
+            // Add identity to identity repository
+            GSISSHIdentityRepository identityRepository = new GSISSHIdentityRepository(jSch);
+            identityRepository.add(identityFile);
+
+            // Set repository to session
+            session.setIdentityRepository(identityRepository);
+
+            // Set the user info
+            SSHKeyPasswordHandler sshKeyPasswordHandler
+                    = new SSHKeyPasswordHandler((SSHKeyAuthentication)authenticationInfo);
+
+            session.setUserInfo(sshKeyPasswordHandler);
+
+        } else if (authenticationInfo instanceof SSHPublicKeyAuthentication) {
+
+            SSHPublicKeyAuthentication sshPublicKeyAuthentication
+                    = (SSHPublicKeyAuthentication)authenticationInfo;
+
+            Identity identityFile;
+
+            try {
+                String name = serverInfo.getUserName() + "_" + serverInfo.getHost();
+                identityFile = GSISSHIdentityFile.newInstance(name,
+                        sshPublicKeyAuthentication.getPrivateKey(serverInfo.getUserName(), serverInfo.getHost()),
+                        sshPublicKeyAuthentication.getPublicKey(serverInfo.getUserName(), serverInfo.getHost()), jSch);
+            } catch (JSchException e) {
+                throw new SSHApiException("An exception occurred while initializing keys using byte arrays. " +
+                        "(private key and public key)." +
+                        "Connecting server - " + serverInfo.getHost() + ":" + serverInfo.getPort() +
+                        " connecting user name - "
+                        + serverInfo.getUserName(), e);
+            }
+
+            // Add identity to identity repository
+            GSISSHIdentityRepository identityRepository = new GSISSHIdentityRepository(jSch);
+            identityRepository.add(identityFile);
+
+            // Set repository to session
+            session.setIdentityRepository(identityRepository);
+
+            // Set the user info
+            SSHKeyPasswordHandler sshKeyPasswordHandler
+                    = new SSHKeyPasswordHandler((SSHKeyAuthentication)authenticationInfo);
+
+            session.setUserInfo(sshKeyPasswordHandler);
+
+        }
+
         // Not a good way, but we dont have any choice
         if (session instanceof ExtendedSession) {
-            ((ExtendedSession) session).setAuthenticationInfo(authenticationInfo);
+            ((ExtendedSession) session).setAuthenticationInfo((GSIAuthenticationInfo)authenticationInfo);
         }
 
         try {
@@ -513,4 +605,10 @@ public class PBSCluster implements Clust
     public Session getSession() {
         return this.session;
     }
+
+    private static void logDebug(String message) {
+        if (log.isDebugEnabled()) {
+            log.debug(message);
+        }
+    }
 }

Added: airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/SSHUserInfo.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/SSHUserInfo.java?rev=1529280&view=auto
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/SSHUserInfo.java (added)
+++ airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/SSHUserInfo.java Fri Oct  4 20:22:51 2013
@@ -0,0 +1,63 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.gsi.ssh.impl;
+
+import com.jcraft.jsch.UserInfo;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 9/20/13
+ * Time: 2:31 PM
+ */
+
+public class SSHUserInfo implements UserInfo {
+
+    private String password;
+
+    public SSHUserInfo(String pwd) {
+        this.password = pwd;
+    }
+
+    public String getPassphrase() {
+        return this.password;
+    }
+
+    public String getPassword() {
+        return this.password;
+    }
+
+    public boolean promptPassword(String message) {
+        return false;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    public boolean promptPassphrase(String message) {
+        return false;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    public boolean promptYesNo(String message) {
+        return false;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    public void showMessage(String message) {
+        //To change body of implemented methods use File | Settings | File Templates.
+    }
+}

Added: airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/authentication/DefaultPasswordAuthenticationInfo.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/authentication/DefaultPasswordAuthenticationInfo.java?rev=1529280&view=auto
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/authentication/DefaultPasswordAuthenticationInfo.java (added)
+++ airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/authentication/DefaultPasswordAuthenticationInfo.java Fri Oct  4 20:22:51 2013
@@ -0,0 +1,50 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.gsi.ssh.impl.authentication;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 9/20/13
+ * Time: 12:15 PM
+ */
+
+import org.apache.airavata.gsi.ssh.api.authentication.GSIAuthenticationInfo;
+import org.apache.airavata.gsi.ssh.api.authentication.SSHPasswordAuthentication;
+import org.ietf.jgss.*;
+
+/**
+ * An authenticator used for raw SSH sessions. Gives SSH user name, password
+ * directly.
+ * This is only an example implementation.
+ */
+public class DefaultPasswordAuthenticationInfo implements SSHPasswordAuthentication {
+
+    private String password;
+
+    public DefaultPasswordAuthenticationInfo(String pwd) {
+        this.password = pwd;
+    }
+
+    public String getPassword(String userName, String hostName) {
+        return password;
+    }
+}

Added: airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/authentication/DefaultPublicKeyAuthentication.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/authentication/DefaultPublicKeyAuthentication.java?rev=1529280&view=auto
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/authentication/DefaultPublicKeyAuthentication.java (added)
+++ airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/authentication/DefaultPublicKeyAuthentication.java Fri Oct  4 20:22:51 2013
@@ -0,0 +1,68 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.gsi.ssh.impl.authentication;
+
+import org.apache.airavata.gsi.ssh.api.authentication.SSHPublicKeyAuthentication;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 10/4/13
+ * Time: 11:44 AM
+ */
+
+/**
+ * Default public key authentication.
+ * Note : This is only a sample implementation.
+ */
+public class DefaultPublicKeyAuthentication implements SSHPublicKeyAuthentication {
+
+    private byte[] privateKey;
+    private byte[] publicKey;
+    private String passPhrase = null;
+
+    public DefaultPublicKeyAuthentication(byte[] priv, byte[] pub) {
+        this.privateKey = priv;
+        this.publicKey = pub;
+    }
+
+    public DefaultPublicKeyAuthentication(byte[] priv, byte[] pub, String pass) {
+        this.privateKey = priv;
+        this.publicKey = pub;
+        this.passPhrase = pass;
+    }
+
+    public String getPassPhrase() {
+        return passPhrase;
+    }
+
+    public void bannerMessage(String message) {
+        System.out.println(message);
+    }
+
+    public byte[] getPrivateKey(String userName, String hostName) {
+        return privateKey;
+    }
+
+    public byte[] getPublicKey(String userName, String hostName) {
+        return publicKey;
+    }
+}

Added: airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/authentication/DefaultPublicKeyFileAuthentication.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/authentication/DefaultPublicKeyFileAuthentication.java?rev=1529280&view=auto
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/authentication/DefaultPublicKeyFileAuthentication.java (added)
+++ airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/authentication/DefaultPublicKeyFileAuthentication.java Fri Oct  4 20:22:51 2013
@@ -0,0 +1,70 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.gsi.ssh.impl.authentication;
+
+import org.apache.airavata.gsi.ssh.api.authentication.SSHPublicKeyFileAuthentication;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 10/4/13
+ * Time: 11:40 AM
+ */
+
+/**
+ * Default public key authentication using files.
+ * Note : This is only a sample implementation.
+ */
+public class DefaultPublicKeyFileAuthentication implements SSHPublicKeyFileAuthentication {
+
+    private String publicKeyFile;
+    private String privateKeyFile;
+    private String passPhrase = null;
+
+    public DefaultPublicKeyFileAuthentication(String pubFile, String privFile) {
+        this.publicKeyFile = pubFile;
+        this.privateKeyFile = privFile;
+
+    }
+
+    public DefaultPublicKeyFileAuthentication(String pubFile, String privFile, String pass) {
+        this.publicKeyFile = pubFile;
+        this.privateKeyFile = privFile;
+        this.passPhrase = pass;
+
+    }
+
+    public String getPassPhrase() {
+        return passPhrase;
+    }
+
+    public void bannerMessage(String message) {
+        System.out.println(message);
+    }
+
+    public String getPublicKeyFile(String userName, String hostName) {
+        return publicKeyFile;
+    }
+
+    public String getPrivateKeyFile(String userName, String hostName) {
+        return privateKeyFile;
+    }
+}

Copied: airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/authentication/MyProxyAuthenticationInfo.java (from r1525044, airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/MyProxyAuthenticationInfo.java)
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/authentication/MyProxyAuthenticationInfo.java?p2=airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/authentication/MyProxyAuthenticationInfo.java&p1=airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/MyProxyAuthenticationInfo.java&r1=1525044&r2=1529280&rev=1529280&view=diff
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/MyProxyAuthenticationInfo.java (original)
+++ airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/authentication/MyProxyAuthenticationInfo.java Fri Oct  4 20:22:51 2013
@@ -19,22 +19,20 @@
  *
  */
 
-package org.apache.airavata.gsi.ssh.impl;
+package org.apache.airavata.gsi.ssh.impl.authentication;
 
-import org.apache.airavata.gsi.ssh.api.AuthenticationInfo;
+import org.apache.airavata.gsi.ssh.api.authentication.GSIAuthenticationInfo;
 import org.globus.myproxy.MyProxy;
 import org.globus.myproxy.MyProxyException;
 import org.ietf.jgss.GSSCredential;
 
-import java.util.Properties;
-
 /**
  * User: AmilaJ (amilaj@apache.org)
  * Date: 8/14/13
  * Time: 5:22 PM
  */
 
-public class MyProxyAuthenticationInfo extends AuthenticationInfo {
+public class MyProxyAuthenticationInfo extends GSIAuthenticationInfo {
 
     public static final String X509_CERT_DIR = "X509_CERT_DIR";
     private String userName;

Modified: airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/jsch/ExtendedJSch.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/jsch/ExtendedJSch.java?rev=1529280&r1=1529279&r2=1529280&view=diff
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/jsch/ExtendedJSch.java (original)
+++ airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/jsch/ExtendedJSch.java Fri Oct  4 20:22:51 2013
@@ -25,7 +25,7 @@ import com.jcraft.jsch.ExtendedSession;
 import com.jcraft.jsch.JSch;
 import com.jcraft.jsch.JSchException;
 import com.jcraft.jsch.Session;
-import org.apache.airavata.gsi.ssh.api.AuthenticationInfo;
+import org.apache.airavata.gsi.ssh.api.authentication.GSIAuthenticationInfo;
 
 /**
  * User: AmilaJ (amilaj@apache.org)
@@ -38,17 +38,17 @@ import org.apache.airavata.gsi.ssh.api.A
  */
 public class ExtendedJSch extends JSch {
 
-    private AuthenticationInfo authenticationInfo;
+    private GSIAuthenticationInfo authenticationInfo;
 
     public ExtendedJSch() {
         super();
     }
 
-    public AuthenticationInfo getAuthenticationInfo() {
+    public GSIAuthenticationInfo getAuthenticationInfo() {
         return authenticationInfo;
     }
 
-    public void setAuthenticationInfo(AuthenticationInfo authenticationInfo) {
+    public void setAuthenticationInfo(GSIAuthenticationInfo authenticationInfo) {
         this.authenticationInfo = authenticationInfo;
     }
 

Added: airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/util/SSHAPIUIKeyboardInteractive.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/util/SSHAPIUIKeyboardInteractive.java?rev=1529280&view=auto
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/util/SSHAPIUIKeyboardInteractive.java (added)
+++ airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/util/SSHAPIUIKeyboardInteractive.java Fri Oct  4 20:22:51 2013
@@ -0,0 +1,73 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.gsi.ssh.util;
+
+import com.jcraft.jsch.UIKeyboardInteractive;
+import com.jcraft.jsch.UserInfo;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 10/4/13
+ * Time: 8:34 AM
+ */
+
+/**
+ * This is dummy class, the keyboard interactivity is not really used when acting as an API.
+ * But to get things working we have this.
+ */
+public class SSHAPIUIKeyboardInteractive implements UIKeyboardInteractive, UserInfo {
+
+    private String password;
+
+    public SSHAPIUIKeyboardInteractive(String pwd) {
+        this.password = pwd;
+    }
+
+    public String[] promptKeyboardInteractive(String destination, String name,
+                                              String instruction, String[] prompt, boolean[] echo) {
+        return null;
+    }
+
+    public String getPassphrase() {
+        return password;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public boolean promptPassword(String message) {
+        return false;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    public boolean promptPassphrase(String message) {
+        return false;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    public boolean promptYesNo(String message) {
+        return false;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    public void showMessage(String message) {
+        //To change body of implemented methods use File | Settings | File Templates.
+    }
+}

Added: airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/util/SSHKeyPasswordHandler.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/util/SSHKeyPasswordHandler.java?rev=1529280&view=auto
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/util/SSHKeyPasswordHandler.java (added)
+++ airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/util/SSHKeyPasswordHandler.java Fri Oct  4 20:22:51 2013
@@ -0,0 +1,68 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.gsi.ssh.util;
+
+import com.jcraft.jsch.UserInfo;
+import org.apache.airavata.gsi.ssh.api.authentication.SSHKeyAuthentication;
+import sun.reflect.generics.reflectiveObjects.NotImplementedException;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 10/4/13
+ * Time: 2:22 PM
+ */
+
+/**
+ * This class is used to get the pass phrase to decrypt public/private keys.
+ */
+public class SSHKeyPasswordHandler implements UserInfo {
+
+    private SSHKeyAuthentication keyAuthenticationHandler;
+
+    public SSHKeyPasswordHandler(SSHKeyAuthentication handler) {
+        this.keyAuthenticationHandler = handler;
+    }
+
+    public String getPassphrase() {
+        return keyAuthenticationHandler.getPassPhrase();
+    }
+
+    public String getPassword() {
+        throw new NotImplementedException();
+    }
+
+    public boolean promptPassword(String message) {
+        return false;
+    }
+
+    public boolean promptPassphrase(String message) {
+        return true;
+    }
+
+    public boolean promptYesNo(String message) {
+        return false;
+    }
+
+    public void showMessage(String message) {
+        keyAuthenticationHandler.bannerMessage(message);
+    }
+}

Modified: airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/util/SSHUtils.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/util/SSHUtils.java?rev=1529280&r1=1529279&r2=1529280&view=diff
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/util/SSHUtils.java (original)
+++ airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/util/SSHUtils.java Fri Oct  4 20:22:51 2013
@@ -21,7 +21,7 @@
 package org.apache.airavata.gsi.ssh.util;
 
 import com.jcraft.jsch.*;
-import org.apache.airavata.gsi.ssh.api.AuthenticationInfo;
+import org.apache.airavata.gsi.ssh.api.authentication.GSIAuthenticationInfo;
 import org.apache.airavata.gsi.ssh.api.SSHApiException;
 import org.apache.airavata.gsi.ssh.api.ServerInfo;
 import org.apache.airavata.gsi.ssh.config.ConfigReader;
@@ -44,7 +44,7 @@ public class SSHUtils {
 
     private ServerInfo serverInfo;
 
-    private AuthenticationInfo authenticationInfo;
+    private GSIAuthenticationInfo authenticationInfo;
 
     private ConfigReader configReader;
 
@@ -55,7 +55,7 @@ public class SSHUtils {
      * @param certificateLocation
      * @param configReader
      */
-    public SSHUtils(ServerInfo serverInfo, AuthenticationInfo authenticationInfo, String certificateLocation, ConfigReader configReader) {
+    public SSHUtils(ServerInfo serverInfo, GSIAuthenticationInfo authenticationInfo, String certificateLocation, ConfigReader configReader) {
         System.setProperty("X509_CERT_DIR", certificateLocation);
         this.serverInfo = serverInfo;
         this.authenticationInfo = authenticationInfo;
@@ -68,7 +68,7 @@ public class SSHUtils {
      * @param authenticationInfo
      * @param configReader
      */
-    public SSHUtils(ServerInfo serverInfo, AuthenticationInfo authenticationInfo
+    public SSHUtils(ServerInfo serverInfo, GSIAuthenticationInfo authenticationInfo
             , ConfigReader configReader) {
         this.serverInfo = serverInfo;
         this.authenticationInfo = authenticationInfo;

Modified: airavata/sandbox/gsissh/src/test/java/org/apache/airavata/gsi/ssh/config/SCPToTest.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/test/java/org/apache/airavata/gsi/ssh/config/SCPToTest.java?rev=1529280&r1=1529279&r2=1529280&view=diff
==============================================================================
--- airavata/sandbox/gsissh/src/test/java/org/apache/airavata/gsi/ssh/config/SCPToTest.java (original)
+++ airavata/sandbox/gsissh/src/test/java/org/apache/airavata/gsi/ssh/config/SCPToTest.java Fri Oct  4 20:22:51 2013
@@ -20,10 +20,10 @@
 */
 package org.apache.airavata.gsi.ssh.config;
 
-import org.apache.airavata.gsi.ssh.api.AuthenticationInfo;
+import org.apache.airavata.gsi.ssh.api.authentication.GSIAuthenticationInfo;
 import org.apache.airavata.gsi.ssh.util.SSHUtils;
 import org.apache.airavata.gsi.ssh.api.ServerInfo;
-import org.apache.airavata.gsi.ssh.impl.MyProxyAuthenticationInfo;
+import org.apache.airavata.gsi.ssh.impl.authentication.MyProxyAuthenticationInfo;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
 
@@ -65,7 +65,7 @@ public class SCPToTest {
     @Test
     public void testExecuteCommand() throws Exception {
          // Create authentication
-        AuthenticationInfo authenticationInfo
+        GSIAuthenticationInfo authenticationInfo
                 = new MyProxyAuthenticationInfo(myProxyUserName, myProxyPassword, "myproxy.teragrid.org",
                 7512, 17280000,certificateLocation);
         ServerInfo serverInfo = new ServerInfo("ogce" ,"trestles.sdsc.edu");

Modified: airavata/sandbox/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/DefaultSSHApiTest.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/DefaultSSHApiTest.java?rev=1529280&r1=1529279&r2=1529280&view=diff
==============================================================================
--- airavata/sandbox/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/DefaultSSHApiTest.java (original)
+++ airavata/sandbox/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/DefaultSSHApiTest.java Fri Oct  4 20:22:51 2013
@@ -23,8 +23,10 @@ package org.apache.airavata.gsi.ssh.impl
 
 import junit.framework.Assert;
 import org.apache.airavata.gsi.ssh.api.*;
+import org.apache.airavata.gsi.ssh.api.authentication.GSIAuthenticationInfo;
 import org.apache.airavata.gsi.ssh.api.job.JobDescriptor;
 import org.apache.airavata.gsi.ssh.config.ConfigReader;
+import org.apache.airavata.gsi.ssh.impl.authentication.MyProxyAuthenticationInfo;
 import org.apache.airavata.gsi.ssh.util.CommonUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -87,7 +89,7 @@ public class DefaultSSHApiTest {
     @Test
     public void testExecuteCommand() throws Exception {
         // Create authentication
-        AuthenticationInfo authenticationInfo
+        GSIAuthenticationInfo authenticationInfo
                 = new MyProxyAuthenticationInfo(myProxyUserName, myProxyPassword, "myproxy.teragrid.org",
                 7512, 17280000, certificateLocation);
 
@@ -108,7 +110,7 @@ public class DefaultSSHApiTest {
     @Test
     public void testSubmitAsyncJobWithPBS() throws Exception {
         // Create authentication
-        AuthenticationInfo authenticationInfo
+        GSIAuthenticationInfo authenticationInfo
                 = new MyProxyAuthenticationInfo(myProxyUserName, myProxyPassword, "myproxy.teragrid.org",
                 7512, 17280000, certificateLocation);
 
@@ -132,7 +134,7 @@ public class DefaultSSHApiTest {
     @Test
     public void testSubmitAsyncJob() throws Exception {
         // Create authentication
-        AuthenticationInfo authenticationInfo
+        GSIAuthenticationInfo authenticationInfo
                 = new MyProxyAuthenticationInfo(myProxyUserName, myProxyPassword, "myproxy.teragrid.org",
                 7512, 17280000, certificateLocation);
 
@@ -198,7 +200,7 @@ public class DefaultSSHApiTest {
 
     @Test
     public void testGetCluster() throws Exception {
-//        AuthenticationInfo authenticationInfo
+//        GSIAuthenticationInfo authenticationInfo
 //                = new MyProxyAuthenticationInfo(myProxyUserName, myProxyPassword, "myproxy.teragrid.org",
 //                7512, 17280000);
 //        // Server info
@@ -218,7 +220,7 @@ public class DefaultSSHApiTest {
     @Test
     public void testsubmitAsyncJobWithFailure() throws Exception {
         // Create authentication
-        AuthenticationInfo authenticationInfo
+        GSIAuthenticationInfo authenticationInfo
                 = new MyProxyAuthenticationInfo(myProxyUserName, myProxyPassword, "myproxy.teragrid.org",
                 7512, 17280000, certificateLocation);
 
@@ -260,7 +262,7 @@ public class DefaultSSHApiTest {
     @Test
     public void testSubmitAsyncJobWithListener() throws Exception {
         // Create authentication
-        AuthenticationInfo authenticationInfo
+        GSIAuthenticationInfo authenticationInfo
                 = new MyProxyAuthenticationInfo(myProxyUserName, myProxyPassword, "myproxy.teragrid.org",
                 7512, 17280000, certificateLocation);
 
@@ -350,7 +352,7 @@ public class DefaultSSHApiTest {
     @Test
     public void testJobCancel() throws Exception {
         // Create authentication
-        AuthenticationInfo authenticationInfo
+        GSIAuthenticationInfo authenticationInfo
                 = new MyProxyAuthenticationInfo(myProxyUserName, myProxyPassword, "myproxy.teragrid.org",
                 7512, 17280000, certificateLocation);
 

Added: airavata/sandbox/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/VanilaSSHTest.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/VanilaSSHTest.java?rev=1529280&view=auto
==============================================================================
--- airavata/sandbox/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/VanilaSSHTest.java (added)
+++ airavata/sandbox/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/VanilaSSHTest.java Fri Oct  4 20:22:51 2013
@@ -0,0 +1,112 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.gsi.ssh.impl;
+
+import com.jcraft.jsch.UserInfo;
+import org.apache.airavata.gsi.ssh.api.*;
+import org.apache.airavata.gsi.ssh.api.authentication.AuthenticationInfo;
+import org.apache.airavata.gsi.ssh.config.ConfigReader;
+import org.apache.airavata.gsi.ssh.impl.authentication.DefaultPasswordAuthenticationInfo;
+import org.apache.airavata.gsi.ssh.impl.authentication.DefaultPublicKeyFileAuthentication;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 9/20/13
+ * Time: 12:05 PM
+ */
+
+public class VanilaSSHTest {
+
+    private String userName;
+    private String password;
+    private String passPhrase;
+    private String hostName;
+
+    @BeforeTest
+    public void setUp() throws Exception {
+
+
+        this.hostName = "bigred2.uits.iu.edu";
+        this.userName = System.getProperty("my.ssh.user");
+        this.password = System.getProperty("my.ssh.user.password");
+        this.passPhrase = System.getProperty("my.ssh.user.pass.phrase");
+
+        if (this.userName == null || this.passPhrase == null || this.password == null) {
+            System.out.println("########### In order to run tests you need to set password and " +
+                    "passphrase ###############");
+            System.out.println("Use -Dmy.ssh.user=xxx -Dmy.ssh.user.password=yyy -Dmy.ssh.user.pass.phrase=zzz");
+        }
+
+    }
+
+
+    @Test
+    public void testSimpleCommand1() throws Exception{
+
+        System.out.println("Starting vanila SSH test ....");
+
+        AuthenticationInfo authenticationInfo = new DefaultPasswordAuthenticationInfo(this.password);
+
+        // Create command
+        CommandInfo commandInfo = new RawCommandInfo("/opt/torque/torque-4.2.3.1/bin/qstat");
+
+        // Server info
+        ServerInfo serverInfo = new ServerInfo(this.userName, this.hostName);
+
+        // Output
+        CommandOutput commandOutput = new SystemCommandOutput();
+
+        // Execute command
+        CommandExecutor.executeCommand(commandInfo, serverInfo, authenticationInfo, commandOutput, new ConfigReader());
+
+
+    }
+
+    @Test
+    public void testSimpleCommand2() throws Exception{
+
+        System.out.println("Starting vanila SSH test ....");
+
+        String privateKeyFile = "/Users/thejaka/.ssh/id_rsa";
+        String publicKeyFile = "/Users/thejaka/.ssh/id_rsa.pub";
+
+        AuthenticationInfo authenticationInfo = new DefaultPublicKeyFileAuthentication(publicKeyFile, privateKeyFile,
+                this.passPhrase);
+
+        // Create command
+        CommandInfo commandInfo = new RawCommandInfo("/opt/torque/torque-4.2.3.1/bin/qstat");
+
+        // Server info
+        ServerInfo serverInfo = new ServerInfo(this.userName, this.hostName);
+
+        // Output
+        CommandOutput commandOutput = new SystemCommandOutput();
+
+        // Execute command
+        CommandExecutor.executeCommand(commandInfo, serverInfo, authenticationInfo, commandOutput, new ConfigReader());
+
+
+    }
+
+}



Mime
View raw message