You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by la...@apache.org on 2014/07/07 15:46:18 UTC

[2/3] git commit: adding ssh key storing and retrieving in credential store

adding ssh key storing and retrieving in credential store


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/964b6afd
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/964b6afd
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/964b6afd

Branch: refs/heads/master
Commit: 964b6afd391e240cafb4dea76c624e4fabd3683d
Parents: c290a04
Author: lahiru <la...@apache.org>
Authored: Mon Jul 7 09:44:56 2014 -0400
Committer: lahiru <la...@apache.org>
Committed: Mon Jul 7 09:44:56 2014 -0400

----------------------------------------------------------------------
 .gitignore                                      |   4 +-
 .../client/samples/CreateLaunchExperiment.java  | 260 +++++++-----
 .../airavata/client/tools/DocumentCreator.java  | 398 +++++++++++--------
 .../credential/impl/ssh/SSHCredential.java      |  13 +
 .../impl/ssh/SSHCredentialGenerator.java        |  20 +-
 .../store/util/TokenGeneratorTest.java          |   2 +-
 modules/gfac/gfac-monitor/pom.xml               |  16 +-
 .../handlers/GridPullMonitorHandler.java        |   4 +-
 .../monitor/impl/pull/qstat/HPCPullMonitor.java |  33 +-
 .../impl/pull/qstat/ResourceConnection.java     |  66 ++-
 modules/gfac/gfac-ssh/pom.xml                   |  23 +-
 .../gfac/ssh/provider/impl/SSHProvider.java     |  65 ++-
 .../airavata/gfac/ssh/util/GFACSSHUtils.java    |  29 +-
 .../registry/jpa/impl/AiravataJPARegistry.java  |  16 +-
 14 files changed, 590 insertions(+), 359 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/964b6afd/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 475cde0..ac916b7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,7 +16,7 @@
 *.ipr
 *.iws
 *.iml
-
+*target
 ## Additional for IntelliJ
 out/
 
@@ -27,4 +27,4 @@ out/
 atlassian-ide-plugin.xml
 
 # generated by Crashlytics plugin (for Android Studio and Intellij)
-com_crashlytics_export_strings.xml
\ No newline at end of file
+com_crashlytics_export_strings.xml

http://git-wip-us.apache.org/repos/asf/airavata/blob/964b6afd/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java b/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java
index c8c9235..a6a6a52 100644
--- a/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java
+++ b/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java
@@ -80,80 +80,80 @@ public class CreateLaunchExperiment {
             List<Project> projects = getAllUserProject(airavata, "admin");
             List<Project> searchProjects1 = searchProjectsByProjectName(airavata, "admin", "project");
             List<Project> searchProjects2 = searchProjectsByProjectDesc(airavata, "admin", "test");
-            for (Experiment exp : experiments){
+            for (Experiment exp : experiments) {
                 System.out.println(" exp id : " + exp.getExperimentID());
-                System.out.println("experiment Description : " + exp.getDescription()) ;
+                System.out.println("experiment Description : " + exp.getDescription());
                 if (exp.getExperimentStatus() != null) {
                     System.out.println(" exp status : " + exp.getExperimentStatus().getExperimentState().toString());
                 }
             }
 
-            for (ExperimentSummary exp : searchedExps1){
+            for (ExperimentSummary exp : searchedExps1) {
                 System.out.println("search results by experiment name");
-                System.out.println("experiment ID : " + exp.getExperimentID()) ;
-                System.out.println("experiment Description : " + exp.getDescription()) ;
+                System.out.println("experiment ID : " + exp.getExperimentID());
+                System.out.println("experiment Description : " + exp.getDescription());
                 if (exp.getExperimentStatus() != null) {
                     System.out.println(" exp status : " + exp.getExperimentStatus().getExperimentState().toString());
                 }
             }
 
-            for (ExperimentSummary exp : searchedExps2){
+            for (ExperimentSummary exp : searchedExps2) {
                 System.out.println("search results by experiment desc");
-                System.out.println("experiment ID : " + exp.getExperimentID()) ;
+                System.out.println("experiment ID : " + exp.getExperimentID());
                 if (exp.getExperimentStatus() != null) {
                     System.out.println(" exp status : " + exp.getExperimentStatus().getExperimentState().toString());
                 }
             }
 
-            for (ExperimentSummary exp : searchedExps3){
+            for (ExperimentSummary exp : searchedExps3) {
                 System.out.println("search results by application");
-                System.out.println("experiment ID : " + exp.getExperimentID()) ;
+                System.out.println("experiment ID : " + exp.getExperimentID());
                 if (exp.getExperimentStatus() != null) {
                     System.out.println(" exp status : " + exp.getExperimentStatus().getExperimentState().toString());
                 }
             }
 
-            for (Project pr : searchProjects1){
+            for (Project pr : searchProjects1) {
                 System.out.println(" project id : " + pr.getProjectID());
             }
 
-            for (Project pr : searchProjects2){
+            for (Project pr : searchProjects2) {
                 System.out.println(" project id : " + pr.getProjectID());
                 System.out.println(" project desc : " + pr.getDescription());
             }
 
-            Thread monitor = (new Thread(){
-                 public void run() {
-                     Map<String, JobStatus> jobStatuses = null;
-                     while (true) {
-                         try {
-                             jobStatuses = airavata.getJobStatuses(expId);
-                             Set<String> strings = jobStatuses.keySet();
-                             for (String key : strings) {
-                                 JobStatus jobStatus = jobStatuses.get(key);
-                                 if(jobStatus == null){
-                                     return;
-                                 }else {
-                                     if (JobState.COMPLETE.equals(jobStatus.getJobState())) {
-                                         System.out.println("Job completed Job ID: " + key);
-                                         return;
-                                     }else{
+            Thread monitor = (new Thread() {
+                public void run() {
+                    Map<String, JobStatus> jobStatuses = null;
+                    while (true) {
+                        try {
+                            jobStatuses = airavata.getJobStatuses(expId);
+                            Set<String> strings = jobStatuses.keySet();
+                            for (String key : strings) {
+                                JobStatus jobStatus = jobStatuses.get(key);
+                                if (jobStatus == null) {
+                                    return;
+                                } else {
+                                    if (JobState.COMPLETE.equals(jobStatus.getJobState())) {
+                                        System.out.println("Job completed Job ID: " + key);
+                                        return;
+                                    } else {
                                         System.out.println("Job ID:" + key + jobStatuses.get(key).getJobState().toString());
-                                     }
-                                 }
-                             }
-                             ExperimentStatus experimentStatus = airavata.getExperimentStatus(expId);
-                             if(experimentStatus.getExperimentState().equals(ExperimentState.FAILED)){
-                            	 return;
-                             }
-							System.out.println(experimentStatus);
-                             Thread.sleep(5000);
-                         } catch (Exception e) {
-                             e.printStackTrace();
-                         }
-                     }
-
-                 }
+                                    }
+                                }
+                            }
+                            ExperimentStatus experimentStatus = airavata.getExperimentStatus(expId);
+                            if (experimentStatus.getExperimentState().equals(ExperimentState.FAILED)) {
+                                return;
+                            }
+                            System.out.println(experimentStatus);
+                            Thread.sleep(5000);
+                        } catch (Exception e) {
+                            e.printStackTrace();
+                        }
+                    }
+
+                }
             });
             monitor.start();
             try {
@@ -161,20 +161,20 @@ public class CreateLaunchExperiment {
             } catch (InterruptedException e) {
                 e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
             }
-			try {
-				Thread.sleep(5000);
-			} catch (InterruptedException e) {
-				e.printStackTrace(); // To change body of catch statement use
-										// File | Settings | File Templates.
-			}
+            try {
+                Thread.sleep(5000);
+            } catch (InterruptedException e) {
+                e.printStackTrace(); // To change body of catch statement use
+                // File | Settings | File Templates.
+            }
 
 //            System.out.println(airavata.getExperimentStatus(expId));
             List<DataObjectType> output = airavata.getExperimentOutputs(expId);
             for (DataObjectType dataObjectType : output) {
                 System.out.println(dataObjectType.getKey() + " : " + dataObjectType.getType() + " : " + dataObjectType.getValue());
-                
-				
-			}
+
+
+            }
             String clonedExpId = cloneExperiment(airavata, expId);
             System.out.println("Cloned Experiment ID : " + clonedExpId);
 //            System.out.println("retrieved exp id : " + experiment.getExperimentID());
@@ -184,7 +184,7 @@ public class CreateLaunchExperiment {
         }
     }
 
-    public static void addDescriptors() throws AiravataAPIInvocationException,ApplicationSettingsException  {
+    public static void addDescriptors() throws AiravataAPIInvocationException, ApplicationSettingsException {
         try {
             DocumentCreator documentCreator = new DocumentCreator(getAiravataAPI());
             documentCreator.createLocalHostDocs();
@@ -194,6 +194,7 @@ public class CreateLaunchExperiment {
             documentCreator.createSlurmDocs();
             documentCreator.createSGEDocs();
             documentCreator.createEchoHostDocs();
+            documentCreator.createBigRedDocs();
         } catch (AiravataAPIInvocationException e) {
             logger.error("Unable to create airavata API", e.getMessage());
             throw new AiravataAPIInvocationException(e);
@@ -219,8 +220,8 @@ public class CreateLaunchExperiment {
         return airavataAPI;
     }
 
-    public static String createExperimentForTrestles(Airavata.Client client) throws TException  {
-        try{
+    public static String createExperimentForTrestles(Airavata.Client client) throws TException {
+        try {
             List<DataObjectType> exInputs = new ArrayList<DataObjectType>();
             DataObjectType input = new DataObjectType();
             input.setKey("echo_input");
@@ -255,50 +256,50 @@ public class CreateLaunchExperiment {
         } catch (AiravataClientException e) {
             logger.error("Error occured while creating the experiment...", e.getMessage());
             throw new AiravataClientException(e);
-        }catch (TException e) {
+        } catch (TException e) {
             logger.error("Error occured while creating the experiment...", e.getMessage());
             throw new TException(e);
         }
     }
-    
-    public static String createExperimentWRFTrestles(Airavata.Client client) throws TException  {
-        try{
+
+    public static String createExperimentWRFTrestles(Airavata.Client client) throws TException {
+        try {
             List<DataObjectType> exInputs = new ArrayList<DataObjectType>();
             DataObjectType input = new DataObjectType();
             input.setKey("WRF_Namelist");
             input.setType(DataType.URI);
             input.setValue("/Users/raminder/Downloads/wrf_sample_inputs/namelist.input");
-            
+
             DataObjectType input1 = new DataObjectType();
             input1.setKey("WRF_Input_File");
             input1.setType(DataType.URI);
             input1.setValue("/Users/raminder/Downloads/wrf_sample_inputs/wrfinput_d01");
-            
+
             DataObjectType input2 = new DataObjectType();
             input2.setKey("WRF_Boundary_File");
             input2.setType(DataType.URI);
             input2.setValue("/Users/raminder/Downloads/wrf_sample_inputs/wrfbdy_d01");
-            
+
             exInputs.add(input);
             exInputs.add(input1);
             exInputs.add(input2);
 
-           
+
             List<DataObjectType> exOut = new ArrayList<DataObjectType>();
             DataObjectType output = new DataObjectType();
             output.setKey("WRF_Output");
             output.setType(DataType.URI);
             output.setValue("");
-            
+
             DataObjectType output1 = new DataObjectType();
             output1.setKey("WRF_Execution_Log");
             output1.setType(DataType.URI);
             output1.setValue("");
-            
-            
+
+
             exOut.add(output);
             exOut.add(output1);
-           
+
 
             Experiment simpleExperiment =
                     ExperimentModelUtil.createSimpleExperiment("default", "admin", "WRFExperiment", "Testing", "WRF", exInputs);
@@ -320,35 +321,35 @@ public class CreateLaunchExperiment {
         } catch (AiravataClientException e) {
             logger.error("Error occured while creating the experiment...", e.getMessage());
             throw new AiravataClientException(e);
-        }catch (TException e) {
+        } catch (TException e) {
             logger.error("Error occured while creating the experiment...", e.getMessage());
             throw new TException(e);
         }
     }
 
-    public static String cloneExperiment(Airavata.Client client, String expId) throws TException  {
-        try{
+    public static String cloneExperiment(Airavata.Client client, String expId) throws TException {
+        try {
             return client.cloneExperiment(expId, "cloneExperiment1");
-        }catch (TException e) {
+        } catch (TException e) {
             logger.error("Error occured while creating the experiment...", e.getMessage());
             throw new TException(e);
         }
     }
 
-    public static void updateExperiment(Airavata.Client client, String expId) throws TException  {
-        try{
+    public static void updateExperiment(Airavata.Client client, String expId) throws TException {
+        try {
             Experiment experiment = client.getExperiment(expId);
             experiment.setDescription("updatedDescription");
-            client.updateExperiment(expId, experiment );
-        }catch (TException e) {
+            client.updateExperiment(expId, experiment);
+        } catch (TException e) {
             logger.error("Error occured while creating the experiment...", e.getMessage());
             throw new TException(e);
         }
     }
 
 
-    public static String createExperimentForLocalHost(Airavata.Client client) throws TException  {
-        try{
+    public static String createExperimentForLocalHost(Airavata.Client client) throws TException {
+        try {
             List<DataObjectType> exInputs = new ArrayList<DataObjectType>();
             DataObjectType input = new DataObjectType();
             input.setKey("echo_input");
@@ -386,14 +387,14 @@ public class CreateLaunchExperiment {
         } catch (AiravataClientException e) {
             logger.error("Error occured while creating the experiment...", e.getMessage());
             throw new AiravataClientException(e);
-        }catch (TException e) {
+        } catch (TException e) {
             logger.error("Error occured while creating the experiment...", e.getMessage());
             throw new TException(e);
         }
     }
-    
-    public static String createExperimentForSSHHost(Airavata.Client client) throws TException  {
-        try{
+
+    public static String createExperimentForSSHHost(Airavata.Client client) throws TException {
+        try {
             List<DataObjectType> exInputs = new ArrayList<DataObjectType>();
             DataObjectType input = new DataObjectType();
             input.setKey("echo_input");
@@ -432,13 +433,14 @@ public class CreateLaunchExperiment {
         } catch (AiravataClientException e) {
             logger.error("Error occured while creating the experiment...", e.getMessage());
             throw new AiravataClientException(e);
-        }catch (TException e) {
+        } catch (TException e) {
             logger.error("Error occured while creating the experiment...", e.getMessage());
             throw new TException(e);
         }
     }
-    public static String createExperimentForStampede(Airavata.Client client) throws TException  {
-        try{
+
+    public static String createExperimentForStampede(Airavata.Client client) throws TException {
+        try {
             List<DataObjectType> exInputs = new ArrayList<DataObjectType>();
             DataObjectType input = new DataObjectType();
             input.setKey("echo_input");
@@ -477,13 +479,14 @@ public class CreateLaunchExperiment {
         } catch (AiravataClientException e) {
             logger.error("Error occured while creating the experiment...", e.getMessage());
             throw new AiravataClientException(e);
-        }catch (TException e) {
+        } catch (TException e) {
             logger.error("Error occured while creating the experiment...", e.getMessage());
             throw new TException(e);
         }
     }
-       public static String createExperimentForLonestar(Airavata.Client client) throws TException  {
-        try{
+
+    public static String createExperimentForLonestar(Airavata.Client client) throws TException {
+        try {
             List<DataObjectType> exInputs = new ArrayList<DataObjectType>();
             DataObjectType input = new DataObjectType();
             input.setKey("echo_input");
@@ -531,15 +534,60 @@ public class CreateLaunchExperiment {
                 }
             }
             throw e;
-        }catch (TException e) {
+        } catch (TException e) {
+            logger.error("Error occured while creating the experiment...", e.getMessage());
+            throw new TException(e);
+        }
+    }
+
+    public static String createExperimentForBR2(Airavata.Client client) throws TException {
+        try {
+            List<DataObjectType> exInputs = new ArrayList<DataObjectType>();
+            DataObjectType input = new DataObjectType();
+            input.setKey("echo_input");
+            input.setType(DataType.STRING);
+            input.setValue("echo_output=Hello World");
+            exInputs.add(input);
+
+            List<DataObjectType> exOut = new ArrayList<DataObjectType>();
+            DataObjectType output = new DataObjectType();
+            output.setKey("echo_output");
+            output.setType(DataType.STRING);
+            output.setValue("");
+            exOut.add(output);
+
+            Project project = ProjectModelUtil.createProject("default", "admin", "test project");
+            String projectId = client.createProject(project);
+
+            Experiment simpleExperiment =
+                    ExperimentModelUtil.createSimpleExperiment(projectId, "admin", "sshEchoExperiment", "SimpleEchoBR", "SimpleEchoBR", exInputs);
+            simpleExperiment.setExperimentOutputs(exOut);
+
+            ComputationalResourceScheduling scheduling = ExperimentModelUtil.createComputationResourceScheduling("bigred2.uits.iu.edu", 1, 1, 1, "normal", 0, 0, 1, "sds128");
+            scheduling.setResourceHostId("bigred2.uits.iu.edu");
+            UserConfigurationData userConfigurationData = new UserConfigurationData();
+            userConfigurationData.setAiravataAutoSchedule(false);
+            userConfigurationData.setOverrideManualScheduledParams(false);
+            userConfigurationData.setComputationalResourceScheduling(scheduling);
+            simpleExperiment.setUserConfigurationData(userConfigurationData);
+            return client.createExperiment(simpleExperiment);
+        } catch (AiravataSystemException e) {
+            logger.error("Error occured while creating the experiment...", e.getMessage());
+            throw new AiravataSystemException(e);
+        } catch (InvalidRequestException e) {
+            logger.error("Error occured while creating the experiment...", e.getMessage());
+            throw new InvalidRequestException(e);
+        } catch (AiravataClientException e) {
+            logger.error("Error occured while creating the experiment...", e.getMessage());
+            throw new AiravataClientException(e);
+        } catch (TException e) {
             logger.error("Error occured while creating the experiment...", e.getMessage());
             throw new TException(e);
         }
     }
-       
-       
-    public static void launchExperiment (Airavata.Client client, String expId)
-            throws TException{
+
+    public static void launchExperiment(Airavata.Client client, String expId)
+            throws TException {
         try {
             client.launchExperiment(expId, "testToken");
         } catch (ExperimentNotFoundException e) {
@@ -554,13 +602,13 @@ public class CreateLaunchExperiment {
         } catch (AiravataClientException e) {
             logger.error("Error occured while launching the experiment...", e.getMessage());
             throw new AiravataClientException(e);
-        }catch (TException e) {
+        } catch (TException e) {
             logger.error("Error occured while launching the experiment...", e.getMessage());
             throw new TException(e);
         }
     }
 
-    public static List<Experiment> getExperimentsForUser (Airavata.Client client, String user){
+    public static List<Experiment> getExperimentsForUser(Airavata.Client client, String user) {
         try {
             return client.getAllUserExperiments(user);
         } catch (AiravataSystemException e) {
@@ -569,13 +617,13 @@ public class CreateLaunchExperiment {
             e.printStackTrace();
         } catch (AiravataClientException e) {
             e.printStackTrace();
-        }catch (TException e){
+        } catch (TException e) {
             e.printStackTrace();
         }
         return null;
     }
 
-    public static List<Project> getAllUserProject (Airavata.Client client, String user){
+    public static List<Project> getAllUserProject(Airavata.Client client, String user) {
         try {
             return client.getAllUserProjects(user);
         } catch (AiravataSystemException e) {
@@ -584,13 +632,13 @@ public class CreateLaunchExperiment {
             e.printStackTrace();
         } catch (AiravataClientException e) {
             e.printStackTrace();
-        }catch (TException e){
+        } catch (TException e) {
             e.printStackTrace();
         }
         return null;
     }
 
-    public static List<Project> searchProjectsByProjectName (Airavata.Client client, String user, String projectName){
+    public static List<Project> searchProjectsByProjectName(Airavata.Client client, String user, String projectName) {
         try {
             return client.searchProjectsByProjectName(user, projectName);
         } catch (AiravataSystemException e) {
@@ -599,13 +647,13 @@ public class CreateLaunchExperiment {
             e.printStackTrace();
         } catch (AiravataClientException e) {
             e.printStackTrace();
-        }catch (TException e){
+        } catch (TException e) {
             e.printStackTrace();
         }
         return null;
     }
 
-    public static List<Project> searchProjectsByProjectDesc (Airavata.Client client, String user, String desc){
+    public static List<Project> searchProjectsByProjectDesc(Airavata.Client client, String user, String desc) {
         try {
             return client.searchProjectsByProjectDesc(user, desc);
         } catch (AiravataSystemException e) {
@@ -614,14 +662,14 @@ public class CreateLaunchExperiment {
             e.printStackTrace();
         } catch (AiravataClientException e) {
             e.printStackTrace();
-        }catch (TException e){
+        } catch (TException e) {
             e.printStackTrace();
         }
         return null;
     }
 
 
-    public static List<ExperimentSummary> searchExperimentsByName (Airavata.Client client, String user, String expName){
+    public static List<ExperimentSummary> searchExperimentsByName(Airavata.Client client, String user, String expName) {
         try {
             return client.searchExperimentsByName(user, expName);
         } catch (AiravataSystemException e) {
@@ -630,13 +678,13 @@ public class CreateLaunchExperiment {
             e.printStackTrace();
         } catch (AiravataClientException e) {
             e.printStackTrace();
-        }catch (TException e){
+        } catch (TException e) {
             e.printStackTrace();
         }
         return null;
     }
 
-    public static List<ExperimentSummary> searchExperimentsByDesc(Airavata.Client client, String user, String desc){
+    public static List<ExperimentSummary> searchExperimentsByDesc(Airavata.Client client, String user, String desc) {
         try {
             return client.searchExperimentsByDesc(user, desc);
         } catch (AiravataSystemException e) {
@@ -645,13 +693,13 @@ public class CreateLaunchExperiment {
             e.printStackTrace();
         } catch (AiravataClientException e) {
             e.printStackTrace();
-        }catch (TException e){
+        } catch (TException e) {
             e.printStackTrace();
         }
         return null;
     }
 
-    public static List<ExperimentSummary> searchExperimentsByApplication(Airavata.Client client, String user, String app){
+    public static List<ExperimentSummary> searchExperimentsByApplication(Airavata.Client client, String user, String app) {
         try {
             return client.searchExperimentsByApplication(user, app);
         } catch (AiravataSystemException e) {
@@ -660,7 +708,7 @@ public class CreateLaunchExperiment {
             e.printStackTrace();
         } catch (AiravataClientException e) {
             e.printStackTrace();
-        }catch (TException e){
+        } catch (TException e) {
             e.printStackTrace();
         }
         return null;

http://git-wip-us.apache.org/repos/asf/airavata/blob/964b6afd/modules/airavata-client/src/main/java/org/apache/airavata/client/tools/DocumentCreator.java
----------------------------------------------------------------------
diff --git a/modules/airavata-client/src/main/java/org/apache/airavata/client/tools/DocumentCreator.java b/modules/airavata-client/src/main/java/org/apache/airavata/client/tools/DocumentCreator.java
index d573da9..2233790 100644
--- a/modules/airavata-client/src/main/java/org/apache/airavata/client/tools/DocumentCreator.java
+++ b/modules/airavata-client/src/main/java/org/apache/airavata/client/tools/DocumentCreator.java
@@ -20,35 +20,28 @@
 */
 package org.apache.airavata.client.tools;
 
+import java.io.File;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
+import java.util.UUID;
 
 import org.apache.airavata.client.api.AiravataAPI;
 import org.apache.airavata.client.api.exception.AiravataAPIInvocationException;
 import org.apache.airavata.commons.gfac.type.ApplicationDescription;
 import org.apache.airavata.commons.gfac.type.HostDescription;
 import org.apache.airavata.commons.gfac.type.ServiceDescription;
-import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType;
-import org.apache.airavata.schemas.gfac.DataType;
-import org.apache.airavata.schemas.gfac.GlobusHostType;
-import org.apache.airavata.schemas.gfac.GsisshHostType;
-import org.apache.airavata.schemas.gfac.HpcApplicationDeploymentType;
-import org.apache.airavata.schemas.gfac.InputParameterType;
-import org.apache.airavata.schemas.gfac.JobTypeType;
-import org.apache.airavata.schemas.gfac.OutputParameterType;
-import org.apache.airavata.schemas.gfac.ParameterType;
-import org.apache.airavata.schemas.gfac.ProjectAccountType;
-import org.apache.airavata.schemas.gfac.QueueType;
-import org.apache.airavata.schemas.gfac.SSHHostType;
+import org.apache.airavata.schemas.gfac.*;
 
 public class DocumentCreator {
 
     private AiravataAPI airavataAPI = null;
     private String trestleshpcHostAddress = "trestles.sdsc.edu";
     private String lonestarHostAddress = "lonestar.tacc.utexas.edu";
-    private String stampedeHostAddress  = "stampede.tacc.xsede.org";
+    private String stampedeHostAddress = "stampede.tacc.xsede.org";
     private String gridftpAddress = "gsiftp://trestles-dm1.sdsc.edu:2811";
     private String gramAddress = "trestles-login1.sdsc.edu:2119/jobmanager-pbstest2";
+    private String bigRed2HostAddress = "bigred2.uits.iu.edu";
 
 
     public DocumentCreator(AiravataAPI airavataAPI) {
@@ -112,9 +105,8 @@ public class DocumentCreator {
             e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
         }
     }
-    
-  
-    
+
+
     public void createSSHHostDocs() {
         HostDescription descriptor = new HostDescription(SSHHostType.type);
         descriptor.getType().setHostName("gw111.iu.xsede.org");
@@ -343,7 +335,7 @@ public class DocumentCreator {
            */
         String tempDir = "/oasis/scratch/trestles/ogce/temp_project/";
 
-     
+
         app.setScratchWorkingDirectory(tempDir);
         app.setInstalledParentPath("/opt/torque/bin/");
 
@@ -450,7 +442,7 @@ public class DocumentCreator {
         }
     }
 
-   
+
     public void createSlurmDocs() {
         HostDescription host = new HostDescription(GsisshHostType.type);
         host.getType().setHostAddress(stampedeHostAddress);
@@ -459,7 +451,7 @@ public class DocumentCreator {
         ((GsisshHostType) host.getType()).setInstalledPath("/usr/bin/");
         ((GsisshHostType) host.getType()).setPort(2222);
         ((GsisshHostType) host.getType()).setMonitorMode("push");
-    
+
 
         try {
             airavataAPI.getApplicationManager().saveHostDescription(host);
@@ -632,173 +624,269 @@ public class DocumentCreator {
         }
     }
 
-	public void createEchoHostDocs() {
-		String serviceName = "Echo";
-		ServiceDescription serviceDescription = new ServiceDescription();
-		List<InputParameterType> inputParameters = new ArrayList<InputParameterType>();
-		List<OutputParameterType> outputParameters = new ArrayList<OutputParameterType>();
-		serviceDescription.getType().setName(serviceName);
-		serviceDescription.getType().setDescription("Echo service");
-		// Creating input parameters
-		InputParameterType parameter = InputParameterType.Factory.newInstance();
-		parameter.setParameterName("echo_input");
-		parameter.setParameterDescription("echo input");
-		ParameterType parameterType = parameter.addNewParameterType();
-		parameterType.setType(DataType.STRING);
-		parameterType.setName("String");
-		inputParameters.add(parameter);
-
-		// Creating output parameters
-		OutputParameterType outputParameter = OutputParameterType.Factory.newInstance();
-		outputParameter.setParameterName("echo_output");
-		outputParameter.setParameterDescription("Echo output");
-		ParameterType outputParaType = outputParameter.addNewParameterType();
-		outputParaType.setType(DataType.STRING);
-		outputParaType.setName("String");
-		outputParameters.add(outputParameter);
-
-		// Setting input and output parameters to serviceDescriptor
-		serviceDescription.getType().setInputParametersArray(inputParameters.toArray(new InputParameterType[] {}));
-		serviceDescription.getType().setOutputParametersArray(outputParameters.toArray(new OutputParameterType[] {}));
-
-		try {
-			airavataAPI.getApplicationManager().saveServiceDescription(serviceDescription);
-		} catch (AiravataAPIInvocationException e) {
-			e.printStackTrace(); // To change body of catch statement use File |
-									// Settings | File Templates.
-		}
-		// Localhost
-		ApplicationDescription applicationDeploymentDescription = new ApplicationDescription();
-		ApplicationDeploymentDescriptionType applicationDeploymentDescriptionType = applicationDeploymentDescription.getType();
-		applicationDeploymentDescriptionType.addNewApplicationName().setStringValue(serviceName);
-		applicationDeploymentDescriptionType.setExecutableLocation("/bin/echo");
-		applicationDeploymentDescriptionType.setScratchWorkingDirectory("/tmp");
-
-		try {
-			airavataAPI.getApplicationManager().saveApplicationDescription(serviceName, "localhost", applicationDeploymentDescription);
-		} catch (AiravataAPIInvocationException e) {
-			e.printStackTrace(); // To change body of catch statement use File |
-									// Settings | File Templates.
-		}
-		// Stampede
-		/*
-		 * Application descriptor creation and saving
+    public void createEchoHostDocs() {
+        String serviceName = "Echo";
+        ServiceDescription serviceDescription = new ServiceDescription();
+        List<InputParameterType> inputParameters = new ArrayList<InputParameterType>();
+        List<OutputParameterType> outputParameters = new ArrayList<OutputParameterType>();
+        serviceDescription.getType().setName(serviceName);
+        serviceDescription.getType().setDescription("Echo service");
+        // Creating input parameters
+        InputParameterType parameter = InputParameterType.Factory.newInstance();
+        parameter.setParameterName("echo_input");
+        parameter.setParameterDescription("echo input");
+        ParameterType parameterType = parameter.addNewParameterType();
+        parameterType.setType(DataType.STRING);
+        parameterType.setName("String");
+        inputParameters.add(parameter);
+
+        // Creating output parameters
+        OutputParameterType outputParameter = OutputParameterType.Factory.newInstance();
+        outputParameter.setParameterName("echo_output");
+        outputParameter.setParameterDescription("Echo output");
+        ParameterType outputParaType = outputParameter.addNewParameterType();
+        outputParaType.setType(DataType.STRING);
+        outputParaType.setName("String");
+        outputParameters.add(outputParameter);
+
+        // Setting input and output parameters to serviceDescriptor
+        serviceDescription.getType().setInputParametersArray(inputParameters.toArray(new InputParameterType[]{}));
+        serviceDescription.getType().setOutputParametersArray(outputParameters.toArray(new OutputParameterType[]{}));
+
+        try {
+            airavataAPI.getApplicationManager().saveServiceDescription(serviceDescription);
+        } catch (AiravataAPIInvocationException e) {
+            e.printStackTrace(); // To change body of catch statement use File |
+            // Settings | File Templates.
+        }
+        // Localhost
+        ApplicationDescription applicationDeploymentDescription = new ApplicationDescription();
+        ApplicationDeploymentDescriptionType applicationDeploymentDescriptionType = applicationDeploymentDescription.getType();
+        applicationDeploymentDescriptionType.addNewApplicationName().setStringValue(serviceName);
+        applicationDeploymentDescriptionType.setExecutableLocation("/bin/echo");
+        applicationDeploymentDescriptionType.setScratchWorkingDirectory("/tmp");
+
+        try {
+            airavataAPI.getApplicationManager().saveApplicationDescription(serviceName, "localhost", applicationDeploymentDescription);
+        } catch (AiravataAPIInvocationException e) {
+            e.printStackTrace(); // To change body of catch statement use File |
+            // Settings | File Templates.
+        }
+        // Stampede
+        /*
+         * Application descriptor creation and saving
 		 */
-		ApplicationDescription appDesc1 = new ApplicationDescription(HpcApplicationDeploymentType.type);
-		HpcApplicationDeploymentType app1 = (HpcApplicationDeploymentType) appDesc1.getType();
-		ApplicationDeploymentDescriptionType.ApplicationName name = ApplicationDeploymentDescriptionType.ApplicationName.Factory.newInstance();
-		name.setStringValue(serviceName);
-		app1.setApplicationName(name);
-		ProjectAccountType projectAccountType = app1.addNewProjectAccount();
-		projectAccountType.setProjectAccountNumber("TG-STA110014S");
-
-		QueueType queueType = app1.addNewQueue();
-		queueType.setQueueName("normal");
-
-		app1.setCpuCount(1);
-		app1.setJobType(JobTypeType.SERIAL);
-		app1.setNodeCount(1);
-		app1.setProcessorsPerNode(1);
-		app1.setMaxWallTime(10);
+        ApplicationDescription appDesc1 = new ApplicationDescription(HpcApplicationDeploymentType.type);
+        HpcApplicationDeploymentType app1 = (HpcApplicationDeploymentType) appDesc1.getType();
+        ApplicationDeploymentDescriptionType.ApplicationName name = ApplicationDeploymentDescriptionType.ApplicationName.Factory.newInstance();
+        name.setStringValue(serviceName);
+        app1.setApplicationName(name);
+        ProjectAccountType projectAccountType = app1.addNewProjectAccount();
+        projectAccountType.setProjectAccountNumber("TG-STA110014S");
+
+        QueueType queueType = app1.addNewQueue();
+        queueType.setQueueName("normal");
+
+        app1.setCpuCount(1);
+        app1.setJobType(JobTypeType.SERIAL);
+        app1.setNodeCount(1);
+        app1.setProcessorsPerNode(1);
+        app1.setMaxWallTime(10);
 		/*
 		 * Use bat file if it is compiled on Windows
 		 */
-		app1.setExecutableLocation("/bin/echo");
+        app1.setExecutableLocation("/bin/echo");
 
 		/*
 		 * Default tmp location
 		 */
-		String tempDir = "/home1/01437/ogce";
-
-		app1.setScratchWorkingDirectory(tempDir);
-		app1.setInstalledParentPath("/usr/bin/");
-
-		try {
-			airavataAPI.getApplicationManager().saveApplicationDescription(serviceName, stampedeHostAddress, appDesc1);
-		} catch (AiravataAPIInvocationException e) {
-			e.printStackTrace(); // To change body of catch statement use File |
-									// Settings | File Templates.
-		}
-		// Trestles
+        String tempDir = "/home1/01437/ogce";
+
+        app1.setScratchWorkingDirectory(tempDir);
+        app1.setInstalledParentPath("/usr/bin/");
+
+        try {
+            airavataAPI.getApplicationManager().saveApplicationDescription(serviceName, stampedeHostAddress, appDesc1);
+        } catch (AiravataAPIInvocationException e) {
+            e.printStackTrace(); // To change body of catch statement use File |
+            // Settings | File Templates.
+        }
+        // Trestles
 		/*
 		 * Application descriptor creation and saving
 		 */
-		ApplicationDescription appDesc2 = new ApplicationDescription(HpcApplicationDeploymentType.type);
-		HpcApplicationDeploymentType app2 = (HpcApplicationDeploymentType) appDesc2.getType();
-		ApplicationDeploymentDescriptionType.ApplicationName name2 = ApplicationDeploymentDescriptionType.ApplicationName.Factory.newInstance();
-		name2.setStringValue(serviceName);
-		app2.setApplicationName(name);
-		ProjectAccountType projectAccountType2 = app2.addNewProjectAccount();
-		projectAccountType2.setProjectAccountNumber("sds128");
-
-		QueueType queueType2 = app2.addNewQueue();
-		queueType2.setQueueName("normal");
-
-		app2.setCpuCount(1);
-		app2.setJobType(JobTypeType.SERIAL);
-		app2.setNodeCount(1);
-		app2.setProcessorsPerNode(1);
-		app2.setMaxWallTime(10);
+        ApplicationDescription appDesc2 = new ApplicationDescription(HpcApplicationDeploymentType.type);
+        HpcApplicationDeploymentType app2 = (HpcApplicationDeploymentType) appDesc2.getType();
+        ApplicationDeploymentDescriptionType.ApplicationName name2 = ApplicationDeploymentDescriptionType.ApplicationName.Factory.newInstance();
+        name2.setStringValue(serviceName);
+        app2.setApplicationName(name);
+        ProjectAccountType projectAccountType2 = app2.addNewProjectAccount();
+        projectAccountType2.setProjectAccountNumber("sds128");
+
+        QueueType queueType2 = app2.addNewQueue();
+        queueType2.setQueueName("normal");
+
+        app2.setCpuCount(1);
+        app2.setJobType(JobTypeType.SERIAL);
+        app2.setNodeCount(1);
+        app2.setProcessorsPerNode(1);
+        app2.setMaxWallTime(10);
 		/*
 		 * Use bat file if it is compiled on Windows
 		 */
-		app2.setExecutableLocation("/bin/echo");
+        app2.setExecutableLocation("/bin/echo");
 
 		/*
 		 * Default tmp location
 		 */
-		String tempDir2 = "/home/ogce/scratch";
-
-		app2.setScratchWorkingDirectory(tempDir2);
-		app2.setInstalledParentPath("/opt/torque/bin/");
-
-		try {
-			airavataAPI.getApplicationManager().saveApplicationDescription(serviceName, trestleshpcHostAddress, appDesc2);
-		} catch (AiravataAPIInvocationException e) {
-			e.printStackTrace(); // To change body of catch statement use File |
-									// Settings | File Templates.
-		}
-		// Lonestar
+        String tempDir2 = "/home/ogce/scratch";
+
+        app2.setScratchWorkingDirectory(tempDir2);
+        app2.setInstalledParentPath("/opt/torque/bin/");
+
+        try {
+            airavataAPI.getApplicationManager().saveApplicationDescription(serviceName, trestleshpcHostAddress, appDesc2);
+        } catch (AiravataAPIInvocationException e) {
+            e.printStackTrace(); // To change body of catch statement use File |
+            // Settings | File Templates.
+        }
+        // Lonestar
 		/*
 		 * Application descriptor creation and saving
 		 */
-		ApplicationDescription appDesc3 = new ApplicationDescription(HpcApplicationDeploymentType.type);
-		HpcApplicationDeploymentType app3 = (HpcApplicationDeploymentType) appDesc3.getType();
-		ApplicationDeploymentDescriptionType.ApplicationName name3 = ApplicationDeploymentDescriptionType.ApplicationName.Factory.newInstance();
-		name3.setStringValue(serviceName);
-		app3.setApplicationName(name);
-		ProjectAccountType projectAccountType3 = app3.addNewProjectAccount();
-		projectAccountType3.setProjectAccountNumber("TG-STA110014S");
-
-		QueueType queueType3 = app3.addNewQueue();
-		queueType3.setQueueName("normal");
-
-		app3.setCpuCount(1);
-		app3.setJobType(JobTypeType.SERIAL);
-		app3.setNodeCount(1);
-		app3.setProcessorsPerNode(1);
-		app3.setMaxWallTime(10);
+        ApplicationDescription appDesc3 = new ApplicationDescription(HpcApplicationDeploymentType.type);
+        HpcApplicationDeploymentType app3 = (HpcApplicationDeploymentType) appDesc3.getType();
+        ApplicationDeploymentDescriptionType.ApplicationName name3 = ApplicationDeploymentDescriptionType.ApplicationName.Factory.newInstance();
+        name3.setStringValue(serviceName);
+        app3.setApplicationName(name);
+        ProjectAccountType projectAccountType3 = app3.addNewProjectAccount();
+        projectAccountType3.setProjectAccountNumber("TG-STA110014S");
+
+        QueueType queueType3 = app3.addNewQueue();
+        queueType3.setQueueName("normal");
+
+        app3.setCpuCount(1);
+        app3.setJobType(JobTypeType.SERIAL);
+        app3.setNodeCount(1);
+        app3.setProcessorsPerNode(1);
+        app3.setMaxWallTime(10);
 		/*
 		 * Use bat file if it is compiled on Windows
 		 */
-		app3.setExecutableLocation("/bin/echo");
+        app3.setExecutableLocation("/bin/echo");
 
 		/*
 		 * Default tmp location
 		 */
-		String tempDir3 = "/home1/01437/ogce";
+        String tempDir3 = "/home1/01437/ogce";
+
+        app3.setScratchWorkingDirectory(tempDir3);
+        app3.setInstalledParentPath("/opt/sge6.2/bin/lx24-amd64/");
 
-		app3.setScratchWorkingDirectory(tempDir3);
-		app3.setInstalledParentPath("/opt/sge6.2/bin/lx24-amd64/");
+        try {
+            airavataAPI.getApplicationManager().saveApplicationDescription(serviceName, lonestarHostAddress, appDesc3);
+        } catch (AiravataAPIInvocationException e) {
+            e.printStackTrace(); // To change body of catch statement use File |
+            // Settings | File Templates.
+        }
+
+    }
+
+    public void createBigRedDocs() {
+         /*
+        * Host
+        */
+        HostDescription host = new HostDescription(SSHHostType.type);
+        host.getType().setHostAddress(bigRed2HostAddress);
+        host.getType().setHostName("bigred2");
+        ((SSHHostType) host.getType()).setHpcResource(true);
+        try {
+            airavataAPI.getApplicationManager().saveHostDescription(host);
+        } catch (AiravataAPIInvocationException e) {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
+        /*
+        * App
+        */
+        ApplicationDescription appDesc = new ApplicationDescription(HpcApplicationDeploymentType.type);
+        HpcApplicationDeploymentType app = (HpcApplicationDeploymentType) appDesc.getType();
+        ApplicationDeploymentDescriptionType.ApplicationName name = ApplicationDeploymentDescriptionType.ApplicationName.Factory.newInstance();
+        name.setStringValue("EchoLocal");
+        app.setApplicationName(name);
+
+        app.setCpuCount(1);
+        app.setJobType(JobTypeType.SERIAL);
+        app.setNodeCount(1);
+        app.setProcessorsPerNode(1);
+
+        /*
+        * Use bat file if it is compiled on Windows
+        */
+        app.setExecutableLocation("/bin/echo");
+
+        /*
+        * Default tmp location
+        */
+        String tempDir = "/tmp";
+        String date = (new Date()).toString();
+        date = date.replaceAll(" ", "_");
+        date = date.replaceAll(":", "_");
+
+        tempDir = tempDir + File.separator
+                + "SimpleEcho" + "_" + date + "_" + UUID.randomUUID();
+
+        System.out.println(tempDir);
+        app.setScratchWorkingDirectory(tempDir);
+        app.setStaticWorkingDirectory(tempDir);
+        app.setInputDataDirectory(tempDir + File.separator + "inputData");
+        app.setOutputDataDirectory(tempDir + File.separator + "outputData");
+        app.setStandardOutput(tempDir + File.separator + app.getApplicationName().getStringValue() + ".stdout");
+        app.setStandardError(tempDir + File.separator + app.getApplicationName().getStringValue() + ".stderr");
+        app.setMaxWallTime(5);
+        app.setJobSubmitterCommand("aprun -n 1");
+        app.setInstalledParentPath("/opt/torque/torque-4.2.3.1/bin/");
+
+        /*
+        * Service
+        */
+        ServiceDescription serv = new ServiceDescription();
+        serv.getType().setName("SimpleEchoBR");
+
+        List<InputParameterType> inputList = new ArrayList<InputParameterType>();
+
+        InputParameterType input = InputParameterType.Factory.newInstance();
+        input.setParameterName("echo_input");
+        input.setParameterType(StringParameterType.Factory.newInstance());
+        inputList.add(input);
+
+        InputParameterType[] inputParamList = inputList.toArray(new InputParameterType[inputList
 
-		try {
-			airavataAPI.getApplicationManager().saveApplicationDescription(serviceName, lonestarHostAddress, appDesc3);
-		} catch (AiravataAPIInvocationException e) {
-			e.printStackTrace(); // To change body of catch statement use File |
-									// Settings | File Templates.
-		}
+                .size()]);
+        List<OutputParameterType> outputList = new ArrayList<OutputParameterType>();
+        OutputParameterType output = OutputParameterType.Factory.newInstance();
+        output.setParameterName("echo_output");
+        output.setParameterType(StringParameterType.Factory.newInstance());
+        outputList.add(output);
+
+        OutputParameterType[] outputParamList = outputList
+                .toArray(new OutputParameterType[outputList.size()]);
+
+        serv.getType().setInputParametersArray(inputParamList);
+        serv.getType().setOutputParametersArray(outputParamList);
+        try {
+            airavataAPI.getApplicationManager().saveServiceDescription(serv);
+        } catch (AiravataAPIInvocationException e) {
+            e.printStackTrace(); // To change body of catch statement use File |
+            // Settings | File Templates.
+        }
+        try {
+            airavataAPI.getApplicationManager().saveApplicationDescription("SimpleEchoBR", trestleshpcHostAddress, appDesc);
+        } catch (AiravataAPIInvocationException e) {
+            e.printStackTrace(); // To change body of catch statement use File |
+            // Settings | File Templates.
+        }
+    }
 
-	}
     public AiravataAPI getAiravataAPI() {
         return airavataAPI;
     }

http://git-wip-us.apache.org/repos/asf/airavata/blob/964b6afd/modules/credential-store-service/credential-store/src/main/java/org/apache/airavata/credential/store/credential/impl/ssh/SSHCredential.java
----------------------------------------------------------------------
diff --git a/modules/credential-store-service/credential-store/src/main/java/org/apache/airavata/credential/store/credential/impl/ssh/SSHCredential.java b/modules/credential-store-service/credential-store/src/main/java/org/apache/airavata/credential/store/credential/impl/ssh/SSHCredential.java
index 710e0c0..87b32ec 100644
--- a/modules/credential-store-service/credential-store/src/main/java/org/apache/airavata/credential/store/credential/impl/ssh/SSHCredential.java
+++ b/modules/credential-store-service/credential-store/src/main/java/org/apache/airavata/credential/store/credential/impl/ssh/SSHCredential.java
@@ -38,6 +38,19 @@ public class SSHCredential extends Credential implements Serializable {
     private byte[] publicKey;
     private String passphrase;
     private String gateway;
+    private String username;
+
+
+    public SSHCredential() {
+    }
+
+    public SSHCredential(byte[] privatekey, byte[] publicKey, String passphrase, String gateway,String username) {
+        this.privatekey = privatekey;
+        this.publicKey = publicKey;
+        this.passphrase = passphrase;
+        this.gateway = gateway;
+        this.username = username;
+    }
 
     public byte[] getPrivateKey() {
         return privatekey;

http://git-wip-us.apache.org/repos/asf/airavata/blob/964b6afd/modules/credential-store-service/credential-store/src/main/java/org/apache/airavata/credential/store/credential/impl/ssh/SSHCredentialGenerator.java
----------------------------------------------------------------------
diff --git a/modules/credential-store-service/credential-store/src/main/java/org/apache/airavata/credential/store/credential/impl/ssh/SSHCredentialGenerator.java b/modules/credential-store-service/credential-store/src/main/java/org/apache/airavata/credential/store/credential/impl/ssh/SSHCredentialGenerator.java
index d8bad04..6841292 100644
--- a/modules/credential-store-service/credential-store/src/main/java/org/apache/airavata/credential/store/credential/impl/ssh/SSHCredentialGenerator.java
+++ b/modules/credential-store-service/credential-store/src/main/java/org/apache/airavata/credential/store/credential/impl/ssh/SSHCredentialGenerator.java
@@ -23,6 +23,9 @@ package org.apache.airavata.credential.store.credential.impl.ssh;
 
 import java.io.File;
 import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
 
 import org.apache.airavata.credential.store.store.CredentialStoreException;
 import org.apache.airavata.credential.store.store.impl.SSHCredentialWriter;
@@ -60,7 +63,7 @@ public class SSHCredentialGenerator {
             String password = generateRandomString();
             // We are encrypting the private key with the hash of (tokenId+password). 
             // Any client which wants to use this private key will also generate a hash and then use it to decrypt the key.  
-            kpair.writePrivateKey(fileName,generateHash(tokenId,password).getBytes());
+            kpair.writePrivateKey(fileName,password.getBytes());
             kpair.writePublicKey(fileName + ".pub"  , "");
             kpair.dispose();
             byte[] priKey = FileUtils.readFileToByteArray(new File(fileName));
@@ -80,9 +83,18 @@ public class SSHCredentialGenerator {
 	}
 	
 	private String generateHash(String tokenId, String password) {
-		// TODO: Hash the password generated and return it
-		return null;
-	}
+        byte[] bytesOfMessage = new byte[0];
+        try {
+            bytesOfMessage = password.getBytes("UTF-8");
+            MessageDigest md = MessageDigest.getInstance("MD5");
+            return new String( md.digest(bytesOfMessage));
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        } catch (NoSuchAlgorithmException e) {
+            e.printStackTrace();
+        }
+        return  null;
+    }
 
 	// Generate a random alphanumberic string of 16 characters length
 	private String generateRandomString() {

http://git-wip-us.apache.org/repos/asf/airavata/blob/964b6afd/modules/credential-store-service/credential-store/src/test/java/org/apache/airavata/credential/store/util/TokenGeneratorTest.java
----------------------------------------------------------------------
diff --git a/modules/credential-store-service/credential-store/src/test/java/org/apache/airavata/credential/store/util/TokenGeneratorTest.java b/modules/credential-store-service/credential-store/src/test/java/org/apache/airavata/credential/store/util/TokenGeneratorTest.java
index 6bde936..57b52ae 100644
--- a/modules/credential-store-service/credential-store/src/test/java/org/apache/airavata/credential/store/util/TokenGeneratorTest.java
+++ b/modules/credential-store-service/credential-store/src/test/java/org/apache/airavata/credential/store/util/TokenGeneratorTest.java
@@ -30,7 +30,7 @@ import junit.framework.TestCase;
  * Time: 4:20 PM
  */
 
-public class TokenGeneratorTest extends TestCase {
+public class    TokenGeneratorTest extends TestCase {
 
     public void testGenerateToken() throws Exception {
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/964b6afd/modules/gfac/gfac-monitor/pom.xml
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/pom.xml b/modules/gfac/gfac-monitor/pom.xml
index 9d22902..0665490 100644
--- a/modules/gfac/gfac-monitor/pom.xml
+++ b/modules/gfac/gfac-monitor/pom.xml
@@ -8,7 +8,8 @@
     ANY ~ KIND, either express or implied. See the License for the specific language governing permissions and limitations under 
     the License. -->
 
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <parent>
         <groupId>org.apache.airavata</groupId>
         <artifactId>gfac</artifactId>
@@ -35,7 +36,7 @@
             <artifactId>airavata-client-api</artifactId>
             <version>${project.version}</version>
         </dependency>
-	    <dependency>
+        <dependency>
             <groupId>org.apache.airavata</groupId>
             <artifactId>airavata-gfac-core</artifactId>
             <version>${project.version}</version>
@@ -47,6 +48,11 @@
         </dependency>
         <dependency>
             <groupId>org.apache.airavata</groupId>
+            <artifactId>airavata-gfac-ssh</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.airavata</groupId>
             <artifactId>airavata-workflow-execution-context</artifactId>
             <version>${project.version}</version>
         </dependency>
@@ -60,7 +66,7 @@
             <artifactId>airavata-registry-cpi</artifactId>
             <version>${project.version}</version>
         </dependency>
-         <dependency>
+        <dependency>
             <groupId>org.apache.airavata</groupId>
             <artifactId>airavata-jpa-registry</artifactId>
             <version>${project.version}</version>
@@ -104,9 +110,9 @@
         <dependency>
             <groupId>org.apache.airavata</groupId>
             <artifactId>airavata-server-configuration</artifactId>
-	    <scope>test</scope>
+            <scope>test</scope>
         </dependency>
-	    <dependency>
+        <dependency>
             <groupId>org.apache.airavata</groupId>
             <artifactId>airavata-client-configuration</artifactId>
             <scope>test</scope>

http://git-wip-us.apache.org/repos/asf/airavata/blob/964b6afd/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/handlers/GridPullMonitorHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/handlers/GridPullMonitorHandler.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/handlers/GridPullMonitorHandler.java
index d6cdcaf..6468542 100644
--- a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/handlers/GridPullMonitorHandler.java
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/handlers/GridPullMonitorHandler.java
@@ -62,9 +62,9 @@ public class GridPullMonitorHandler extends ThreadedHandler {
             setAuthenticationInfo(new MyProxyAuthenticationInfo(myProxyUser, myProxyPass, myProxyServer,
                     7512, 17280000, certPath));
             if(GFacImpl.getMonitorPublisher() != null){
-                hpcPullMonitor = new HPCPullMonitor(GFacImpl.getMonitorPublisher());    // todo remove the GFacImpl
+                hpcPullMonitor = new HPCPullMonitor(GFacImpl.getMonitorPublisher(),getAuthenticationInfo());    // we use our own credentials for monitoring, not from the store
             }else {
-                hpcPullMonitor = new HPCPullMonitor(BetterGfacImpl.getMonitorPublisher());
+                hpcPullMonitor = new HPCPullMonitor(BetterGfacImpl.getMonitorPublisher(),getAuthenticationInfo());  // we use our own credentials for monitoring, not from the store
             }
         } catch (ApplicationSettingsException e) {
             e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.

http://git-wip-us.apache.org/repos/asf/airavata/blob/964b6afd/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/impl/pull/qstat/HPCPullMonitor.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/impl/pull/qstat/HPCPullMonitor.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/impl/pull/qstat/HPCPullMonitor.java
index a126243..c13fc3e 100644
--- a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/impl/pull/qstat/HPCPullMonitor.java
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/impl/pull/qstat/HPCPullMonitor.java
@@ -35,6 +35,7 @@ import org.apache.airavata.gfac.monitor.core.PullMonitor;
 import org.apache.airavata.gfac.monitor.exception.AiravataMonitorException;
 import org.apache.airavata.gfac.monitor.util.CommonUtils;
 import org.apache.airavata.gsi.ssh.api.SSHApiException;
+import org.apache.airavata.gsi.ssh.api.authentication.AuthenticationInfo;
 import org.apache.airavata.model.workspace.experiment.JobState;
 import org.apache.airavata.schemas.gfac.GsisshHostType;
 import org.apache.openjpa.lib.log.Log;
@@ -65,16 +66,19 @@ public class HPCPullMonitor extends PullMonitor {
 
     private GFac gfac;
 
-    public HPCPullMonitor(){
+    private AuthenticationInfo authenticationInfo;
+
+    public HPCPullMonitor() {
         connections = new HashMap<String, ResourceConnection>();
         this.queue = new LinkedBlockingDeque<UserMonitorData>();
         publisher = new MonitorPublisher(new EventBus());
     }
 
-     public HPCPullMonitor(MonitorPublisher monitorPublisher){
+    public HPCPullMonitor(MonitorPublisher monitorPublisher, AuthenticationInfo authInfo) {
         connections = new HashMap<String, ResourceConnection>();
         this.queue = new LinkedBlockingDeque<UserMonitorData>();
         publisher = monitorPublisher;
+        authenticationInfo = authInfo;
     }
 
     public HPCPullMonitor(BlockingQueue<UserMonitorData> queue, MonitorPublisher publisher) {
@@ -84,7 +88,6 @@ public class HPCPullMonitor extends PullMonitor {
     }
 
 
-
     public void run() {
         /* implement a logic to pick each monitorID object from the queue and do the
         monitoring
@@ -95,7 +98,7 @@ public class HPCPullMonitor extends PullMonitor {
                 startPulling();
                 // After finishing one iteration of the full queue this thread sleeps 1 second
                 Thread.sleep(10000);
-            } catch (Exception e){
+            } catch (Exception e) {
                 // we catch all the exceptions here because no matter what happens we do not stop running this
                 // thread, but ideally we should report proper error messages, but this is handled in startPulling
                 // method, incase something happen in Thread.sleep we handle it with this catch block.
@@ -105,7 +108,7 @@ public class HPCPullMonitor extends PullMonitor {
         }
         // thread is going to return so we close all the connections
         Iterator<String> iterator = connections.keySet().iterator();
-        while(iterator.hasNext()){
+        while (iterator.hasNext()) {
             String next = iterator.next();
             ResourceConnection resourceConnection = connections.get(next);
             try {
@@ -145,7 +148,7 @@ public class HPCPullMonitor extends PullMonitor {
                         logger.debug("We already have this connection so not going to create one");
                         connection = connections.get(hostName);
                     } else {
-                        connection = new ResourceConnection(iHostMonitorData);
+                        connection = new ResourceConnection(iHostMonitorData,getAuthenticationInfo());
                         connections.put(hostName, connection);
                     }
                     List<MonitorID> monitorID = iHostMonitorData.getMonitorIDs();
@@ -164,10 +167,10 @@ public class HPCPullMonitor extends PullMonitor {
                         if (jobStatus.getState().equals(JobState.COMPLETE)) {
                             completedJobs.add(iMonitorID);
                             try {
-								gfac.invokeOutFlowHandlers(iMonitorID.getJobExecutionContext());
-							} catch (GFacException e) {
-								logger.info(e.getLocalizedMessage(),e);
-							}
+                                gfac.invokeOutFlowHandlers(iMonitorID.getJobExecutionContext());
+                            } catch (GFacException e) {
+                                logger.info(e.getLocalizedMessage(), e);
+                            }
                         } else if (iMonitorID.getFailedCount() > 2 && iMonitorID.getStatus().equals(JobState.UNKNOWN)) {
                             logger.error("Tried to monitor the job with ID " + iMonitorID.getJobID() + " But failed 3 times, so skip this Job from Monitor");
                             iMonitorID.setLastMonitored(new Timestamp((new Date()).getTime()));
@@ -188,7 +191,7 @@ public class HPCPullMonitor extends PullMonitor {
             queue.put(take);
             // cleaning up the completed jobs, this method will remove some of the userMonitorData from the queue if
             // they become empty
-            for(MonitorID completedJob:completedJobs){
+            for (MonitorID completedJob : completedJobs) {
                 CommonUtils.removeMonitorFromQueue(queue, completedJob);
             }
         } catch (InterruptedException e) {
@@ -307,4 +310,12 @@ public class HPCPullMonitor extends PullMonitor {
     public void setGfac(GFac gfac) {
         this.gfac = gfac;
     }
+
+    public AuthenticationInfo getAuthenticationInfo() {
+        return authenticationInfo;
+    }
+
+    public void setAuthenticationInfo(AuthenticationInfo authenticationInfo) {
+        this.authenticationInfo = authenticationInfo;
+    }
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/964b6afd/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/impl/pull/qstat/ResourceConnection.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/impl/pull/qstat/ResourceConnection.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/impl/pull/qstat/ResourceConnection.java
index 957e288..d217926 100644
--- a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/impl/pull/qstat/ResourceConnection.java
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/impl/pull/qstat/ResourceConnection.java
@@ -24,7 +24,9 @@ import org.apache.airavata.gfac.GFacException;
 import org.apache.airavata.gfac.core.monitor.MonitorID;
 import org.apache.airavata.gfac.gsissh.security.GSISecurityContext;
 import org.apache.airavata.gfac.monitor.HostMonitorData;
+import org.apache.airavata.gfac.ssh.security.SSHSecurityContext;
 import org.apache.airavata.gsi.ssh.api.SSHApiException;
+import org.apache.airavata.gsi.ssh.api.authentication.AuthenticationInfo;
 import org.apache.airavata.gsi.ssh.impl.JobStatus;
 import org.apache.airavata.gsi.ssh.impl.PBSCluster;
 import org.apache.airavata.model.workspace.experiment.JobState;
@@ -41,16 +43,43 @@ public class ResourceConnection {
 
     private PBSCluster cluster;
 
+    private AuthenticationInfo authenticationInfo;
+
+
+    public ResourceConnection(HostMonitorData hostMonitorData,AuthenticationInfo authInfo) throws SSHApiException {
+        MonitorID monitorID = hostMonitorData.getMonitorIDs().get(0);
+        try {
+            GSISecurityContext securityContext = (GSISecurityContext) monitorID.getJobExecutionContext().getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT);
+            if(securityContext != null) {
+                cluster = (PBSCluster) securityContext.getPbsCluster();
+            }else {
+                SSHSecurityContext sshSecurityContext = (SSHSecurityContext) monitorID.getJobExecutionContext().getSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT);
+                cluster = (PBSCluster)securityContext.getPbsCluster();
+            }
+
+            // we just use cluster configuration from the incoming request and construct a new cluster because for monitoring
+            // we are using our own credentials and not using one users account to do everything.
+            authenticationInfo = authInfo;
+            cluster = new PBSCluster(cluster.getServerInfo(), authenticationInfo, cluster.getJobManagerConfiguration());
+        } catch (GFacException e) {
+            log.error("Error reading data from job ExecutionContext");
+        }
+    }
 
     public ResourceConnection(HostMonitorData hostMonitorData) throws SSHApiException {
         MonitorID monitorID = hostMonitorData.getMonitorIDs().get(0);
         try {
-            GSISecurityContext securityContext = (GSISecurityContext)monitorID.getJobExecutionContext().getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT);
-            cluster = (PBSCluster)securityContext.getPbsCluster();
+            GSISecurityContext securityContext = (GSISecurityContext) monitorID.getJobExecutionContext().getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT);
+            cluster = (PBSCluster) securityContext.getPbsCluster();
+
+            // we just use cluster configuration from the incoming request and construct a new cluster because for monitoring
+            // we are using our own credentials and not using one users account to do everything.
+            cluster = new PBSCluster(cluster.getServerInfo(), authenticationInfo, cluster.getJobManagerConfiguration());
         } catch (GFacException e) {
             log.error("Error reading data from job ExecutionContext");
         }
     }
+
     public JobState getJobStatus(MonitorID monitorID) throws SSHApiException {
         String jobID = monitorID.getJobID();
         //todo so currently we execute the qstat for each job but we can use user based monitoring
@@ -58,9 +87,9 @@ public class ResourceConnection {
         return getStatusFromString(cluster.getJobStatus(jobID).toString());
     }
 
-    public Map<String,JobState> getJobStatuses(List<MonitorID> monitorIDs) throws SSHApiException {
-        Map<String,JobStatus> treeMap = new TreeMap<String,JobStatus>();
-        Map<String,JobState> treeMap1 = new TreeMap<String,JobState>();
+    public Map<String, JobState> getJobStatuses(List<MonitorID> monitorIDs) throws SSHApiException {
+        Map<String, JobStatus> treeMap = new TreeMap<String, JobStatus>();
+        Map<String, JobState> treeMap1 = new TreeMap<String, JobState>();
         // creating a sorted map with all the jobIds and with the predefined
         // status as UNKNOWN
         for (MonitorID monitorID : monitorIDs) {
@@ -69,36 +98,37 @@ public class ResourceConnection {
         String userName = cluster.getServerInfo().getUserName();
         //todo so currently we execute the qstat for each job but we can use user based monitoring
         //todo or we should concatenate all the commands and execute them in one go and parse the response
-        cluster.getJobStatuses(userName,treeMap);
-        for(String key:treeMap.keySet()){
-            treeMap1.put(key,getStatusFromString(treeMap.get(key).toString()));
+        cluster.getJobStatuses(userName, treeMap);
+        for (String key : treeMap.keySet()) {
+            treeMap1.put(key, getStatusFromString(treeMap.get(key).toString()));
         }
         return treeMap1;
     }
+
     private JobState getStatusFromString(String status) {
         log.info("parsing the job status returned : " + status);
-        if(status != null){
-            if("C".equals(status) || "CD".equals(status)|| "E".equals(status) || "CG".equals(status)){
+        if (status != null) {
+            if ("C".equals(status) || "CD".equals(status) || "E".equals(status) || "CG".equals(status)) {
                 return JobState.COMPLETE;
-            }else if("H".equals(status) || "h".equals(status)){
+            } else if ("H".equals(status) || "h".equals(status)) {
                 return JobState.HELD;
-            }else if("Q".equals(status) || "qw".equals(status)){
+            } else if ("Q".equals(status) || "qw".equals(status)) {
                 return JobState.QUEUED;
-            }else if("R".equals(status)  || "CF".equals(status) || "r".equals(status)){
+            } else if ("R".equals(status) || "CF".equals(status) || "r".equals(status)) {
                 return JobState.ACTIVE;
-            }else if ("T".equals(status)) {
+            } else if ("T".equals(status)) {
                 return JobState.HELD;
             } else if ("W".equals(status) || "PD".equals(status)) {
                 return JobState.QUEUED;
             } else if ("S".equals(status)) {
                 return JobState.SUSPENDED;
-            }else if("CA".equals(status)){
+            } else if ("CA".equals(status)) {
                 return JobState.CANCELED;
-            }else if ("F".equals(status) || "NF".equals(status) || "TO".equals(status)) {
+            } else if ("F".equals(status) || "NF".equals(status) || "TO".equals(status)) {
                 return JobState.FAILED;
-            }else if ("PR".equals(status) || "Er".equals(status)) {
+            } else if ("PR".equals(status) || "Er".equals(status)) {
                 return JobState.FAILED;
-            }else if ("U".equals(status)){
+            } else if ("U".equals(status)) {
                 return JobState.UNKNOWN;
             }
         }

http://git-wip-us.apache.org/repos/asf/airavata/blob/964b6afd/modules/gfac/gfac-ssh/pom.xml
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-ssh/pom.xml b/modules/gfac/gfac-ssh/pom.xml
index 5e31f45..e850a49 100644
--- a/modules/gfac/gfac-ssh/pom.xml
+++ b/modules/gfac/gfac-ssh/pom.xml
@@ -1,14 +1,15 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
-<!--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 
+<!--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. -->
 
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <parent>
         <groupId>org.apache.airavata</groupId>
         <artifactId>gfac</artifactId>
@@ -19,7 +20,7 @@
     <modelVersion>4.0.0</modelVersion>
     <artifactId>airavata-gfac-ssh</artifactId>
     <name>Airavata GFac SSH implementation</name>
-    <description>This is the extension of </description>
+    <description>This is the extension of</description>
     <url>http://airavata.apache.org/</url>
 
     <dependencies>
@@ -107,7 +108,11 @@
             <artifactId>sshj</artifactId>
             <version>0.6.1</version>
         </dependency>
-
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+            <version>${mysql.connector.version}</version>
+        </dependency>
     </dependencies>
 
 </project>

http://git-wip-us.apache.org/repos/asf/airavata/blob/964b6afd/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/ssh/provider/impl/SSHProvider.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/ssh/provider/impl/SSHProvider.java b/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/ssh/provider/impl/SSHProvider.java
index fd6ce15..667031b 100644
--- a/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/ssh/provider/impl/SSHProvider.java
+++ b/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/ssh/provider/impl/SSHProvider.java
@@ -25,21 +25,21 @@ import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
-import java.util.Calendar;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.*;
 import java.util.Map.Entry;
-import java.util.Random;
-import java.util.Set;
 
 import org.apache.airavata.common.exception.ApplicationSettingsException;
 import org.apache.airavata.commons.gfac.type.ActualParameter;
 import org.apache.airavata.commons.gfac.type.MappingFactory;
 import org.apache.airavata.gfac.Constants;
+import org.apache.airavata.gfac.ExecutionMode;
 import org.apache.airavata.gfac.GFacException;
 import org.apache.airavata.gfac.core.context.JobExecutionContext;
 import org.apache.airavata.gfac.core.context.MessageContext;
+import org.apache.airavata.gfac.core.cpi.BetterGfacImpl;
+import org.apache.airavata.gfac.core.cpi.GFacImpl;
 import org.apache.airavata.gfac.core.handler.GFacHandlerException;
+import org.apache.airavata.gfac.core.handler.ThreadedHandler;
 import org.apache.airavata.gfac.core.notification.events.StartExecutionEvent;
 import org.apache.airavata.gfac.core.provider.AbstractProvider;
 import org.apache.airavata.gfac.core.provider.GFacProviderException;
@@ -74,8 +74,8 @@ public class SSHProvider extends AbstractProvider {
     private boolean hpcType = false;
 
     public void initialize(JobExecutionContext jobExecutionContext) throws GFacProviderException, GFacException {
-    	super.initialize(jobExecutionContext);
-    	 if(jobExecutionContext.getSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT) == null){
+        super.initialize(jobExecutionContext);
+        if (jobExecutionContext.getSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT) == null) {
             try {
                 GFACSSHUtils.addSecurityContext(jobExecutionContext);
             } catch (ApplicationSettingsException e) {
@@ -84,10 +84,10 @@ public class SSHProvider extends AbstractProvider {
             }
         }
         taskID = jobExecutionContext.getTaskData().getTaskID();
-		if (!((SSHHostType) jobExecutionContext.getApplicationContext().getHostDescription().getType()).getHpcResource()) {
+        if (!((SSHHostType) jobExecutionContext.getApplicationContext().getHostDescription().getType()).getHpcResource()) {
             jobID = "SSH_" + jobExecutionContext.getApplicationContext().getHostDescription().getType().getHostAddress() + "_" + Calendar.getInstance().getTimeInMillis();
             cluster = ((SSHSecurityContext) jobExecutionContext.getSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT)).getPbsCluster();
-            
+
             ApplicationDeploymentDescriptionType app = jobExecutionContext.getApplicationContext().getApplicationDeploymentDescription().getType();
             String remoteFile = app.getStaticWorkingDirectory() + File.separatorChar + Constants.EXECUTABLE_NAME;
             details.setJobID(taskID);
@@ -95,17 +95,17 @@ public class SSHProvider extends AbstractProvider {
             jobExecutionContext.setJobDetails(details);
             JobDescriptor jobDescriptor = GFACSSHUtils.createJobDescriptor(jobExecutionContext, app, null);
             details.setJobDescription(jobDescriptor.toXML());
-         
+
             GFacUtils.saveJobStatus(jobExecutionContext, details, JobState.SETUP);
             log.info(remoteFile);
             try {
-            	File runscript = createShellScript(jobExecutionContext);
+                File runscript = createShellScript(jobExecutionContext);
                 cluster.scpTo(remoteFile, runscript.getAbsolutePath());
             } catch (Exception e) {
                 throw new GFacProviderException(e.getLocalizedMessage(), e);
             }
-        }else{
-           hpcType = true;
+        } else {
+            hpcType = true;
         }
     }
 
@@ -124,22 +124,22 @@ public class SSHProvider extends AbstractProvider {
                 RawCommandInfo rawCommandInfo = new RawCommandInfo("/bin/chmod 755 " + execuable + "; " + execuable);
 
                 StandardOutReader jobIDReaderCommandOutput = new StandardOutReader();
-                
+
                 CommandExecutor.executeCommand(rawCommandInfo, cluster.getSession(), jobIDReaderCommandOutput);
                 String stdOutputString = getOutputifAvailable(jobIDReaderCommandOutput, "Error submitting job to resource");
 
                 log.info("stdout=" + stdOutputString);
-             
+
 //                GFacUtils.updateJobStatus(details, JobState.COMPLETE);
             } catch (Exception e) {
                 throw new GFacProviderException(e.getMessage(), e);
             } finally {
                 if (cluster != null) {
-                	try {
-						cluster.disconnect();
-					} catch (SSHApiException e) {
-						throw new GFacProviderException(e.getMessage(), e);
-					}
+                    try {
+                        cluster.disconnect();
+                    } catch (SSHApiException e) {
+                        throw new GFacProviderException(e.getMessage(), e);
+                    }
                 }
             }
         } else {
@@ -177,7 +177,7 @@ public class SSHProvider extends AbstractProvider {
                         jobDetails.setJobID(jobID);
                         GFacUtils.saveJobStatus(jobExecutionContext, jobDetails, JobState.SUBMITTED);
                     }
-
+                    delegateToMonitorHandlers(jobExecutionContext);
                 } catch (SSHApiException e) {
                     String error = "Error submitting the job to host " + host.getHostAddress() + " message: " + e.getMessage();
                     log.error(error);
@@ -288,8 +288,10 @@ public class SSHProvider extends AbstractProvider {
     public void initProperties(Map<String, String> properties) throws GFacProviderException, GFacException {
 
     }
+
     /**
      * This method will read standard output and if there's any it will be parsed
+     *
      * @param jobIDReaderCommandOutput
      * @param errorMsg
      * @return
@@ -299,12 +301,31 @@ public class SSHProvider extends AbstractProvider {
         String stdOutputString = jobIDReaderCommandOutput.getStdOutputString();
         String stdErrorString = jobIDReaderCommandOutput.getStdErrorString();
 
-        if(stdOutputString == null || stdOutputString.isEmpty() || (stdErrorString != null && !stdErrorString.isEmpty())){
+        if (stdOutputString == null || stdOutputString.isEmpty() || (stdErrorString != null && !stdErrorString.isEmpty())) {
             log.error("Standard Error output : " + stdErrorString);
             throw new SSHApiException(errorMsg + stdErrorString);
         }
         return stdOutputString;
     }
 
+    public void delegateToMonitorHandlers(JobExecutionContext jobExecutionContext) throws GFacHandlerException {
+        List<ThreadedHandler> daemonHandlers = GFacImpl.getDaemonHandlers();
+        if (daemonHandlers == null) {
+            daemonHandlers = BetterGfacImpl.getDaemonHandlers();
+        }
+        ThreadedHandler pullMonitorHandler = null;
+        ThreadedHandler pushMonitorHandler = null;
+        for (ThreadedHandler threadedHandler : daemonHandlers) {
+            if ("org.apache.airavata.gfac.monitor.handlers.GridPullMonitorHandler".equals(threadedHandler.getClass().getName())) {
+                pullMonitorHandler = threadedHandler;
+                pullMonitorHandler.invoke(jobExecutionContext);
+            }
+            // have to handle the GridPushMonitorHandler logic
+        }
+        if (pullMonitorHandler == null && pushMonitorHandler == null && ExecutionMode.ASYNCHRONOUS.equals(jobExecutionContext.getGFacConfiguration().getExecutionMode())) {
+            log.error("No Daemon handler is configured in gfac-config.xml, either pull or push, so monitoring will not invoked" +
+                    ", execution is configured as asynchronous, so Outhandler will not be invoked");
+        }
+    }
 
 }