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 B5FF91092B for ; Fri, 13 Sep 2013 01:59:31 +0000 (UTC) Received: (qmail 28126 invoked by uid 500); 12 Sep 2013 20:38:50 -0000 Delivered-To: apmail-airavata-commits-archive@airavata.apache.org Received: (qmail 27272 invoked by uid 500); 12 Sep 2013 20:38:47 -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 27033 invoked by uid 99); 12 Sep 2013 20:38:43 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Sep 2013 20:38:43 +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, 12 Sep 2013 20:38:40 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 9BD6E238889B; Thu, 12 Sep 2013 20:38:20 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1522719 - in /airavata/trunk: modules/rest/client/ modules/rest/client/src/main/java/org/apache/airavata/rest/utils/ modules/security/src/main/java/org/apache/airavata/security/util/ samples/sample-gateway/ samples/sample-gateway/src/main/... Date: Thu, 12 Sep 2013 20:38:20 -0000 To: commits@airavata.apache.org From: amilaj@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20130912203820.9BD6E238889B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: amilaj Date: Thu Sep 12 20:38:19 2013 New Revision: 1522719 URL: http://svn.apache.org/r1522719 Log: Attempting to fix AIRAVATA-914. And also adding some improvments made to sample gateway Added: airavata/trunk/samples/sample-gateway/src/main/webapp/gateway/job_execute.jsp airavata/trunk/samples/sample-gateway/src/main/webapp/gateway/logout.jsp airavata/trunk/samples/sample-gateway/src/main/webapp/images/ Modified: airavata/trunk/modules/rest/client/pom.xml airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/utils/BasicAuthHeaderUtil.java airavata/trunk/modules/security/src/main/java/org/apache/airavata/security/util/PasswordDigester.java airavata/trunk/samples/sample-gateway/pom.xml 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/GatewayUserStore.java airavata/trunk/samples/sample-gateway/src/main/webapp/gateway/acs.jsp airavata/trunk/samples/sample-gateway/src/main/webapp/gateway/callback.jsp airavata/trunk/samples/sample-gateway/src/main/webapp/gateway/job.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 airavata/trunk/samples/sample-gateway/src/test/java/org/apache/airavata/sample/gateway/executor/WorkflowExecutorTest.java Modified: airavata/trunk/modules/rest/client/pom.xml URL: http://svn.apache.org/viewvc/airavata/trunk/modules/rest/client/pom.xml?rev=1522719&r1=1522718&r2=1522719&view=diff ============================================================================== --- airavata/trunk/modules/rest/client/pom.xml (original) +++ airavata/trunk/modules/rest/client/pom.xml Thu Sep 12 20:38:19 2013 @@ -24,9 +24,9 @@ airavata-rest-client jar airavata-rest-client - + Modified: airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/utils/BasicAuthHeaderUtil.java URL: http://svn.apache.org/viewvc/airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/utils/BasicAuthHeaderUtil.java?rev=1522719&r1=1522718&r2=1522719&view=diff ============================================================================== --- airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/utils/BasicAuthHeaderUtil.java (original) +++ airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/utils/BasicAuthHeaderUtil.java Thu Sep 12 20:38:19 2013 @@ -24,11 +24,18 @@ package org.apache.airavata.rest.utils; import com.sun.jersey.api.client.WebResource; import org.apache.airavata.registry.api.PasswordCallback; import org.apache.commons.codec.binary.Base64; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import javax.ws.rs.core.Cookie; import javax.ws.rs.core.MultivaluedMap; +import java.io.UnsupportedEncodingException; public class BasicAuthHeaderUtil { + + protected static Logger log = LoggerFactory.getLogger(BasicAuthHeaderUtil.class); + + /** * A method to use by clients in the case of Basic Access authentication. * Creates Basic Auth header structure. @@ -40,7 +47,14 @@ public class BasicAuthHeaderUtil { public static String getBasicAuthHeader(String userName, String password) { String credentials = userName + ":" + password; - String encodedString = new String(Base64.encodeBase64(credentials.getBytes())); + String encodedString = null; + try { + encodedString = new String(Base64.encodeBase64(credentials.getBytes("UTF-8"))); + } catch (UnsupportedEncodingException e) { + // TODO we need to do proper exception handling + log.error("Error encoding credentials. ", e); + throw new RuntimeException("Error encoding credentials. ", e); + } return "Basic " + encodedString; } Modified: airavata/trunk/modules/security/src/main/java/org/apache/airavata/security/util/PasswordDigester.java URL: http://svn.apache.org/viewvc/airavata/trunk/modules/security/src/main/java/org/apache/airavata/security/util/PasswordDigester.java?rev=1522719&r1=1522718&r2=1522719&view=diff ============================================================================== --- airavata/trunk/modules/security/src/main/java/org/apache/airavata/security/util/PasswordDigester.java (original) +++ airavata/trunk/modules/security/src/main/java/org/apache/airavata/security/util/PasswordDigester.java Thu Sep 12 20:38:19 2013 @@ -26,6 +26,7 @@ import org.apache.airavata.security.User import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; @@ -69,7 +70,11 @@ public class PasswordDigester { } catch (NoSuchAlgorithmException e) { throw new UserStoreException("Error creating message digest with hash algorithm - " + hashMethod, e); } - return new String(messageDigest.digest(password.getBytes())); + try { + return new String(messageDigest.digest(password.getBytes("UTF-8"))); + } catch (UnsupportedEncodingException e) { + throw new UserStoreException("Unable to create password digest", e); + } } } Modified: airavata/trunk/samples/sample-gateway/pom.xml URL: http://svn.apache.org/viewvc/airavata/trunk/samples/sample-gateway/pom.xml?rev=1522719&r1=1522718&r2=1522719&view=diff ============================================================================== --- airavata/trunk/samples/sample-gateway/pom.xml (original) +++ airavata/trunk/samples/sample-gateway/pom.xml Thu Sep 12 20:38:19 2013 @@ -297,8 +297,24 @@ + SampleGateway + + + org.apache.maven.plugins + maven-war-plugin + 2.4 + + + + + src/main/resources + + + + + Modified: 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=1522719&r1=1522718&r2=1522719&view=diff ============================================================================== --- airavata/trunk/samples/sample-gateway/src/main/java/org/apache/airavata/sample/gateway/SampleGateway.java (original) +++ airavata/trunk/samples/sample-gateway/src/main/java/org/apache/airavata/sample/gateway/SampleGateway.java Thu Sep 12 20:38:19 2013 @@ -47,6 +47,8 @@ public class SampleGateway { public static final String GATEWAY_SESSION = "Gateway"; + private static boolean databaseStarted = false; + protected static Logger log = LoggerFactory.getLogger(GatewayUserStore.class); public SampleGateway(ServletContext servletContext) throws Exception { @@ -58,10 +60,13 @@ public class SampleGateway { String host = servletContext.getInitParameter("jdbc.host"); String driver = servletContext.getInitParameter("jdbc.driver"); - // Start the database - DerbyUtil.startDerbyInServerMode(host, - port, userName, - password); + if (!databaseStarted) { + // Start the database + DerbyUtil.startDerbyInServerMode(host, + port, userName, + password); + } + String jdbcUrl = getJDBCUrl(host, port, userName, password); @@ -71,7 +76,10 @@ public class SampleGateway { password, driver); - GatewayUserStore.initializeData(dbUtil); + if (!databaseStarted) { + GatewayUserStore.initializeData(dbUtil); + databaseStarted = true; + } gatewayUserStore = new GatewayUserStore(dbUtil); @@ -130,6 +138,10 @@ public class SampleGateway { this.gatewayUserStore.updateTokens(tokenId); } + public String getTokenIdForUser(String user) { + return this.gatewayUserStore.getUserToken(user); + } + public boolean authenticate(String userName, String password) { Modified: 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=1522719&r1=1522718&r2=1522719&view=diff ============================================================================== --- airavata/trunk/samples/sample-gateway/src/main/java/org/apache/airavata/sample/gateway/userstore/GatewayUserStore.java (original) +++ airavata/trunk/samples/sample-gateway/src/main/java/org/apache/airavata/sample/gateway/userstore/GatewayUserStore.java Thu Sep 12 20:38:19 2013 @@ -382,6 +382,65 @@ public class GatewayUserStore { } + + + public String getUserToken(String userName) { + + String sql = "select token_id from Users where user_name=?"; + + PreparedStatement preparedStatement = null; + ResultSet resultSet = null; + Connection connection = null; + + try { + + connection = dbUtil.getConnection(); + preparedStatement = connection.prepareStatement(sql); + + preparedStatement.setString(1, userName); + + resultSet = preparedStatement.executeQuery(); + + if (resultSet.next()) { + return resultSet.getString("token_id"); + } + + } catch (SQLException e) { + String errorString = "Error retrieving token for user " + userName; + 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 null; + + } + public static String getPasswordRegularExpression() { return "'^[a-zA-Z0-9_-]{6,15}$'"; } Modified: 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=1522719&r1=1522718&r2=1522719&view=diff ============================================================================== --- airavata/trunk/samples/sample-gateway/src/main/webapp/gateway/acs.jsp (original) +++ airavata/trunk/samples/sample-gateway/src/main/webapp/gateway/acs.jsp Thu Sep 12 20:38:19 2013 @@ -29,7 +29,15 @@ + + + +
Home Logout
+

Sample Gateway

+ + +

This demonstrates how portal can use Credential Store to obtain community credentials ...

Modified: airavata/trunk/samples/sample-gateway/src/main/webapp/gateway/callback.jsp URL: http://svn.apache.org/viewvc/airavata/trunk/samples/sample-gateway/src/main/webapp/gateway/callback.jsp?rev=1522719&r1=1522718&r2=1522719&view=diff ============================================================================== --- airavata/trunk/samples/sample-gateway/src/main/webapp/gateway/callback.jsp (original) +++ airavata/trunk/samples/sample-gateway/src/main/webapp/gateway/callback.jsp Thu Sep 12 20:38:19 2013 @@ -41,6 +41,11 @@ + + + +
Home Logout
+

Sample Gateway

<% out.println("The received token id - "); Modified: airavata/trunk/samples/sample-gateway/src/main/webapp/gateway/job.jsp URL: http://svn.apache.org/viewvc/airavata/trunk/samples/sample-gateway/src/main/webapp/gateway/job.jsp?rev=1522719&r1=1522718&r2=1522719&view=diff ============================================================================== --- airavata/trunk/samples/sample-gateway/src/main/webapp/gateway/job.jsp (original) +++ airavata/trunk/samples/sample-gateway/src/main/webapp/gateway/job.jsp Thu Sep 12 20:38:19 2013 @@ -1,8 +1,73 @@ +<%@ page import="org.apache.airavata.sample.gateway.SampleGateway" %> +<% + SampleGateway sampleGateway = null; + sampleGateway = (SampleGateway)session.getAttribute(SampleGateway.GATEWAY_SESSION); + + String user = (String) session.getAttribute("userName"); + + String token = sampleGateway.getTokenIdForUser(user); +%> + + + + +
Home Logout
+

Sample Gateway

Execute a Workflow.

+Echo Workflow + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Configure Echo Workflow
Host Name
Host Address
Gate Keeper Address
GRID FTP Endpoint
Project Number
Queue Name
Working Directory
Echo Input
Associated Token Id<%=token%>
+ + +
+ \ No newline at end of file Added: airavata/trunk/samples/sample-gateway/src/main/webapp/gateway/job_execute.jsp URL: http://svn.apache.org/viewvc/airavata/trunk/samples/sample-gateway/src/main/webapp/gateway/job_execute.jsp?rev=1522719&view=auto ============================================================================== --- airavata/trunk/samples/sample-gateway/src/main/webapp/gateway/job_execute.jsp (added) +++ airavata/trunk/samples/sample-gateway/src/main/webapp/gateway/job_execute.jsp Thu Sep 12 20:38:19 2013 @@ -0,0 +1,101 @@ +<%@ page import="org.apache.airavata.sample.gateway.SampleGateway" %> +<%@ page import="org.apache.airavata.sample.gateway.ExecutionParameters" %> +<%@ page import="org.apache.airavata.sample.gateway.executor.WorkflowExecutor" %> +<%@ page import="org.apache.airavata.workflow.model.wf.Workflow" %> +<%@ page import="java.util.Arrays" %> +<% + SampleGateway sampleGateway = null; + sampleGateway = (SampleGateway)session.getAttribute(SampleGateway.GATEWAY_SESSION); + + String user = (String) session.getAttribute("userName"); + + String token = sampleGateway.getTokenIdForUser(user); + + String hostName = request.getParameter("hostName"); + String hostAddress = request.getParameter("hostAddress"); + String gateKeeperAddress = request.getParameter("gateKeeperAddress"); + String gridFTPEndpoint = request.getParameter("gridFTPEndpoint"); + String projectNumber = request.getParameter("projectNumber"); + String queueName = request.getParameter("queueName"); + String workingDirectory = request.getParameter("workingDirectory"); + String echoInput = request.getParameter("echoInput"); + + ExecutionParameters executionParameters = new ExecutionParameters(); + + executionParameters.setHostAddress(hostAddress); + executionParameters.setHostName(hostName); + executionParameters.setGateKeeperAddress(gateKeeperAddress); + executionParameters.setGridftpAddress(gridFTPEndpoint); + executionParameters.setProjectNumber(projectNumber); + executionParameters.setQueueName(queueName); + executionParameters.setWorkingDirectory(workingDirectory); + + WorkflowExecutor workflowExecutor = new WorkflowExecutor("default"); + + String errorMessage = null; + StackTraceElement[] stackTraceElements = null; + String output = null; + + Workflow workflow = null; + try { + workflow = workflowExecutor.setupExperiment(executionParameters); + } catch (Exception e) { + + e.printStackTrace(); + + errorMessage = "An error occurred while setting up the experiment " + e.getMessage(); + stackTraceElements = e.getStackTrace(); + } + + if (errorMessage == null) { + try { + output = workflowExecutor.runWorkflow(workflow, Arrays.asList("echo_output=" + echoInput), + token, user); + } catch (Exception e) { + e.printStackTrace(); + + errorMessage = "An error occurred while running the experiment " + e.getMessage(); + stackTraceElements = e.getStackTrace(); + } + + } + +%> + + + + + + +
Home Logout
+ +

Sample Gateway

+ +

Workflow Execution Results.

+ +<% + if (errorMessage == null) { +%> +

Workflow successfully executed.

+

Output <%=output%>

+ +<% + } else { +%> + +

<%=errorMessage%>

+

Detail Error

+

+<% + for (StackTraceElement stackTraceElement : stackTraceElements) { +%> + <%=stackTraceElement.toString()%>
+<% + } + } +%> +

+ + + + \ No newline at end of file Modified: 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=1522719&r1=1522718&r2=1522719&view=diff ============================================================================== --- airavata/trunk/samples/sample-gateway/src/main/webapp/gateway/list_users.jsp (original) +++ airavata/trunk/samples/sample-gateway/src/main/webapp/gateway/list_users.jsp Thu Sep 12 20:38:19 2013 @@ -18,8 +18,14 @@ List Users + + + +
Home Logout
+

Sample Gateway

+

This page lists all users and their attributes.

Added: airavata/trunk/samples/sample-gateway/src/main/webapp/gateway/logout.jsp URL: http://svn.apache.org/viewvc/airavata/trunk/samples/sample-gateway/src/main/webapp/gateway/logout.jsp?rev=1522719&view=auto ============================================================================== --- airavata/trunk/samples/sample-gateway/src/main/webapp/gateway/logout.jsp (added) +++ airavata/trunk/samples/sample-gateway/src/main/webapp/gateway/logout.jsp Thu Sep 12 20:38:19 2013 @@ -0,0 +1,17 @@ +<%@ page import="org.apache.airavata.sample.gateway.SampleGateway" %><% + session.removeAttribute("userName"); + session.removeAttribute(SampleGateway.GATEWAY_SESSION); + session.invalidate(); +%> + + + + + + + + \ No newline at end of file Modified: 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=1522719&r1=1522718&r2=1522719&view=diff ============================================================================== --- airavata/trunk/samples/sample-gateway/src/main/webapp/gateway/user.jsp (original) +++ airavata/trunk/samples/sample-gateway/src/main/webapp/gateway/user.jsp Thu Sep 12 20:38:19 2013 @@ -8,31 +8,48 @@ --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <% - SampleGateway sampleGateway = null; - sampleGateway = (SampleGateway)session.getAttribute(SampleGateway.GATEWAY_SESSION); + String loginScreen = request.getParameter("loginScreen"); - if (sampleGateway == null) { - sampleGateway = new SampleGateway(session.getServletContext()); - } + String user = (String)session.getAttribute("userName"); + boolean authenticate = false; + + if (loginScreen != null && loginScreen.equals("true")) { + SampleGateway sampleGateway = null; + sampleGateway = (SampleGateway) session.getAttribute(SampleGateway.GATEWAY_SESSION); + + if (sampleGateway == null) { + sampleGateway = new SampleGateway(session.getServletContext()); + } - session.setAttribute(SampleGateway.GATEWAY_SESSION, sampleGateway); + session.setAttribute(SampleGateway.GATEWAY_SESSION, sampleGateway); - String user = request.getParameter("username"); - String password = request.getParameter("password"); + user = request.getParameter("username"); + String password = request.getParameter("password"); - boolean authenticate = sampleGateway.authenticate(user, password); + authenticate = sampleGateway.authenticate(user, password); + } else { + authenticate = true; + } %> + Manage + +
+ +
Home Logout
+

Sample Gateway

<% if (authenticate) { + session.setAttribute("userName", user); + if (SampleGateway.isAdmin(user)) { %>

Administration

@@ -49,7 +66,7 @@ } else { %> -

You are a normal user. You are not allowed to operate on this page.

+

You are a normal user. Click here to configure and run "Echo" workflow on a GRID machine.

<% } Modified: 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=1522719&r1=1522718&r2=1522719&view=diff ============================================================================== --- airavata/trunk/samples/sample-gateway/src/main/webapp/index.jsp (original) +++ airavata/trunk/samples/sample-gateway/src/main/webapp/index.jsp Thu Sep 12 20:38:19 2013 @@ -7,6 +7,8 @@

Welcome to Sample Gateway

+ + Modified: airavata/trunk/samples/sample-gateway/src/test/java/org/apache/airavata/sample/gateway/executor/WorkflowExecutorTest.java URL: http://svn.apache.org/viewvc/airavata/trunk/samples/sample-gateway/src/test/java/org/apache/airavata/sample/gateway/executor/WorkflowExecutorTest.java?rev=1522719&r1=1522718&r2=1522719&view=diff ============================================================================== --- airavata/trunk/samples/sample-gateway/src/test/java/org/apache/airavata/sample/gateway/executor/WorkflowExecutorTest.java (original) +++ airavata/trunk/samples/sample-gateway/src/test/java/org/apache/airavata/sample/gateway/executor/WorkflowExecutorTest.java Thu Sep 12 20:38:19 2013 @@ -47,8 +47,6 @@ public class WorkflowExecutorTest { Workflow workflow = workflowExecutor.setupExperiment(executionParameters); workflowExecutor.runWorkflow(workflow, Arrays.asList("echo_output=Hello World")); - System.out.println("sadsd"); - } //@Test @@ -75,7 +73,7 @@ public class WorkflowExecutorTest { } - //@Test + @Test public void testRunWorkflowStampedeUS3WithToken() throws Exception { WorkflowExecutor workflowExecutor = getSampleGatewayExecutor(); @@ -83,7 +81,7 @@ public class WorkflowExecutorTest { Workflow workflow = workflowExecutor.setupExperiment(executionParameters); workflowExecutor.runWorkflow(workflow, Arrays.asList("echo_output=Hello World"), - "a70b5c63-48d8-4a34-9b9a-d77f74894fb8X", "bunny"); + "9964c023-7d30-4247-a6eb-b0c9cd7be138", "bunny"); }
Login ...