airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ami...@apache.org
Subject svn commit: r1514337 - in /airavata/sandbox/gsissh: ./ lib/ src/main/java/ src/main/java/com/jcraft/jsch/ src/main/java/org/apache/airavata/gsi/ssh/ src/main/java/org/apache/airavata/gsi/ssh/api/ src/main/java/org/apache/airavata/gsi/ssh/config/ src/ma...
Date Thu, 15 Aug 2013 16:04:02 GMT
Author: amilaj
Date: Thu Aug 15 16:04:01 2013
New Revision: 1514337

URL: http://svn.apache.org/r1514337
Log:
Adding initial SSH API version

Added:
    airavata/sandbox/gsissh/lib/install.sh   (with props)
    airavata/sandbox/gsissh/src/main/java/SSHDemo.java
      - copied, changed from r1513977, airavata/sandbox/gsissh/src/main/java/SSHProvider.java
    airavata/sandbox/gsissh/src/main/java/com/jcraft/jsch/ExtendedSession.java
    airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/
    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/CommandInfo.java
    airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/CommandOutput.java
    airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/SSHApi.java
    airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/SSHApiException.java
    airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/SSHApiFactory.java
    airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/ServerInfo.java
    airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/config/
    airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/config/ConfigReader.java
    airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/
    airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/DefaultSSHApi.java
    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/impl/RawCommandInfo.java
    airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/SystemCommandOutput.java
    airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/jsch/
    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/
    airavata/sandbox/gsissh/src/main/resources/
    airavata/sandbox/gsissh/src/main/resources/gsissh.properties
    airavata/sandbox/gsissh/src/test/
    airavata/sandbox/gsissh/src/test/java/
    airavata/sandbox/gsissh/src/test/java/org/
    airavata/sandbox/gsissh/src/test/java/org/apache/
    airavata/sandbox/gsissh/src/test/java/org/apache/airavata/
    airavata/sandbox/gsissh/src/test/java/org/apache/airavata/gsi/
    airavata/sandbox/gsissh/src/test/java/org/apache/airavata/gsi/ssh/
    airavata/sandbox/gsissh/src/test/java/org/apache/airavata/gsi/ssh/config/
    airavata/sandbox/gsissh/src/test/java/org/apache/airavata/gsi/ssh/config/ConfigReaderTest.java
    airavata/sandbox/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/
    airavata/sandbox/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/DefaultSSHApiTest.java
    airavata/sandbox/gsissh/src/test/resources/
Removed:
    airavata/sandbox/gsissh/src/main/java/SSHProvider.java
    airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/SSHGSSContextImpl.java
Modified:
    airavata/sandbox/gsissh/pom.xml
    airavata/sandbox/gsissh/src/main/java/com/jcraft/jsch/UserAuthGSSAPIWithMICGSSCredentials.java
    airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/GSSContextX509.java

Added: airavata/sandbox/gsissh/lib/install.sh
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/lib/install.sh?rev=1514337&view=auto
==============================================================================
--- airavata/sandbox/gsissh/lib/install.sh (added)
+++ airavata/sandbox/gsissh/lib/install.sh Thu Aug 15 16:04:01 2013
@@ -0,0 +1 @@
+mvn install:install-file -Dfile=./ncsa-lcrypto-146.jar -DgroupId=edu.illinois.ncsa -DartifactId=bcgss -Dversion=146 -Dpackaging=jar

Propchange: airavata/sandbox/gsissh/lib/install.sh
------------------------------------------------------------------------------
    svn:executable = *

Modified: airavata/sandbox/gsissh/pom.xml
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/pom.xml?rev=1514337&r1=1514336&r2=1514337&view=diff
==============================================================================
--- airavata/sandbox/gsissh/pom.xml (original)
+++ airavata/sandbox/gsissh/pom.xml Thu Aug 15 16:04:01 2013
@@ -26,13 +26,6 @@
         <maven>3.0</maven>
     </prerequisites>
 
-    <!--parent>
-        <groupId>org.apache</groupId>
-        <artifactId>apache</artifactId>
-        <version>13</version>
-        <relativePath/>
-    </parent-->
-
     <repositories>
         <repository>
             <id>my-local-repo</id>
@@ -62,22 +55,78 @@
             <version>${jglobus.version}</version>
         </dependency>
         <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>${junit.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <version>${org.slf4j.version}</version>
+        </dependency>
+        <dependency>
             <groupId>log4j</groupId>
             <artifactId>log4j</artifactId>
-            <version>1.2.17</version>
+            <version>${log4j.version}</version>
         </dependency>
         <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>${junit.version}</version>
+            <groupId>org.testng</groupId>
+            <artifactId>testng</artifactId>
+            <version>6.1.1</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>edu.illinois.ncsa</groupId>
+            <artifactId>bcgss</artifactId>
+            <version>146</version>
         </dependency>
     </dependencies>
 
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>2.3.2</version>
+                <configuration>
+                    <source>1.6</source>
+                    <target>1.6</target>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>${surefire.version}</version>
+                <configuration>
+                    <!--systemPropertyVariables>
+                        <credential.module.directory>${basedir}</credential.module.directory>
+                    </systemPropertyVariables>
+                    <excludes>
+                        <exclude>**/DAOBaseTestCase.java</exclude>
+                        <exclude>**/MappingDAOTest.java</exclude>
+                    </excludes-->
+                    <testSourceDirectory>${basedir}\src\test\java\</testSourceDirectory>
+                </configuration>
+            </plugin>
+
+        </plugins>
+        <testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory>
+        <testOutputDirectory>${project.build.directory}/test-classes</testOutputDirectory>
+        <testResources>
+            <testResource>
+                <directory>${project.basedir}/src/test/resources</directory>
+            </testResource>
+        </testResources>
+    </build>
+
 
     <properties>
         <jglobus.version>2.0.6-rc2</jglobus.version>
         <surefire.version>2.12</surefire.version>
         <junit.version>4.7</junit.version>
+        <log4j.version>1.2.17</log4j.version>
+        <org.slf4j.version>1.7.2</org.slf4j.version>
         <skipTests>false</skipTests>
     </properties>
 </project>

Copied: airavata/sandbox/gsissh/src/main/java/SSHDemo.java (from r1513977, airavata/sandbox/gsissh/src/main/java/SSHProvider.java)
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/SSHDemo.java?p2=airavata/sandbox/gsissh/src/main/java/SSHDemo.java&p1=airavata/sandbox/gsissh/src/main/java/SSHProvider.java&r1=1513977&r2=1514337&rev=1514337&view=diff
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/SSHProvider.java (original)
+++ airavata/sandbox/gsissh/src/main/java/SSHDemo.java Thu Aug 15 16:04:01 2013
@@ -39,12 +39,16 @@
  */
 
 import com.jcraft.jsch.*;
+import org.apache.airavata.gsi.ssh.jsch.ExtendedJSch;
 
 import javax.swing.*;
 import java.awt.*;
 import java.io.InputStream;
 
-public class SSHProvider {
+/**
+ * A main class that demonstrates GSI-SSH execution.
+ */
+public class SSHDemo {
 
     static {
         JSch.setConfig("gssapi-with-mic.x509", "org.apache.airavata.gsi.ssh.GSSContextX509");
@@ -56,7 +60,7 @@ public class SSHProvider {
     public static void main(String[] arg) {
         try {
 
-            JSch jsch = new JSch();
+            JSch jsch = new ExtendedJSch();
 
             String host;
             int port = 22;

Added: 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=1514337&view=auto
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/com/jcraft/jsch/ExtendedSession.java (added)
+++ airavata/sandbox/gsissh/src/main/java/com/jcraft/jsch/ExtendedSession.java Thu Aug 15 16:04:01 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 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;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 8/15/13
+ * Time: 10:06 AM
+ */
+
+public class ExtendedSession extends Session {
+
+    private AuthenticationInfo authenticationInfo;
+
+    public ExtendedSession(JSch jsch, String username, String host, int port) throws JSchException {
+        super(jsch, username, host, port);
+    }
+
+    public AuthenticationInfo getAuthenticationInfo() {
+        return authenticationInfo;
+    }
+
+    public void setAuthenticationInfo(AuthenticationInfo authenticationInfo) {
+        this.authenticationInfo = authenticationInfo;
+    }
+}

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=1514337&r1=1514336&r2=1514337&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 Thu Aug 15 16:04:01 2013
@@ -4,6 +4,8 @@ import java.util.ArrayList;
 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.globus.gsi.gssapi.GSSConstants;
 import org.ietf.jgss.GSSException;
 import org.ietf.jgss.Oid;
@@ -65,6 +67,7 @@ public class UserAuthGSSAPIWithMICGSSCre
 
     @Override
     public boolean start(Session session) throws Exception {
+
         // this.userinfo = userinfo;
         Packet packet = session.packet;
         Buffer buf = session.buf;
@@ -158,12 +161,25 @@ public class UserAuthGSSAPIWithMICGSSCre
         try {
             Class c = Class.forName(session.getConfig(method));
             context = (GSSContext) (c.newInstance());
-            // logger.debug( "GOT CONTEXT: " + context );
+
         } catch (Exception e) {
             // logger.error( "could not instantiate GSSContext", e );
             return false;
         }
 
+        // 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();
+
+            if (context instanceof GSSContextX509) {
+                ((GSSContextX509) context).setCredential(authenticationInfo.getCredentials());
+            }
+        }
+
+        // logger.debug( "GOT CONTEXT: " + context );
+
+
         // FIXME
         // if ( userinfo instanceof IX509UserInfo ) {
         // if ( context instanceof GSSContextX509 ) {

Modified: airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/GSSContextX509.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/GSSContextX509.java?rev=1514337&r1=1514336&r2=1514337&view=diff
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/GSSContextX509.java (original)
+++ airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/GSSContextX509.java Thu Aug 15 16:04:01 2013
@@ -66,7 +66,7 @@ public class GSSContextX509 implements c
 
             if (credential == null) {
                 try {
-                    credential = getMyProxyCredentials();
+                    credential = getCredential();
                 } catch (SecurityException t) {
                     System.out.printf("Could not get proxy: %s: %s\n", t.getClass().getSimpleName(), t.getMessage());
                     throw new JSchException(t.toString());
@@ -125,15 +125,6 @@ public class GSSContextX509 implements c
         return getProxy(null, GSSCredential.DEFAULT_LIFETIME);
     }
 
-    private static GSSCredential getMyProxyCredentials() throws JSchException {
-        MyProxy myproxy = new MyProxy("myproxy.teragrid.org", 7512);
-        try {
-            return myproxy.get("xxx", "xxx", 17280000);
-        } catch (MyProxyException e) {
-            throw new JSchException("Error getting proxy credentials", e);
-        }
-    }
-
     /**
      * @param x509_USER_PROXY
      *            path to the proxy.
@@ -211,5 +202,9 @@ public class GSSContextX509 implements c
     public void setCredential(GSSCredential credential) {
         this.credential = credential;
     }
+
+    public GSSCredential getCredential() {
+        return credential;
+    }
 }
 

Added: 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/AuthenticationInfo.java?rev=1514337&view=auto
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/AuthenticationInfo.java (added)
+++ airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/AuthenticationInfo.java Thu Aug 15 16:04:01 2013
@@ -0,0 +1,37 @@
+package org.apache.airavata.gsi.ssh.api;/*
+ *
+ * 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: 8/14/13
+ * Time: 3:38 PM
+ */
+
+import org.ietf.jgss.GSSCredential;
+
+/**
+ * Authentication data. Could be MyProxy user name, password, could be GSSCredentials
+ * or could be SSH keys.
+ */
+public interface AuthenticationInfo {
+
+    GSSCredential getCredentials() throws SecurityException;
+}

Added: airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/CommandInfo.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/CommandInfo.java?rev=1514337&view=auto
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/CommandInfo.java (added)
+++ airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/CommandInfo.java Thu Aug 15 16:04:01 2013
@@ -0,0 +1,41 @@
+package org.apache.airavata.gsi.ssh.api;/*
+ *
+ * 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: 8/14/13
+ * Time: 3:18 PM
+ */
+
+/**
+ * Encapsulates information about
+ */
+public interface CommandInfo {
+
+    /**
+     * Gets the executable command as a string.
+     * @return String encoded command. Should be able to execute
+     * directly on remote shell. Should includes appropriate parameters.
+     */
+    String getCommand();
+
+}

Added: airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/CommandOutput.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/CommandOutput.java?rev=1514337&view=auto
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/CommandOutput.java (added)
+++ airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/CommandOutput.java Thu Aug 15 16:04:01 2013
@@ -0,0 +1,54 @@
+package org.apache.airavata.gsi.ssh.api;/*
+ *
+ * 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: 8/14/13
+ * Time: 3:33 PM
+ */
+
+import com.jcraft.jsch.Channel;
+
+import java.io.OutputStream;
+
+/**
+ * Output of a certain command. TODO rethink
+ */
+public interface CommandOutput {
+
+    /**
+     * Gets the output of the command as an stream.
+     * @param  channel Command output as a stream.
+     */
+    void onOutput(Channel channel);
+
+    /**
+     * Gets standard error as a output stream.
+     * @return Command error as a stream.
+     */
+    OutputStream getStandardError();
+
+    /**
+     * The command exit code.
+     * @param code The program exit code
+     */
+    void exitCode(int code);
+}

Added: airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/SSHApi.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/SSHApi.java?rev=1514337&view=auto
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/SSHApi.java (added)
+++ airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/SSHApi.java Thu Aug 15 16:04:01 2013
@@ -0,0 +1,47 @@
+/*
+ *
+ * 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;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 8/14/13
+ * Time: 3:12 PM
+ */
+
+/**
+ * An API to executed commands/jobs using GSI-SSH or SSH.
+ */
+public interface SSHApi {
+
+    /**
+     * Executes a given command.
+     * @param commandInfo Encapsulated information about command. E.g :- executable name
+     *                    parameters etc ...
+     * @param serverInfo The SSHing server information.
+     * @param authenticationInfo Security data needs to be communicated with remote server.
+     * @param commandOutput The output of the command.
+     */
+    void executeCommand(CommandInfo commandInfo, ServerInfo serverInfo,
+                                 AuthenticationInfo authenticationInfo,
+                                 CommandOutput commandOutput) throws SSHApiException;
+
+}

Added: airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/SSHApiException.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/SSHApiException.java?rev=1514337&view=auto
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/SSHApiException.java (added)
+++ airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/SSHApiException.java Thu Aug 15 16:04:01 2013
@@ -0,0 +1,42 @@
+/*
+ *
+ * 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;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 8/14/13
+ * Time: 3:14 PM
+ */
+
+/**
+ * An exception class to wrap SSH command execution related errors.
+ */
+public class SSHApiException extends Exception {
+
+    public SSHApiException(String message) {
+        super(message);
+    }
+
+    public SSHApiException(String message, Exception e) {
+        super(message, e);
+    }
+}

Added: airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/SSHApiFactory.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/SSHApiFactory.java?rev=1514337&view=auto
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/SSHApiFactory.java (added)
+++ airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/SSHApiFactory.java Thu Aug 15 16:04:01 2013
@@ -0,0 +1,59 @@
+/*
+ *
+ * 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;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 8/15/13
+ * Time: 10:48 AM
+ */
+
+import com.jcraft.jsch.JSch;
+import org.apache.airavata.gsi.ssh.impl.DefaultSSHApi;
+
+import java.io.IOException;
+
+/**
+ * Factory class to create SSH API implementations.
+ */
+public class SSHApiFactory {
+
+    static {
+        JSch.setConfig("gssapi-with-mic.x509", "org.apache.airavata.gsi.ssh.GSSContextX509");
+        JSch.setConfig("userauth.gssapi-with-mic", "com.jcraft.jsch.UserAuthGSSAPIWithMICGSSCredentials");
+
+    }
+
+    /**
+     * Creates a new instance of SSHAPI. For the moment we only have default implementation.
+     * i.e. org.apache.airavata.gsi.ssh.impl.DefaultSSHApi
+     * @param certificateLocation The file location where certificates are stored.
+     * @return An SSHAPI implementation.
+     * @throws SSHApiException If an error occurred while initialization.
+     */
+    public static SSHApi createSSHApi(String certificateLocation) throws SSHApiException {
+
+        System.setProperty("X509_CERT_DIR", certificateLocation);
+        return new DefaultSSHApi();
+
+    }
+}

Added: airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/ServerInfo.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/ServerInfo.java?rev=1514337&view=auto
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/ServerInfo.java (added)
+++ airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/ServerInfo.java Thu Aug 15 16:04:01 2013
@@ -0,0 +1,71 @@
+package org.apache.airavata.gsi.ssh.api;/*
+ *
+ * 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: 8/14/13
+ * Time: 4:15 PM
+ */
+
+/**
+ * Encapsulate server information.
+ */
+public class ServerInfo {
+
+    private String host;
+    private String userName;
+    private int port = 22;
+
+    public ServerInfo(String userName, String host) {
+        this.userName = userName;
+        this.host = host;
+    }
+
+    public ServerInfo(String host, String userName, int port) {
+        this.host = host;
+        this.userName = userName;
+        this.port = port;
+    }
+
+    public String getHost() {
+        return host;
+    }
+
+    public void setHost(String host) {
+        this.host = host;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    public int getPort() {
+        return port;
+    }
+
+    public void setPort(int port) {
+        this.port = port;
+    }
+}

Added: airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/config/ConfigReader.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/config/ConfigReader.java?rev=1514337&view=auto
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/config/ConfigReader.java (added)
+++ airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/config/ConfigReader.java Thu Aug 15 16:04:01 2013
@@ -0,0 +1,81 @@
+/*
+ *
+ * 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.config;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 8/14/13
+ * Time: 2:41 PM
+ */
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+/**
+ * Reads basic configurations.
+ */
+public class ConfigReader {
+
+    private static final String CONFIGURATION_FILE = "gsissh.properties";
+
+
+    private Properties properties;
+
+    /**
+     * Reads configurations from the class path configuration file.
+     * @throws IOException If an error occurred while reading configurations.
+     */
+    public ConfigReader() throws IOException {
+        this.properties = getPropertiesFromClasspath(CONFIGURATION_FILE);
+    }
+
+    private Properties getPropertiesFromClasspath(String propFileName) throws IOException {
+        Properties props = new Properties();
+        InputStream inputStream = this.getClass().getClassLoader()
+                .getResourceAsStream(propFileName);
+
+        if (inputStream == null) {
+            throw new FileNotFoundException("System configuration file '" + propFileName
+                    + "' not found in the classpath");
+        }
+
+        props.load(inputStream);
+
+        return props;
+    }
+
+    public String getConfiguration(String key) {
+        return this.properties.getProperty(key);
+    }
+
+    /**
+     * Gets all the SSH related properties used by JSch.
+     * @return All properties.
+     */
+    public Properties getProperties() {
+        return this.properties;
+    }
+
+
+}

Added: airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/DefaultSSHApi.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/DefaultSSHApi.java?rev=1514337&view=auto
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/DefaultSSHApi.java (added)
+++ airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/DefaultSSHApi.java Thu Aug 15 16:04:01 2013
@@ -0,0 +1,141 @@
+/*
+ *
+ * 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.*;
+import org.apache.airavata.gsi.ssh.api.*;
+import org.apache.airavata.gsi.ssh.config.ConfigReader;
+import org.apache.airavata.gsi.ssh.jsch.ExtendedJSch;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.swing.*;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 8/14/13
+ * Time: 5:18 PM
+ */
+
+/**
+ * Default SSH API implementation.
+ */
+public class DefaultSSHApi implements SSHApi {
+
+    private static final Logger log = LoggerFactory.getLogger(DefaultSSHApi.class);
+
+
+    private ConfigReader configReader;
+
+    /**
+     * Initializes default SSH API. During initialization basic configurations
+     * are read.
+     * @throws IOException If an error occurred while reading basic configurations.
+     */
+    public DefaultSSHApi() throws SSHApiException {
+        try {
+            this.configReader = new ConfigReader();
+        } catch (IOException e) {
+            throw new SSHApiException("Unable to load system configurations.", e);
+        }
+    }
+
+    public void executeCommand(CommandInfo commandInfo, ServerInfo serverInfo,
+                                        AuthenticationInfo authenticationInfo,
+                                        CommandOutput commandOutput) throws SSHApiException {
+
+        JSch jsch = new ExtendedJSch();
+
+        log.info("Connecting to server - " + serverInfo.getHost() + ":" + serverInfo.getPort() + " with user name - "
+                + serverInfo.getUserName());
+
+        Session session = null;
+
+        try {
+            session = jsch.getSession(serverInfo.getUserName(), serverInfo.getHost(), serverInfo.getPort());
+        } catch (JSchException e) {
+            throw new SSHApiException("An exception occurred while creating SSH session." +
+                    "Connecting server - " + serverInfo.getHost() + ":" + serverInfo.getPort() +
+                    " connecting user name - "
+                    + serverInfo.getUserName(), e);
+        }
+
+        java.util.Properties config = this.configReader.getProperties();
+        session.setConfig(config);
+
+        // Not a good way, but we dont have any choice
+        if (session instanceof ExtendedSession) {
+            ((ExtendedSession)session).setAuthenticationInfo(authenticationInfo);
+        }
+
+        try {
+            session.connect();
+        } catch (JSchException e) {
+            throw new SSHApiException("An exception occurred while connecting to server." +
+                    "Connecting server - " + serverInfo.getHost() + ":" + serverInfo.getPort() +
+                    " connecting user name - "
+                    + serverInfo.getUserName(), e);
+        }
+
+        String command = commandInfo.getCommand();
+
+        Channel channel = null;
+        try {
+            channel = session.openChannel("exec");
+            ((ChannelExec) channel).setCommand(command);
+        } catch (JSchException e) {
+            session.disconnect();
+
+            throw new SSHApiException("Unable to execute command - " + command +
+                    " on server - " + serverInfo.getHost() + ":" + serverInfo.getPort() +
+                    " connecting user name - "
+                    + serverInfo.getUserName(), e);
+        }
+
+
+
+        channel.setInputStream(null);
+        ((ChannelExec) channel).setErrStream(commandOutput.getStandardError());
+
+        try {
+            channel.connect();
+        } catch (JSchException e) {
+
+            channel.disconnect();
+            session.disconnect();
+
+            throw new SSHApiException("Unable to retrieve command output. Command - " + command +
+                    " on server - " + serverInfo.getHost() + ":" + serverInfo.getPort() +
+                    " connecting user name - "
+                    + serverInfo.getUserName(), e);
+        }
+
+        commandOutput.onOutput(channel);
+
+        channel.disconnect();
+        session.disconnect();
+
+
+    }
+}

Added: 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/MyProxyAuthenticationInfo.java?rev=1514337&view=auto
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/MyProxyAuthenticationInfo.java (added)
+++ airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/MyProxyAuthenticationInfo.java Thu Aug 15 16:04:01 2013
@@ -0,0 +1,104 @@
+/*
+ *
+ * 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 org.apache.airavata.gsi.ssh.api.AuthenticationInfo;
+import org.globus.myproxy.MyProxy;
+import org.globus.myproxy.MyProxyException;
+import org.ietf.jgss.GSSCredential;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 8/14/13
+ * Time: 5:22 PM
+ */
+
+public class MyProxyAuthenticationInfo implements AuthenticationInfo {
+
+    private String userName;
+    private String password;
+    private String myProxyUrl;
+    private int myProxyPort;
+    private int lifeTime;
+
+    public MyProxyAuthenticationInfo(String userName, String password, String myProxyUrl, int myProxyPort,
+                                     int life) {
+        this.userName = userName;
+        this.password = password;
+        this.myProxyUrl = myProxyUrl;
+        this.myProxyPort = myProxyPort;
+        this.lifeTime = life;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    public String getMyProxyUrl() {
+        return myProxyUrl;
+    }
+
+    public void setMyProxyUrl(String myProxyUrl) {
+        this.myProxyUrl = myProxyUrl;
+    }
+
+    public int getMyProxyPort() {
+        return myProxyPort;
+    }
+
+    public void setMyProxyPort(int myProxyPort) {
+        this.myProxyPort = myProxyPort;
+    }
+
+    public int getLifeTime() {
+        return lifeTime;
+    }
+
+    public void setLifeTime(int lifeTime) {
+        this.lifeTime = lifeTime;
+    }
+
+    public GSSCredential getCredentials() throws SecurityException{
+        return getMyProxyCredentials();
+    }
+
+    private GSSCredential getMyProxyCredentials() throws SecurityException {
+        MyProxy myproxy = new MyProxy(this.myProxyUrl, this.myProxyPort);
+        try {
+            return myproxy.get(this.getUserName(), this.password, this.lifeTime);
+        } catch (MyProxyException e) {
+            throw new SecurityException("Error getting proxy credentials", e);
+        }
+    }
+}

Added: airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/RawCommandInfo.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/RawCommandInfo.java?rev=1514337&view=auto
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/RawCommandInfo.java (added)
+++ airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/RawCommandInfo.java Thu Aug 15 16:04:01 2013
@@ -0,0 +1,55 @@
+/*
+ *
+ * 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 org.apache.airavata.gsi.ssh.api.CommandInfo;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 8/14/13
+ * Time: 5:18 PM
+ */
+
+/**
+ * The raw command information. String returned by getCommand is directly executed in SSH
+ * shell. E.g :- getCommand return string set for rawCommand - "/opt/torque/bin/qsub /home/ogce/test.pbs".
+ */
+public class RawCommandInfo implements CommandInfo {
+
+    private String rawCommand;
+
+    public RawCommandInfo(String cmd) {
+        this.rawCommand = cmd;
+    }
+
+    public String getCommand() {
+        return this.rawCommand;
+    }
+
+    public String getRawCommand() {
+        return rawCommand;
+    }
+
+    public void setRawCommand(String rawCommand) {
+        this.rawCommand = rawCommand;
+    }
+}

Added: airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/SystemCommandOutput.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/SystemCommandOutput.java?rev=1514337&view=auto
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/SystemCommandOutput.java (added)
+++ airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/SystemCommandOutput.java Thu Aug 15 16:04:01 2013
@@ -0,0 +1,74 @@
+/*
+ *
+ * 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.Channel;
+import org.apache.airavata.gsi.ssh.api.CommandOutput;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 8/15/13
+ * Time: 10:44 AM
+ */
+
+public class SystemCommandOutput implements CommandOutput {
+
+    public void onOutput(Channel channel) {
+        try {
+            InputStream inputStream = channel.getInputStream();
+            byte[] tmp = new byte[1024];
+            while (true) {
+                while (inputStream.available() > 0) {
+                    int i = inputStream.read(tmp, 0, 1024);
+                    if (i < 0) break;
+                    System.out.print(new String(tmp, 0, i));
+                }
+                if (channel.isClosed()) {
+                    System.out.println("exit-status: " + channel.getExitStatus());
+                    break;
+                }
+                try {
+                    Thread.sleep(1000);
+                } catch (Exception ignored) {
+                }
+            }
+
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+
+    }
+
+    public OutputStream getStandardError() {
+        return System.err;
+    }
+
+    public void exitCode(int code) {
+        System.out.println("Program exit code - " + code);
+    }
+
+
+}

Added: 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=1514337&view=auto
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/jsch/ExtendedJSch.java (added)
+++ airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/jsch/ExtendedJSch.java Thu Aug 15 16:04:01 2013
@@ -0,0 +1,64 @@
+/*
+ *
+ * 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.jsch;
+
+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;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 8/15/13
+ * Time: 10:03 AM
+ */
+
+/**
+ * Extended JSch to incorporate authentication info.
+ */
+public class ExtendedJSch extends JSch {
+
+    private AuthenticationInfo authenticationInfo;
+
+    public ExtendedJSch() {
+        super();
+    }
+
+    public AuthenticationInfo getAuthenticationInfo() {
+        return authenticationInfo;
+    }
+
+    public void setAuthenticationInfo(AuthenticationInfo authenticationInfo) {
+        this.authenticationInfo = authenticationInfo;
+    }
+
+    public Session getSession(String username, String host, int port) throws JSchException {
+
+        if(host==null){
+            throw new JSchException("host must not be null.");
+        }
+        Session s = new ExtendedSession(this, username, host, port);
+        return s;
+
+    }
+}

Added: airavata/sandbox/gsissh/src/main/resources/gsissh.properties
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/resources/gsissh.properties?rev=1514337&view=auto
==============================================================================
--- airavata/sandbox/gsissh/src/main/resources/gsissh.properties (added)
+++ airavata/sandbox/gsissh/src/main/resources/gsissh.properties Thu Aug 15 16:04:01 2013
@@ -0,0 +1,3 @@
+# Specifies system level configurations as a key/value pairs.
+
+StrictHostKeyChecking=no
\ No newline at end of file

Added: airavata/sandbox/gsissh/src/test/java/org/apache/airavata/gsi/ssh/config/ConfigReaderTest.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/test/java/org/apache/airavata/gsi/ssh/config/ConfigReaderTest.java?rev=1514337&view=auto
==============================================================================
--- airavata/sandbox/gsissh/src/test/java/org/apache/airavata/gsi/ssh/config/ConfigReaderTest.java (added)
+++ airavata/sandbox/gsissh/src/test/java/org/apache/airavata/gsi/ssh/config/ConfigReaderTest.java Thu Aug 15 16:04:01 2013
@@ -0,0 +1,42 @@
+/*
+ *
+ * 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.config;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 8/14/13
+ * Time: 3:07 PM
+ */
+
+public class ConfigReaderTest {
+
+    @Test
+    public void testGetConfiguration() throws Exception {
+
+        ConfigReader configReader = new ConfigReader();
+        Assert.assertEquals(configReader.getConfiguration("StrictHostKeyChecking"), "no");
+
+    }
+}

Added: 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=1514337&view=auto
==============================================================================
--- airavata/sandbox/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/DefaultSSHApiTest.java (added)
+++ airavata/sandbox/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/DefaultSSHApiTest.java Thu Aug 15 16:04:01 2013
@@ -0,0 +1,103 @@
+/*
+ *
+ * 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 org.apache.airavata.gsi.ssh.api.*;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 8/15/13
+ * Time: 10:54 AM
+ */
+
+
+public class DefaultSSHApiTest {
+
+    private String myProxyUserName;
+    private String myProxyPassword;
+
+    private static final String CERT_LOCATION
+            = "/Users/thejaka/development/apache/airavata/sandbox/grid-tools/certificates";
+
+    @BeforeTest
+    public void setUp() throws Exception {
+        myProxyUserName = System.getProperty("myproxy.user");
+        myProxyPassword = System.getProperty("myproxy.password");
+
+        if (myProxyUserName == null || myProxyPassword == null) {
+            System.out.println(">>>>>> Please run tests with my proxy user name and password. " +
+                    "E.g :- mvn clean install -Dmyproxy.user=xxx -Dmyproxy.password=xxx <<<<<<<");
+            throw new Exception("Need my proxy user name password to run tests.");
+        }
+    }
+
+    public void tearDown() throws Exception {
+    }
+
+    @Test
+    public void testExecuteCommand() throws Exception {
+         // Create authentication
+        AuthenticationInfo authenticationInfo
+                = new MyProxyAuthenticationInfo(myProxyUserName, myProxyPassword, "myproxy.teragrid.org",
+                7512, 17280000);
+
+        // Create command
+        CommandInfo commandInfo = new RawCommandInfo("/opt/torque/bin/qstat");
+
+        // Server info
+        ServerInfo serverInfo = new ServerInfo("ogce" ,"trestles.sdsc.edu");
+
+        // Output
+        CommandOutput commandOutput = new SystemCommandOutput();
+
+        // Get the API
+        SSHApi sshApi = SSHApiFactory.createSSHApi(CERT_LOCATION);
+
+        // Execute command
+        sshApi.executeCommand(commandInfo, serverInfo, authenticationInfo, commandOutput);
+    }
+
+    @Test
+    public void testSubmitJob() throws Exception {
+        // Create authentication
+        AuthenticationInfo authenticationInfo
+                = new MyProxyAuthenticationInfo(myProxyUserName, myProxyPassword, "myproxy.teragrid.org",
+                7512, 17280000);
+
+        // Create command
+        CommandInfo commandInfo = new RawCommandInfo("/opt/torque/bin/qsub /home/ogce/test.pbs");
+
+        // Server info
+        ServerInfo serverInfo = new ServerInfo("ogce" ,"trestles.sdsc.edu");
+
+        // Output
+        CommandOutput commandOutput = new SystemCommandOutput();
+
+        // Get the API
+        SSHApi sshApi = SSHApiFactory.createSSHApi(CERT_LOCATION);
+
+        // Execute command
+        sshApi.executeCommand(commandInfo, serverInfo, authenticationInfo, commandOutput);
+    }
+}



Mime
View raw message