Return-Path:
X-Original-To: apmail-airavata-commits-archive@www.apache.org
Delivered-To: apmail-airavata-commits-archive@www.apache.org
Received: from mail.apache.org (hermes.apache.org [140.211.11.3])
by minotaur.apache.org (Postfix) with SMTP id 11FD610DD7
for ;
Thu, 22 Aug 2013 02:57:40 +0000 (UTC)
Received: (qmail 14113 invoked by uid 500); 22 Aug 2013 02:57:39 -0000
Delivered-To: apmail-airavata-commits-archive@airavata.apache.org
Received: (qmail 14060 invoked by uid 500); 22 Aug 2013 02:57:36 -0000
Mailing-List: contact commits-help@airavata.apache.org; run by ezmlm
Precedence: bulk
List-Help:
List-Unsubscribe:
List-Post:
List-Id:
Reply-To: dev@airavata.apache.org
Delivered-To: mailing list commits@airavata.apache.org
Received: (qmail 14053 invoked by uid 99); 22 Aug 2013 02:57:35 -0000
Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136)
by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Aug 2013 02:57:35 +0000
X-ASF-Spam-Status: No, hits=-2000.0 required=5.0
tests=ALL_TRUSTED
X-Spam-Check-By: apache.org
Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4)
by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Aug 2013 02:57:31 +0000
Received: from eris.apache.org (localhost [127.0.0.1])
by eris.apache.org (Postfix) with ESMTP id 835672388980;
Thu, 22 Aug 2013 02:57:11 +0000 (UTC)
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
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 -0000
To: commits@airavata.apache.org
From: amilaj@apache.org
X-Mailer: svnmailer-1.0.9
Message-Id: <20130822025711.835672388980@eris.apache.org>
X-Virus-Checked: Checked by ClamAV on apache.org
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 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 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 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 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 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 @@
org.apache.airavata
airavata-rest-mappings
${project.version}
+
+
+ commons-codec
+ commons-codec
+
+
org.apache.airavata
airavata-rest-services
${project.version}
+
+
+ commons-codec
+ commons-codec
+
+
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 @@
Contact Email |
|
-
- Associated Token |
- |
-
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 @@
samples/simple-math-service
samples/complex-math-service
samples/levenshtein-distance-service
+ samples/sample-gateway
modules/server
modules/test-suite
samples/airavata-client
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 @@
+
+
+
+ org.apache.airavata
+ airavata
+ 0.9-SNAPSHOT
+ ../../pom.xml
+
+
+ 4.0.0
+ SampleGateway
+ war
+ SampleGateway Maven Webapp
+
+
+
+ junit
+ junit
+ 3.8.1
+ test
+
+
+ org.apache.airavata
+ airavata-client-api
+ ${project.version}
+
+
+ org.slf4j
+ slf4j-simple
+
+
+
+
+ org.apache.derby
+ derby
+ ${derby.version}
+
+
+ org.apache.derby
+ derbyclient
+ ${derby.version}
+
+
+ org.apache.derby
+ derbynet
+ ${derby.version}
+
+
+ org.apache.derby
+ derbytools
+ ${derby.version}
+
+
+
+ SampleGateway
+
+
+
+ 10.9.1.0
+
+
+
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 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 getUsers() {
+
+ List userList = new ArrayList();
+
+ 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 @@
+
+
+
+ Sample Gateway
+
+
+
+ jdbc.url
+ jdbc:derby://localhost:20000/persistent_data;create=false
+
+
+ jdbc.host
+ localhost
+
+
+ jdbc.port
+ 20000
+
+
+ jdbc.user
+ admin
+
+
+ jdbc.password
+ admin
+
+
+ jdbc.driver
+ org.apache.derby.jdbc.ClientDriver
+
+
+
+
+
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.
+ --%>
+
+
+
+
+Sample Gateway
+This demonstrates how portal can use Credential Store to obtain community credentials ...
+
+
+
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);
+%>
+
+
+
+ List Users
+
+
+Sample Gateway
+
+ This page lists all users and their attributes.
+
+
+
+ UserName |
+ E-Mail |
+ TokenId |
+
+<%
+ List userList = sampleGateway.getAllUsers();
+ for (User u : userList) {
+%>
+
+
+ <%=u.getUserName() %>
+ |
+
+ <%=u.getEmail() %>
+ |
+
+ <%=u.getToken() %>
+ |
+
+
+ <%
+ }
+ %>
+
+
+
+
\ 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);
+
+%>
+
+
+ Manage
+
+
+Sample Gateway
+
+<%
+ if (authenticate) {
+
+ if (SampleGateway.isAdmin(user)) {
+%>
+Administration
+
+ This page allows administration functionality.
+
+ - Retrieve Credentials
+ - List Users
+
+
+
+
+<%
+ } else {
+%>
+
+ You are a normal user. You are not allowed to operate on this page.
+
+<%
+ }
+ } else {
+%>
+
+Authentication failed
+
+<%
+ }
+%>
+
+
+
\ 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);
+%>
+
+
+Welcome to Sample Gateway
+
+
+
+
+