airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ami...@apache.org
Subject svn commit: r1520473 [1/2] - in /airavata/trunk: modules/airavata-client/src/main/java/org/apache/airavata/client/ modules/airavata-client/src/main/java/org/apache/airavata/client/api/ modules/airavata-client/src/main/java/org/apache/airavata/client/im...
Date Fri, 06 Sep 2013 02:03:03 GMT
Author: amilaj
Date: Fri Sep  6 02:03:01 2013
New Revision: 1520473

URL: http://svn.apache.org/r1520473
Log:
Adding changes relevant to sample gateway.

Added:
    airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/util/ConfigurationReader.java
    airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/util/CredentialStoreConstants.java
    airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/util/PrivateKeyStore.java
    airavata/trunk/modules/credential-store/src/test/java/org/apache/airavata/credential/store/util/ConfigurationReaderTest.java
    airavata/trunk/modules/credential-store/src/test/resources/credential-store/
    airavata/trunk/modules/credential-store/src/test/resources/credential-store/client.xml
    airavata/trunk/samples/sample-gateway/src/configurations/
    airavata/trunk/samples/sample-gateway/src/configurations/airavata-server.properties
    airavata/trunk/samples/sample-gateway/src/configurations/client.xml
    airavata/trunk/samples/sample-gateway/src/configurations/oauth-privkey.pk8
    airavata/trunk/samples/sample-gateway/src/configurations/oauth-pubkey.pem
    airavata/trunk/samples/sample-gateway/src/main/java/org/apache/airavata/sample/gateway/ExecutionParameters.java
    airavata/trunk/samples/sample-gateway/src/main/java/org/apache/airavata/sample/gateway/executor/
    airavata/trunk/samples/sample-gateway/src/main/java/org/apache/airavata/sample/gateway/executor/PasswordCallbackImpl.java
    airavata/trunk/samples/sample-gateway/src/main/java/org/apache/airavata/sample/gateway/executor/WorkflowExecutor.java
    airavata/trunk/samples/sample-gateway/src/main/resources/EchoWorkflow.xwf
    airavata/trunk/samples/sample-gateway/src/main/resources/airavata-client.properties
    airavata/trunk/samples/sample-gateway/src/main/resources/gateway.properties
    airavata/trunk/samples/sample-gateway/src/main/webapp/WEB-INF/lib/
    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/test/
    airavata/trunk/samples/sample-gateway/src/test/java/
    airavata/trunk/samples/sample-gateway/src/test/java/org/
    airavata/trunk/samples/sample-gateway/src/test/java/org/apache/
    airavata/trunk/samples/sample-gateway/src/test/java/org/apache/airavata/
    airavata/trunk/samples/sample-gateway/src/test/java/org/apache/airavata/sample/
    airavata/trunk/samples/sample-gateway/src/test/java/org/apache/airavata/sample/gateway/
    airavata/trunk/samples/sample-gateway/src/test/java/org/apache/airavata/sample/gateway/executor/
    airavata/trunk/samples/sample-gateway/src/test/java/org/apache/airavata/sample/gateway/executor/WorkflowExecutorTest.java
Removed:
    airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/servlet/CredentialStoreOA4MPServer.java
    airavata/trunk/modules/rest/webapp/src/main/webapp/credential-store/index.jsp
Modified:
    airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataAPIUtils.java
    airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/CredentialStoreSecuritySettings.java
    airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/CredentialStoreSecuritySettingsImpl.java
    airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/DBUtil.java
    airavata/trunk/modules/commons/workflow-execution-context/src/main/java/org/apache/airavata/common/workflow/execution/context/WorkflowContextHeaderBuilder.java
    airavata/trunk/modules/commons/workflow-execution-context/src/main/resources/workflow_execution_context.xsd
    airavata/trunk/modules/credential-store/pom.xml
    airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/credential/impl/certificate/CertificateCredential.java
    airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/servlet/CredentialStoreCallbackServlet.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/store/impl/CertificateCredentialWriter.java
    airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/store/impl/db/CredentialsDAO.java
    airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/util/TokenGenerator.java
    airavata/trunk/modules/credential-store/src/test/java/org/apache/airavata/credential/store/store/impl/db/CredentialsDAOTest.java
    airavata/trunk/modules/distribution/airavata-client/pom.xml
    airavata/trunk/modules/distribution/airavata-server/src/main/resources/conf/airavata-server.properties
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/GFacAPI.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/context/security/GSISecurityContext.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/GramProvider.java
    airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/client/DescriptorResourceClient.java
    airavata/trunk/modules/rest/webapp/src/main/resources/credential-store/client.xml
    airavata/trunk/modules/rest/webapp/src/main/webapp/WEB-INF/web.xml
    airavata/trunk/modules/rest/webapp/src/main/webapp/acs/index.jsp
    airavata/trunk/modules/rest/webapp/src/main/webapp/credential-store/error.jsp
    airavata/trunk/modules/rest/webapp/src/main/webapp/credential-store/show-redirect.jsp
    airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/invoker/EmbeddedGFacInvoker.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

Modified: airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataAPIUtils.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataAPIUtils.java?rev=1520473&r1=1520472&r2=1520473&view=diff
==============================================================================
--- airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataAPIUtils.java (original)
+++ airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataAPIUtils.java Fri Sep  6 02:03:01 2013
@@ -74,7 +74,10 @@ public class AiravataAPIUtils {
         if (options.getCustomSecuritySettings().getCredentialStoreSecuritySettings() != null) {
             builder.setCredentialManagementService(options.getCustomSecuritySettings().
                     getCredentialStoreSecuritySettings().getTokenId(),
-                    executionUser);
+                    options.getCustomSecuritySettings().
+                            getCredentialStoreSecuritySettings().getPortalUser(),
+                    options.getCustomSecuritySettings().
+                            getCredentialStoreSecuritySettings().getGatewayId());
         }
 
 

Modified: airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/CredentialStoreSecuritySettings.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/CredentialStoreSecuritySettings.java?rev=1520473&r1=1520472&r2=1520473&view=diff
==============================================================================
--- airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/CredentialStoreSecuritySettings.java (original)
+++ airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/CredentialStoreSecuritySettings.java Fri Sep  6 02:03:01 2013
@@ -32,12 +32,38 @@ public interface CredentialStoreSecurity
      * Returns the token id to get the credentials.
      * @return The token id.
      */
-    public String getTokenId();
+    String getTokenId();
 
     /**
      * Sets the token to be used when accessing the credential store.
      * @param token The token.
      */
-    public void setTokenId(String token);
+    void setTokenId(String token);
+
+    /**
+     * Sets the portal user name.
+     * @param portalUserName The name of the portal user.
+     */
+    void setPortalUser(String portalUserName);
+
+    /**
+     * Gets the portal user name.
+     * @return portal user name.
+     */
+    String getPortalUser();
+
+    /**
+     * Sets the gateway id.
+     * @param gatewayId The gateway id.
+     */
+    void setGatewayId(String gatewayId);
+
+    /**
+     * Gets the gateway id.
+     * @return name of the gateway.
+     */
+    String getGatewayId();
+
+
 
 }

Modified: airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/CredentialStoreSecuritySettingsImpl.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/CredentialStoreSecuritySettingsImpl.java?rev=1520473&r1=1520472&r2=1520473&view=diff
==============================================================================
--- airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/CredentialStoreSecuritySettingsImpl.java (original)
+++ airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/CredentialStoreSecuritySettingsImpl.java Fri Sep  6 02:03:01 2013
@@ -29,6 +29,8 @@ import org.apache.airavata.client.api.Cr
 public class CredentialStoreSecuritySettingsImpl implements CredentialStoreSecuritySettings {
 
     private String tokenId;
+    private String portalUserId;
+    private String gatewayId;
 
     public CredentialStoreSecuritySettingsImpl(String tokenId) {
         this.tokenId = tokenId;
@@ -41,6 +43,26 @@ public class CredentialStoreSecuritySett
         this.tokenId = tokenId;
     }
 
+    @Override
+    public void setPortalUser(String portalUserName) {
+        this.portalUserId = portalUserName;
+    }
+
+    @Override
+    public String getPortalUser() {
+        return this.portalUserId;
+    }
+
+    @Override
+    public void setGatewayId(String gatewayId) {
+        this.gatewayId = gatewayId;
+    }
+
+    @Override
+    public String getGatewayId() {
+        return this.gatewayId;
+    }
+
     public String getTokenId() {
         return tokenId;
     }

Modified: airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/DBUtil.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/DBUtil.java?rev=1520473&r1=1520472&r2=1520473&view=diff
==============================================================================
--- airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/DBUtil.java (original)
+++ airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/DBUtil.java Fri Sep  6 02:03:01 2013
@@ -254,6 +254,24 @@ public class DBUtil {
     }
 
     /**
+     * Utility method to close statements and connections.
+     *
+     * @param preparedStatement
+     *            The prepared statement to close.
+     */
+    public static void cleanup(PreparedStatement preparedStatement, ResultSet resultSet) {
+        if (resultSet != null) {
+            try {
+                resultSet.close();
+            } catch (SQLException e) {
+                log.error("Error closing prepared statement.", e);
+            }
+        }
+
+        cleanup(preparedStatement);
+    }
+
+    /**
      * Cleanup the connection.
      * @param connection The connection to close.
      */
@@ -262,7 +280,8 @@ public class DBUtil {
             try {
                 connection.close();
             } catch (SQLException e) {
-                log.error("Error closing prepared statement.", e);
+                log.debug("Error closing connection.", e);
+                log.warn("Error closing connection.");
             }
         }
     }

Modified: airavata/trunk/modules/commons/workflow-execution-context/src/main/java/org/apache/airavata/common/workflow/execution/context/WorkflowContextHeaderBuilder.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/commons/workflow-execution-context/src/main/java/org/apache/airavata/common/workflow/execution/context/WorkflowContextHeaderBuilder.java?rev=1520473&r1=1520472&r2=1520473&view=diff
==============================================================================
--- airavata/trunk/modules/commons/workflow-execution-context/src/main/java/org/apache/airavata/common/workflow/execution/context/WorkflowContextHeaderBuilder.java (original)
+++ airavata/trunk/modules/commons/workflow-execution-context/src/main/java/org/apache/airavata/common/workflow/execution/context/WorkflowContextHeaderBuilder.java Fri Sep  6 02:03:01 2013
@@ -288,7 +288,8 @@ public class WorkflowContextHeaderBuilde
         return this;
     }
 
-    public WorkflowContextHeaderBuilder setCredentialManagementService(String tokenId, String portalUser) {
+    public WorkflowContextHeaderBuilder setCredentialManagementService(String tokenId, String portalUser,
+                                                                       String gatewayId) {
         if (this.securityContext == null) {
             this.securityContext = SecurityContextDocument.SecurityContext.Factory.newInstance();
         }
@@ -296,6 +297,7 @@ public class WorkflowContextHeaderBuilde
                 .addNewCredentialManagementService();
         credentialManagementService.setTokenId(tokenId);
         credentialManagementService.setPortalUser(portalUser);
+        credentialManagementService.setGatewayId(gatewayId);
         return this;
     }
 

Modified: airavata/trunk/modules/commons/workflow-execution-context/src/main/resources/workflow_execution_context.xsd
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/commons/workflow-execution-context/src/main/resources/workflow_execution_context.xsd?rev=1520473&r1=1520472&r2=1520473&view=diff
==============================================================================
--- airavata/trunk/modules/commons/workflow-execution-context/src/main/resources/workflow_execution_context.xsd (original)
+++ airavata/trunk/modules/commons/workflow-execution-context/src/main/resources/workflow_execution_context.xsd Fri Sep  6 02:03:01 2013
@@ -521,6 +521,12 @@
 									</documentation>
 								</annotation>
 							</element>
+                            <element name="gateway-id" type="string">
+                                <annotation>
+                                    <documentation xml:lang="en"> The Id associated with the science gateway.
+                                    </documentation>
+                                </annotation>
+                            </element>
 						</sequence>
 					</complexType>
 				</element>

Modified: airavata/trunk/modules/credential-store/pom.xml
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/credential-store/pom.xml?rev=1520473&r1=1520472&r2=1520473&view=diff
==============================================================================
--- airavata/trunk/modules/credential-store/pom.xml (original)
+++ airavata/trunk/modules/credential-store/pom.xml Fri Sep  6 02:03:01 2013
@@ -22,6 +22,7 @@
     <description>Module to manage credentials</description>
 
     <dependencies>
+
         <dependency>
             <groupId>edu.uiuc.ncsa.myproxy</groupId>
             <artifactId>oa4mp-client-api</artifactId>

Modified: airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/credential/impl/certificate/CertificateCredential.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/credential/impl/certificate/CertificateCredential.java?rev=1520473&r1=1520472&r2=1520473&view=diff
==============================================================================
--- airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/credential/impl/certificate/CertificateCredential.java (original)
+++ airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/credential/impl/certificate/CertificateCredential.java Fri Sep  6 02:03:01 2013
@@ -40,7 +40,7 @@ public class CertificateCredential exten
 
     private String notAfter;
 
-    private X509Certificate certificate;
+    private X509Certificate[] certificates;
 
     private PrivateKey privateKey;
 
@@ -75,12 +75,12 @@ public class CertificateCredential exten
         this.privateKey = privateKey;
     }
 
-    public X509Certificate getCertificate() {
-        return certificate;
+    public X509Certificate[] getCertificates() {
+        return certificates;
     }
 
-    public void setCertificate(X509Certificate certificate) {
-        this.certificate = certificate;
+    public void setCertificates(X509Certificate[] certificate) {
+        this.certificates = certificate;
     }
 
     public long getLifeTime() {

Modified: airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/servlet/CredentialStoreCallbackServlet.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/servlet/CredentialStoreCallbackServlet.java?rev=1520473&r1=1520472&r2=1520473&view=diff
==============================================================================
--- airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/servlet/CredentialStoreCallbackServlet.java (original)
+++ airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/servlet/CredentialStoreCallbackServlet.java Fri Sep  6 02:03:01 2013
@@ -23,7 +23,6 @@ package org.apache.airavata.credential.s
 
 import edu.uiuc.ncsa.myproxy.oa4mp.client.AssetResponse;
 import edu.uiuc.ncsa.myproxy.oa4mp.client.ClientEnvironment;
-import edu.uiuc.ncsa.myproxy.oa4mp.client.OA4MPResponse;
 import edu.uiuc.ncsa.myproxy.oa4mp.client.OA4MPService;
 import edu.uiuc.ncsa.myproxy.oa4mp.client.servlet.ClientServlet;
 import edu.uiuc.ncsa.security.core.exceptions.GeneralException;
@@ -32,12 +31,15 @@ import org.apache.airavata.common.utils.
 import org.apache.airavata.credential.store.credential.CommunityUser;
 import org.apache.airavata.credential.store.credential.impl.certificate.CertificateCredential;
 import org.apache.airavata.credential.store.store.impl.CertificateCredentialWriter;
+import org.apache.airavata.credential.store.util.ConfigurationReader;
+import org.apache.airavata.credential.store.util.CredentialStoreConstants;
+import org.apache.airavata.credential.store.util.PrivateKeyStore;
 import org.apache.airavata.credential.store.util.Utility;
-
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
+import java.security.PrivateKey;
 import java.security.cert.X509Certificate;
 import java.util.HashMap;
 import java.util.Map;
@@ -50,19 +52,12 @@ import static edu.uiuc.ncsa.myproxy.oa4m
  */
 public class CredentialStoreCallbackServlet extends ClientServlet {
 
-    private static final String ERROR_PAGE = "/credential-store/error.jsp";
-    private static final String SUCCESS_PAGE = "/credential-store/success.jsp";
-
-    private static final String GATEWAY_NAME_QUERY_PARAMETER = "gatewayName";
-    private static final String PORTAL_USER_QUERY_PARAMETER = "portalUserName";
-    private static final String PORTAL_USER_EMAIL_QUERY_PARAMETER = "email";
-    private static final String PORTAL_TOKEN_ID_ASSIGNED = "associatedToken";
-    private static final String DURATION_QUERY_PARAMETER = "duration";
-
     private OA4MPService oa4mpService;
 
     private CertificateCredentialWriter certificateCredentialWriter;
 
+    private static ConfigurationReader configurationReader;
+
     public void init() throws ServletException {
 
         DBUtil dbUtil;
@@ -73,6 +68,12 @@ public class CredentialStoreCallbackServ
             throw new ServletException("Error initializing database operations.", e);
         }
 
+        try {
+            configurationReader = new ConfigurationReader();
+        } catch (Exception e) {
+            throw new ServletException("Error initializing configuration reader.", e);
+        }
+
         super.init();
         certificateCredentialWriter = new CertificateCredentialWriter(dbUtil);
 
@@ -87,17 +88,17 @@ public class CredentialStoreCallbackServ
     @Override
     public void loadEnvironment() throws IOException {
         environment = getConfigurationLoader().load();
-        oa4mpService = new CredentialStoreOA4MPServer((ClientEnvironment) environment);
+        oa4mpService = new OA4MPService((ClientEnvironment) environment);
     }
 
     @Override
     protected void doIt(HttpServletRequest request, HttpServletResponse response) throws Throwable {
 
-        String gatewayName = request.getParameter(GATEWAY_NAME_QUERY_PARAMETER);
-        String portalUserName = request.getParameter(PORTAL_USER_QUERY_PARAMETER);
-        String durationParameter = request.getParameter(DURATION_QUERY_PARAMETER);
-        String contactEmail = request.getParameter(PORTAL_USER_EMAIL_QUERY_PARAMETER);
-        String portalTokenId = request.getParameter(PORTAL_TOKEN_ID_ASSIGNED);
+        String gatewayName = request.getParameter(CredentialStoreConstants.GATEWAY_NAME_QUERY_PARAMETER);
+        String portalUserName = request.getParameter(CredentialStoreConstants.PORTAL_USER_QUERY_PARAMETER);
+        String durationParameter = request.getParameter(CredentialStoreConstants.DURATION_QUERY_PARAMETER);
+        String contactEmail = request.getParameter(CredentialStoreConstants.PORTAL_USER_EMAIL_QUERY_PARAMETER);
+        String portalTokenId = request.getParameter(CredentialStoreConstants.PORTAL_TOKEN_ID_ASSIGNED);
 
         // TODO remove hard coded values, once passing query parameters is
         // fixed in OA4MP client api
@@ -111,7 +112,7 @@ public class CredentialStoreCallbackServ
             error("Token given by portal is invalid.");
             GeneralException ge = new GeneralException("Error: The token presented by portal is null.");
             request.setAttribute("exception", ge);
-            JSPUtil.fwd(request, response, ERROR_PAGE);
+            JSPUtil.fwd(request, response, configurationReader.getErrorUrl());
             return;
         }
 
@@ -129,65 +130,97 @@ public class CredentialStoreCallbackServ
             GeneralException ge = new GeneralException(
                     "Error: This servlet requires parameters for the token and verifier. It cannot be called directly.");
             request.setAttribute("exception", ge);
-            JSPUtil.fwd(request, response, ERROR_PAGE);
+            JSPUtil.fwd(request, response, configurationReader.getErrorUrl());
             return;
         }
         info("2.a Token and verifier found.");
-        X509Certificate cert = null;
+        X509Certificate[] certificates;
         AssetResponse assetResponse = null;
-        OA4MPResponse oa4MPResponse = null;
 
-        Map<String, String> parameters = createQueryParameters(gatewayName, portalUserName, contactEmail, portalTokenId);
+        PrivateKey privateKey;
 
         try {
-            info("Requesting private key ...");
-            oa4MPResponse = getOA4MPService().requestCert(parameters);
-            // oa4MPResponse = getOA4MPService().requestCert();
+
+            PrivateKeyStore privateKeyStore = PrivateKeyStore.getPrivateKeyStore();
+            privateKey = privateKeyStore.getKey(portalTokenId);
+
+            if (privateKey != null) {
+                info("Found private key for token " + portalTokenId);
+            } else {
+                info("Could not find private key for token " + portalTokenId);
+            }
 
             info("2.a. Getting the cert(s) from the service");
             assetResponse = getOA4MPService().getCert(token, verifier);
-            cert = assetResponse.getX509Certificates()[0];
 
-            // The work in this call
+            certificates = assetResponse.getX509Certificates();
+
         } catch (Throwable t) {
             warn("2.a. Exception from the server: " + t.getCause().getMessage());
             error("Exception while trying to get cert. message:" + t.getMessage());
             request.setAttribute("exception", t);
-            JSPUtil.fwd(request, response, ERROR_PAGE);
+            JSPUtil.fwd(request, response, configurationReader.getErrorUrl());
             return;
         }
+
         info("2.b. Done! Displaying success page.");
 
         CertificateCredential certificateCredential = new CertificateCredential();
 
-        certificateCredential.setNotBefore(Utility.convertDateToString(cert.getNotBefore()));
-        certificateCredential.setNotAfter(Utility.convertDateToString(cert.getNotAfter()));
-        certificateCredential.setCertificate(cert);
-        certificateCredential.setPrivateKey(oa4MPResponse.getPrivateKey());
+        certificateCredential.setNotBefore(Utility.convertDateToString(certificates[0].getNotBefore())); //TODO check this is correct
+        certificateCredential.setNotAfter(Utility.convertDateToString(certificates[0].getNotAfter()));
+        certificateCredential.setCertificates(certificates);
+        certificateCredential.setPrivateKey(privateKey);
         certificateCredential
                 .setCommunityUser(new CommunityUser(gatewayName, assetResponse.getUsername(), contactEmail));
         certificateCredential.setPortalUserName(portalUserName);
         certificateCredential.setLifeTime(duration);
         certificateCredential.setToken(portalTokenId);
 
+
         certificateCredentialWriter.writeCredentials(certificateCredential);
 
         StringBuilder stringBuilder = new StringBuilder("Certificate for community user ");
         stringBuilder.append(assetResponse.getUsername()).append(" successfully persisted.");
-        stringBuilder.append(" Certificate DN - ").append(cert.getSubjectDN());
+        stringBuilder.append(" Certificate DN - ").append(certificates[0].getSubjectDN());
 
         info(stringBuilder.toString());
 
-        String contextPath = request.getContextPath();
-        if (!contextPath.endsWith("/")) {
-            contextPath = contextPath + "/";
+        if (isUrlInSameServer(configurationReader.getSuccessUrl())) {
+
+            String contextPath = request.getContextPath();
+            if (!contextPath.endsWith("/")) {
+                contextPath = contextPath + "/";
+            }
+            request.setAttribute("action", contextPath);
+            request.setAttribute("tokenId", portalTokenId);
+            JSPUtil.fwd(request, response, configurationReader.getSuccessUrl());
+        } else {
+
+            String urlToRedirect = decorateUrlWithToken(configurationReader.getSuccessUrl(), portalTokenId);
+
+            info("Redirecting to url - " + urlToRedirect);
+
+            response.sendRedirect(urlToRedirect);
         }
-        request.setAttribute("action", contextPath);
-        JSPUtil.fwd(request, response, SUCCESS_PAGE);
+
         info("2.a. Completely finished with delegation.");
 
     }
 
+    private boolean isUrlInSameServer(String url) {
+
+        return !(url.toLowerCase().startsWith("http") || url.toLowerCase().startsWith("https"));
+
+    }
+
+    private String decorateUrlWithToken(String url, String tokenId) {
+
+        StringBuilder stringBuilder = new StringBuilder(url);
+        stringBuilder.append("?tokenId=").append(tokenId);
+        return stringBuilder.toString();
+    }
+
     private Map<String, String> createQueryParameters(String gatewayName, String portalUserName, String portalEmail,
             String tokenId) {
 
@@ -198,10 +231,10 @@ public class CredentialStoreCallbackServ
 
         StringBuilder stringBuilder = new StringBuilder(callbackUri);
 
-        stringBuilder.append("?").append(GATEWAY_NAME_QUERY_PARAMETER).append("=").append(gatewayName).append("&")
-                .append(PORTAL_USER_QUERY_PARAMETER).append("=").append(portalUserName).append("&")
-                .append(PORTAL_USER_EMAIL_QUERY_PARAMETER).append("=").append(portalEmail).append("&")
-                .append(PORTAL_TOKEN_ID_ASSIGNED).append("=").append(tokenId);
+        stringBuilder.append("?").append(CredentialStoreConstants.GATEWAY_NAME_QUERY_PARAMETER).append("=").append(gatewayName).append("&")
+                .append(CredentialStoreConstants.PORTAL_USER_QUERY_PARAMETER).append("=").append(portalUserName).append("&")
+                .append(CredentialStoreConstants.PORTAL_USER_EMAIL_QUERY_PARAMETER).append("=").append(portalEmail).append("&")
+                .append(CredentialStoreConstants.PORTAL_TOKEN_ID_ASSIGNED).append("=").append(tokenId);
 
         info("Callback URI is set to - " + stringBuilder.toString());
 

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=1520473&r1=1520472&r2=1520473&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 Fri Sep  6 02:03:01 2013
@@ -24,18 +24,19 @@ package org.apache.airavata.credential.s
 import edu.uiuc.ncsa.myproxy.oa4mp.client.OA4MPResponse;
 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.store.CredentialStoreException;
+import org.apache.airavata.credential.store.util.ConfigurationReader;
+import org.apache.airavata.credential.store.util.CredentialStoreConstants;
+import org.apache.airavata.credential.store.util.PrivateKeyStore;
 import org.apache.airavata.credential.store.util.TokenGenerator;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import java.io.File;
 import java.net.URI;
-import java.net.URISyntaxException;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
 
 import static edu.uiuc.ncsa.myproxy.oa4mp.client.ClientEnvironment.CALLBACK_URI_KEY;
@@ -45,8 +46,7 @@ import static edu.uiuc.ncsa.myproxy.oa4m
  */
 public class CredentialStoreStartServlet extends ClientServlet {
 
-    private String errorUrl;
-    private String redirectUrl;
+    private static ConfigurationReader configurationReader = null;
 
     private static Logger log = LoggerFactory.getLogger(CredentialStoreStartServlet.class);
 
@@ -76,40 +76,57 @@ public class CredentialStoreStartServlet
 
     }
 
+    public void init() throws ServletException {
+
+        super.init();
+
+        try {
+            if (configurationReader == null) {
+                configurationReader = new ConfigurationReader();
+            }
+        } catch (CredentialStoreException e) {
+            throw new ServletException(e);
+        }
+
+    }
+
     @Override
     protected void doIt(HttpServletRequest request, HttpServletResponse response) throws Throwable {
 
-        String gatewayName = request.getParameter("gatewayName");
-        String portalUserName = request.getParameter("portalUserName");
-        String contactEmail = request.getParameter("email");
+        String gatewayName
+                = request.getParameter(CredentialStoreConstants.GATEWAY_NAME_QUERY_PARAMETER);
+        String portalUserName
+                = request.getParameter(CredentialStoreConstants.PORTAL_USER_QUERY_PARAMETER);
+        String contactEmail
+                = request.getParameter(CredentialStoreConstants.PORTAL_USER_EMAIL_QUERY_PARAMETER);
         String associatedToken = TokenGenerator.generateToken(gatewayName, portalUserName);
 
         if (gatewayName == null) {
             JSPUtil.handleException(new RuntimeException("Please specify a gateway name."), request, response,
-                    "/credential-store/error.jsp");
+                    configurationReader.getErrorUrl());
             return;
         }
 
         if (portalUserName == null) {
             JSPUtil.handleException(new RuntimeException("Please specify a portal user name."), request, response,
-                    "/credential-store/error.jsp");
+                    configurationReader.getErrorUrl());
             return;
         }
 
         if (contactEmail == null) {
             JSPUtil.handleException(new RuntimeException("Please specify a contact email address for community"
-                    + " user account."), request, response, "/credential-store/error.jsp");
+                    + " user account."), request, response, configurationReader.getErrorUrl());
             return;
         }
 
         log.info("1.a. Starting transaction");
-        OA4MPResponse gtwResp = null;
+        OA4MPResponse gtwResp;
 
         Map<String, String> queryParameters = new HashMap<String, String>();
-        queryParameters.put("gatewayName", gatewayName);
-        queryParameters.put("portalUserName", portalUserName);
-        queryParameters.put("email", contactEmail);
-        queryParameters.put("associatedToken", associatedToken);
+        queryParameters.put(CredentialStoreConstants.GATEWAY_NAME_QUERY_PARAMETER, gatewayName);
+        queryParameters.put(CredentialStoreConstants.PORTAL_USER_QUERY_PARAMETER, portalUserName);
+        queryParameters.put(CredentialStoreConstants.PORTAL_USER_EMAIL_QUERY_PARAMETER, contactEmail);
+        queryParameters.put(CredentialStoreConstants.PORTAL_TOKEN_ID_ASSIGNED, associatedToken);
 
         Map<String, String> additionalParameters = new HashMap<String, String>();
 
@@ -119,11 +136,15 @@ public class CredentialStoreStartServlet
 
         additionalParameters.put(getEnvironment().getConstants().get(CALLBACK_URI_KEY), modifiedCallbackUri);
 
-        // Drumroll please: here is the work for this call.
         try {
             gtwResp = getOA4MPService().requestCert(additionalParameters);
+
+            // Private key in store
+            PrivateKeyStore privateKeyStore = PrivateKeyStore.getPrivateKeyStore();
+            privateKeyStore.addKey(associatedToken, gtwResp.getPrivateKey());
+
         } catch (Throwable t) {
-            JSPUtil.handleException(t, request, response, "/credential-store/error.jsp");
+            JSPUtil.handleException(t, request, response, configurationReader.getErrorUrl());
             return;
         }
         log.info("1.b. Got response. Creating page with redirect for " + gtwResp.getRedirect().getHost());
@@ -137,7 +158,7 @@ public class CredentialStoreStartServlet
         request.setAttribute(ACTION_KEY, ACTION_KEY);
         request.setAttribute("action", ACTION_REDIRECT_VALUE);
         log.info("1.b. Showing redirect page.");
-        JSPUtil.fwd(request, response, "/credential-store/show-redirect.jsp");
+        JSPUtil.fwd(request, response, configurationReader.getPortalRedirectUrl());
 
     }
 }

Modified: airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/store/impl/CertificateCredentialWriter.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/store/impl/CertificateCredentialWriter.java?rev=1520473&r1=1520472&r2=1520473&view=diff
==============================================================================
--- airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/store/impl/CertificateCredentialWriter.java (original)
+++ airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/store/impl/CertificateCredentialWriter.java Fri Sep  6 02:03:01 2013
@@ -29,6 +29,8 @@ import org.apache.airavata.credential.st
 import org.apache.airavata.credential.store.store.impl.db.CredentialsDAO;
 import org.apache.airavata.credential.store.store.CredentialStoreException;
 import org.apache.airavata.credential.store.store.CredentialWriter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.sql.Connection;
 import java.sql.SQLException;
@@ -41,6 +43,8 @@ public class CertificateCredentialWriter
     private CredentialsDAO credentialsDAO;
     private CommunityUserDAO communityUserDAO;
 
+    protected static Logger log = LoggerFactory.getLogger(CertificateCredentialWriter.class);
+
     private DBUtil dbUtil;
 
     public CertificateCredentialWriter(DBUtil dbUtil) {
@@ -69,7 +73,18 @@ public class CertificateCredentialWriter
             credentialsDAO.addCredentials(certificateCredential.getCommunityUser().getGatewayName(), credential,
                     connection);
 
+            if (!connection.getAutoCommit()) {
+                connection.commit();
+            }
+
         } catch (SQLException e) {
+            if (connection != null) {
+                try {
+                    connection.rollback();
+                } catch (SQLException e1) {
+                    log.error("Unable to rollback transaction", e1);
+                }
+            }
             throw new CredentialStoreException("Unable to retrieve database connection.", e);
         } finally {
             DBUtil.cleanup(connection);

Modified: airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/store/impl/db/CredentialsDAO.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/store/impl/db/CredentialsDAO.java?rev=1520473&r1=1520472&r2=1520473&view=diff
==============================================================================
--- airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/store/impl/db/CredentialsDAO.java (original)
+++ airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/store/impl/db/CredentialsDAO.java Fri Sep  6 02:03:01 2013
@@ -204,6 +204,7 @@ public class CredentialsDAO extends Pare
         String sql = "select * from credentials where GATEWAY_ID=? and TOKEN_ID=?";
 
         PreparedStatement preparedStatement = null;
+        ResultSet resultSet = null;
 
         try {
             preparedStatement = connection.prepareStatement(sql);
@@ -211,7 +212,7 @@ public class CredentialsDAO extends Pare
             preparedStatement.setString(1, gatewayName);
             preparedStatement.setString(2, tokenId);
 
-            ResultSet resultSet = preparedStatement.executeQuery();
+            resultSet = preparedStatement.executeQuery();
 
             if (resultSet.next()) {
                 // CertificateCredential certificateCredential = new CertificateCredential();
@@ -254,7 +255,7 @@ public class CredentialsDAO extends Pare
 
             throw new CredentialStoreException(stringBuilder.toString(), e);
         } finally {
-            DBUtil.cleanup(preparedStatement);
+            DBUtil.cleanup(preparedStatement, resultSet);
         }
 
         return null;
@@ -274,13 +275,14 @@ public class CredentialsDAO extends Pare
         String sql = "select * from credentials where GATEWAY_ID=?";
 
         PreparedStatement preparedStatement = null;
+        ResultSet resultSet = null;
 
         try {
             preparedStatement = connection.prepareStatement(sql);
 
             preparedStatement.setString(1, gatewayName);
 
-            ResultSet resultSet = preparedStatement.executeQuery();
+            resultSet = preparedStatement.executeQuery();
 
             Credential certificateCredential;
 
@@ -319,7 +321,7 @@ public class CredentialsDAO extends Pare
 
             throw new CredentialStoreException(stringBuilder.toString(), e);
         } finally {
-            DBUtil.cleanup(preparedStatement);
+            DBUtil.cleanup(preparedStatement, resultSet);
         }
 
         return credentialList;

Added: airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/util/ConfigurationReader.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/util/ConfigurationReader.java?rev=1520473&view=auto
==============================================================================
--- airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/util/ConfigurationReader.java (added)
+++ airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/util/ConfigurationReader.java Fri Sep  6 02:03:01 2013
@@ -0,0 +1,121 @@
+/*
+ *
+ * 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 org.apache.airavata.credential.store.store.CredentialStoreException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 8/25/13
+ * Time: 6:40 AM
+ */
+
+/**
+ * Reads credential store specific configurations from the client.xml file.
+ */
+public class ConfigurationReader {
+
+    private String successUrl;
+
+    private String errorUrl;
+
+    private String portalRedirectUrl;
+
+    public String getPortalRedirectUrl() {
+        return portalRedirectUrl;
+    }
+
+    public void setPortalRedirectUrl(String portalRedirectUrl) {
+        this.portalRedirectUrl = portalRedirectUrl;
+    }
+
+    public ConfigurationReader() throws CredentialStoreException {
+
+        try {
+            loadConfigurations();
+        } catch (Exception e) {
+            throw new CredentialStoreException("Unable to read credential store specific configurations." , e);
+        }
+
+
+    }
+
+    private void loadConfigurations() throws ParserConfigurationException,
+            IOException, SAXException {
+        InputStream inputStream
+                = this.getClass().getClassLoader().getResourceAsStream("credential-store/client.xml");
+
+        DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
+        DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
+        Document doc = dBuilder.parse(inputStream);
+
+        doc.getDocumentElement().normalize();
+
+        NodeList nodeList = doc.getElementsByTagName("credential-store");
+
+        readElementValue(nodeList);
+
+    }
+
+    private void readElementValue(NodeList nodeList) {
+        for (int temp = 0; temp < nodeList.getLength(); temp++) {
+
+            Node nNode = nodeList.item(temp);
+
+            if (nNode.getNodeType() == Node.ELEMENT_NODE) {
+
+                Element eElement = (Element) nNode;
+
+                this.successUrl = eElement.getElementsByTagName("successUri").item(0).getTextContent();
+                this.errorUrl =  eElement.getElementsByTagName("errorUri").item(0).getTextContent();
+                this.portalRedirectUrl = eElement.getElementsByTagName("redirectUri").item(0).getTextContent();
+            }
+        }
+    }
+
+    public String getSuccessUrl() {
+        return successUrl;
+    }
+
+    public void setSuccessUrl(String successUrl) {
+        this.successUrl = successUrl;
+    }
+
+    public String getErrorUrl() {
+        return errorUrl;
+    }
+
+    public void setErrorUrl(String errorUrl) {
+        this.errorUrl = errorUrl;
+    }
+}

Added: airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/util/CredentialStoreConstants.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/util/CredentialStoreConstants.java?rev=1520473&view=auto
==============================================================================
--- airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/util/CredentialStoreConstants.java (added)
+++ airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/util/CredentialStoreConstants.java Fri Sep  6 02:03:01 2013
@@ -0,0 +1,37 @@
+/*
+ *
+ * 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;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 8/25/13
+ * Time: 4:34 PM
+ */
+
+public class CredentialStoreConstants {
+
+    public static final String GATEWAY_NAME_QUERY_PARAMETER = "gatewayName";
+    public static final String PORTAL_USER_QUERY_PARAMETER = "portalUserName";
+    public static final String PORTAL_USER_EMAIL_QUERY_PARAMETER = "email";
+    public static final String PORTAL_TOKEN_ID_ASSIGNED = "associatedToken";
+    public static final String DURATION_QUERY_PARAMETER = "duration";
+}

Added: airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/util/PrivateKeyStore.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/util/PrivateKeyStore.java?rev=1520473&view=auto
==============================================================================
--- airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/util/PrivateKeyStore.java (added)
+++ airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/util/PrivateKeyStore.java Fri Sep  6 02:03:01 2013
@@ -0,0 +1,70 @@
+/*
+ *
+ * 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 java.security.PrivateKey;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 9/5/13
+ * Time: 6:47 PM
+ */
+
+public class PrivateKeyStore {
+
+    private Map<String, PrivateKey> privateKeyMap;
+
+    private static PrivateKeyStore privateKeyStore = null;
+
+    private PrivateKeyStore() {
+        privateKeyMap = new HashMap<String, PrivateKey>();
+    }
+
+    public static PrivateKeyStore getPrivateKeyStore() {
+
+        if (privateKeyStore == null) {
+            privateKeyStore = new PrivateKeyStore();
+        }
+
+        return privateKeyStore;
+    }
+
+    public synchronized void addKey(String tokenId, PrivateKey privateKey) {
+
+        privateKeyMap.put(tokenId, privateKey);
+    }
+
+    public synchronized PrivateKey getKey(String tokenId) {
+
+        PrivateKey privateKey = privateKeyMap.get(tokenId);
+
+        if (privateKey != null) {
+            privateKeyMap.remove(tokenId);
+        }
+
+        return privateKey;
+    }
+
+
+}

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=1520473&r1=1520472&r2=1520473&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 Fri Sep  6 02:03:01 2013
@@ -31,6 +31,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.sql.Timestamp;
+import java.util.UUID;
 
 /**
  * Generates tokens for users.
@@ -45,15 +46,8 @@ public class TokenGenerator {
     }
 
     public static String generateToken(String gatewayId, String metadata) {
-        StringBuilder tokenBuilder = new StringBuilder("#token#");
-        tokenBuilder.append(gatewayId.trim()).append("#").append(metadata.trim()).append("#");
 
-
-        java.util.Date date= new java.util.Date();
-        Timestamp timestamp = new Timestamp(date.getTime());
-        tokenBuilder.append(Integer.toString(timestamp.getNanos()));
-
-        return tokenBuilder.toString();
+        return UUID.randomUUID().toString();
     }
 
     public String encryptToken(String token) {

Modified: airavata/trunk/modules/credential-store/src/test/java/org/apache/airavata/credential/store/store/impl/db/CredentialsDAOTest.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/credential-store/src/test/java/org/apache/airavata/credential/store/store/impl/db/CredentialsDAOTest.java?rev=1520473&r1=1520472&r2=1520473&view=diff
==============================================================================
--- airavata/trunk/modules/credential-store/src/test/java/org/apache/airavata/credential/store/store/impl/db/CredentialsDAOTest.java (original)
+++ airavata/trunk/modules/credential-store/src/test/java/org/apache/airavata/credential/store/store/impl/db/CredentialsDAOTest.java Fri Sep  6 02:03:01 2013
@@ -52,7 +52,7 @@ public class CredentialsDAOTest extends 
 
     private CredentialsDAO credentialsDAO;
 
-    private X509Certificate x509Certificate;
+    private X509Certificate[] x509Certificates;
     private PrivateKey privateKey;
 
     @BeforeClass
@@ -100,6 +100,8 @@ public class CredentialsDAOTest extends 
 
         credentialsDAO = new CredentialsDAO();
 
+        x509Certificates = new X509Certificate[1];
+
         // Cleanup tables;
         Connection connection = getConnection();
 
@@ -147,7 +149,7 @@ public class CredentialsDAOTest extends 
         fis.close();
 
         privateKey = (PrivateKey) ks.getKey("selfsigned", password);
-        x509Certificate = (X509Certificate) ks.getCertificate("selfsigned");
+        x509Certificates[0] = (X509Certificate) ks.getCertificate("selfsigned");
 
     }
 
@@ -155,10 +157,10 @@ public class CredentialsDAOTest extends 
     public void testKeyReading() throws Exception {
         initializeKeys();
         System.out.println(privateKey.getAlgorithm());
-        System.out.println(x509Certificate.getIssuerDN());
+        System.out.println(x509Certificates[0].getIssuerDN());
 
         Assert.assertNotNull(privateKey);
-        Assert.assertNotNull(x509Certificate);
+        Assert.assertNotNull(x509Certificates);
     }
 
     private CommunityUser getCommunityUser(String gateway, String name) {
@@ -183,7 +185,7 @@ public class CredentialsDAOTest extends 
 
         CertificateCredential certificateCredential = new CertificateCredential();
         certificateCredential.setToken("tom");
-        certificateCredential.setCertificate(x509Certificate);
+        certificateCredential.setCertificates(x509Certificates);
         certificateCredential.setPrivateKey(privateKey);
         certificateCredential.setCommunityUser(getCommunityUser("gw1", "tom"));
         certificateCredential.setLifeTime(1000);
@@ -204,7 +206,7 @@ public class CredentialsDAOTest extends 
         CertificateCredential readCertificateCredential = (CertificateCredential) CredentialsDAO
                 .convertByteArrayToObject(array);
 
-        Assert.assertEquals(certificateCredential.getCertificate(), readCertificateCredential.getCertificate());
+        checkEquality(certificateCredential.getCertificates(), readCertificateCredential.getCertificates());
         Assert.assertEquals(certificateCredential.getCertificateRequestedTime(),
                 readCertificateCredential.getCertificateRequestedTime());
         Assert.assertEquals(certificateCredential.getCommunityUser().getGatewayName(), readCertificateCredential
@@ -228,6 +230,18 @@ public class CredentialsDAOTest extends 
         Assert.assertTrue(Arrays.equals(privateKey.getEncoded(), newKey.getEncoded()));
     }
 
+    private void checkEquality(X509Certificate[] certificates1, X509Certificate[] certificates2) {
+
+        int i = 0;
+
+        for (X509Certificate certificate : certificates1) {
+            Assert.assertEquals(certificate, certificates2[i]);
+        }
+
+        Assert.assertEquals(certificates1.length, certificates2.length);
+
+    }
+
     @Test
     public void testAddCredentials() throws Exception {
 
@@ -240,7 +254,7 @@ public class CredentialsDAOTest extends 
                     "tom", connection);
             Assert.assertNotNull(certificateCredential);
             Assert.assertEquals("jerry", certificateCredential.getPortalUserName());
-            Assert.assertEquals(x509Certificate, certificateCredential.getCertificate());
+            checkEquality(x509Certificates, certificateCredential.getCertificates());
             Assert.assertEquals(privateKey.getFormat(), certificateCredential.getPrivateKey().getFormat());
         } finally {
             connection.close();
@@ -281,7 +295,7 @@ public class CredentialsDAOTest extends 
             CertificateCredential certificateCredential = new CertificateCredential();
             certificateCredential.setToken("tom");
             certificateCredential.setCommunityUser(communityUser);
-            certificateCredential.setCertificate(x509Certificate);
+            certificateCredential.setCertificates(x509Certificates);
             // certificateCredential.setPrivateKey(privateKey);
             certificateCredential.setPortalUserName("test2");
             certificateCredential.setLifeTime(50);
@@ -293,7 +307,7 @@ public class CredentialsDAOTest extends 
             certificateCredential = (CertificateCredential) credentialsDAO.getCredential("gw1", "tom", connection);
 
             Assert.assertEquals("CN=Airavata Project, OU=IU, O=Indiana University, L=Bloomington, ST=IN, C=US",
-                    certificateCredential.getCertificate().getIssuerDN().toString());
+                    certificateCredential.getCertificates()[0].getIssuerDN().toString());
             // Assert.assertNotNull(certificateCredential.getPrivateKey());
             Assert.assertEquals("test2", certificateCredential.getPortalUserName());
 
@@ -315,7 +329,7 @@ public class CredentialsDAOTest extends 
             CertificateCredential certificateCredential = (CertificateCredential) credentialsDAO.getCredential("gw1",
                     "tom", connection);
             Assert.assertEquals("CN=Airavata Project, OU=IU, O=Indiana University, L=Bloomington, ST=IN, C=US",
-                    certificateCredential.getCertificate().getIssuerDN().toString());
+                    certificateCredential.getCertificates()[0].getIssuerDN().toString());
             // Assert.assertNotNull(certificateCredential.getPrivateKey());
 
         } finally {

Added: airavata/trunk/modules/credential-store/src/test/java/org/apache/airavata/credential/store/util/ConfigurationReaderTest.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/credential-store/src/test/java/org/apache/airavata/credential/store/util/ConfigurationReaderTest.java?rev=1520473&view=auto
==============================================================================
--- airavata/trunk/modules/credential-store/src/test/java/org/apache/airavata/credential/store/util/ConfigurationReaderTest.java (added)
+++ airavata/trunk/modules/credential-store/src/test/java/org/apache/airavata/credential/store/util/ConfigurationReaderTest.java Fri Sep  6 02:03:01 2013
@@ -0,0 +1,58 @@
+/*
+ *
+ * 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/25/13
+ * Time: 10:28 AM
+ */
+
+public class ConfigurationReaderTest extends TestCase {
+    public void setUp() throws Exception {
+        super.setUp();
+
+    }
+
+    public void testGetSuccessUrl() throws Exception {
+
+        ConfigurationReader configurationReader = new ConfigurationReader();
+        System.out.println(configurationReader.getSuccessUrl());
+        Assert.assertEquals("/credential-store/success.jsp", configurationReader.getSuccessUrl());
+    }
+
+    public void testGetErrorUrl() throws Exception {
+
+        ConfigurationReader configurationReader = new ConfigurationReader();
+        Assert.assertEquals("/credential-store/error.jsp", configurationReader.getErrorUrl());
+
+    }
+
+    public void testRedirectUrl() throws Exception {
+
+        ConfigurationReader configurationReader = new ConfigurationReader();
+        Assert.assertEquals("/credential-store/show-redirect.jsp", configurationReader.getPortalRedirectUrl());
+    }
+}

Added: airavata/trunk/modules/credential-store/src/test/resources/credential-store/client.xml
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/credential-store/src/test/resources/credential-store/client.xml?rev=1520473&view=auto
==============================================================================
--- airavata/trunk/modules/credential-store/src/test/resources/credential-store/client.xml (added)
+++ airavata/trunk/modules/credential-store/src/test/resources/credential-store/client.xml Fri Sep  6 02:03:01 2013
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--Licensed to the Apache Software
+	Foundation (ASF) under one or more contributor license agreements. See the
+	NOTICE file distributed with this work for additional information regarding
+	copyright ownership. The ASF licenses this file to you under the Apache License,
+	Version 2.0 (theÏ "License"); you may not use this file except in compliance
+	with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+	Unless required by applicable law or agreed to in writing, software distributed
+	under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
+	OR CONDITIONS OF ANY ~ KIND, either express or implied. See the License for
+	the specific language governing permissions and limitations under the License. -->
+
+<config>
+    <client name="acs">
+        <logging
+                logFileName="../logs/oa4mp.log"
+                logName="oa4mp"
+                logSize="1000000"
+                logFileCount="2"
+                debug="true"/>
+        <id>myproxy:oa4mp,2012:/client/24c45c2eb65d93231d02d423e94d0362</id>
+        <serviceUri>https://portal.xsede.org/oauth</serviceUri>
+        <callbackUri>https://156.56.179.169:8443/airavata/callback</callbackUri>
+        <lifetime>864000</lifetime>
+        <publicKeyFile>../webapps/airavata/WEB-INF/classes/credential-store/oauth-pubkey.pem</publicKeyFile>
+        <privateKeyFile>../webapps/airavata/WEB-INF/classes/credential-store/oauth-privkey.pk8</privateKeyFile>
+    </client>
+
+    <credential-store>
+        <successUri>/credential-store/success.jsp</successUri>
+        <errorUri>/credential-store/error.jsp</errorUri>
+        <redirectUri>/credential-store/show-redirect.jsp</redirectUri>
+    </credential-store>
+
+</config>

Modified: airavata/trunk/modules/distribution/airavata-client/pom.xml
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/distribution/airavata-client/pom.xml?rev=1520473&r1=1520472&r2=1520473&view=diff
==============================================================================
--- airavata/trunk/modules/distribution/airavata-client/pom.xml (original)
+++ airavata/trunk/modules/distribution/airavata-client/pom.xml Fri Sep  6 02:03:01 2013
@@ -249,6 +249,11 @@
         </dependency>
         <dependency>
             <groupId>org.apache.airavata</groupId>
+            <artifactId>airavata-rest-mappings</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.airavata</groupId>
             <artifactId>json</artifactId>
             <version>${project.version}</version>
         </dependency>

Modified: airavata/trunk/modules/distribution/airavata-server/src/main/resources/conf/airavata-server.properties
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/distribution/airavata-server/src/main/resources/conf/airavata-server.properties?rev=1520473&r1=1520472&r2=1520473&view=diff
==============================================================================
--- airavata/trunk/modules/distribution/airavata-server/src/main/resources/conf/airavata-server.properties (original)
+++ airavata/trunk/modules/distribution/airavata-server/src/main/resources/conf/airavata-server.properties Fri Sep  6 02:03:01 2013
@@ -236,3 +236,5 @@ amqp.broadcast.sender=org.apache.airavat
 #http://localhost:8080/axis2/services/RegistryService?wsdl
 registry.service.wsdl=http://localhost:${port}/${server.context-root}/services/RegistryService?wsdl
 
+# If false, disables two phase commit when submitting jobs
+TwoPhase=true

Modified: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/GFacAPI.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/GFacAPI.java?rev=1520473&r1=1520472&r2=1520473&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/GFacAPI.java (original)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/GFacAPI.java Fri Sep  6 02:03:01 2013
@@ -176,7 +176,7 @@ public class GFacAPI {
                 handler.invoke(jobExecutionContext);
             } catch (Exception e) {
                 // TODO: Better error reporting.
-                throw new GFacException("Error Executing a OutFlow Handler" , e.getCause());
+                throw new GFacException("Error Executing a OutFlow Handler" , e);
             }
         }
     }

Modified: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/context/security/GSISecurityContext.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/context/security/GSISecurityContext.java?rev=1520473&r1=1520472&r2=1520473&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/context/security/GSISecurityContext.java (original)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/context/security/GSISecurityContext.java Fri Sep  6 02:03:01 2013
@@ -39,6 +39,7 @@ import org.globus.gsi.provider.GlobusPro
 import org.globus.myproxy.GetParams;
 import org.globus.myproxy.MyProxy;
 import org.globus.myproxy.MyProxyException;
+import org.gridforum.jgss.ExtendedGSSCredential;
 import org.ietf.jgss.GSSCredential;
 import org.ietf.jgss.GSSException;
 import org.slf4j.Logger;
@@ -184,13 +185,14 @@ public class GSISecurityContext extends 
 
                 CertificateCredential certificateCredential = (CertificateCredential) credential;
 
-                X509Certificate[] certificates = new X509Certificate[1];
-                certificates[0] = certificateCredential.getCertificate();
-
+                X509Certificate[] certificates = certificateCredential.getCertificates();
                 X509Credential newCredential = new X509Credential(certificateCredential.getPrivateKey(), certificates);
 
-                return new GlobusGSSCredentialImpl(newCredential,
-                        GSSCredential.INITIATE_AND_ACCEPT);
+                GlobusGSSCredentialImpl cred = new GlobusGSSCredentialImpl(newCredential, GSSCredential.INITIATE_AND_ACCEPT);
+                System.out.print(cred.export(ExtendedGSSCredential.IMPEXP_OPAQUE));
+                return cred;
+                //return new GlobusGSSCredentialImpl(newCredential,
+                //        GSSCredential.INITIATE_AND_ACCEPT);
             } else {
                 log.info("Credential type is not CertificateCredential. Cannot create mapping globus credentials. " +
                         "Credential type - " + credential.getClass().getName());

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=1520473&r1=1520472&r2=1520473&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 Fri Sep  6 02:03:01 2013
@@ -27,6 +27,8 @@ import java.net.MalformedURLException;
 import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
 
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.ServerSettings;
 import org.apache.airavata.gfac.GFacException;
 import org.apache.airavata.gfac.JobSubmissionFault;
 import org.apache.airavata.gfac.context.JobExecutionContext;
@@ -108,6 +110,17 @@ public class GramProvider implements GFa
 
     // This method prepare the environment before the application invocation.
     public void initialize(JobExecutionContext jobExecutionContext) throws GFacProviderException {
+
+        try {
+            String strTwoPhase = ServerSettings.getSetting("TwoPhase");
+            if (strTwoPhase != null) {
+                twoPhase = Boolean.parseBoolean(strTwoPhase);
+                log.info("Two phase commit is set to " + twoPhase);
+            }
+        } catch (ApplicationSettingsException e) {
+            log.warn("Error reading TwoPhase property from configurations.", e);
+        }
+
         job = GramProviderUtils.setupEnvironment(jobExecutionContext, twoPhase);
         listener = new GramJobSubmissionListener(job, jobExecutionContext);
         job.addListener(listener);

Modified: airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/client/DescriptorResourceClient.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/client/DescriptorResourceClient.java?rev=1520473&r1=1520472&r2=1520473&view=diff
==============================================================================
--- airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/client/DescriptorResourceClient.java (original)
+++ airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/client/DescriptorResourceClient.java Fri Sep  6 02:03:01 2013
@@ -163,18 +163,19 @@ public class DescriptorResourceClient {
                     MediaType.APPLICATION_JSON).post(ClientResponse.class, hostDescriptor);
             status = response.getStatus();
 
-            if (status != ClientConstant.HTTP_OK) {
-                logger.error(response.getEntity(String.class));
-                throw new RuntimeException("Failed : HTTP error code : "
-                        + status);
-            }else if (status == ClientConstant.HTTP_BAD_REQUEST){
-                logger.debug("Descriptor already exists...");
-                throw new DescriptorAlreadyExistsException(hostDescription.getType().getHostName());
-            } else {
+            if (status == ClientConstant.HTTP_OK) {
                 if (response.getCookies().size() > 0) {
                     cookie = response.getCookies().get(0).toCookie();
                     CookieManager.setCookie(cookie);
                 }
+            }else if (status == ClientConstant.HTTP_BAD_REQUEST){
+                logger.debug("Descriptor already exists...");
+                throw new DescriptorAlreadyExistsException(hostDescription.getType().getHostName());
+            } else {
+                logger.error(response.getEntity(String.class));
+                throw new RuntimeException("Failed : HTTP error code : "
+                        + status);
+
             }
         }else if (status == ClientConstant.HTTP_BAD_REQUEST){
             logger.debug("Descriptor already exists...");

Modified: airavata/trunk/modules/rest/webapp/src/main/resources/credential-store/client.xml
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/rest/webapp/src/main/resources/credential-store/client.xml?rev=1520473&r1=1520472&r2=1520473&view=diff
==============================================================================
--- airavata/trunk/modules/rest/webapp/src/main/resources/credential-store/client.xml (original)
+++ airavata/trunk/modules/rest/webapp/src/main/resources/credential-store/client.xml Fri Sep  6 02:03:01 2013
@@ -21,11 +21,18 @@
         <id>myproxy:oa4mp,2012:/client/24c45c2eb65d93231d02d423e94d0362</id>
         <serviceUri>https://portal.xsede.org/oauth</serviceUri>
         <!--callbackUri>https://156.56.179.104:8443/client/pages/client-success.jsp</callbackUri-->
-        <callbackUri>https://156.56.179.169:8443/airavata/callback</callbackUri>
+        <callbackUri>https://192.168.0.13:8443/airavata/callback</callbackUri>
         <lifetime>864000</lifetime>
         <!--publicKeyFile>/Users/thejaka/manager-server/webapps/airavata-registry/WEB-INF/classes/credential-store/oauth-pubkey.pem</publicKeyFile-->
         <publicKeyFile>../webapps/airavata/WEB-INF/classes/credential-store/oauth-pubkey.pem</publicKeyFile>
         <!--privateKeyFile>/Users/thejaka/manager-server/webapps/airavata-registry/WEB-INF/classes/credential-store/oauth-privkey.pk8</privateKeyFile-->
         <privateKeyFile>../webapps/airavata/WEB-INF/classes/credential-store/oauth-privkey.pk8</privateKeyFile>
     </client>
+
+    <credential-store>
+        <successUri>/credential-store/success.jsp</successUri>
+        <errorUri>/credential-store/error.jsp</errorUri>
+        <redirectUri>/credential-store/show-redirect.jsp</redirectUri>
+    </credential-store>
+
 </config>

Modified: airavata/trunk/modules/rest/webapp/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/rest/webapp/src/main/webapp/WEB-INF/web.xml?rev=1520473&r1=1520472&r2=1520473&view=diff
==============================================================================
--- airavata/trunk/modules/rest/webapp/src/main/webapp/WEB-INF/web.xml (original)
+++ airavata/trunk/modules/rest/webapp/src/main/webapp/WEB-INF/web.xml Fri Sep  6 02:03:01 2013
@@ -120,7 +120,7 @@
 
     <!-- Credential Store Configurations -->
     <servlet>
-        <servlet-name>credential-store</servlet-name>
+        <servlet-name>credential-store-start</servlet-name>
         <!--internal name of the servlet-->
         <servlet-class>org.apache.airavata.credential.store.servlet.CredentialStoreStartServlet</servlet-class>
 
@@ -129,9 +129,9 @@
     </servlet>
 
     <servlet-mapping>
-        <servlet-name>credential-store</servlet-name>
+        <servlet-name>credential-store-start</servlet-name>
         <!--the servlet-name above-->
-        <url-pattern>/credential-store</url-pattern>
+        <url-pattern>/acs-start-servlet</url-pattern>
         <!--what needs to be in the url, so http://foo.org/client/simple-->
     </servlet-mapping>
 

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=1520473&r1=1520472&r2=1520473&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 Fri Sep  6 02:03:01 2013
@@ -21,7 +21,7 @@
 <body>
 <h2>Sample Portal</h2>
 <p>This demonstrates how portal can use Credential Store to obtain community credentials ...</p>
-<form name="input" action="../credential-store" method="post">
+<form name="input" action="../acs-start-servlet" method="post">
 
     <table border="0">
         <tr>

Modified: airavata/trunk/modules/rest/webapp/src/main/webapp/credential-store/error.jsp
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/rest/webapp/src/main/webapp/credential-store/error.jsp?rev=1520473&r1=1520472&r2=1520473&view=diff
==============================================================================
--- airavata/trunk/modules/rest/webapp/src/main/webapp/credential-store/error.jsp (original)
+++ airavata/trunk/modules/rest/webapp/src/main/webapp/credential-store/error.jsp Fri Sep  6 02:03:01 2013
@@ -1,3 +1,4 @@
+<%@ page import="org.apache.airavata.credential.store.util.CredentialStoreConstants" %>
 <%--
   ~ Licensed to the Apache Software Foundation (ASF) under one
   ~ or more contributor license agreements. See the NOTICE file
@@ -17,28 +18,36 @@
   ~ under the License.
   --%>
   
-<script type="text/javascript">
-    function getUrlVars() {
-        var vars = {};
-        var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
-            vars[key] = value;
-        });
-        return vars;
-    }
-
-    var gatewayName = getUrlVars()["gatewayName"];
-    var portalUserName = getUrlVars()["portalUserName"];
-    var lifetime = getUrlVars()["lifetime"];
-
-    alert(gatewayName);
-    alert(portalUserName);
-    alert(lifetime);
 
+<%
+    String gatewayName = request.getParameter(CredentialStoreConstants.GATEWAY_NAME_QUERY_PARAMETER);
+    String portalUserName = request.getParameter(CredentialStoreConstants.PORTAL_USER_QUERY_PARAMETER);
+    Throwable exception = (Throwable) request.getAttribute("exception");
+
+%>
 
-</script>
 <html>
 <body>
 <h1>Credential Store</h1>
 <p>An error occurred while processing</p>
+<p>
+    Gateway Name - <%=gatewayName%>. Portal user name - <%=portalUserName%>.
+    Exception -
+
+</p>
+
+<p>
+    <%
+
+        out.println("Exception - " + exception.getMessage());
+        out.println();
+        StackTraceElement[] elements = exception.getStackTrace();
+        for (StackTraceElement element : elements) {
+            out.print("         ");
+            out.println(element.toString());
+        }
+
+    %>
+</p>
 </body>
 </html>

Modified: airavata/trunk/modules/rest/webapp/src/main/webapp/credential-store/show-redirect.jsp
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/rest/webapp/src/main/webapp/credential-store/show-redirect.jsp?rev=1520473&r1=1520472&r2=1520473&view=diff
==============================================================================
--- airavata/trunk/modules/rest/webapp/src/main/webapp/credential-store/show-redirect.jsp (original)
+++ airavata/trunk/modules/rest/webapp/src/main/webapp/credential-store/show-redirect.jsp Fri Sep  6 02:03:01 2013
@@ -18,12 +18,17 @@
   --%>
   
 <%@ page contentType="text/html;charset=UTF-8" language="java" %>
+
+<%
+    String redirectUrlInRequest = (String) request.getAttribute("redirectUrl");
+%>
+
 <html>
 <head>
     <script type="text/javascript">
         <!--
         function redirect(){
-            window.location = "${redirectUrl}"
+            window.location = "<%=redirectUrlInRequest%>"
         }
         //-->
     </script>
@@ -32,7 +37,7 @@
 <h2>You will be now redirect to MyProxy portal !</h2>
 <p>
     If your browser didn't redirect to MyProxy Portal within 1 minute click following link,
-    <br><br> <a href="${redirectUrl}">${redirectUrl}</a>
+    <br><br> <a href="<%=redirectUrlInRequest%>"><%=redirectUrlInRequest%></a>
 </p>
 
 </body>

Modified: airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/invoker/EmbeddedGFacInvoker.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/invoker/EmbeddedGFacInvoker.java?rev=1520473&r1=1520472&r2=1520473&view=diff
==============================================================================
--- airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/invoker/EmbeddedGFacInvoker.java (original)
+++ airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/invoker/EmbeddedGFacInvoker.java Fri Sep  6 02:03:01 2013
@@ -421,7 +421,7 @@ public class EmbeddedGFacInvoker impleme
             GSISecurityContext context;
             RequestData requestData;
 
-            String gatewayId = jobExecutionContext.getGFacConfiguration().getAiravataAPI().getGateway();
+            String gatewayId = contextHeader.getSecurityContext().getCredentialManagementService().getGatewayId();
 
             if (credentialManagementService != null) {
                 String tokenId



Mime
View raw message