You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by am...@apache.org on 2014/01/02 05:18:28 UTC

svn commit: r1554737 - in /airavata/trunk/modules: commons/utils/src/main/java/org/apache/airavata/common/utils/ credential-store/src/main/java/org/apache/airavata/credential/store/notifier/ credential-store/src/main/java/org/apache/airavata/credential...

Author: amilaj
Date: Thu Jan  2 04:18:26 2014
New Revision: 1554737

URL: http://svn.apache.org/r1554737
Log:
Wrapping up credential store work. Completed notifier. Updated encryption methodologies

Added:
    airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/DefaultKeyStorePasswordCallback.java
    airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/notifier/NotifierBootstrap.java
    airavata/trunk/modules/credential-store/src/test/java/org/apache/airavata/credential/store/notifier/
    airavata/trunk/modules/credential-store/src/test/java/org/apache/airavata/credential/store/notifier/impl/
    airavata/trunk/modules/credential-store/src/test/java/org/apache/airavata/credential/store/notifier/impl/EmailNotifierTest.java
    airavata/trunk/modules/rest/webapp/src/main/resources/credential-store/airavata.jks   (with props)
Modified:
    airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ApplicationSettings.java
    airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/KeyStorePasswordCallback.java
    airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/SecurityUtil.java
    airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/notifier/impl/EmailNotifierConfiguration.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/store/CredentialReader.java
    airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/store/CredentialReaderFactory.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/CredentialReaderImpl.java
    airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/store/impl/SSHCredentialWriter.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/Utility.java
    airavata/trunk/modules/distribution/airavata-server/src/main/resources/conf/airavata-server.properties
    airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/AiravataJPARegistry.java
    airavata/trunk/modules/rest/webapp/src/main/resources/airavata-server.properties

Modified: airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ApplicationSettings.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ApplicationSettings.java?rev=1554737&r1=1554736&r2=1554737&view=diff
==============================================================================
--- airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ApplicationSettings.java (original)
+++ airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ApplicationSettings.java Thu Jan  2 04:18:26 2014
@@ -180,6 +180,50 @@ public abstract class ApplicationSetting
         SecurityUtil.setTrustStoreParameters(getTrustStorePath(), getTrustStorePassword());
     }
 
+    public static String getCredentialStoreKeyStorePath() throws ApplicationSettingsException {
+        return getSetting("credential.store.keystore.url");
+    }
+
+    public static String getCredentialStoreKeyAlias() throws ApplicationSettingsException {
+        return getSetting("credential.store.keystore.alias");
+    }
+
+    public static String getCredentialStoreKeyStorePassword() throws ApplicationSettingsException {
+        return getSetting("credential.store.keystore.password");
+    }
+
+    public static String getCredentialStoreNotifierEnabled() throws ApplicationSettingsException {
+        return getSetting("notifier.enabled");
+    }
+
+    public static String getCredentialStoreNotifierDuration() throws ApplicationSettingsException {
+        return getSetting("notifier.duration");
+    }
+
+    public static String getCredentialStoreEmailServer() throws ApplicationSettingsException {
+        return getSetting("email.server");
+    }
+
+    public static String getCredentialStoreEmailServerPort() throws ApplicationSettingsException {
+        return getSetting("email.server.port");
+    }
+
+    public static String getCredentialStoreEmailUser() throws ApplicationSettingsException {
+        return getSetting("email.user");
+    }
+
+    public static String getCredentialStoreEmailPassword() throws ApplicationSettingsException {
+        return getSetting("email.password");
+    }
+
+    public static String getCredentialStoreEmailSSLConnect() throws ApplicationSettingsException {
+        return getSetting("email.ssl");
+    }
+
+    public static String getCredentialStoreEmailFromEmail() throws ApplicationSettingsException {
+        return getSetting("email.from");
+    }
+
     public static Properties getProperties() {
         return properties;
     }

Added: airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/DefaultKeyStorePasswordCallback.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/DefaultKeyStorePasswordCallback.java?rev=1554737&view=auto
==============================================================================
--- airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/DefaultKeyStorePasswordCallback.java (added)
+++ airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/DefaultKeyStorePasswordCallback.java Thu Jan  2 04:18:26 2014
@@ -0,0 +1,55 @@
+/*
+ *
+ * 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.common.utils;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 12/29/13
+ * Time: 12:10 PM
+ */
+
+public class DefaultKeyStorePasswordCallback implements KeyStorePasswordCallback {
+
+    public DefaultKeyStorePasswordCallback(){
+
+    }
+
+    @Override
+    public char[] getStorePassword() {
+        try {
+            return ApplicationSettings.getCredentialStoreKeyStorePassword().toCharArray();
+        } catch (ApplicationSettingsException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    @Override
+    public char[] getSecretKeyPassPhrase(String keyAlias) {
+        try {
+            return ApplicationSettings.getCredentialStoreKeyStorePassword().toCharArray();
+        } catch (ApplicationSettingsException e) {
+            throw new RuntimeException(e);
+        }
+    }
+}

Modified: airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/KeyStorePasswordCallback.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/KeyStorePasswordCallback.java?rev=1554737&r1=1554736&r2=1554737&view=diff
==============================================================================
--- airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/KeyStorePasswordCallback.java (original)
+++ airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/KeyStorePasswordCallback.java Thu Jan  2 04:18:26 2014
@@ -36,7 +36,7 @@ public interface KeyStorePasswordCallbac
      * Instead of the actual file.
      * @return The password to open the keystore.
      */
-    char[] getStorePassword();
+    char[] getStorePassword() throws RuntimeException;
 
     /**
      * Caller should implement the interface. Should return the pass phrase for

Modified: airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/SecurityUtil.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/SecurityUtil.java?rev=1554737&r1=1554736&r2=1554737&view=diff
==============================================================================
--- airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/SecurityUtil.java (original)
+++ airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/SecurityUtil.java Thu Jan  2 04:18:26 2014
@@ -27,10 +27,7 @@ import org.slf4j.LoggerFactory;
 import javax.crypto.Cipher;
 import javax.crypto.spec.IvParameterSpec;
 import javax.crypto.spec.SecretKeySpec;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
+import java.io.*;
 import java.security.*;
 import java.security.cert.CertificateException;
 

Added: airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/notifier/NotifierBootstrap.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/notifier/NotifierBootstrap.java?rev=1554737&view=auto
==============================================================================
--- airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/notifier/NotifierBootstrap.java (added)
+++ airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/notifier/NotifierBootstrap.java Thu Jan  2 04:18:26 2014
@@ -0,0 +1,144 @@
+/*
+ *
+ * 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.notifier;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 12/27/13
+ * Time: 2:22 PM
+ */
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.DBUtil;
+import org.apache.airavata.credential.store.credential.CommunityUser;
+import org.apache.airavata.credential.store.credential.Credential;
+import org.apache.airavata.credential.store.credential.impl.certificate.CertificateCredential;
+import org.apache.airavata.credential.store.notifier.impl.EmailNotificationMessage;
+import org.apache.airavata.credential.store.notifier.impl.EmailNotifier;
+import org.apache.airavata.credential.store.notifier.impl.EmailNotifierConfiguration;
+import org.apache.airavata.credential.store.store.CredentialReader;
+import org.apache.airavata.credential.store.store.CredentialStoreException;
+import org.apache.airavata.credential.store.store.impl.CredentialReaderImpl;
+import org.apache.airavata.credential.store.util.Utility;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * This class runs a timer. Periodically it checks for expiring credentials.
+ * Then if there are expiring credentials this will send an email.
+ */
+public class NotifierBootstrap extends TimerTask {
+
+    private static boolean enabled = false;
+
+    private static String MESSAGE = "Credentials for community user {0} expires at {1}";
+    private static String SUBJECT = "Expiring credentials for user {0}";
+
+    private DBUtil dbUtil;
+
+    private long period;
+
+    protected static Logger log = LoggerFactory.getLogger(NotifierBootstrap.class);
+
+
+    private CredentialStoreNotifier credentialStoreNotifier;
+
+    public NotifierBootstrap(long period, DBUtil db, EmailNotifierConfiguration configuration) {
+        this.period = period;
+
+        // bootstrap
+        if (enabled) {
+            Timer timer = new Timer();
+            timer.scheduleAtFixedRate(this, 0, period);
+        }
+
+        this.dbUtil = db;
+
+        this.credentialStoreNotifier = new EmailNotifier(configuration);
+    }
+
+
+
+    public long getPeriod() {
+        return period;
+    }
+
+    public void setPeriod(long period) {
+        this.period = period;
+    }
+
+    public static boolean isEnabled() {
+        return enabled;
+    }
+
+    public static void setEnabled(boolean enabled) {
+        NotifierBootstrap.enabled = enabled;
+    }
+
+    @Override
+    public void run() {
+
+        if (!enabled)
+            return;
+
+        // retrieve OA4MP credentials
+        try {
+            CredentialReader credentialReader = new CredentialReaderImpl(this.dbUtil);
+            List<Credential> credentials = credentialReader.getAllCredentials();
+
+            for(Credential credential : credentials) {
+                if (credential instanceof CertificateCredential) {
+                    CertificateCredential certificateCredential = (CertificateCredential)credential;
+
+                    Date date = Utility.convertStringToDate(certificateCredential.getNotAfter());
+                    date.setDate(date.getDate() + 1);    // gap is 1 days
+
+                    Date currentDate = new Date();
+                    if (currentDate.after(date)) {
+                        // Send an email
+                        CommunityUser communityUser = certificateCredential.getCommunityUser();
+                        String body =
+                                String.format(MESSAGE, communityUser.getUserName(), certificateCredential.getNotAfter());
+                        String subject = String.format(SUBJECT, communityUser.getUserName());
+                        NotificationMessage notificationMessage
+                                = new EmailNotificationMessage(subject, communityUser.getUserEmail(), body);
+
+                        this.credentialStoreNotifier.notifyMessage(notificationMessage);
+
+                    }
+                }
+            }
+
+        } catch (ApplicationSettingsException e) {
+            log.error("Error configuring email senders.", e);
+        } catch (CredentialStoreException e) {
+            log.error("Error sending emails about credential expiring.", e);
+        } catch (ParseException e) {
+            log.error("Error parsing date time when sending emails", e);
+        }
+
+    }
+}

Modified: airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/notifier/impl/EmailNotifierConfiguration.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/notifier/impl/EmailNotifierConfiguration.java?rev=1554737&r1=1554736&r2=1554737&view=diff
==============================================================================
--- airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/notifier/impl/EmailNotifierConfiguration.java (original)
+++ airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/notifier/impl/EmailNotifierConfiguration.java Thu Jan  2 04:18:26 2014
@@ -21,6 +21,9 @@
 
 package org.apache.airavata.credential.store.notifier.impl;
 
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.ApplicationSettings;
+
 /**
  * User: AmilaJ (amilaj@apache.org)
  * Date: 12/3/13
@@ -68,4 +71,14 @@ public class EmailNotifierConfiguration 
     public String getFromAddress() {
         return fromAddress;
     }
+
+    public static EmailNotifierConfiguration getEmailNotifierConfigurations() throws ApplicationSettingsException {
+        return new EmailNotifierConfiguration(ApplicationSettings.getCredentialStoreEmailServer(),
+                Integer.parseInt(ApplicationSettings.getCredentialStoreEmailServerPort()),
+                ApplicationSettings.getCredentialStoreEmailUser(),
+                ApplicationSettings.getCredentialStoreEmailPassword(),
+                Boolean.parseBoolean(ApplicationSettings.getCredentialStoreEmailSSLConnect()),
+                ApplicationSettings.getCredentialStoreEmailFromEmail());
+    }
+
 }

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=1554737&r1=1554736&r2=1554737&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 Thu Jan  2 04:18:26 2014
@@ -27,9 +27,13 @@ import edu.uiuc.ncsa.myproxy.oa4mp.clien
 import edu.uiuc.ncsa.myproxy.oa4mp.client.servlet.ClientServlet;
 import edu.uiuc.ncsa.security.core.exceptions.GeneralException;
 import edu.uiuc.ncsa.security.servlet.JSPUtil;
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.ApplicationSettings;
 import org.apache.airavata.common.utils.DBUtil;
 import org.apache.airavata.credential.store.credential.CommunityUser;
 import org.apache.airavata.credential.store.credential.impl.certificate.CertificateCredential;
+import org.apache.airavata.credential.store.notifier.NotifierBootstrap;
+import org.apache.airavata.credential.store.notifier.impl.EmailNotifierConfiguration;
 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;
@@ -58,6 +62,8 @@ public class CredentialStoreCallbackServ
 
     private static ConfigurationReader configurationReader;
 
+    private NotifierBootstrap notifierBootstrap;
+
     public void init() throws ServletException {
 
         DBUtil dbUtil;
@@ -70,12 +76,29 @@ public class CredentialStoreCallbackServ
 
         try {
             configurationReader = new ConfigurationReader();
+            super.init();
+            certificateCredentialWriter = new CertificateCredentialWriter(dbUtil);
         } catch (Exception e) {
             throw new ServletException("Error initializing configuration reader.", e);
         }
 
-        super.init();
-        certificateCredentialWriter = new CertificateCredentialWriter(dbUtil);
+
+        // initialize notifier
+        try {
+            boolean enabled = Boolean.parseBoolean(ApplicationSettings.getCredentialStoreNotifierEnabled());
+
+            if (enabled) {
+                EmailNotifierConfiguration notifierConfiguration
+                        = EmailNotifierConfiguration.getEmailNotifierConfigurations();
+                long duration = Long.parseLong(ApplicationSettings.getCredentialStoreNotifierDuration());
+
+                notifierBootstrap = new NotifierBootstrap(duration, dbUtil, notifierConfiguration);
+            }
+
+        } catch (ApplicationSettingsException e) {
+            throw new ServletException("Error initializing notifier.", e);
+        }
+
 
         info("Credential store callback initialized successfully.");
     }

Modified: airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/store/CredentialReader.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/store/CredentialReader.java?rev=1554737&r1=1554736&r2=1554737&view=diff
==============================================================================
--- airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/store/CredentialReader.java (original)
+++ airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/store/CredentialReader.java Thu Jan  2 04:18:26 2014
@@ -24,6 +24,8 @@ package org.apache.airavata.credential.s
 import org.apache.airavata.credential.store.credential.AuditInfo;
 import org.apache.airavata.credential.store.credential.Credential;
 
+import java.util.List;
+
 /**
  * This interface provides an API for Credential Store. Provides methods to manipulate credential store data.
  */
@@ -65,8 +67,15 @@ public interface CredentialReader {
     AuditInfo getAuditInfo(String gatewayName, String tokenId) throws CredentialStoreException;
 
     /**
+     * Gets all the credential records.
+     * @return All credential records as a list
+     * @throws CredentialStoreException If an error occurred while retrieving credentials.
+     */
+    public List<Credential> getAllCredentials() throws CredentialStoreException;
+
+    /**
      * Updates the community user contact email address.
-     * 
+     *
      * @param gatewayName
      *            The gateway name.
      * @param communityUser

Modified: airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/store/CredentialReaderFactory.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/store/CredentialReaderFactory.java?rev=1554737&r1=1554736&r2=1554737&view=diff
==============================================================================
--- airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/store/CredentialReaderFactory.java (original)
+++ airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/store/CredentialReaderFactory.java Thu Jan  2 04:18:26 2014
@@ -35,7 +35,7 @@ public class CredentialReaderFactory {
      * @param dbUti The database configurations.
      * @return CredentialReader object.
      */
-    public static CredentialReader createCredentialStoreReader(DBUtil dbUti) {
+    public static CredentialReader createCredentialStoreReader(DBUtil dbUti) throws ApplicationSettingsException {
         return new CredentialReaderImpl(dbUti);
     }
 

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=1554737&r1=1554736&r2=1554737&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 Thu Jan  2 04:18:26 2014
@@ -21,7 +21,10 @@
 
 package org.apache.airavata.credential.store.store.impl;
 
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.ApplicationSettings;
 import org.apache.airavata.common.utils.DBUtil;
+import org.apache.airavata.common.utils.DefaultKeyStorePasswordCallback;
 import org.apache.airavata.credential.store.credential.CommunityUser;
 import org.apache.airavata.credential.store.credential.Credential;
 import org.apache.airavata.credential.store.credential.impl.certificate.CertificateCredential;
@@ -47,11 +50,13 @@ public class CertificateCredentialWriter
 
     private DBUtil dbUtil;
 
-    public CertificateCredentialWriter(DBUtil dbUtil) {
+    public CertificateCredentialWriter(DBUtil dbUtil) throws ApplicationSettingsException {
 
         this.dbUtil = dbUtil;
 
-        credentialsDAO = new CredentialsDAO();
+        this.credentialsDAO = new CredentialsDAO(ApplicationSettings.getCredentialStoreKeyStorePath(),
+                ApplicationSettings.getCredentialStoreKeyAlias(), new DefaultKeyStorePasswordCallback());
+
         communityUserDAO = new CommunityUserDAO();
     }
 

Modified: airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/store/impl/CredentialReaderImpl.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/store/impl/CredentialReaderImpl.java?rev=1554737&r1=1554736&r2=1554737&view=diff
==============================================================================
--- airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/store/impl/CredentialReaderImpl.java (original)
+++ airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/store/impl/CredentialReaderImpl.java Thu Jan  2 04:18:26 2014
@@ -21,7 +21,10 @@
 
 package org.apache.airavata.credential.store.store.impl;
 
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.ApplicationSettings;
 import org.apache.airavata.common.utils.DBUtil;
+import org.apache.airavata.common.utils.DefaultKeyStorePasswordCallback;
 import org.apache.airavata.credential.store.credential.CommunityUser;
 import org.apache.airavata.credential.store.credential.Credential;
 import org.apache.airavata.credential.store.credential.impl.certificate.CertificateAuditInfo;
@@ -33,6 +36,7 @@ import org.apache.airavata.credential.st
 import java.io.Serializable;
 import java.sql.Connection;
 import java.sql.SQLException;
+import java.util.List;
 
 /**
  * Credential store API implementation.
@@ -43,9 +47,10 @@ public class CredentialReaderImpl implem
 
     private DBUtil dbUtil;
 
-    public CredentialReaderImpl(DBUtil dbUtil) {
+    public CredentialReaderImpl(DBUtil dbUtil) throws ApplicationSettingsException {
 
-        this.credentialsDAO = new CredentialsDAO();
+        this.credentialsDAO = new CredentialsDAO(ApplicationSettings.getCredentialStoreKeyStorePath(),
+                ApplicationSettings.getCredentialStoreKeyAlias(), new DefaultKeyStorePasswordCallback());
 
         this.dbUtil = dbUtil;
     }
@@ -70,6 +75,18 @@ public class CredentialReaderImpl implem
         }
     }
 
+    public List<Credential> getAllCredentials() throws CredentialStoreException {
+
+        Connection connection = getConnection();
+
+        try {
+            return this.credentialsDAO.getCredentials(connection);
+        } finally {
+            DBUtil.cleanup(connection);
+        }
+
+    }
+
     public String getPortalUser(String gatewayName, String tokenId) throws CredentialStoreException {
 
         Connection connection = getConnection();

Modified: airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/store/impl/SSHCredentialWriter.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/store/impl/SSHCredentialWriter.java?rev=1554737&r1=1554736&r2=1554737&view=diff
==============================================================================
--- airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/store/impl/SSHCredentialWriter.java (original)
+++ airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/store/impl/SSHCredentialWriter.java Thu Jan  2 04:18:26 2014
@@ -24,7 +24,10 @@ package org.apache.airavata.credential.s
 import java.sql.Connection;
 import java.sql.SQLException;
 
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.ApplicationSettings;
 import org.apache.airavata.common.utils.DBUtil;
+import org.apache.airavata.common.utils.DefaultKeyStorePasswordCallback;
 import org.apache.airavata.credential.store.credential.Credential;
 import org.apache.airavata.credential.store.credential.impl.ssh.SSHCredential;
 import org.apache.airavata.credential.store.store.CredentialStoreException;
@@ -43,9 +46,11 @@ public class SSHCredentialWriter impleme
     
     protected static Logger logger = LoggerFactory.getLogger(SSHCredentialWriter.class);
 
-    public SSHCredentialWriter(DBUtil dbUtil) {
+    public SSHCredentialWriter(DBUtil dbUtil) throws ApplicationSettingsException {
         this.dbUtil = dbUtil;
-        credentialsDAO = new CredentialsDAO();
+        this.credentialsDAO = new CredentialsDAO(ApplicationSettings.getCredentialStoreKeyStorePath(),
+                ApplicationSettings.getCredentialStoreKeyAlias(), new DefaultKeyStorePasswordCallback());
+
     }
 
     public void writeCredentials(Credential credential) throws CredentialStoreException {

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=1554737&r1=1554736&r2=1554737&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 Thu Jan  2 04:18:26 2014
@@ -42,9 +42,7 @@ public class CredentialsDAO extends Pare
     private String secretKeyAlias = null;
     private KeyStorePasswordCallback keyStorePasswordCallback = null;
 
-
     public CredentialsDAO() {
-        super();
     }
 
     public CredentialsDAO(String keyStore, String alias, KeyStorePasswordCallback passwordCallback) {
@@ -299,6 +297,54 @@ public class CredentialsDAO extends Pare
         return credentialList;
     }
 
+    /**
+     * Gets all credentials.
+     * @param connection The database connection
+     * @return All credentials as a list
+     * @throws CredentialStoreException If an error occurred while rerieving credentials.
+     */
+    public List<Credential> getCredentials(Connection connection) throws CredentialStoreException {
+
+        List<Credential> credentialList = new ArrayList<Credential>();
+
+        String sql = "select * from credentials";
+
+        PreparedStatement preparedStatement = null;
+        ResultSet resultSet = null;
+
+        try {
+            preparedStatement = connection.prepareStatement(sql);
+
+            resultSet = preparedStatement.executeQuery();
+
+            Credential certificateCredential;
+
+            while (resultSet.next()) {
+
+                Blob blobCredentials = resultSet.getBlob("CREDENTIAL");
+                byte[] certificate = blobCredentials.getBytes(1, (int) blobCredentials.length());
+
+                certificateCredential = (Credential) convertByteArrayToObject(certificate);
+
+                certificateCredential.setPortalUserName(resultSet.getString("PORTAL_USER_ID"));
+                certificateCredential.setCertificateRequestedTime(resultSet.getTimestamp("TIME_PERSISTED"));
+
+                credentialList.add(certificateCredential);
+            }
+
+        } catch (SQLException e) {
+            StringBuilder stringBuilder = new StringBuilder("Error retrieving all credentials");
+
+            log.debug(stringBuilder.toString(), e);
+
+            throw new CredentialStoreException(stringBuilder.toString(), e);
+        } finally {
+            DBUtil.cleanup(preparedStatement, resultSet);
+        }
+
+        return credentialList;
+    }
+
     public Object convertByteArrayToObject(byte[] data) throws CredentialStoreException {
         ObjectInputStream objectInputStream = null;
         Object o = null;

Modified: airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/util/Utility.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/util/Utility.java?rev=1554737&r1=1554736&r2=1554737&view=diff
==============================================================================
--- airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/util/Utility.java (original)
+++ airavata/trunk/modules/credential-store/src/main/java/org/apache/airavata/credential/store/util/Utility.java Thu Jan  2 04:18:26 2014
@@ -25,6 +25,7 @@ import java.io.FileInputStream;
 import java.security.KeyStore;
 import java.security.KeyStoreException;
 import java.text.DateFormat;
+import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 
@@ -41,6 +42,12 @@ public class Utility {
         return df.format(date);
     }
 
+    public static Date convertStringToDate(String date) throws ParseException {
+
+        DateFormat df = new SimpleDateFormat(DATE_FORMAT);
+        return df.parse(date);
+    }
+
     public static String encrypt(String stringToEncrypt) {
         return null;
 

Added: airavata/trunk/modules/credential-store/src/test/java/org/apache/airavata/credential/store/notifier/impl/EmailNotifierTest.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/credential-store/src/test/java/org/apache/airavata/credential/store/notifier/impl/EmailNotifierTest.java?rev=1554737&view=auto
==============================================================================
--- airavata/trunk/modules/credential-store/src/test/java/org/apache/airavata/credential/store/notifier/impl/EmailNotifierTest.java (added)
+++ airavata/trunk/modules/credential-store/src/test/java/org/apache/airavata/credential/store/notifier/impl/EmailNotifierTest.java Thu Jan  2 04:18:26 2014
@@ -0,0 +1,56 @@
+/*
+ *
+ * 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.notifier.impl;
+
+import junit.framework.TestCase;
+import org.apache.airavata.credential.store.notifier.NotificationMessage;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 12/27/13
+ * Time: 1:54 PM
+ */
+
+public class EmailNotifierTest extends TestCase {
+    public void setUp() throws Exception {
+        super.setUp();
+
+    }
+
+    // Test is disabled. Need to fill in parameters to send mails
+    public void xtestNotifyMessage() throws Exception {
+
+        EmailNotifierConfiguration emailNotifierConfiguration = new EmailNotifierConfiguration("smtp.googlemail.com",
+                465, "yyy", "xxx", true, "yyy@gmail.com");
+
+        EmailNotifier notifier = new EmailNotifier(emailNotifierConfiguration);
+        EmailNotificationMessage emailNotificationMessage = new EmailNotificationMessage("Test",
+                "ggg@gmail.com", "Testing credential store");
+        notifier.notifyMessage(emailNotificationMessage);
+
+    }
+
+    // Just to ignore test failures.
+    public void testIgnore() {
+
+    }
+}

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=1554737&r1=1554736&r2=1554737&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 Thu Jan  2 04:18:26 2014
@@ -251,3 +251,4 @@ registry.service.wsdl=http://localhost:$
 
 # If false, disables two phase commit when submitting jobs
 TwoPhase=true
+

Modified: airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/AiravataJPARegistry.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/AiravataJPARegistry.java?rev=1554737&r1=1554736&r2=1554737&view=diff
==============================================================================
--- airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/AiravataJPARegistry.java (original)
+++ airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/AiravataJPARegistry.java Thu Jan  2 04:18:26 2014
@@ -33,6 +33,7 @@ import java.util.Map;
 import java.util.regex.Pattern;
 
 import org.apache.airavata.common.exception.AiravataConfigurationException;
+import org.apache.airavata.common.exception.ApplicationSettingsException;
 import org.apache.airavata.common.utils.DBUtil;
 import org.apache.airavata.common.utils.Version;
 import org.apache.airavata.commons.gfac.type.ApplicationDescription;
@@ -2509,32 +2510,37 @@ public class AiravataJPARegistry extends
 	@Override
 	public boolean isCredentialExist(String gatewayId, String tokenId)
 			throws RegistryException {
-		credentialReader = new CredentialReaderImpl(getDBConnector());
 		try {
-			SSHCredential credential = (SSHCredential) credentialReader.getCredential(gatewayId, tokenId);
+            credentialReader = new CredentialReaderImpl(getDBConnector());
+            SSHCredential credential = (SSHCredential) credentialReader.getCredential(gatewayId, tokenId);
 	    	if (credential!=null) {
 	    		return true;
 	    	}
 		} catch(CredentialStoreException e) {
 			return false;
-		}
-		return false;
+		} catch (ApplicationSettingsException e) {
+            throw new RegistryException("An error occurred while creating credential reader.");
+        }
+        return false;
 	}
 
 	@Override
 	public String getCredentialPublicKey(String gatewayId, String tokenId)
 			throws RegistryException {
 		
-		credentialReader = new CredentialReaderImpl(getDBConnector());
 		try {
-			SSHCredential credential = (SSHCredential) credentialReader.getCredential(gatewayId, tokenId);
+            credentialReader = new CredentialReaderImpl(getDBConnector());
+
+            SSHCredential credential = (SSHCredential) credentialReader.getCredential(gatewayId, tokenId);
 	    	if (credential!=null) {
 	    		return new String(credential.getPublicKey());
 	    	}
 		} catch(CredentialStoreException e) {
 			return null;
-		}
-		return null;
+		} catch (ApplicationSettingsException e) {
+            throw new RegistryException("An error occurred while creating credential reader");
+        }
+        return null;
 	}
 
 	@Override
@@ -2546,9 +2552,10 @@ public class AiravataJPARegistry extends
 	@Override
 	public String createCredential(String gatewayId, String tokenId,
 			String username) throws RegistryException {
-    	credentialWriter = new SSHCredentialWriter(getDBConnector());
-    	credentialGenerator = new SSHCredentialGenerator();
+
     	try {
+            credentialWriter = new SSHCredentialWriter(getDBConnector());
+            credentialGenerator = new SSHCredentialGenerator();
 	    	SSHCredential credential = credentialGenerator.generateCredential(tokenId);
 	    	if (credential!=null) {
 	    		credential.setGateway(gatewayId);
@@ -2559,8 +2566,10 @@ public class AiravataJPARegistry extends
 	    	}
     	} catch (CredentialStoreException e) {
     		return null;
-    	}
-		return null;
+    	} catch (ApplicationSettingsException e) {
+            throw new RegistryException("An error occurred while creating ssh credential writer");
+        }
+        return null;
 	}
 
 	private static DBUtil getDBConnector() throws RegistryException{

Modified: airavata/trunk/modules/rest/webapp/src/main/resources/airavata-server.properties
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/rest/webapp/src/main/resources/airavata-server.properties?rev=1554737&r1=1554736&r2=1554737&view=diff
==============================================================================
--- airavata/trunk/modules/rest/webapp/src/main/resources/airavata-server.properties (original)
+++ airavata/trunk/modules/rest/webapp/src/main/resources/airavata-server.properties Thu Jan  2 04:18:26 2014
@@ -218,3 +218,19 @@ class.registry.accessor=org.apache.airav
 #class.registry.accessor=org.apache.airavata.rest.client.RegistryClient
 registry.service.wsdl=http://localhost:${port}/axis2/services/RegistryService?wsdl
 
+# credential store specific parameters
+credential.store.keystore.url=../webapps/airavata/WEB-INF/classes/credential-store/airavata.jks
+credential.store.keystore.alias=airavata
+credential.store.keystore.password=airavata
+
+notifier.enabled=false
+#period in milliseconds
+notifier.duration=5000
+
+email.server=smtp.googlemail.com
+email.server.port=465
+email.user=airavata
+email.password=xxx
+email.ssl=true
+email.from=airavata@apache.org
+

Added: airavata/trunk/modules/rest/webapp/src/main/resources/credential-store/airavata.jks
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/rest/webapp/src/main/resources/credential-store/airavata.jks?rev=1554737&view=auto
==============================================================================
Binary file - no diff available.

Propchange: airavata/trunk/modules/rest/webapp/src/main/resources/credential-store/airavata.jks
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream