You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ch...@apache.org on 2014/06/24 20:23:39 UTC

[5/5] git commit: initial changes to make credential store as a seperate webapp

initial changes to make credential store as a seperate webapp


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

Branch: refs/heads/master
Commit: 5c7acf3012060cdc69e0f6cf1c02b4ddd426827d
Parents: 4c34a51
Author: Chathuri Wimalasena <ka...@gmail.com>
Authored: Tue Jun 24 14:23:26 2014 -0400
Committer: Chathuri Wimalasena <ka...@gmail.com>
Committed: Tue Jun 24 14:23:26 2014 -0400

----------------------------------------------------------------------
 .../apache/airavata/common/utils/DBUtil.java    |   5 +-
 .../session/HttpAuthenticatorFilter.java        | 191 +++++++++
 .../session/ServletRequestHelper.java           | 118 ++++++
 .../main/resources/credential-store/client.xml  |  35 ++
 .../credential-store/oauth-privkey.pk8          |  28 ++
 .../resources/credential-store/oauth-pubkey.pem |   9 +
 .../src/main/webapp/WEB-INF/web.xml             | 130 ++++++
 .../src/main/webapp/credential-store/error.jsp  |  53 +++
 .../credential-store/password-credentials.jsp   |  33 ++
 .../webapp/credential-store/show-redirect.jsp   |  44 ++
 .../main/webapp/credential-store/success.jsp    |  25 ++
 .../src/main/webapp/gateway/acs.jsp             |  62 +++
 .../src/main/webapp/gateway/callback.jsp        |  78 ++++
 .../src/main/webapp/gateway/list_users.jsp      |  78 ++++
 .../src/main/webapp/gateway/logout.jsp          |  35 ++
 .../src/main/webapp/gateway/user.jsp            | 102 +++++
 .../src/main/webapp/index.jsp                   |  26 ++
 .../credential-store/pom.xml                    | 147 +++++++
 .../scripts/credential-store-h2.sql             |  42 ++
 .../scripts/credential-store-mysql.sql          |  42 ++
 .../credential/store/credential/AuditInfo.java  |  53 +++
 .../store/credential/CommunityUser.java         |  71 ++++
 .../credential/store/credential/Credential.java |  62 +++
 .../impl/certificate/CertificateAuditInfo.java  | 101 +++++
 .../impl/certificate/CertificateCredential.java | 102 +++++
 .../impl/password/PasswordCredential.java       |  52 +++
 .../credential/impl/ssh/SSHCredential.java      |  73 ++++
 .../impl/ssh/SSHCredentialGenerator.java        |  91 ++++
 .../store/notifier/CredentialStoreNotifier.java |  42 ++
 .../store/notifier/NotificationMessage.java     |  46 ++
 .../store/notifier/NotifierBootstrap.java       | 144 +++++++
 .../notifier/impl/EmailNotificationMessage.java |  58 +++
 .../store/notifier/impl/EmailNotifier.java      |  71 ++++
 .../impl/EmailNotifierConfiguration.java        |  84 ++++
 .../store/servlet/CredentialBootstrapper.java   |  49 +++
 .../servlet/CredentialStoreCallbackServlet.java | 272 ++++++++++++
 .../servlet/CredentialStoreStartServlet.java    | 164 +++++++
 .../store/store/CredentialReader.java           | 101 +++++
 .../store/store/CredentialReaderFactory.java    |  54 +++
 .../store/store/CredentialStoreException.java   |  40 ++
 .../store/store/CredentialWriter.java           |  39 ++
 .../store/impl/CertificateCredentialWriter.java | 121 ++++++
 .../store/store/impl/CredentialReaderImpl.java  | 152 +++++++
 .../store/store/impl/SSHCredentialWriter.java   |  87 ++++
 .../store/store/impl/db/CommunityUserDAO.java   | 257 +++++++++++
 .../store/store/impl/db/CredentialsDAO.java     | 424 +++++++++++++++++++
 .../store/store/impl/db/ParentDAO.java          |  37 ++
 .../store/util/ConfigurationReader.java         | 121 ++++++
 .../store/util/CredentialStoreConstants.java    |  37 ++
 .../credential/store/util/PrivateKeyStore.java  |  70 +++
 .../credential/store/util/TokenGenerator.java   |  57 +++
 .../airavata/credential/store/util/Utility.java |  78 ++++
 .../store/notifier/impl/EmailNotifierTest.java  |  56 +++
 .../store/impl/db/CommunityUserDAOTest.java     | 207 +++++++++
 .../store/store/impl/db/CredentialsDAOTest.java | 418 ++++++++++++++++++
 .../store/util/ConfigurationReaderTest.java     |  58 +++
 .../store/util/TokenGeneratorTest.java          |  42 ++
 .../test/resources/credential-store/client.xml  |  35 ++
 .../src/test/resources/keystore.jks             | Bin 0 -> 2230 bytes
 .../src/test/resources/mykeystore.jks           | Bin 0 -> 498 bytes
 modules/credential-store-service/pom.xml        |  42 ++
 modules/credential-store/pom.xml                | 147 -------
 .../scripts/credential-store-h2.sql             |  42 --
 .../scripts/credential-store-mysql.sql          |  42 --
 .../credential/store/credential/AuditInfo.java  |  53 ---
 .../store/credential/CommunityUser.java         |  71 ----
 .../credential/store/credential/Credential.java |  62 ---
 .../impl/certificate/CertificateAuditInfo.java  | 101 -----
 .../impl/certificate/CertificateCredential.java | 102 -----
 .../impl/password/PasswordCredential.java       |  52 ---
 .../credential/impl/ssh/SSHCredential.java      |  73 ----
 .../impl/ssh/SSHCredentialGenerator.java        |  91 ----
 .../store/notifier/CredentialStoreNotifier.java |  42 --
 .../store/notifier/NotificationMessage.java     |  46 --
 .../store/notifier/NotifierBootstrap.java       | 144 -------
 .../notifier/impl/EmailNotificationMessage.java |  58 ---
 .../store/notifier/impl/EmailNotifier.java      |  71 ----
 .../impl/EmailNotifierConfiguration.java        |  84 ----
 .../store/servlet/CredentialBootstrapper.java   |  49 ---
 .../servlet/CredentialStoreCallbackServlet.java | 270 ------------
 .../servlet/CredentialStoreStartServlet.java    | 164 -------
 .../store/store/CredentialReader.java           | 101 -----
 .../store/store/CredentialReaderFactory.java    |  54 ---
 .../store/store/CredentialStoreException.java   |  40 --
 .../store/store/CredentialWriter.java           |  39 --
 .../store/impl/CertificateCredentialWriter.java | 121 ------
 .../store/store/impl/CredentialReaderImpl.java  | 152 -------
 .../store/store/impl/SSHCredentialWriter.java   |  87 ----
 .../store/store/impl/db/CommunityUserDAO.java   | 257 -----------
 .../store/store/impl/db/CredentialsDAO.java     | 424 -------------------
 .../store/store/impl/db/ParentDAO.java          |  37 --
 .../store/util/ConfigurationReader.java         | 121 ------
 .../store/util/CredentialStoreConstants.java    |  37 --
 .../credential/store/util/PrivateKeyStore.java  |  70 ---
 .../credential/store/util/TokenGenerator.java   |  57 ---
 .../airavata/credential/store/util/Utility.java |  78 ----
 .../store/notifier/impl/EmailNotifierTest.java  |  56 ---
 .../store/impl/db/CommunityUserDAOTest.java     | 207 ---------
 .../store/store/impl/db/CredentialsDAOTest.java | 418 ------------------
 .../store/util/ConfigurationReaderTest.java     |  58 ---
 .../store/util/TokenGeneratorTest.java          |  42 --
 .../test/resources/credential-store/client.xml  |  35 --
 .../src/test/resources/keystore.jks             | Bin 2230 -> 0 bytes
 .../src/test/resources/mykeystore.jks           | Bin 498 -> 0 bytes
 modules/security/pom.xml                        |   2 +-
 pom.xml                                         |   4 +-
 106 files changed, 5350 insertions(+), 4262 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/5c7acf30/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/DBUtil.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/DBUtil.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/DBUtil.java
index f720677..bb2ff1d 100644
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/DBUtil.java
+++ b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/DBUtil.java
@@ -310,11 +310,10 @@ public class DBUtil {
      *
      * @return DBUtil object.
      * @throws Exception
-     *             If an error occurred while reading configurations or while creating database object.
+     * If an error occurred while reading configurations or while creating database object.
      */
     public static DBUtil getCredentialStoreDBUtil() throws ApplicationSettingsException, IllegalAccessException,
             ClassNotFoundException, InstantiationException {
-          /* todo fix this
         String jdbcUrl = ServerSettings.getCredentialStoreDBURL();
         String userName = ServerSettings.getCredentialStoreDBUser();
         String password = ServerSettings.getCredentialStoreDBPassword();
@@ -330,8 +329,6 @@ public class DBUtil {
         dbUtil.init();
 
         return dbUtil;
-        */
-        return null;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/5c7acf30/modules/credential-store-service/credential-store-webapp/src/main/java/org/apache/airavata/credentialstore/session/HttpAuthenticatorFilter.java
----------------------------------------------------------------------
diff --git a/modules/credential-store-service/credential-store-webapp/src/main/java/org/apache/airavata/credentialstore/session/HttpAuthenticatorFilter.java b/modules/credential-store-service/credential-store-webapp/src/main/java/org/apache/airavata/credentialstore/session/HttpAuthenticatorFilter.java
new file mode 100644
index 0000000..0847d54
--- /dev/null
+++ b/modules/credential-store-service/credential-store-webapp/src/main/java/org/apache/airavata/credentialstore/session/HttpAuthenticatorFilter.java
@@ -0,0 +1,191 @@
+/*
+ * 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.credentialstore.session;
+
+import org.apache.airavata.security.AuthenticationException;
+import org.apache.airavata.security.Authenticator;
+import org.apache.airavata.security.configurations.AuthenticatorConfigurationReader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.xml.sax.SAXException;
+
+import javax.servlet.*;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Calendar;
+import java.util.List;
+
+/**
+ * A servlet filter class which intercepts the request and do authentication.
+ */
+public class HttpAuthenticatorFilter implements Filter {
+
+    private List<Authenticator> authenticatorList;
+
+    private static Logger log = LoggerFactory.getLogger(HttpAuthenticatorFilter.class);
+
+    private ServletRequestHelper servletRequestHelper = new ServletRequestHelper();
+
+    @Override
+    public void init(FilterConfig filterConfig) throws ServletException {
+        String authenticatorConfiguration = filterConfig.getInitParameter("authenticatorConfigurations");
+
+        //TODO make this able to read from a file as well
+
+
+        InputStream configurationFileStream = HttpAuthenticatorFilter.class.getClassLoader().
+                getResourceAsStream(authenticatorConfiguration);
+
+        if (configurationFileStream == null) {
+            String msg = "Invalid authenticator configuration. Cannot read file - ".concat(authenticatorConfiguration);
+            log.error(msg);
+            throw new ServletException(msg);
+        }
+
+        AuthenticatorConfigurationReader authenticatorConfigurationReader
+                = new AuthenticatorConfigurationReader();
+        try {
+            authenticatorConfigurationReader.init(configurationFileStream);
+        } catch (IOException e) {
+            String msg = "Error reading authenticator configurations.";
+
+            log.error(msg, e);
+            throw new ServletException(msg, e);
+        } catch (ParserConfigurationException e) {
+            String msg = "Error parsing authenticator configurations.";
+
+            log.error(msg, e);
+            throw new ServletException(msg, e);
+        } catch (SAXException e) {
+            String msg = "Error parsing authenticator configurations.";
+
+            log.error(msg, e);
+            throw new ServletException(msg, e);
+        } finally {
+            try {
+                configurationFileStream.close();
+            } catch (IOException e) {
+                log.error("Error closing authenticator file stream.", e);
+            }
+        }
+
+        this.authenticatorList = authenticatorConfigurationReader.getAuthenticatorList();
+
+        if (this.authenticatorList.isEmpty()) {
+            String msg = "No authenticators registered in the system. System cannot function without authenticators";
+            log.error(msg);
+            throw new ServletException(msg);
+        }
+
+    }
+
+    @Override
+    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
+
+        // Firs check whether authenticators are disabled
+        if (! AuthenticatorConfigurationReader.isAuthenticationEnabled()) {
+
+            // Extract user id and gateway id
+            try {
+                servletRequestHelper.addIdentityInformationToSession((HttpServletRequest) servletRequest);
+            } catch (AuthenticationException e) {
+                log.warn("Error adding identity information to session.", e);
+                populateUnauthorisedData(servletResponse, "Error adding identity information to session.");
+
+            }
+
+            filterChain.doFilter(servletRequest, servletResponse);
+            return;
+        }
+
+        HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest;
+
+        Authenticator authenticator = getAuthenticator(httpServletRequest);
+
+        if (authenticator == null) {
+            //sendUnauthorisedError(servletResponse, "Invalid request. Request does not contain sufficient credentials to authenticate");
+            populateUnauthorisedData(servletResponse, "Invalid request. Request does not contain sufficient credentials to authenticate");
+        } else {
+            if (authenticator.isAuthenticated(httpServletRequest)) {
+                // Allow request to flow
+                filterChain.doFilter(servletRequest, servletResponse);
+            } else {
+                try {
+                    if (!authenticator.authenticate(httpServletRequest)) {
+                        //sendUnauthorisedError(servletResponse, "Unauthorised : Provided credentials are not valid.");
+                        populateUnauthorisedData(servletResponse, "Invalid request. Request does not contain sufficient credentials to authenticate");
+                    } else {
+                        // Allow request to flow
+                        filterChain.doFilter(servletRequest, servletResponse);
+                    }
+                } catch (AuthenticationException e) {
+                    String msg = "An error occurred while authenticating request.";
+                    log.error(msg, e);
+                    //sendUnauthorisedError(servletResponse, e.getMessage());
+                    populateUnauthorisedData(servletResponse, "Invalid request. Request does not contain sufficient credentials to authenticate");
+                }
+            }
+        }
+    }
+
+    public static void sendUnauthorisedError(ServletResponse servletResponse, String message) throws IOException {
+        HttpServletResponse httpServletResponse = (HttpServletResponse) servletResponse;
+        httpServletResponse.sendError(HttpServletResponse.SC_UNAUTHORIZED, message);
+    }
+
+    @Override
+    public void destroy() {
+
+        this.authenticatorList = null;
+    }
+
+    private Authenticator getAuthenticator(HttpServletRequest httpServletRequest) {
+
+        for (Authenticator authenticator : authenticatorList) {
+            if (authenticator.canProcess(httpServletRequest)) {
+                return authenticator;
+            }
+        }
+
+        return null;
+    }
+
+    /**
+     * This method will create a 401 unauthorized response to be sent.
+     *
+     * @param servletResponse The HTTP response.
+     */
+    public static void populateUnauthorisedData(ServletResponse servletResponse, String message) {
+
+        HttpServletResponse httpServletResponse = (HttpServletResponse)servletResponse;
+
+        httpServletResponse.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
+        httpServletResponse.addHeader("Server", "Airavata Server");
+        httpServletResponse.addHeader("Description", message);
+        httpServletResponse.addDateHeader("Date", Calendar.getInstance().getTimeInMillis());
+        httpServletResponse.addHeader("WWW-Authenticate", "Basic realm=Airavata");
+        httpServletResponse.setContentType("text/html");
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/5c7acf30/modules/credential-store-service/credential-store-webapp/src/main/java/org/apache/airavata/credentialstore/session/ServletRequestHelper.java
----------------------------------------------------------------------
diff --git a/modules/credential-store-service/credential-store-webapp/src/main/java/org/apache/airavata/credentialstore/session/ServletRequestHelper.java b/modules/credential-store-service/credential-store-webapp/src/main/java/org/apache/airavata/credentialstore/session/ServletRequestHelper.java
new file mode 100644
index 0000000..c7cc85b
--- /dev/null
+++ b/modules/credential-store-service/credential-store-webapp/src/main/java/org/apache/airavata/credentialstore/session/ServletRequestHelper.java
@@ -0,0 +1,118 @@
+/*
+ *
+ * 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.credentialstore.session;
+
+import org.apache.airavata.common.context.RequestContext;
+import org.apache.airavata.common.context.WorkflowContext;
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.Constants;
+import org.apache.airavata.common.utils.ServerSettings;
+import org.apache.airavata.security.AuthenticationException;
+import org.apache.commons.codec.binary.Base64;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * Helper class to extract request information.
+ */
+public class ServletRequestHelper {
+
+    /**
+     * Header names
+     */
+    public static final String AUTHORISATION_HEADER_NAME = "Authorization";
+
+    protected void addIdentityInformationToSession(HttpServletRequest servletRequest) throws AuthenticationException {
+
+        addUserToSession(null, servletRequest);
+    }
+
+    public void addUserToSession(String userName, HttpServletRequest servletRequest) throws AuthenticationException {
+
+        if (userName == null) {
+            userName = getUserName(servletRequest);
+        }
+
+        String gatewayId = getGatewayId(servletRequest);
+
+        if (servletRequest.getSession() != null) {
+            servletRequest.getSession().setAttribute(Constants.USER_IN_SESSION, userName);
+            servletRequest.getSession().setAttribute(Constants.GATEWAY_NAME, gatewayId);
+        }
+
+        addToContext(userName, gatewayId);
+    }
+
+    String getUserName(HttpServletRequest httpServletRequest) throws AuthenticationException {
+
+        String basicHeader = httpServletRequest.getHeader(AUTHORISATION_HEADER_NAME);
+
+        if (basicHeader == null) {
+            throw new AuthenticationException("Authorization Required");
+        }
+
+        String[] userNamePasswordArray = basicHeader.split(" ");
+
+        if (userNamePasswordArray == null || userNamePasswordArray.length != 2) {
+            throw new AuthenticationException("Authorization Required");
+        }
+
+        String decodedString = decode(userNamePasswordArray[1]);
+
+        String[] array = decodedString.split(":");
+
+        if (array == null || array.length != 1) {
+            throw new AuthenticationException("Authorization Required");
+        }
+
+        return array[0];
+
+    }
+
+    public String decode(String encoded) {
+        return new String(Base64.decodeBase64(encoded.getBytes()));
+    }
+
+    String getGatewayId(HttpServletRequest request) throws AuthenticationException {
+        String gatewayId = request.getHeader(Constants.GATEWAY_NAME);
+
+        if (gatewayId == null) {
+            try {
+                gatewayId = ServerSettings.getSystemUserGateway();
+            } catch (ApplicationSettingsException e) {
+                throw new AuthenticationException("Unable to retrieve default gateway", e);
+            }
+        }
+
+        return gatewayId;
+    }
+
+    public void addToContext(String userName, String gatewayId) {
+
+        RequestContext requestContext = new RequestContext();
+        requestContext.setUserIdentity(userName);
+        requestContext.setGatewayId(gatewayId);
+
+        WorkflowContext.set(requestContext);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/5c7acf30/modules/credential-store-service/credential-store-webapp/src/main/resources/credential-store/client.xml
----------------------------------------------------------------------
diff --git a/modules/credential-store-service/credential-store-webapp/src/main/resources/credential-store/client.xml b/modules/credential-store-service/credential-store-webapp/src/main/resources/credential-store/client.xml
new file mode 100644
index 0000000..b6cdb1a
--- /dev/null
+++ b/modules/credential-store-service/credential-store-webapp/src/main/resources/credential-store/client.xml
@@ -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/5a323fc6fcffcff7a95401046a303520</id>
+        <serviceUri>https://oa4mp.xsede.org/oauth</serviceUri>
+        <callbackUri>https://149.160.145.44:8443/credential-store/callback</callbackUri>
+        <lifetime>864000</lifetime>
+        <publicKeyFile>/Users/chathuri/dev/airavata/source/trunk_git/airavata/modules/credential-store-service/credential-store-webapp/keys/credential-store/oauth-pubkey.pem</publicKeyFile>
+        <privateKeyFile>/Users/chathuri/dev/airavata/source/trunk_git/airavata/modules/credential-store-service/credential-store-webapp/keys/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>

http://git-wip-us.apache.org/repos/asf/airavata/blob/5c7acf30/modules/credential-store-service/credential-store-webapp/src/main/resources/credential-store/oauth-privkey.pk8
----------------------------------------------------------------------
diff --git a/modules/credential-store-service/credential-store-webapp/src/main/resources/credential-store/oauth-privkey.pk8 b/modules/credential-store-service/credential-store-webapp/src/main/resources/credential-store/oauth-privkey.pk8
new file mode 100644
index 0000000..60f5b03
--- /dev/null
+++ b/modules/credential-store-service/credential-store-webapp/src/main/resources/credential-store/oauth-privkey.pk8
@@ -0,0 +1,28 @@
+-----BEGIN PRIVATE KEY-----
+MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCx/4hqCePa3scs
+oyGuwjnNdQCGfoPBlaCfl02Xq4L623EygIVo0faCX1ZZ/gA9ldw0TqZ6weCHfGck
+22TLeFQnJ4plAqJMMUbYwqmhnSsC9zTuc+c/yzcvdw2aCLPkMXnofFUasQEGhPI3
+/avTHOeUYBeu4ZU3u7G2Dp0jMDg1yh95v0FnGAjSPSBWQm1q4sxT90YB8jZyGvZ8
+kRs4S9Ik8Vz1VKNHJ16LZOuThfsRV4Af7vM8jXztjKUsrxQf1ZpKauAvXbJcDS2O
+pTjHWSvASk2pQxnDZDNcENE40MtG7V7qiDblMCuYumO8xnsJIGLreMKnSOQZKnDL
+uoBPNLB9AgMBAAECggEBAIJtcfHxaUr5rwygRJAftec88rOahMUW9Om8Hpkijglv
+PtT4o8kZAP6rCUVL/7Ug2IhjkU2mPvZIS/QP5x3JADDoolo9wdr+yKEQkuffmKLF
+rb2EpFB0ge1/2TGjat2s+11Frb6vMMcsJ6ircnpxVae9ed0lYwfBuwhiUPZ14NpY
+Figcq4mbM1fOmKIc035sR/fRVeuSEYPguw0sZkkx9LPGluvNXypwhfho60WCpxaB
+tgAadJRQgTEqz4kjHDD7xqY0w/KUJyqCOaJHnv2RmrdwrzDWFls6ETcc93PmINJU
+Mt2uLZZdd2nlZki91EhHA5XpPC1LoM2qXKaShfUMDWkCgYEA2oSVtz0ftT1njuX2
+OjsJi3ENOjmSuHaw81h72ZcIskCVrxZVeq0LGJdBQt361Q5ZhtnIgPA1bJXWtQ9s
+miFGkkPiPJb5GI45aLqpv+dJ/F/tXa0Q9LN++hfW8fKN8LejlM6tTiiYs3EqYEXO
+qqcLPoptxak8ZwDkOfj8yvJib6cCgYEA0IesCrCy8fpjVeDQdiAlIZqsecPJ2+Fz
+jLMik2hvAk6Yiyd8DmK8HMtSPfYMN4BhiphW49TXSyIoFEeCRQE8KMdSu3W4Z1wP
+AURZzQL78GRHc1n7EgCi2gzu38rSQDekmaQYr/hw+IlTpURjT68pDGKYXOybbjxu
+zUb67PHaAzsCgYADgs/ZAt1ojxUD4cQECYDMwcNBpT0rQ5TyRACxbVDRdGIzTvuO
+ngsomP2OcnyeQb3EgelL0RA6r2mkvRu0mkZFAVw4NwDHmTlo6l7h23h/2pa4w5gb
+Jmsq34kvmAMZ1AmH0Y5NTC+v6miQ5W49pbNzjMvYujBjQ0tndw2wwRY9zwKBgQDG
+FksgcI/b+z1Hg+Kig5CiJlr25DypibWJD1Wl74ucBmszrNNUmwgU1jOOtl8Ojf6a
+eHH5xOKq9YxbDz65LB4oood9masNTE7YpkQj0lTfG3MgKXatuDr6pVR49CLba8AJ
+Tu9AoeE2xsTVdmxccoiswi/3/a78fZ3HlEiism+lpwKBgCx7aX3MESqgxbf1kHgI
+Tu0nnvu06UwzAhBU6IpGKCqwu8zwfGN/PTTTz95hySUc1S4fSLuHVrdTAQTT3Zwr
+hwX85AxYdiyGhbeXFLue+eDWQ7PxAKXfRAwsKpdC72ixkXVqnVRh2yhRMPqKqnEu
+A5i3nuKHICZgD2fwQf+A8OL6
+-----END PRIVATE KEY-----

http://git-wip-us.apache.org/repos/asf/airavata/blob/5c7acf30/modules/credential-store-service/credential-store-webapp/src/main/resources/credential-store/oauth-pubkey.pem
----------------------------------------------------------------------
diff --git a/modules/credential-store-service/credential-store-webapp/src/main/resources/credential-store/oauth-pubkey.pem b/modules/credential-store-service/credential-store-webapp/src/main/resources/credential-store/oauth-pubkey.pem
new file mode 100644
index 0000000..f094a6d
--- /dev/null
+++ b/modules/credential-store-service/credential-store-webapp/src/main/resources/credential-store/oauth-pubkey.pem
@@ -0,0 +1,9 @@
+-----BEGIN PUBLIC KEY-----
+MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsf+Iagnj2t7HLKMhrsI5
+zXUAhn6DwZWgn5dNl6uC+ttxMoCFaNH2gl9WWf4APZXcNE6mesHgh3xnJNtky3hU
+JyeKZQKiTDFG2MKpoZ0rAvc07nPnP8s3L3cNmgiz5DF56HxVGrEBBoTyN/2r0xzn
+lGAXruGVN7uxtg6dIzA4Ncofeb9BZxgI0j0gVkJtauLMU/dGAfI2chr2fJEbOEvS
+JPFc9VSjRydei2Trk4X7EVeAH+7zPI187YylLK8UH9WaSmrgL12yXA0tjqU4x1kr
+wEpNqUMZw2QzXBDRONDLRu1e6og25TArmLpjvMZ7CSBi63jCp0jkGSpwy7qATzSw
+fQIDAQAB
+-----END PUBLIC KEY-----

http://git-wip-us.apache.org/repos/asf/airavata/blob/5c7acf30/modules/credential-store-service/credential-store-webapp/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/modules/credential-store-service/credential-store-webapp/src/main/webapp/WEB-INF/web.xml b/modules/credential-store-service/credential-store-webapp/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..252f889
--- /dev/null
+++ b/modules/credential-store-service/credential-store-webapp/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,130 @@
+<?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. -->
+
+<!-- This web.xml file is not required when using Servlet 3.0 container,
+     see implementation details http://jersey.java.net/nonav/documentation/latest/jax-rs.html#d4e194 -->
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xmlns="http://java.sun.com/xml/ns/javaee"
+         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+         id="WebApp_ID" version="2.5">
+
+    <listener>
+        <listener-class>org.apache.airavata.credential.store.servlet.CredentialBootstrapper</listener-class>
+    </listener>
+
+    <context-param>
+        <param-name>oa4mp:client.config.file</param-name>
+        <param-value>${catalina.home}/webapps/credential-store/WEB-INF/classes/credential-store/client.xml</param-value>
+    </context-param>
+
+    <!-- Credential store parameters -->
+    <context-param>
+        <param-name>credential-store-jdbc-url</param-name>
+        <param-value>jdbc:mysql://localhost/airavata</param-value>
+    </context-param>
+
+    <context-param>
+        <param-name>credential-store-db-user</param-name>
+        <param-value>root</param-value>
+    </context-param>
+
+    <context-param>
+        <param-name>credential-store-db-password</param-name>
+        <param-value>root123</param-value>
+    </context-param>
+
+    <context-param>
+        <param-name>credential-store-db-driver</param-name>
+        <param-value>com.mysql.jdbc.Driver</param-value>
+    </context-param>
+
+    <!-- ========================= Security Related Configurations go here ================================== -->
+
+    <filter>
+        <filter-name>CORS Filter</filter-name>
+        <filter-class>org.ebaysf.web.cors.CORSFilter</filter-class>
+        <init-param>
+            <description>A comma separated list of allowed origins. Note: An '*' cannot be used for an allowed origin when using credentials.</description>
+            <param-name>cors.allowed.origins</param-name>
+            <param-value>*</param-value>
+        </init-param>
+        <init-param>
+            <param-name>cors.allowed.methods</param-name>
+            <param-value>GET,POST,HEAD,OPTIONS,PUT</param-value>
+        </init-param>
+        <init-param>
+            <param-name>cors.allowed.headers</param-name>
+            <param-value>Content-Type,X-Requested-With,accept,Origin,Access-Control-Request-Method,Access-Control-Request-Headers,Authorization</param-value>
+        </init-param>
+        <init-param>
+            <param-name>cors.exposed.headers</param-name>
+            <param-value></param-value>
+        </init-param>
+        <init-param>
+            <param-name>cors.support.credentials</param-name>
+            <param-value>true</param-value>
+        </init-param>
+        <init-param>
+            <param-name>cors.logging.enabled</param-name>
+            <param-value>false</param-value>
+        </init-param>
+        <init-param>
+            <param-name>cors.preflight.maxage</param-name>
+            <param-value>1800</param-value>
+        </init-param>
+        <init-param>
+            <param-name>cors.request.decorate</param-name>
+            <param-value>true</param-value>
+        </init-param>
+    </filter>
+
+    <filter-mapping>
+        <filter-name>CORS Filter</filter-name>
+        <url-pattern>/user-store/*</url-pattern>
+    </filter-mapping>
+
+    <!-- ================================ End Security Related Configurations =============================== -->
+
+    <!-- Credential Store Configurations -->
+    <servlet>
+        <servlet-name>credential-store-start</servlet-name>
+        <!--internal name of the servlet-->
+        <servlet-class>org.apache.airavata.credential.store.servlet.CredentialStoreStartServlet</servlet-class>
+
+        <load-on-startup>1</load-on-startup>
+        <!--load as soon as tomcat starts?-->
+    </servlet>
+
+    <servlet-mapping>
+        <servlet-name>credential-store-start</servlet-name>
+        <!--the servlet-name above-->
+        <url-pattern>/acs-start-servlet</url-pattern>
+        <!--what needs to be in the url, so http://foo.org/client/simple-->
+    </servlet-mapping>
+
+    <servlet>
+        <servlet-name>callback</servlet-name>
+        <!--internal name of the servlet-->
+        <servlet-class>org.apache.airavata.credential.store.servlet.CredentialStoreCallbackServlet</servlet-class>
+        <load-on-startup>1</load-on-startup>
+        <!--load as soon as tomcat starts?-->
+    </servlet>
+
+    <servlet-mapping>
+        <servlet-name>callback</servlet-name>
+        <!--the servlet-name above-->
+        <url-pattern>/callback</url-pattern>
+        <!--what needs to be in the url, so http://foo.org/client/simple-->
+    </servlet-mapping>
+</web-app>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/5c7acf30/modules/credential-store-service/credential-store-webapp/src/main/webapp/credential-store/error.jsp
----------------------------------------------------------------------
diff --git a/modules/credential-store-service/credential-store-webapp/src/main/webapp/credential-store/error.jsp b/modules/credential-store-service/credential-store-webapp/src/main/webapp/credential-store/error.jsp
new file mode 100644
index 0000000..adc430d
--- /dev/null
+++ b/modules/credential-store-service/credential-store-webapp/src/main/webapp/credential-store/error.jsp
@@ -0,0 +1,53 @@
+<%@ 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
+  ~ 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.
+  --%>
+  
+
+<%
+    String gatewayName = request.getParameter(CredentialStoreConstants.GATEWAY_NAME_QUERY_PARAMETER);
+    String portalUserName = request.getParameter(CredentialStoreConstants.PORTAL_USER_QUERY_PARAMETER);
+    Throwable exception = (Throwable) request.getAttribute("exception");
+
+%>
+
+<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>

http://git-wip-us.apache.org/repos/asf/airavata/blob/5c7acf30/modules/credential-store-service/credential-store-webapp/src/main/webapp/credential-store/password-credentials.jsp
----------------------------------------------------------------------
diff --git a/modules/credential-store-service/credential-store-webapp/src/main/webapp/credential-store/password-credentials.jsp b/modules/credential-store-service/credential-store-webapp/src/main/webapp/credential-store/password-credentials.jsp
new file mode 100644
index 0000000..59a1e04
--- /dev/null
+++ b/modules/credential-store-service/credential-store-webapp/src/main/webapp/credential-store/password-credentials.jsp
@@ -0,0 +1,33 @@
+<%--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements. See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership. The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License. You may obtain a copy of the License at
+  ~
+  ~ http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied. See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  --%>
+
+<html>
+<body>
+<h2>Store Passwords</h2>
+<p>This demonstrates how portal can use Credential Store to obtain community credentials ...</p>
+<form name="input" action="../airavata-registry-rest-services/credential-store" method="post">
+
+    Gateway Name   : <input type="text" name="gatewayName"><br>
+    Portal Username: <input type="text" name="portalUserName"><br>
+    Contact Email: <input type="text" name="email">
+
+    <input type="submit" value="Submit">
+</form>
+</body>
+</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/5c7acf30/modules/credential-store-service/credential-store-webapp/src/main/webapp/credential-store/show-redirect.jsp
----------------------------------------------------------------------
diff --git a/modules/credential-store-service/credential-store-webapp/src/main/webapp/credential-store/show-redirect.jsp b/modules/credential-store-service/credential-store-webapp/src/main/webapp/credential-store/show-redirect.jsp
new file mode 100644
index 0000000..84b54cf
--- /dev/null
+++ b/modules/credential-store-service/credential-store-webapp/src/main/webapp/credential-store/show-redirect.jsp
@@ -0,0 +1,44 @@
+<%--
+  ~ 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.
+  --%>
+  
+<%@ 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 = "<%=redirectUrlInRequest%>"
+        }
+        //-->
+    </script>
+</head>
+<body onLoad="setTimeout('redirect()', 1000)">
+<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="<%=redirectUrlInRequest%>"><%=redirectUrlInRequest%></a>
+</p>
+
+</body>
+</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/5c7acf30/modules/credential-store-service/credential-store-webapp/src/main/webapp/credential-store/success.jsp
----------------------------------------------------------------------
diff --git a/modules/credential-store-service/credential-store-webapp/src/main/webapp/credential-store/success.jsp b/modules/credential-store-service/credential-store-webapp/src/main/webapp/credential-store/success.jsp
new file mode 100644
index 0000000..f2964d0
--- /dev/null
+++ b/modules/credential-store-service/credential-store-webapp/src/main/webapp/credential-store/success.jsp
@@ -0,0 +1,25 @@
+<%--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements. See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership. The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License. You may obtain a copy of the License at
+  ~
+  ~ http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied. See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  --%>
+  
+<html>
+<body>
+<h1>Credential Store</h1>
+<p>Certificate Successfully Stored !</p>
+</body>
+</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/5c7acf30/modules/credential-store-service/credential-store-webapp/src/main/webapp/gateway/acs.jsp
----------------------------------------------------------------------
diff --git a/modules/credential-store-service/credential-store-webapp/src/main/webapp/gateway/acs.jsp b/modules/credential-store-service/credential-store-webapp/src/main/webapp/gateway/acs.jsp
new file mode 100644
index 0000000..94bc6d9
--- /dev/null
+++ b/modules/credential-store-service/credential-store-webapp/src/main/webapp/gateway/acs.jsp
@@ -0,0 +1,62 @@
+<%@ page import="org.apache.airavata.sample.gateway.SampleGateway" %>
+<%--
+  Created by IntelliJ IDEA.
+  User: thejaka
+  Date: 8/5/13
+  Time: 4:48 PM
+  To change this template use File | Settings | File Templates.
+--%>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<%--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements. See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership. The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License. You may obtain a copy of the License at
+  ~
+  ~ http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied. See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  --%>
+
+
+<html>
+<body>
+
+<table width="100%" border="0">
+    <tr bgcolor="#999999"><td align="right"><a href="user.jsp"><font color="#f5f5f5">Home</font> </a> <a href="logout.jsp"><font color="#f5f5f5">Logout</font></a></td></tr>
+</table>
+
+<h2>Sample Gateway</h2>
+
+
+
+<p>This demonstrates how portal can use Credential Store to obtain community credentials ...</p>
+<form name="input" action="https://localhost:8443/airavata/acs-start-servlet" method="post">
+
+    <table border="0">
+        <tr>
+            <td>Gateway Name</td>
+            <td><input type="text" name="gatewayName" value="default" readonly="readonly"></td>
+        </tr>
+        <tr>
+            <td>Portal Username</td>
+            <td><input type="text" name="portalUserName"></td>
+        </tr>
+        <tr>
+            <td>Contact Email</td>
+            <td><input type="text" name="email"></td>
+        </tr>
+    </table>
+
+    <input type="submit" value="Submit">
+</form>
+</body>
+</html>

http://git-wip-us.apache.org/repos/asf/airavata/blob/5c7acf30/modules/credential-store-service/credential-store-webapp/src/main/webapp/gateway/callback.jsp
----------------------------------------------------------------------
diff --git a/modules/credential-store-service/credential-store-webapp/src/main/webapp/gateway/callback.jsp b/modules/credential-store-service/credential-store-webapp/src/main/webapp/gateway/callback.jsp
new file mode 100644
index 0000000..560f64f
--- /dev/null
+++ b/modules/credential-store-service/credential-store-webapp/src/main/webapp/gateway/callback.jsp
@@ -0,0 +1,78 @@
+<%@ page import="org.apache.airavata.sample.gateway.SampleGateway" %>
+<%--
+  Created by IntelliJ IDEA.
+  User: thejaka
+  Date: 8/5/13
+  Time: 4:48 PM
+  To change this template use File | Settings | File Templates.
+--%>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<%--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements. See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership. The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License. You may obtain a copy of the License at
+  ~
+  ~ http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied. See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  --%>
+
+<%
+    SampleGateway sampleGateway = (SampleGateway)session.getAttribute(SampleGateway.GATEWAY_SESSION);
+
+    boolean success = false;
+
+    String tokenId = request.getParameter("tokenId");
+
+    if (tokenId != null) {
+        sampleGateway.updateTokenId(tokenId);
+        success = true;
+    }
+%>
+
+<html>
+<body>
+
+<table width="100%" border="0">
+    <tr bgcolor="#999999"><td align="right"><a href="user.jsp"><font color="#f5f5f5">Home</font> </a> <a href="logout.jsp"><font color="#f5f5f5">Logout</font></a></td></tr>
+</table>
+
+<h2>Sample Gateway</h2>
+<%
+    out.println("The received token id - ");
+    out.println(tokenId);
+
+    if (success) {
+%>
+<p>Token id successfully updated.</p>
+
+<p>
+    View users who obtained token id.
+<ol>
+    <li><a href="list_users.jsp">List Users</a></li>
+</ol>
+</p>
+
+<%
+    } else {
+
+%>
+<p> Error updating token id.</p>
+<%
+
+    }
+
+%>
+
+
+</body>
+</html>

http://git-wip-us.apache.org/repos/asf/airavata/blob/5c7acf30/modules/credential-store-service/credential-store-webapp/src/main/webapp/gateway/list_users.jsp
----------------------------------------------------------------------
diff --git a/modules/credential-store-service/credential-store-webapp/src/main/webapp/gateway/list_users.jsp b/modules/credential-store-service/credential-store-webapp/src/main/webapp/gateway/list_users.jsp
new file mode 100644
index 0000000..36883b7
--- /dev/null
+++ b/modules/credential-store-service/credential-store-webapp/src/main/webapp/gateway/list_users.jsp
@@ -0,0 +1,78 @@
+<%--
+  ~ 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.
+  --%>
+
+<%@ page import="org.apache.airavata.sample.gateway.SampleGateway" %>
+<%@ page import="java.util.List" %>
+<%@ page import="org.apache.airavata.sample.gateway.userstore.User" %>
+<%--
+  Created by IntelliJ IDEA.
+  User: thejaka
+  Date: 8/5/13
+  Time: 12:30 PM
+  To change this template use File | Settings | File Templates.
+--%>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<%
+    SampleGateway sampleGateway = (SampleGateway)session.getAttribute(SampleGateway.GATEWAY_SESSION);
+%>
+
+<html>
+<head>
+    <title>List Users</title>
+</head>
+<body>
+
+<table width="100%" border="0">
+    <tr bgcolor="#999999"><td align="right"><a href="user.jsp"><font color="#f5f5f5">Home</font> </a> <a href="logout.jsp"><font color="#f5f5f5">Logout</font></a></td></tr>
+</table>
+
+<h1>Sample Gateway</h1>
+
+
+<p> This page lists all users and their attributes. </p>
+
+<table>
+    <tr>
+        <td>UserName</td>
+        <td>E-Mail</td>
+        <td>TokenId</td>
+    </tr>
+<%
+    List<User> userList = sampleGateway.getAllUsers();
+    for (User u : userList) {
+%>
+    <tr>
+        <td>
+            <%=u.getUserName() %>
+        </td>
+        <td>
+            <%=u.getEmail() %>
+        </td>
+        <td>
+            <%=u.getToken() %>
+        </td>
+
+    </tr>
+    <%
+        }
+    %>
+</table>
+
+</body>
+</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/5c7acf30/modules/credential-store-service/credential-store-webapp/src/main/webapp/gateway/logout.jsp
----------------------------------------------------------------------
diff --git a/modules/credential-store-service/credential-store-webapp/src/main/webapp/gateway/logout.jsp b/modules/credential-store-service/credential-store-webapp/src/main/webapp/gateway/logout.jsp
new file mode 100644
index 0000000..63d90be
--- /dev/null
+++ b/modules/credential-store-service/credential-store-webapp/src/main/webapp/gateway/logout.jsp
@@ -0,0 +1,35 @@
+<%--
+  ~ 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.
+  --%>
+<%@ page import="org.apache.airavata.sample.gateway.SampleGateway" %><%
+    session.removeAttribute("userName");
+    session.removeAttribute(SampleGateway.GATEWAY_SESSION);
+    session.invalidate();
+%>
+
+<html>
+<head>
+    <script language=javascript>
+        function redirect(){
+            window.location = "../index.jsp";
+        }
+    </script>
+</head>
+<body onload="redirect()">
+</body>
+</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/5c7acf30/modules/credential-store-service/credential-store-webapp/src/main/webapp/gateway/user.jsp
----------------------------------------------------------------------
diff --git a/modules/credential-store-service/credential-store-webapp/src/main/webapp/gateway/user.jsp b/modules/credential-store-service/credential-store-webapp/src/main/webapp/gateway/user.jsp
new file mode 100644
index 0000000..1fd1957
--- /dev/null
+++ b/modules/credential-store-service/credential-store-webapp/src/main/webapp/gateway/user.jsp
@@ -0,0 +1,102 @@
+<%--
+  ~ 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.
+  --%>
+
+<%@ page import="org.apache.airavata.sample.gateway.SampleGateway" %>
+<%--
+  Created by IntelliJ IDEA.
+  User: thejaka
+  Date: 7/31/13
+  Time: 5:08 PM
+  To change this template use File | Settings | File Templates.
+--%>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<%
+    String loginScreen = request.getParameter("loginScreen");
+
+    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);
+
+        user = request.getParameter("username");
+        String password = request.getParameter("password");
+
+        authenticate = sampleGateway.authenticate(user, password);
+    } else {
+        authenticate = true;
+    }
+
+%>
+<html>
+
+<head>
+    <title>Manage</title>
+</head>
+<body>
+
+<table width="100%" border="0">
+    <tr bgcolor="#999999"><td align="right"><a href="user.jsp"><font color="#f5f5f5">Home</font> </a> <a href="logout.jsp"><font color="#f5f5f5">Logout</font></a></td></tr>
+</table>
+
+<h1>Sample Gateway</h1>
+
+<%
+    if (authenticate) {
+
+        session.setAttribute("userName", user);
+
+        if (SampleGateway.isAdmin(user)) {
+%>
+<h1>Administration</h1>
+<p>
+    This page allows administration functionality.
+<ol>
+    <li><a href="acs.jsp">Retrieve Credentials</a></li>
+    <li><a href="list_users.jsp">List Users</a></li>
+</ol>
+</p>
+
+
+<%
+     } else {
+%>
+
+<p> You are a normal user. Click <a href="job.jsp">here</a> to configure and run "Echo" workflow on a GRID machine.</p>
+
+<%
+     }
+    } else {
+%>
+
+<h1>Authentication failed</h1>
+
+<%
+    }
+%>
+
+</body>
+</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/5c7acf30/modules/credential-store-service/credential-store-webapp/src/main/webapp/index.jsp
----------------------------------------------------------------------
diff --git a/modules/credential-store-service/credential-store-webapp/src/main/webapp/index.jsp b/modules/credential-store-service/credential-store-webapp/src/main/webapp/index.jsp
new file mode 100644
index 0000000..1bf0ed6
--- /dev/null
+++ b/modules/credential-store-service/credential-store-webapp/src/main/webapp/index.jsp
@@ -0,0 +1,26 @@
+<%--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+--%>
+
+<html>
+<body>
+<img src="images/airavata-logo-2.png">
+<h2>Airavata Credential Store</h2>
+<p>Welcome to Airavata Credential Store Web Application</p>
+
+<p><a href="user-store/add.jsp"><b>Manage Local User Store</b></a></p>
+</body>
+</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/5c7acf30/modules/credential-store-service/credential-store/pom.xml
----------------------------------------------------------------------
diff --git a/modules/credential-store-service/credential-store/pom.xml b/modules/credential-store-service/credential-store/pom.xml
new file mode 100644
index 0000000..534544a
--- /dev/null
+++ b/modules/credential-store-service/credential-store/pom.xml
@@ -0,0 +1,147 @@
+<?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. -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <groupId>org.apache.airavata</groupId>
+        <artifactId>airavata</artifactId>
+        <version>0.13-SNAPSHOT</version>
+        <relativePath>../../pom.xml</relativePath>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>airavata-credential-store</artifactId>
+    <name>Airavata Credential Store</name>
+    <description>Module to manage credentials</description>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>edu.uiuc.ncsa.myproxy</groupId>
+            <artifactId>oa4mp-client-api</artifactId>
+            <version>${oa4mp.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>edu.uiuc.ncsa.myproxy</groupId>
+            <artifactId>oa4mp-client-oauth1</artifactId>
+            <version>${oa4mp.version}</version>
+            <exclusions>
+        	<exclusion>
+          		<groupId>net.oauth.core</groupId> 
+          		<artifactId>oauth-httpclient4</artifactId>
+        	</exclusion>
+			<exclusion>
+				<groupId>net.oauth.core</groupId>
+				<artifactId>oauth-consumer</artifactId>
+			</exclusion>
+			<exclusion>
+				<groupId>mysql</groupId>
+				<artifactId>mysql-connector-java</artifactId>
+			</exclusion>
+			<exclusion>
+				<groupId>postgresql</groupId>
+				<artifactId>postgresql</artifactId>
+			</exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.7</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.derby</groupId>
+            <artifactId>derby</artifactId>
+            <version>${derby.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.derby</groupId>
+            <artifactId>derbyclient</artifactId>
+            <version>${derby.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.derby</groupId>
+            <artifactId>derbynet</artifactId>
+            <version>${derby.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.derby</groupId>
+            <artifactId>derbytools</artifactId>
+            <version>${derby.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>commons-dbcp</groupId>
+            <artifactId>commons-dbcp</artifactId>
+            <version>1.4</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.airavata</groupId>
+            <artifactId>airavata-common-utils</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+			<groupId>com.jcraft</groupId>
+			<artifactId>jsch</artifactId>
+			<version>0.1.50</version>
+		</dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>servlet-api</artifactId>
+            <version>2.5</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-email</artifactId>
+            <version>1.3.2</version>
+        </dependency>
+    </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>${surefire.version}</version>
+                <inherited>true</inherited>
+                <configuration>
+                    <systemPropertyVariables>
+                        <credential.module.directory>${basedir}</credential.module.directory>
+                    </systemPropertyVariables>
+                    <excludes>
+                        <exclude>**/DAOBaseTestCase.java</exclude>
+                        <exclude>**/MappingDAOTest.java</exclude>
+                    </excludes>
+                    <testSourceDirectory>${basedir}\src\test\java\</testSourceDirectory>
+                </configuration>
+            </plugin>
+
+        </plugins>
+        <testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory>
+        <testOutputDirectory>${project.build.directory}/test-classes</testOutputDirectory>
+        <testResources>
+            <testResource>
+                <directory>${project.basedir}/src/test/resources</directory>
+            </testResource>
+        </testResources>
+    </build>
+</project>

http://git-wip-us.apache.org/repos/asf/airavata/blob/5c7acf30/modules/credential-store-service/credential-store/scripts/credential-store-h2.sql
----------------------------------------------------------------------
diff --git a/modules/credential-store-service/credential-store/scripts/credential-store-h2.sql b/modules/credential-store-service/credential-store/scripts/credential-store-h2.sql
new file mode 100644
index 0000000..91915b6
--- /dev/null
+++ b/modules/credential-store-service/credential-store/scripts/credential-store-h2.sql
@@ -0,0 +1,42 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+CREATE TABLE COMMUNITY_USER
+(
+	GATEWAY_NAME VARCHAR(256) NOT NULL,
+	COMMUNITY_USER_NAME VARCHAR(256) NOT NULL,
+	COMMUNITY_USER_EMAIL VARCHAR(256) NOT NULL,
+        PRIMARY KEY (GATEWAY_NAME, COMMUNITY_USER_NAME)
+);
+
+
+CREATE TABLE CREDENTIALS
+(
+	GATEWAY_NAME VARCHAR(256) NOT NULL,
+	COMMUNITY_USER_NAME VARCHAR(256) NOT NULL,
+	CREDENTIAL CLOB NOT NULL,
+	PRIVATE_KEY CLOB NOT NULL,
+	NOT_BEFORE VARCHAR(256) NOT NULL,
+	NOT_AFTER VARCHAR(256) NOT NULL,
+	LIFETIME MEDIUMINT NOT NULL,
+	REQUESTING_PORTAL_USER_NAME VARCHAR(256) NOT NULL,
+	REQUESTED_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00',
+        PRIMARY KEY (GATEWAY_NAME, COMMUNITY_USER_NAME)
+);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/5c7acf30/modules/credential-store-service/credential-store/scripts/credential-store-mysql.sql
----------------------------------------------------------------------
diff --git a/modules/credential-store-service/credential-store/scripts/credential-store-mysql.sql b/modules/credential-store-service/credential-store/scripts/credential-store-mysql.sql
new file mode 100644
index 0000000..50d5e0f
--- /dev/null
+++ b/modules/credential-store-service/credential-store/scripts/credential-store-mysql.sql
@@ -0,0 +1,42 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+CREATE TABLE COMMUNITY_USER
+(
+	GATEWAY_NAME VARCHAR(256) NOT NULL,
+	COMMUNITY_USER_NAME VARCHAR(256) NOT NULL,
+	COMMUNITY_USER_EMAIL VARCHAR(256) NOT NULL,
+        PRIMARY KEY (GATEWAY_NAME, COMMUNITY_USER_NAME)
+);
+
+
+CREATE TABLE CREDENTIALS
+(
+	GATEWAY_NAME VARCHAR(256) NOT NULL,
+	COMMUNITY_USER_NAME VARCHAR(256) NOT NULL,
+	CREDENTIAL TEXT NOT NULL,
+	PRIVATE_KEY TEXT NOT NULL,
+	NOT_BEFORE VARCHAR(256) NOT NULL,
+	NOT_AFTER VARCHAR(256) NOT NULL,
+	LIFETIME MEDIUMINT NOT NULL,
+	REQUESTING_PORTAL_USER_NAME VARCHAR(256) NOT NULL,
+	REQUESTED_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00',
+    PRIMARY KEY (GATEWAY_NAME, COMMUNITY_USER_NAME)
+);

http://git-wip-us.apache.org/repos/asf/airavata/blob/5c7acf30/modules/credential-store-service/credential-store/src/main/java/org/apache/airavata/credential/store/credential/AuditInfo.java
----------------------------------------------------------------------
diff --git a/modules/credential-store-service/credential-store/src/main/java/org/apache/airavata/credential/store/credential/AuditInfo.java b/modules/credential-store-service/credential-store/src/main/java/org/apache/airavata/credential/store/credential/AuditInfo.java
new file mode 100644
index 0000000..93b4e94
--- /dev/null
+++ b/modules/credential-store-service/credential-store/src/main/java/org/apache/airavata/credential/store/credential/AuditInfo.java
@@ -0,0 +1,53 @@
+/*
+ *
+ * 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.credential;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * Any audit information related to a credential.
+ */
+public interface AuditInfo extends Serializable {
+
+    /**
+     * Gets the community user associated with the credential.
+     * 
+     * @return The community user associated with the credential.
+     */
+    public CommunityUser getCommunityUser();
+
+    /**
+     * The portal user associated with the credential.
+     * 
+     * @return The portal user name.
+     */
+    public String getPortalUserId();
+
+    /**
+     * Get the time which credentials are persisted.
+     * 
+     * @return Time credentials are persisted.
+     */
+    public Date getTimePersisted();
+
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/5c7acf30/modules/credential-store-service/credential-store/src/main/java/org/apache/airavata/credential/store/credential/CommunityUser.java
----------------------------------------------------------------------
diff --git a/modules/credential-store-service/credential-store/src/main/java/org/apache/airavata/credential/store/credential/CommunityUser.java b/modules/credential-store-service/credential-store/src/main/java/org/apache/airavata/credential/store/credential/CommunityUser.java
new file mode 100644
index 0000000..2856f36
--- /dev/null
+++ b/modules/credential-store-service/credential-store/src/main/java/org/apache/airavata/credential/store/credential/CommunityUser.java
@@ -0,0 +1,71 @@
+/*
+ *
+ * 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.credential;
+
+import java.io.Serializable;
+
+/**
+ * Represents the community user.
+ */
+public class CommunityUser implements Serializable {
+
+    static final long serialVersionUID = 5783370135149452010L;
+
+    private String gatewayName;
+    private String userName;
+    private String userEmail;
+
+    public String getGatewayName() {
+        return gatewayName;
+    }
+
+    public void setGatewayName(String gatewayName) {
+        this.gatewayName = gatewayName;
+    }
+
+    public String getUserEmail() {
+        return userEmail;
+    }
+
+    public void setUserEmail(String userEmail) {
+        this.userEmail = userEmail;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    public CommunityUser(String gatewayName, String userName, String userEmail) {
+        this.gatewayName = gatewayName;
+        this.userName = userName;
+        this.userEmail = userEmail;
+    }
+
+    public CommunityUser(String gatewayName, String userName) {
+        this.gatewayName = gatewayName;
+        this.userName = userName;
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/5c7acf30/modules/credential-store-service/credential-store/src/main/java/org/apache/airavata/credential/store/credential/Credential.java
----------------------------------------------------------------------
diff --git a/modules/credential-store-service/credential-store/src/main/java/org/apache/airavata/credential/store/credential/Credential.java b/modules/credential-store-service/credential-store/src/main/java/org/apache/airavata/credential/store/credential/Credential.java
new file mode 100644
index 0000000..4f04123
--- /dev/null
+++ b/modules/credential-store-service/credential-store/src/main/java/org/apache/airavata/credential/store/credential/Credential.java
@@ -0,0 +1,62 @@
+/*
+ *
+ * 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.credential;
+
+import java.io.Serializable;
+import java.sql.Timestamp;
+import java.util.Date;
+
+/**
+ * This class represents the actual credential. The credential can be a certificate, user name password or a SSH key. As
+ * per now we only have certificate implementation.
+ */
+public abstract class Credential implements Serializable {
+
+    private String portalUserName;
+    private Date persistedTime;
+    private String token;
+
+    public String getToken() {
+        return token;
+    }
+
+    public void setToken(String token) {
+        this.token = token;
+    }
+
+    public void setPortalUserName(String userName) {
+        portalUserName = userName;
+    }
+
+    public String getPortalUserName() {
+        return portalUserName;
+    }
+
+    public void setCertificateRequestedTime(Date ts) {
+        persistedTime = ts;
+    }
+
+    public Date getCertificateRequestedTime() {
+        return persistedTime;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/5c7acf30/modules/credential-store-service/credential-store/src/main/java/org/apache/airavata/credential/store/credential/impl/certificate/CertificateAuditInfo.java
----------------------------------------------------------------------
diff --git a/modules/credential-store-service/credential-store/src/main/java/org/apache/airavata/credential/store/credential/impl/certificate/CertificateAuditInfo.java b/modules/credential-store-service/credential-store/src/main/java/org/apache/airavata/credential/store/credential/impl/certificate/CertificateAuditInfo.java
new file mode 100644
index 0000000..17ddb3f
--- /dev/null
+++ b/modules/credential-store-service/credential-store/src/main/java/org/apache/airavata/credential/store/credential/impl/certificate/CertificateAuditInfo.java
@@ -0,0 +1,101 @@
+/*
+ *
+ * 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.credential.impl.certificate;
+
+import org.apache.airavata.credential.store.credential.AuditInfo;
+import org.apache.airavata.credential.store.credential.CommunityUser;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import java.util.Date;
+
+/**
+ * Audit information related to community credential.
+ */
+@XmlRootElement
+public class CertificateAuditInfo implements AuditInfo {
+
+    private static final long serialVersionUID = 13213123L;
+
+    private String gatewayName;
+    private String communityUserName;
+    private String portalUserName;
+    private Date credentialsRequestedTime;
+    private String notBefore;
+    private String notAfter;
+    private long credentialLifeTime;
+
+    public String getGatewayName() {
+        return gatewayName;
+    }
+
+    public void setGatewayName(String gatewayName) {
+        this.gatewayName = gatewayName;
+    }
+
+    public void setCommunityUserName(String communityUserName) {
+        this.communityUserName = communityUserName;
+    }
+
+    public void setPortalUserName(String portalUserName) {
+        this.portalUserName = portalUserName;
+    }
+
+    public void setCredentialsRequestedTime(Date credentialsRequestedTime) {
+        this.credentialsRequestedTime = credentialsRequestedTime;
+    }
+
+    public String getNotBefore() {
+        return notBefore;
+    }
+
+    public void setNotBefore(String notBefore) {
+        this.notBefore = notBefore;
+    }
+
+    public String getNotAfter() {
+        return notAfter;
+    }
+
+    public void setNotAfter(String notAfter) {
+        this.notAfter = notAfter;
+    }
+
+    public long getCredentialLifeTime() {
+        return credentialLifeTime;
+    }
+
+    public void setCredentialLifeTime(long credentialLifeTime) {
+        this.credentialLifeTime = credentialLifeTime;
+    }
+
+    public CommunityUser getCommunityUser() {
+        return new CommunityUser(gatewayName, communityUserName);
+    }
+
+    public String getPortalUserId() {
+        return portalUserName;
+    }
+
+    public Date getTimePersisted() {
+        return credentialsRequestedTime;
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/5c7acf30/modules/credential-store-service/credential-store/src/main/java/org/apache/airavata/credential/store/credential/impl/certificate/CertificateCredential.java
----------------------------------------------------------------------
diff --git a/modules/credential-store-service/credential-store/src/main/java/org/apache/airavata/credential/store/credential/impl/certificate/CertificateCredential.java b/modules/credential-store-service/credential-store/src/main/java/org/apache/airavata/credential/store/credential/impl/certificate/CertificateCredential.java
new file mode 100644
index 0000000..16c3351
--- /dev/null
+++ b/modules/credential-store-service/credential-store/src/main/java/org/apache/airavata/credential/store/credential/impl/certificate/CertificateCredential.java
@@ -0,0 +1,102 @@
+/*
+ *
+ * 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.credential.impl.certificate;
+
+import org.apache.airavata.credential.store.credential.CommunityUser;
+import org.apache.airavata.credential.store.credential.Credential;
+import java.security.PrivateKey;
+import java.security.cert.X509Certificate;
+
+/**
+ * Represents the certificate credentials.
+ */
+public class CertificateCredential extends Credential {
+
+    static final long serialVersionUID = 6603675553790734432L;
+
+    /**
+     * The community user associated with this credentials.
+     */
+    private CommunityUser communityUser;
+
+    private String notAfter;
+
+    private X509Certificate[] certificates;
+
+    private PrivateKey privateKey;
+
+    private long lifeTime;
+
+    private String notBefore;
+
+    public CertificateCredential() {
+    }
+
+    public String getNotBefore() {
+        return notBefore;
+    }
+
+    public void setNotBefore(String notBefore) {
+        this.notBefore = notBefore;
+    }
+
+    public String getNotAfter() {
+        return notAfter;
+    }
+
+    public void setNotAfter(String notAfter) {
+        this.notAfter = notAfter;
+    }
+
+    public PrivateKey getPrivateKey() {
+        return privateKey;
+    }
+
+    public void setPrivateKey(PrivateKey privateKey) {
+        this.privateKey = privateKey;
+    }
+
+    public X509Certificate[] getCertificates() {
+        return certificates;
+    }
+
+    public void setCertificates(X509Certificate[] certificate) {
+        this.certificates = certificate;
+    }
+
+    public long getLifeTime() {
+        return lifeTime;
+    }
+
+    public void setLifeTime(long lifeTime) {
+        this.lifeTime = lifeTime;
+    }
+
+    public CommunityUser getCommunityUser() {
+        return communityUser;
+    }
+
+    public void setCommunityUser(CommunityUser communityUser) {
+        this.communityUser = communityUser;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/5c7acf30/modules/credential-store-service/credential-store/src/main/java/org/apache/airavata/credential/store/credential/impl/password/PasswordCredential.java
----------------------------------------------------------------------
diff --git a/modules/credential-store-service/credential-store/src/main/java/org/apache/airavata/credential/store/credential/impl/password/PasswordCredential.java b/modules/credential-store-service/credential-store/src/main/java/org/apache/airavata/credential/store/credential/impl/password/PasswordCredential.java
new file mode 100644
index 0000000..ee32ef4
--- /dev/null
+++ b/modules/credential-store-service/credential-store/src/main/java/org/apache/airavata/credential/store/credential/impl/password/PasswordCredential.java
@@ -0,0 +1,52 @@
+/*
+ *
+ * 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.credential.impl.password;
+
+import org.apache.airavata.credential.store.credential.Credential;
+
+import java.util.Date;
+
+/**
+ * User name password credentials.
+ */
+public class PasswordCredential extends Credential {
+
+    private String userName;
+    private String password;
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/5c7acf30/modules/credential-store-service/credential-store/src/main/java/org/apache/airavata/credential/store/credential/impl/ssh/SSHCredential.java
----------------------------------------------------------------------
diff --git a/modules/credential-store-service/credential-store/src/main/java/org/apache/airavata/credential/store/credential/impl/ssh/SSHCredential.java b/modules/credential-store-service/credential-store/src/main/java/org/apache/airavata/credential/store/credential/impl/ssh/SSHCredential.java
new file mode 100644
index 0000000..710e0c0
--- /dev/null
+++ b/modules/credential-store-service/credential-store/src/main/java/org/apache/airavata/credential/store/credential/impl/ssh/SSHCredential.java
@@ -0,0 +1,73 @@
+/*
+ *
+ * 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.credential.impl.ssh;
+
+import org.apache.airavata.credential.store.credential.Credential;
+import java.io.Serializable;
+
+/**
+ * An SSH Credential class which is an extension of Airavata Credential 
+ */
+public class SSHCredential extends Credential implements Serializable {
+
+    /**
+	 * 
+	 */
+	private static final long serialVersionUID = 1277154647420198981L;
+	
+	private byte[] privatekey;
+    private byte[] publicKey;
+    private String passphrase;
+    private String gateway;
+
+    public byte[] getPrivateKey() {
+        return privatekey;
+    }
+
+    public void setPrivateKey(byte[] privatekey) {
+        this.privatekey = privatekey;
+    }
+
+    public byte[] getPublicKey() {
+        return publicKey;
+    }
+
+    public void setPublicKey(byte[] pubKey) {
+        this.publicKey = pubKey;
+    }
+
+    public String getPassphrase() {
+        return passphrase;
+    }
+
+    public void setPassphrase(String passphrase) {
+        this.passphrase = passphrase;
+    }
+
+	public String getGateway() {
+		return gateway;
+	}
+
+	public void setGateway(String gateway) {
+		this.gateway = gateway;
+	}
+}