airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ami...@apache.org
Subject svn commit: r1516364 - in /airavata/trunk: ./ modules/credential-store/src/main/java/org/apache/airavata/credential/store/servlet/ modules/credential-store/src/main/java/org/apache/airavata/credential/store/util/ modules/credential-store/src/test/java/...
Date Thu, 22 Aug 2013 02:57:10 GMT
Author: amilaj
Date: Thu Aug 22 02:57:09 2013
New Revision: 1516364

URL: http://svn.apache.org/r1516364
Log:
Adding initial version of sample gateway. Did some improvements related to providers and credential store

Added:
    airavata/trunk/modules/credential-store/src/test/java/org/apache/airavata/credential/store/util/
    airavata/trunk/modules/credential-store/src/test/java/org/apache/airavata/credential/store/util/TokenGeneratorTest.java
    airavata/trunk/samples/sample-gateway/
    airavata/trunk/samples/sample-gateway/pom.xml
    airavata/trunk/samples/sample-gateway/src/
    airavata/trunk/samples/sample-gateway/src/main/
    airavata/trunk/samples/sample-gateway/src/main/java/
    airavata/trunk/samples/sample-gateway/src/main/java/org/
    airavata/trunk/samples/sample-gateway/src/main/java/org/apache/
    airavata/trunk/samples/sample-gateway/src/main/java/org/apache/airavata/
    airavata/trunk/samples/sample-gateway/src/main/java/org/apache/airavata/sample/
    airavata/trunk/samples/sample-gateway/src/main/java/org/apache/airavata/sample/gateway/
    airavata/trunk/samples/sample-gateway/src/main/java/org/apache/airavata/sample/gateway/SampleGateway.java
    airavata/trunk/samples/sample-gateway/src/main/java/org/apache/airavata/sample/gateway/userstore/
    airavata/trunk/samples/sample-gateway/src/main/java/org/apache/airavata/sample/gateway/userstore/GatewayUserStore.java
    airavata/trunk/samples/sample-gateway/src/main/java/org/apache/airavata/sample/gateway/userstore/User.java
    airavata/trunk/samples/sample-gateway/src/main/java/org/apache/airavata/sample/gateway/xx
    airavata/trunk/samples/sample-gateway/src/main/resources/
    airavata/trunk/samples/sample-gateway/src/main/webapp/
    airavata/trunk/samples/sample-gateway/src/main/webapp/WEB-INF/
    airavata/trunk/samples/sample-gateway/src/main/webapp/WEB-INF/web.xml
    airavata/trunk/samples/sample-gateway/src/main/webapp/gateway/
    airavata/trunk/samples/sample-gateway/src/main/webapp/gateway/acs.jsp
    airavata/trunk/samples/sample-gateway/src/main/webapp/gateway/list_users.jsp
    airavata/trunk/samples/sample-gateway/src/main/webapp/gateway/user.jsp
    airavata/trunk/samples/sample-gateway/src/main/webapp/index.jsp
Modified:
    airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/servlet/CredentialStoreOA4MPServer.java
    airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/servlet/CredentialStoreStartServlet.java
    airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/util/TokenGenerator.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/GFacProvider.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/BESProvider.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/EC2Provider.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/GramProvider.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/HadoopProvider.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/LocalProvider.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/SSHProvider.java
    airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/GFacBaseTestCase.java
    airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/GramProviderTest.java
    airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/gfac/context/security/GSISecurityContextTest.java
    airavata/trunk/modules/rest/webapp/pom.xml
    airavata/trunk/modules/rest/webapp/src/main/webapp/acs/index.jsp
    airavata/trunk/pom.xml

Modified: airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/servlet/CredentialStoreOA4MPServer.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/servlet/CredentialStoreOA4MPServer.java?rev=1516364&r1=1516363&r2=1516364&view=diff
==============================================================================
--- airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/servlet/CredentialStoreOA4MPServer.java (original)
+++ airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/servlet/CredentialStoreOA4MPServer.java Thu Aug 22 02:57:09 2013
@@ -58,7 +58,7 @@ public class CredentialStoreOA4MPServer 
             OA4MPResponse mpdsResponse = new OA4MPResponse();
             mpdsResponse.setPrivateKey(keyPair.getPrivate());
             additionalParameters.put(ClientEnvironment.CERT_REQUEST_KEY,
-                    Base64.encodeBase64String(certReq.getDEREncoded()));
+                    Base64.encodeBase64(certReq.getDEREncoded()));
 
             if (additionalParameters.get(getEnvironment().getConstants().get(CALLBACK_URI_KEY)) == null) {
                 additionalParameters.put(getEnvironment().getConstants().get(CALLBACK_URI_KEY), getEnvironment()

Modified: airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/servlet/CredentialStoreStartServlet.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/servlet/CredentialStoreStartServlet.java?rev=1516364&r1=1516363&r2=1516364&view=diff
==============================================================================
--- airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/servlet/CredentialStoreStartServlet.java (original)
+++ airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/servlet/CredentialStoreStartServlet.java Thu Aug 22 02:57:09 2013
@@ -25,6 +25,7 @@ import edu.uiuc.ncsa.myproxy.oa4mp.clien
 import edu.uiuc.ncsa.myproxy.oa4mp.client.servlet.ClientServlet;
 import edu.uiuc.ncsa.security.servlet.JSPUtil;
 import edu.uiuc.ncsa.security.util.pkcs.KeyUtil;
+import org.apache.airavata.credential.store.util.TokenGenerator;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -81,7 +82,7 @@ public class CredentialStoreStartServlet
         String gatewayName = request.getParameter("gatewayName");
         String portalUserName = request.getParameter("portalUserName");
         String contactEmail = request.getParameter("email");
-        String associatedToken = request.getParameter("associatedToken");
+        String associatedToken = TokenGenerator.generateToken(gatewayName, portalUserName);
 
         if (gatewayName == null) {
             JSPUtil.handleException(new RuntimeException("Please specify a gateway name."), request, response,

Modified: airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/util/TokenGenerator.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/util/TokenGenerator.java?rev=1516364&r1=1516363&r2=1516364&view=diff
==============================================================================
--- airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/util/TokenGenerator.java (original)
+++ airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/util/TokenGenerator.java Thu Aug 22 02:57:09 2013
@@ -44,9 +44,9 @@ public class TokenGenerator {
 
     }
 
-    public String generateToken(String gatewayId, String metadata) {
+    public static String generateToken(String gatewayId, String metadata) {
         StringBuilder tokenBuilder = new StringBuilder("#token#");
-        tokenBuilder.append(gatewayId).append("#").append(metadata).append("#");
+        tokenBuilder.append(gatewayId.trim()).append("#").append(metadata.trim()).append("#");
 
 
         java.util.Date date= new java.util.Date();

Added: airavata/trunk/modules/credential-store/src/test/java/org/apache/airavata/credential/store/util/TokenGeneratorTest.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/credential-store/src/test/java/org/apache/airavata/credential/store/util/TokenGeneratorTest.java?rev=1516364&view=auto
==============================================================================
--- airavata/trunk/modules/credential-store/src/test/java/org/apache/airavata/credential/store/util/TokenGeneratorTest.java (added)
+++ airavata/trunk/modules/credential-store/src/test/java/org/apache/airavata/credential/store/util/TokenGeneratorTest.java Thu Aug 22 02:57:09 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.credential.store.util;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 8/5/13
+ * Time: 4:20 PM
+ */
+
+public class TokenGeneratorTest extends TestCase {
+
+    public void testGenerateToken() throws Exception {
+
+        String token = TokenGenerator.generateToken("gw1", "admin");
+        Assert.assertNotNull(token);
+        System.out.println(token);
+
+    }
+}

Modified: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/GFacProvider.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/GFacProvider.java?rev=1516364&r1=1516363&r2=1516364&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/GFacProvider.java (original)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/GFacProvider.java Thu Aug 22 02:57:09 2013
@@ -54,31 +54,11 @@ public interface GFacProvider {
 
     /**
      * Cancels all jobs relevant to an experiment.
-     * @param experimentId The experiment id
+     * @param jobId The experiment id
      * @param jobExecutionContext The job execution context, contains runtime information.
      * @throws GFacException If an error occurred while cancelling the job.
      */
-    void cancelJob(String experimentId, JobExecutionContext jobExecutionContext) throws GFacException;
+    public void cancelJob(String jobId, JobExecutionContext jobExecutionContext) throws GFacException;
 
-    /**
-     * Cancels all jobs relevant to a workflow in an experiment.
-     * @param experimentId The experiment id
-     * @param workflowId The workflow id.
-     * @param jobExecutionContext The job execution context, contains runtime information.
-     * @throws GFacException If an error occurred while cancelling the job.
-     */
-    void cancelJob(String experimentId, String workflowId,
-                   JobExecutionContext jobExecutionContext) throws GFacException;
-
-    /**
-     * Cancels the job for a given a workflow id and node id in an experiment.
-     * @param experimentId The experiment id.
-     * @param workflowId The workflow id.
-     * @param nodeId The node id.
-     * @param jobExecutionContext The job execution context relevant to cancel job operation.
-     * @throws GFacException If an error occurred while cancelling the job.
-     */
-    void cancelJob(String experimentId, String workflowId, String nodeId,
-                   JobExecutionContext jobExecutionContext) throws GFacException;
 
 }

Modified: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/BESProvider.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/BESProvider.java?rev=1516364&r1=1516363&r2=1516364&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/BESProvider.java (original)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/BESProvider.java Thu Aug 22 02:57:09 2013
@@ -213,23 +213,10 @@ public class BESProvider implements GFac
 	}
 
     @Override
-    public void cancelJob(String experimentId, JobExecutionContext jobExecutionContext) throws GFacException {
+    public void cancelJob(String jobId, JobExecutionContext jobExecutionContext) throws GFacException {
         throw new NotImplementedException();
     }
 
-    @Override
-    public void cancelJob(String experimentId, String workflowId, JobExecutionContext jobExecutionContext)
-            throws GFacException {
-        throw new NotImplementedException();
-    }
-
-    @Override
-    public void cancelJob(String experimentId, String workflowId, String nodeId,
-                          JobExecutionContext jobExecutionContext) throws GFacException {
-        throw new NotImplementedException();
-    }
-
-
     protected void initSecurityProperties(JobExecutionContext jobExecutionContext) throws GFacProviderException, GFacException{
 		
 		if (secProperties != null) return;

Modified: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/EC2Provider.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/EC2Provider.java?rev=1516364&r1=1516363&r2=1516364&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/EC2Provider.java (original)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/EC2Provider.java Thu Aug 22 02:57:09 2013
@@ -247,17 +247,7 @@ public class EC2Provider implements GFac
     }
 
     @Override
-    public void cancelJob(String experimentId, JobExecutionContext jobExecutionContext) throws GFacException {
-        throw new NotImplementedException();
-    }
-
-    @Override
-    public void cancelJob(String experimentId, String workflowId, JobExecutionContext jobExecutionContext) throws GFacException {
-        throw new NotImplementedException();
-    }
-
-    @Override
-    public void cancelJob(String experimentId, String workflowId, String nodeId, JobExecutionContext jobExecutionContext) throws GFacException {
+    public void cancelJob(String jobId, JobExecutionContext jobExecutionContext) throws GFacException {
         throw new NotImplementedException();
     }
 

Modified: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/GramProvider.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/GramProvider.java?rev=1516364&r1=1516363&r2=1516364&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/GramProvider.java (original)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/GramProvider.java Thu Aug 22 02:57:09 2013
@@ -331,33 +331,8 @@ public class GramProvider implements GFa
     }
 
     @Override
-    public void cancelJob(String experimentId, JobExecutionContext jobExecutionContext) throws GFacException {
-
-        List<ApplicationJob> jobs = GFacUtils.getJobIds(jobExecutionContext, experimentId);
-
-        for (ApplicationJob job : jobs) {
-            cancelSingleJob(job.getJobId(), jobExecutionContext);
-        }
-    }
-
-    @Override
-    public void cancelJob(String experimentId, String workflowId,
-                          JobExecutionContext jobExecutionContext) throws GFacException {
-        List<ApplicationJob> jobs = GFacUtils.getJobIds(jobExecutionContext, experimentId, workflowId);
-
-        for (ApplicationJob job : jobs) {
-            cancelSingleJob(job.getJobId(), jobExecutionContext);
-        }
-    }
-
-    @Override
-    public void cancelJob(String experimentId, String workflowId, String nodeId,
-                          JobExecutionContext jobExecutionContext) throws GFacException {
-        List<ApplicationJob> jobs = GFacUtils.getJobIds(jobExecutionContext, experimentId, workflowId, nodeId);
-
-        for (ApplicationJob job : jobs) {
-            cancelSingleJob(job.getJobId(), jobExecutionContext);
-        }
+    public void cancelJob(String jobId, JobExecutionContext jobExecutionContext) throws GFacException {
+        cancelSingleJob(jobId, jobExecutionContext);
     }
 
 

Modified: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/HadoopProvider.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/HadoopProvider.java?rev=1516364&r1=1516363&r2=1516364&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/HadoopProvider.java (original)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/HadoopProvider.java Thu Aug 22 02:57:09 2013
@@ -142,19 +142,10 @@ public class HadoopProvider implements G
     }
 
     @Override
-    public void cancelJob(String experimentId, JobExecutionContext jobExecutionContext) throws GFacException {
+    public void cancelJob(String jobId, JobExecutionContext jobExecutionContext) throws GFacException {
         throw new NotImplementedException();
     }
 
-    @Override
-    public void cancelJob(String experimentId, String workflowId, JobExecutionContext jobExecutionContext) throws GFacException {
-        throw new NotImplementedException();
-    }
-
-    @Override
-    public void cancelJob(String experimentId, String workflowId, String nodeId, JobExecutionContext jobExecutionContext) throws GFacException {
-        throw new NotImplementedException();
-    }
 
     public void initProperties(Map<String, String> properties) throws GFacProviderException, GFacException {
 

Modified: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/LocalProvider.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/LocalProvider.java?rev=1516364&r1=1516363&r2=1516364&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/LocalProvider.java (original)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/LocalProvider.java Thu Aug 22 02:57:09 2013
@@ -215,19 +215,10 @@ public class LocalProvider implements GF
     }
 
     @Override
-    public void cancelJob(String experimentId, JobExecutionContext jobExecutionContext) throws GFacException {
+    public void cancelJob(String jobId, JobExecutionContext jobExecutionContext) throws GFacException {
         throw new NotImplementedException();
     }
 
-    @Override
-    public void cancelJob(String experimentId, String workflowId, JobExecutionContext jobExecutionContext) throws GFacException {
-        throw new NotImplementedException();
-    }
-
-    @Override
-    public void cancelJob(String experimentId, String workflowId, String nodeId, JobExecutionContext jobExecutionContext) throws GFacException {
-        throw new NotImplementedException();
-    }
 
     private void buildCommand(String executable, List<String> inputParameterList){
         cmdList.add(executable);

Modified: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/SSHProvider.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/SSHProvider.java?rev=1516364&r1=1516363&r2=1516364&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/SSHProvider.java (original)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/SSHProvider.java Thu Aug 22 02:57:09 2013
@@ -137,19 +137,10 @@ public class SSHProvider implements GFac
 	}
 
     @Override
-    public void cancelJob(String experimentId, JobExecutionContext jobExecutionContext) throws GFacException {
+    public void cancelJob(String jobId, JobExecutionContext jobExecutionContext) throws GFacException {
         throw new NotImplementedException();
     }
 
-    @Override
-    public void cancelJob(String experimentId, String workflowId, JobExecutionContext jobExecutionContext) throws GFacException {
-        throw new NotImplementedException();
-    }
-
-    @Override
-    public void cancelJob(String experimentId, String workflowId, String nodeId, JobExecutionContext jobExecutionContext) throws GFacException {
-        throw new NotImplementedException();
-    }
 
     private File createShellScript(JobExecutionContext context) throws IOException {
 		ApplicationDeploymentDescriptionType app = context.getApplicationContext()

Modified: airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/GFacBaseTestCase.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/GFacBaseTestCase.java?rev=1516364&r1=1516363&r2=1516364&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/GFacBaseTestCase.java (original)
+++ airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/GFacBaseTestCase.java Thu Aug 22 02:57:09 2013
@@ -21,12 +21,15 @@
 
 package org.apache.airavata.core.gfac.services.impl;
 
+import junit.framework.Assert;
+import org.apache.airavata.common.utils.AiravataUtils;
 import org.apache.airavata.common.utils.DatabaseTestCases;
 import org.apache.airavata.common.utils.DerbyUtil;
 import org.apache.airavata.credential.store.store.CredentialReader;
 import org.apache.airavata.credential.store.store.impl.CredentialReaderImpl;
 import org.apache.airavata.gfac.RequestData;
 import org.apache.airavata.gfac.context.security.GSISecurityContext;
+import org.apache.log4j.Logger;
 import org.junit.BeforeClass;
 
 /**
@@ -37,7 +40,33 @@ import org.junit.BeforeClass;
 
 public class GFacBaseTestCase extends DatabaseTestCases {
 
+    private static String myProxyUserName;
+    private static String myProxyPassword;
+
+    private static final Logger log = Logger.getLogger(GFacBaseTestCase.class);
+
+
     @BeforeClass
+    public static void setUpClass() throws Exception {
+        AiravataUtils.setExecutionAsServer();
+
+        myProxyUserName = System.getProperty("myproxy.user");
+        myProxyPassword = System.getProperty("myproxy.password");
+
+        if (userName == null || password == null || userName.trim().equals("") || password.trim().equals("")) {
+            log.error("===== Please set myproxy.user and myproxy.password system properties. =======");
+            Assert.fail("Please set myproxy.user and myproxy.password system properties.");
+        }
+
+        log.info("Using my proxy user name - " + userName);
+
+        setUpDatabase();
+
+    }
+
+
+
+
     public static void setUpDatabase() throws Exception {
         DerbyUtil.startDerbyInServerMode(getHostAddress(), getPort(), getUserName(), getPassword());
 

Modified: airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/GramProviderTest.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/GramProviderTest.java?rev=1516364&r1=1516363&r2=1516364&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/GramProviderTest.java (original)
+++ airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/GramProviderTest.java Thu Aug 22 02:57:09 2013
@@ -217,4 +217,9 @@ public class GramProviderTest extends GF
         MessageContext outMessageContext = jobExecutionContext.getOutMessageContext();
         Assert.assertEquals(MappingFactory.toString((ActualParameter)outMessageContext.getParameter("echo_output")), "hello");
     }
+
+    @Test
+    public void testGetJdbcUrl()  {
+        System.out.println(getJDBCUrl());
+    }
 }

Modified: airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/gfac/context/security/GSISecurityContextTest.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/gfac/context/security/GSISecurityContextTest.java?rev=1516364&r1=1516363&r2=1516364&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/gfac/context/security/GSISecurityContextTest.java (original)
+++ airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/gfac/context/security/GSISecurityContextTest.java Thu Aug 22 02:57:09 2013
@@ -29,6 +29,7 @@ import org.apache.airavata.credential.st
 import org.apache.airavata.credential.store.store.CredentialReaderFactory;
 import org.apache.airavata.gfac.RequestData;
 import org.apache.log4j.Logger;
+import org.ietf.jgss.GSSCredential;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
@@ -41,7 +42,6 @@ import java.io.File;
  * Time: 12:58 PM
  */
 
-@Test(enabled=false)
 public class GSISecurityContextTest extends DatabaseTestCases {
 
     private static String userName;
@@ -113,8 +113,14 @@ public class GSISecurityContextTest exte
         Assert.assertTrue(f.exists());
     }
 
-    @Test
-    public void testGetGssCredentials() throws Exception {
+    private GSSCredential getGSSCredentials() throws Exception {
+
+        GSISecurityContext gsiSecurityContext = getGSISecurityContext();
+
+        return gsiSecurityContext.getGssCredentials();
+    }
+
+    private GSISecurityContext getGSISecurityContext() throws Exception {
 
         RequestData requestData = new RequestData();
 
@@ -123,35 +129,46 @@ public class GSISecurityContextTest exte
 
         CredentialReader credentialReader = CredentialReaderFactory.createCredentialStoreReader(getDbUtil());
 
-        GSISecurityContext gsiSecurityContext = new GSISecurityContext(credentialReader, requestData);
-
-        Assert.assertNotNull(gsiSecurityContext.getGssCredentials());
+        return new GSISecurityContext(credentialReader, requestData);
+    }
 
+    @Test
+    public void testGetGssCredentials() throws Exception {
 
+        Assert.assertNotNull(getGSSCredentials());
     }
 
     @Test
     public void testRenewCredentials() throws Exception {
+        GSISecurityContext gsiSecurityContext = getGSISecurityContext();
+        Assert.assertNotNull(gsiSecurityContext.renewCredentials());
 
     }
 
     @Test
     public void testGetCredentialsFromStore() throws Exception {
+        GSISecurityContext gsiSecurityContext = getGSISecurityContext();
+        Assert.assertNotNull(gsiSecurityContext.getCredentialsFromStore());
 
     }
 
     @Test
     public void testGetDefaultCredentials() throws Exception {
+        GSISecurityContext gsiSecurityContext = getGSISecurityContext();
+        Assert.assertNotNull(gsiSecurityContext.getDefaultCredentials());
 
     }
 
     @Test
     public void testGetProxyCredentials() throws Exception {
+        GSISecurityContext gsiSecurityContext = getGSISecurityContext();
+        Assert.assertNotNull(gsiSecurityContext.getProxyCredentials());
 
     }
 
     @Test
     public void testRenewCredentialsAsATrustedHost() throws Exception {
-
+        GSISecurityContext gsiSecurityContext = getGSISecurityContext();
+        Assert.assertNotNull(gsiSecurityContext.renewCredentialsAsATrustedHost());
     }
 }

Modified: airavata/trunk/modules/rest/webapp/pom.xml
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/rest/webapp/pom.xml?rev=1516364&r1=1516363&r2=1516364&view=diff
==============================================================================
--- airavata/trunk/modules/rest/webapp/pom.xml (original)
+++ airavata/trunk/modules/rest/webapp/pom.xml Thu Aug 22 02:57:09 2013
@@ -186,11 +186,23 @@
 			<groupId>org.apache.airavata</groupId>
 			<artifactId>airavata-rest-mappings</artifactId>
 			<version>${project.version}</version>
+            <exclusions>
+                <exclusion>  <!-- declare the exclusion here -->
+                    <groupId>commons-codec</groupId>
+                    <artifactId>commons-codec</artifactId>
+                </exclusion>
+            </exclusions>
 		</dependency>
         <dependency>
             <groupId>org.apache.airavata</groupId>
             <artifactId>airavata-rest-services</artifactId>
             <version>${project.version}</version>
+            <exclusions>
+                <exclusion>  <!-- declare the exclusion here -->
+                    <groupId>commons-codec</groupId>
+                    <artifactId>commons-codec</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
 		<!-- Logging -->
 		<dependency>

Modified: airavata/trunk/modules/rest/webapp/src/main/webapp/acs/index.jsp
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/rest/webapp/src/main/webapp/acs/index.jsp?rev=1516364&r1=1516363&r2=1516364&view=diff
==============================================================================
--- airavata/trunk/modules/rest/webapp/src/main/webapp/acs/index.jsp (original)
+++ airavata/trunk/modules/rest/webapp/src/main/webapp/acs/index.jsp Thu Aug 22 02:57:09 2013
@@ -36,10 +36,6 @@
             <td>Contact Email</td>
             <td><input type="text" name="email"></td>
         </tr>
-        <tr>
-            <td>Associated Token</td>
-            <td><input type="password" name="associatedToken"></td>
-        </tr>
     </table>
 
     <input type="submit" value="Submit">

Modified: airavata/trunk/pom.xml
URL: http://svn.apache.org/viewvc/airavata/trunk/pom.xml?rev=1516364&r1=1516363&r2=1516364&view=diff
==============================================================================
--- airavata/trunk/pom.xml (original)
+++ airavata/trunk/pom.xml Thu Aug 22 02:57:09 2013
@@ -441,6 +441,7 @@
                 <module>samples/simple-math-service</module>
                 <module>samples/complex-math-service</module>
                 <module>samples/levenshtein-distance-service</module>
+                <module>samples/sample-gateway</module>
                 <module>modules/server</module>
                 <module>modules/test-suite</module>
                 <module>samples/airavata-client</module>

Added: airavata/trunk/samples/sample-gateway/pom.xml
URL: http://svn.apache.org/viewvc/airavata/trunk/samples/sample-gateway/pom.xml?rev=1516364&view=auto
==============================================================================
--- airavata/trunk/samples/sample-gateway/pom.xml (added)
+++ airavata/trunk/samples/sample-gateway/pom.xml Thu Aug 22 02:57:09 2013
@@ -0,0 +1,63 @@
+<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/maven-v4_0_0.xsd">
+
+    <parent>
+        <groupId>org.apache.airavata</groupId>
+        <artifactId>airavata</artifactId>
+        <version>0.9-SNAPSHOT</version>
+        <relativePath>../../pom.xml</relativePath>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>SampleGateway</artifactId>
+    <packaging>war</packaging>
+    <name>SampleGateway Maven Webapp</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>3.8.1</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.airavata</groupId>
+            <artifactId>airavata-client-api</artifactId>
+            <version>${project.version}</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>slf4j-simple</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.derby</groupId>
+            <artifactId>derby</artifactId>
+            <version>${derby.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.derby</groupId>
+            <artifactId>derbyclient</artifactId>
+            <version>${derby.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.derby</groupId>
+            <artifactId>derbynet</artifactId>
+            <version>${derby.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.derby</groupId>
+            <artifactId>derbytools</artifactId>
+            <version>${derby.version}</version>
+        </dependency>
+    </dependencies>
+    <build>
+        <finalName>SampleGateway</finalName>
+    </build>
+
+    <properties>
+        <derby.version>10.9.1.0</derby.version>
+    </properties>
+
+</project>

Added: airavata/trunk/samples/sample-gateway/src/main/java/org/apache/airavata/sample/gateway/SampleGateway.java
URL: http://svn.apache.org/viewvc/airavata/trunk/samples/sample-gateway/src/main/java/org/apache/airavata/sample/gateway/SampleGateway.java?rev=1516364&view=auto
==============================================================================
--- airavata/trunk/samples/sample-gateway/src/main/java/org/apache/airavata/sample/gateway/SampleGateway.java (added)
+++ airavata/trunk/samples/sample-gateway/src/main/java/org/apache/airavata/sample/gateway/SampleGateway.java Thu Aug 22 02:57:09 2013
@@ -0,0 +1,160 @@
+/*
+ *
+ * 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.sample.gateway;
+
+import org.apache.airavata.common.utils.DBUtil;
+import org.apache.airavata.common.utils.DerbyUtil;
+import org.apache.airavata.sample.gateway.userstore.GatewayUserStore;
+import org.apache.airavata.sample.gateway.userstore.User;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.servlet.ServletContext;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.List;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 7/31/13
+ * Time: 9:12 PM
+ */
+
+public class SampleGateway {
+
+    private DBUtil dbUtil;
+
+    private GatewayUserStore gatewayUserStore;
+
+    public static final String GATEWAY_SESSION = "Gateway";
+
+    protected static Logger log = LoggerFactory.getLogger(GatewayUserStore.class);
+
+    public SampleGateway(ServletContext servletContext) throws Exception {
+
+        int port = Integer.parseInt(servletContext.getInitParameter("jdbc.port"));
+
+        String userName = servletContext.getInitParameter("jdbc.user");
+        String password = servletContext.getInitParameter("jdbc.password");
+        String host = servletContext.getInitParameter("jdbc.host");
+        String driver = servletContext.getInitParameter("jdbc.driver");
+
+        // Start the database
+        DerbyUtil.startDerbyInServerMode(host,
+                port, userName,
+                password);
+
+        String jdbcUrl = getJDBCUrl(host, port, userName, password);
+
+        // Create the dbutil class
+        dbUtil = new DBUtil(jdbcUrl,
+                userName,
+                password,
+                driver);
+
+        GatewayUserStore.initializeData(dbUtil);
+
+        gatewayUserStore = new GatewayUserStore(dbUtil);
+
+    }
+
+    public List<User> getAllUsers() {
+        return gatewayUserStore.getUsers();
+    }
+
+    public static String getJDBCUrl(String host, int port, String user, String password) {
+        return new StringBuilder().append("jdbc:derby://").append(host).append(":").append(port)
+                .append("/persistent_data;create=true;user=").append(user).append(";password=")
+                .append(password).toString();
+    }
+
+    private static void waitTillServerStarts(String jdbcUrl, String userName, String password, String driver) {
+        DBUtil dbUtil = null;
+
+        try {
+            dbUtil = new DBUtil(jdbcUrl, userName, password, driver);
+        } catch (Exception e) {
+            // ignore
+        }
+
+        Connection connection = null;
+        try {
+            if (dbUtil != null) {
+                connection = dbUtil.getConnection();
+            }
+        } catch (Throwable e) {
+            // ignore
+        }
+
+        while (connection == null) {
+            try {
+                Thread.sleep(1000);
+                try {
+                    if (dbUtil != null) {
+                        connection = dbUtil.getConnection();
+                    }
+                } catch (SQLException e) {
+                    // ignore
+                }
+            } catch (InterruptedException e) {
+                // ignore
+            }
+        }
+
+    }
+
+    public static boolean isAdmin(String user) {
+        return user.equals("admin");
+    }
+
+
+    public boolean authenticate(String userName, String password) {
+
+        Connection connection = null;
+        try {
+            connection = dbUtil.getConnection();
+            String storedPassword = this.gatewayUserStore.getPassword(userName, connection);
+
+            if (password.equals(storedPassword)) {
+                return true;
+            }
+
+
+        } catch (SQLException e) {
+            log.error("An error occurred while authentication", e);
+            return false;
+        } finally {
+            if (connection != null) {
+                try {
+                    connection.close();
+                } catch (SQLException e) {
+                    log.error("Error while closing the connection", e);
+                }
+            }
+        }
+
+        return false;
+
+    }
+
+
+}

Added: airavata/trunk/samples/sample-gateway/src/main/java/org/apache/airavata/sample/gateway/userstore/GatewayUserStore.java
URL: http://svn.apache.org/viewvc/airavata/trunk/samples/sample-gateway/src/main/java/org/apache/airavata/sample/gateway/userstore/GatewayUserStore.java?rev=1516364&view=auto
==============================================================================
--- airavata/trunk/samples/sample-gateway/src/main/java/org/apache/airavata/sample/gateway/userstore/GatewayUserStore.java (added)
+++ airavata/trunk/samples/sample-gateway/src/main/java/org/apache/airavata/sample/gateway/userstore/GatewayUserStore.java Thu Aug 22 02:57:09 2013
@@ -0,0 +1,356 @@
+/*
+ *
+ * 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.sample.gateway.userstore;
+
+import org.apache.airavata.common.utils.DBUtil;
+import org.apache.airavata.common.utils.DerbyUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.servlet.ServletContext;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * User store to maintain internal DB database.
+ */
+public class GatewayUserStore {
+
+    protected static Logger log = LoggerFactory.getLogger(GatewayUserStore.class);
+
+    private DBUtil dbUtil;
+
+    private static boolean dbInitialized = false;
+
+
+    public GatewayUserStore(DBUtil dbUtil) throws Exception {
+
+        this.dbUtil = dbUtil;
+
+    }
+
+    public static void initializeData(DBUtil dbUtil) throws Exception {
+
+        if (dbInitialized) {
+            return;
+        }
+
+        String dropTableSQL = "drop table Users";
+
+        try {
+            dbUtil.executeSQL(dropTableSQL);
+        } catch (Exception e) {}
+
+        String createTableSQL = "CREATE TABLE Users\n" +
+                "(\n" +
+                "        user_name VARCHAR(256) NOT NULL,\n" +
+                "        password VARCHAR(256) NOT NULL,\n" +
+                "        email VARCHAR(256) NOT NULL,\n" +
+                "        token_id VARCHAR(256) DEFAULT NULL,\n" +
+                "        PRIMARY KEY (USER_NAME)\n" +
+                ")";
+
+        dbUtil.executeSQL(createTableSQL);
+
+        System.out.println("Table created ....");
+
+        GatewayUserStore gatewayUserStore = new GatewayUserStore(dbUtil);
+        gatewayUserStore.addUser("admin", "admin", "admin@samplegateway.org");
+        gatewayUserStore.addUser("kermit", "kermit", "kermit@samplegateway.org");
+        gatewayUserStore.addUser("taz", "taz", "taz@samplegateway.org");
+        gatewayUserStore.addUser("coyote", "coyote", "coyote@samplegateway.org");
+
+        System.out.println("Users added ...");
+
+
+    }
+
+
+    public void addUser(String userName, String password, String email) {
+
+        String sql = "insert into Users values (?, ?, ?, ?)";
+
+        Connection connection = null;
+        PreparedStatement preparedStatement = null;
+
+        try {
+            connection = dbUtil.getConnection();
+            preparedStatement = connection.prepareStatement(sql);
+
+            preparedStatement.setString(1, userName);
+            preparedStatement.setString(2, password);
+            preparedStatement.setString(3, email);
+            preparedStatement.setString(4, null);
+
+            preparedStatement.executeUpdate();
+
+            connection.commit();
+
+            log.debug("User " + userName + " successfully added.");
+
+        } catch (SQLException e) {
+            StringBuilder stringBuilder = new StringBuilder("Error persisting user information.");
+            stringBuilder.append(" user - ").append(userName);
+
+            log.error(stringBuilder.toString(), e);
+
+            throw new RuntimeException(stringBuilder.toString(), e);
+        } finally {
+
+            dbUtil.cleanup(preparedStatement, connection);
+        }
+
+    }
+
+    public String getPassword(String userName, Connection connection) {
+
+        String sql = "select password from Users where user_name = ?";
+
+        PreparedStatement preparedStatement = null;
+        ResultSet resultSet = null;
+
+        try {
+            preparedStatement = connection.prepareStatement(sql);
+
+            preparedStatement.setString(1, userName);
+
+            resultSet = preparedStatement.executeQuery();
+
+            if (resultSet.next()) {
+                return resultSet.getString("password");
+            }
+
+        } catch (SQLException e) {
+            StringBuilder stringBuilder = new StringBuilder("Error retrieving credentials for user.");
+            stringBuilder.append("name - ").append(userName);
+
+            log.error(stringBuilder.toString(), e);
+
+            throw new RuntimeException(stringBuilder.toString(), e);
+        } finally {
+
+            if (resultSet != null) {
+                try {
+                    resultSet.close();
+                } catch (SQLException e) {
+                    log.error("Error closing result set", e);
+                }
+            }
+
+            if (preparedStatement != null) {
+                try {
+                    preparedStatement.close();
+                } catch (SQLException e) {
+                    log.error("Error closing prepared statement", e);
+                }
+            }
+        }
+
+        return null;
+    }
+
+    public void changePassword(String userName, String oldPassword, String newPassword) {
+
+        Connection connection = null;
+        PreparedStatement preparedStatement = null;
+
+        try {
+            connection = dbUtil.getConnection();
+
+            String storedPassword = getPassword(userName, connection);
+
+            String oldDigestedPassword = oldPassword;
+
+            if (storedPassword != null) {
+                if (!storedPassword.equals(oldDigestedPassword)) {
+                    throw new RuntimeException("Previous password did not match correctly. Please specify old password"
+                            + " correctly.");
+                }
+            }
+
+            String sql = "update Users set password = ? where user_name = ?";
+
+            preparedStatement = connection.prepareStatement(sql);
+
+            preparedStatement.setString(1, newPassword);
+            preparedStatement.setString(2, userName);
+
+            preparedStatement.executeUpdate();
+
+            connection.commit();
+
+            log.debug("Password changed for user " + userName);
+
+        } catch (SQLException e) {
+            StringBuilder stringBuilder = new StringBuilder("Error updating credentials.");
+            stringBuilder.append(" user - ").append(userName);
+
+            log.error(stringBuilder.toString(), e);
+
+            throw new RuntimeException(stringBuilder.toString(), e);
+        } finally {
+
+            dbUtil.cleanup(preparedStatement, connection);
+        }
+
+    }
+
+    public void changePasswordByAdmin(String userName, String newPassword) {
+
+        Connection connection = null;
+        PreparedStatement preparedStatement = null;
+
+        try {
+            connection = dbUtil.getConnection();
+
+            String sql = "update Users set password = ? where user_name = ?";
+
+            preparedStatement = connection.prepareStatement(sql);
+
+            preparedStatement.setString(1, newPassword);
+            preparedStatement.setString(2, userName);
+
+            preparedStatement.executeUpdate();
+
+            connection.commit();
+
+            log.debug("Admin changed password of user " + userName);
+
+        } catch (SQLException e) {
+            StringBuilder stringBuilder = new StringBuilder("Error updating credentials.");
+            stringBuilder.append(" user - ").append(userName);
+
+            log.error(stringBuilder.toString(), e);
+
+            throw new RuntimeException(stringBuilder.toString(), e);
+        } finally {
+
+            dbUtil.cleanup(preparedStatement, connection);
+        }
+
+    }
+
+    public void deleteUser(String userName) {
+
+        String sql = "delete from Users where user_name=?";
+
+        Connection connection = null;
+        PreparedStatement preparedStatement = null;
+
+        try {
+            connection = dbUtil.getConnection();
+            preparedStatement = connection.prepareStatement(sql);
+
+            preparedStatement.setString(1, userName);
+
+            preparedStatement.executeUpdate();
+
+            connection.commit();
+
+            log.debug("User " + userName + " deleted.");
+
+        } catch (SQLException e) {
+            StringBuilder stringBuilder = new StringBuilder("Error deleting user.");
+            stringBuilder.append("user - ").append(userName);
+
+            log.error(stringBuilder.toString(), e);
+
+            throw new RuntimeException(stringBuilder.toString(), e);
+        } finally {
+            dbUtil.cleanup(preparedStatement, connection);
+        }
+
+    }
+
+    public List<User> getUsers() {
+
+        List<User> userList = new ArrayList<User>();
+
+        String sql = "select * from Users";
+
+        PreparedStatement preparedStatement = null;
+        ResultSet resultSet = null;
+        Connection connection = null;
+
+        try {
+
+            connection = dbUtil.getConnection();
+            preparedStatement = connection.prepareStatement(sql);
+
+            resultSet = preparedStatement.executeQuery();
+
+            while (resultSet.next()) {
+                User user = new User();
+                user.setUserName(resultSet.getString("user_name"));
+                user.setPassword(resultSet.getString("password"));
+                user.setEmail(resultSet.getString("email"));
+                user.setToken(resultSet.getString("token_id"));
+
+                userList.add(user);
+            }
+
+        } catch (SQLException e) {
+            String errorString = "Error retrieving Users.";
+            log.error(errorString, e);
+
+            throw new RuntimeException(errorString, e);
+        } finally {
+
+            if (resultSet != null) {
+                try {
+                    resultSet.close();
+                } catch (SQLException e) {
+                    log.error("Error closing result set", e);
+                }
+            }
+
+            if (preparedStatement != null) {
+                try {
+                    preparedStatement.close();
+                } catch (SQLException e) {
+                    log.error("Error closing prepared statement", e);
+                }
+            }
+
+            if (connection != null) {
+                try {
+                    connection.close();
+                } catch (SQLException e) {
+                    log.error("Error closing connection", e);
+                }
+            }
+        }
+
+        return userList;
+
+    }
+
+    public static String getPasswordRegularExpression() {
+        return "'^[a-zA-Z0-9_-]{6,15}$'";
+    }
+}
+

Added: airavata/trunk/samples/sample-gateway/src/main/java/org/apache/airavata/sample/gateway/userstore/User.java
URL: http://svn.apache.org/viewvc/airavata/trunk/samples/sample-gateway/src/main/java/org/apache/airavata/sample/gateway/userstore/User.java?rev=1516364&view=auto
==============================================================================
--- airavata/trunk/samples/sample-gateway/src/main/java/org/apache/airavata/sample/gateway/userstore/User.java (added)
+++ airavata/trunk/samples/sample-gateway/src/main/java/org/apache/airavata/sample/gateway/userstore/User.java Thu Aug 22 02:57:09 2013
@@ -0,0 +1,68 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.sample.gateway.userstore;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 8/2/13
+ * Time: 12:42 PM
+ */
+
+public class User {
+
+    private String userName;
+    private String password;
+    private String email;
+    private String token;
+
+    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 getEmail() {
+        return email;
+    }
+
+    public void setEmail(String email) {
+        this.email = email;
+    }
+
+    public String getToken() {
+        return token;
+    }
+
+    public void setToken(String token) {
+        this.token = token;
+    }
+}

Added: airavata/trunk/samples/sample-gateway/src/main/java/org/apache/airavata/sample/gateway/xx
URL: http://svn.apache.org/viewvc/airavata/trunk/samples/sample-gateway/src/main/java/org/apache/airavata/sample/gateway/xx?rev=1516364&view=auto
==============================================================================
    (empty)

Added: airavata/trunk/samples/sample-gateway/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/airavata/trunk/samples/sample-gateway/src/main/webapp/WEB-INF/web.xml?rev=1516364&view=auto
==============================================================================
--- airavata/trunk/samples/sample-gateway/src/main/webapp/WEB-INF/web.xml (added)
+++ airavata/trunk/samples/sample-gateway/src/main/webapp/WEB-INF/web.xml Thu Aug 22 02:57:09 2013
@@ -0,0 +1,36 @@
+<!DOCTYPE web-app PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd" >
+
+<web-app>
+  <display-name>Sample Gateway</display-name>
+
+    <!-- User database configurations -->
+    <context-param>
+        <param-name>jdbc.url</param-name>
+        <param-value>jdbc:derby://localhost:20000/persistent_data;create=false</param-value>
+    </context-param>
+    <context-param>
+        <param-name>jdbc.host</param-name>
+        <param-value>localhost</param-value>
+    </context-param>
+    <context-param>
+        <param-name>jdbc.port</param-name>
+        <param-value>20000</param-value>
+    </context-param>
+    <context-param>
+        <param-name>jdbc.user</param-name>
+        <param-value>admin</param-value>
+    </context-param>
+    <context-param>
+        <param-name>jdbc.password</param-name>
+        <param-value>admin</param-value>
+    </context-param>
+    <context-param>
+        <param-name>jdbc.driver</param-name>
+        <param-value>org.apache.derby.jdbc.ClientDriver</param-value>
+    </context-param>
+    <!-- End of user database configurations -->
+
+</web-app>
+

Added: airavata/trunk/samples/sample-gateway/src/main/webapp/gateway/acs.jsp
URL: http://svn.apache.org/viewvc/airavata/trunk/samples/sample-gateway/src/main/webapp/gateway/acs.jsp?rev=1516364&view=auto
==============================================================================
--- airavata/trunk/samples/sample-gateway/src/main/webapp/gateway/acs.jsp (added)
+++ airavata/trunk/samples/sample-gateway/src/main/webapp/gateway/acs.jsp Thu Aug 22 02:57:09 2013
@@ -0,0 +1,54 @@
+<%@ page import="org.apache.airavata.sample.gateway.SampleGateway" %>
+<%--
+  Created by IntelliJ IDEA.
+  User: thejaka
+  Date: 8/5/13
+  Time: 4:48 PM
+  To change this template use File | Settings | File Templates.
+--%>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<%--
+  ~ 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.
+  --%>
+
+
+<html>
+<body>
+<h2>Sample Gateway</h2>
+<p>This demonstrates how portal can use Credential Store to obtain community credentials ...</p>
+<form name="input" action="https://localhost:8443/airavata-registry/credential-store" method="post">
+
+    <table border="0">
+        <tr>
+            <td>Gateway Name</td>
+            <td><input type="text" name="gatewayName" value="sampleGateway" disabled="true"></td>
+        </tr>
+        <tr>
+            <td>Portal Username</td>
+            <td><input type="text" name="portalUserName" value="admin" disabled="true"></td>
+        </tr>
+        <tr>
+            <td>Contact Email</td>
+            <td><input type="text" name="email" value="admin@samplegateway.org" disabled="true"></td>
+        </tr>
+    </table>
+
+    <input type="submit" value="Submit">
+</form>
+</body>
+</html>

Added: airavata/trunk/samples/sample-gateway/src/main/webapp/gateway/list_users.jsp
URL: http://svn.apache.org/viewvc/airavata/trunk/samples/sample-gateway/src/main/webapp/gateway/list_users.jsp?rev=1516364&view=auto
==============================================================================
--- airavata/trunk/samples/sample-gateway/src/main/webapp/gateway/list_users.jsp (added)
+++ airavata/trunk/samples/sample-gateway/src/main/webapp/gateway/list_users.jsp Thu Aug 22 02:57:09 2013
@@ -0,0 +1,53 @@
+<%@ page import="org.apache.airavata.sample.gateway.SampleGateway" %>
+<%@ page import="java.util.List" %>
+<%@ page import="org.apache.airavata.sample.gateway.userstore.User" %>
+<%--
+  Created by IntelliJ IDEA.
+  User: thejaka
+  Date: 8/5/13
+  Time: 12:30 PM
+  To change this template use File | Settings | File Templates.
+--%>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<%
+    SampleGateway sampleGateway = (SampleGateway)session.getAttribute(SampleGateway.GATEWAY_SESSION);
+%>
+
+<html>
+<head>
+    <title>List Users</title>
+</head>
+<body>
+<h1>Sample Gateway</h1>
+
+<p> This page lists all users and their attributes. </p>
+
+<table>
+    <tr>
+        <td>UserName</td>
+        <td>E-Mail</td>
+        <td>TokenId</td>
+    </tr>
+<%
+    List<User> userList = sampleGateway.getAllUsers();
+    for (User u : userList) {
+%>
+    <tr>
+        <td>
+            <%=u.getUserName() %>
+        </td>
+        <td>
+            <%=u.getEmail() %>
+        </td>
+        <td>
+            <%=u.getToken() %>
+        </td>
+
+    </tr>
+    <%
+        }
+    %>
+</table>
+
+</body>
+</html>
\ No newline at end of file

Added: airavata/trunk/samples/sample-gateway/src/main/webapp/gateway/user.jsp
URL: http://svn.apache.org/viewvc/airavata/trunk/samples/sample-gateway/src/main/webapp/gateway/user.jsp?rev=1516364&view=auto
==============================================================================
--- airavata/trunk/samples/sample-gateway/src/main/webapp/gateway/user.jsp (added)
+++ airavata/trunk/samples/sample-gateway/src/main/webapp/gateway/user.jsp Thu Aug 22 02:57:09 2013
@@ -0,0 +1,66 @@
+<%@ page import="org.apache.airavata.sample.gateway.SampleGateway" %>
+<%--
+  Created by IntelliJ IDEA.
+  User: thejaka
+  Date: 7/31/13
+  Time: 5:08 PM
+  To change this template use File | Settings | File Templates.
+--%>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<%
+    SampleGateway sampleGateway = null;
+    sampleGateway = (SampleGateway)session.getAttribute(SampleGateway.GATEWAY_SESSION);
+
+    if (sampleGateway == null) {
+        sampleGateway = new SampleGateway(session.getServletContext());
+    }
+
+    session.setAttribute(SampleGateway.GATEWAY_SESSION, sampleGateway);
+
+    String user = request.getParameter("username");
+    String password = request.getParameter("password");
+
+    boolean authenticate = sampleGateway.authenticate(user, password);
+
+%>
+<html>
+<head>
+    <title>Manage</title>
+</head>
+<body>
+<h1>Sample Gateway</h1>
+
+<%
+    if (authenticate) {
+
+        if (SampleGateway.isAdmin(user)) {
+%>
+<h1>Administration</h1>
+<p>
+    This page allows administration functionality.
+<ol>
+    <li><a href="acs.jsp">Retrieve Credentials</a></li>
+    <li><a href="list_users.jsp">List Users</a></li>
+</ol>
+</p>
+
+
+<%
+     } else {
+%>
+
+<p> You are a normal user. You are not allowed to operate on this page.</p>
+
+<%
+     }
+    } else {
+%>
+
+<h1>Authentication failed</h1>
+
+<%
+    }
+%>
+
+</body>
+</html>
\ No newline at end of file

Added: airavata/trunk/samples/sample-gateway/src/main/webapp/index.jsp
URL: http://svn.apache.org/viewvc/airavata/trunk/samples/sample-gateway/src/main/webapp/index.jsp?rev=1516364&view=auto
==============================================================================
--- airavata/trunk/samples/sample-gateway/src/main/webapp/index.jsp (added)
+++ airavata/trunk/samples/sample-gateway/src/main/webapp/index.jsp Thu Aug 22 02:57:09 2013
@@ -0,0 +1,32 @@
+<%@ page import="org.apache.airavata.sample.gateway.SampleGateway" %><%
+    SampleGateway sampleGateway = new SampleGateway(session.getServletContext());
+    session.setAttribute("Gateway", sampleGateway);
+%>
+<html>
+<body>
+<h2>Welcome to Sample Gateway</h2>
+
+<form name="input" action="gateway/user.jsp" method="post">
+    <table border="0" width="100%">
+        <tr bgcolor="#999999">
+            <td><font color="#f5f5f5">Login ...</font></td>
+        </tr>
+    </table>
+    <table border="0" align="left">
+        <tr>
+            <td>User Name</td>
+            <td><input type="text" name="username"></td>
+        </tr>
+        <tr>
+            <td>Password</td>
+            <td><input type="password" name="password"></td>
+        </tr>
+        <tr><td></td><td><input type="submit" value="Login"></td></tr>
+    </table>
+    <table border="0" width="100%">
+        <tr bgcolor="#999999"><td>&nbsp;</td></tr>
+    </table>
+</form>
+
+</body>
+</html>



Mime
View raw message