airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scnakand...@apache.org
Subject [09/51] [partial] airavata-php-gateway git commit: removing files from wrong merge
Date Tue, 13 Dec 2016 22:14:33 GMT
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/util/Utility.java
----------------------------------------------------------------------
diff --git a/modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/util/Utility.java b/modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/util/Utility.java
deleted file mode 100644
index e135244..0000000
--- a/modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/util/Utility.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.credential.store.util;
-
-import com.jcraft.jsch.JSch;
-import com.jcraft.jsch.KeyPair;
-import org.apache.airavata.credential.store.credential.impl.ssh.SSHCredential;
-import org.apache.commons.io.FileUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.security.KeyStore;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-/**
- * Contains some utility methods.
- */
-public class Utility {
-
-    protected static Logger log = LoggerFactory.getLogger(Utility.class);
-
-    private static final String DATE_FORMAT = "MM/dd/yyyy HH:mm:ss";
-
-    public static String convertDateToString(Date date) {
-
-        DateFormat df = new SimpleDateFormat(DATE_FORMAT);
-        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;
-
-    }
-
-    public static KeyStore loadKeyStore(String keyStoreFile) throws Exception {
-        KeyStore ks = KeyStore.getInstance("JKS");
-        // get user password and file input stream
-        char[] password = getPassword();
-
-        java.io.FileInputStream fis = null;
-        try {
-            fis = new FileInputStream(keyStoreFile);
-            ks.load(fis, password);
-
-            return ks;
-        } finally {
-            if (fis != null) {
-                fis.close();
-            }
-        }
-    }
-
-    public static char[] getPassword() {
-        return new char[0];
-    }
-
-    public static org.apache.airavata.credential.store.credential.impl.ssh.SSHCredential generateKeyPair(SSHCredential credential) throws Exception{
-        JSch jsch=new JSch();
-        try{
-            KeyPair kpair=KeyPair.genKeyPair(jsch, KeyPair.RSA, 2048);
-            File file = File.createTempFile("id_rsa", "");
-            String fileName = file.getAbsolutePath();
-
-            kpair.writePrivateKey(fileName,credential.getPassphrase().getBytes());
-            kpair.writePublicKey(fileName + ".pub"  , "");
-            kpair.dispose();
-            byte[] priKey = FileUtils.readFileToByteArray(new File(fileName));
-
-            byte[] pubKey = FileUtils.readFileToByteArray(new File(fileName + ".pub"));
-            credential.setPrivateKey(priKey);
-            credential.setPublicKey(pubKey);
-            return credential;
-        }
-        catch(Exception e){
-            log.error("Error while creating key pair", e);
-            throw new Exception("Error while creating key pair", e);
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/credential-store/credential-store-service/src/test/java/org/apache/airavata/credential/store/cpi/SSHSummaryTest/SSHSummaryTest.java
----------------------------------------------------------------------
diff --git a/modules/credential-store/credential-store-service/src/test/java/org/apache/airavata/credential/store/cpi/SSHSummaryTest/SSHSummaryTest.java b/modules/credential-store/credential-store-service/src/test/java/org/apache/airavata/credential/store/cpi/SSHSummaryTest/SSHSummaryTest.java
deleted file mode 100644
index 0852023..0000000
--- a/modules/credential-store/credential-store-service/src/test/java/org/apache/airavata/credential/store/cpi/SSHSummaryTest/SSHSummaryTest.java
+++ /dev/null
@@ -1,173 +0,0 @@
-package org.apache.airavata.credential.store.cpi.SSHSummaryTest;
-
-import junit.framework.Assert;
-import org.apache.airavata.common.utils.DBUtil;
-import org.apache.airavata.common.utils.DatabaseTestCases;
-import org.apache.airavata.common.utils.DerbyUtil;
-import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.airavata.credential.store.credential.impl.ssh.SSHCredential;
-import org.apache.airavata.credential.store.store.impl.SSHCredentialWriter;
-import org.apache.airavata.credential.store.store.impl.db.CredentialsDAO;
-import org.apache.airavata.credential.store.util.TokenGenerator;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.security.KeyStore;
-import java.security.PrivateKey;
-import java.security.cert.X509Certificate;
-import java.sql.Connection;
-
-/**
- * Created by abhandar on 10/24/16.
- */
-public class SSHSummaryTest extends DatabaseTestCases {
-    private static final Logger logger = LoggerFactory.getLogger(SSHSummaryTest.class);
-
-    private CredentialsDAO credentialsDAO;
-
-    private X509Certificate[] x509Certificates;
-    private PrivateKey privateKey;
-
-    @BeforeClass
-    public static void setUpDatabase() throws Exception {
-        DerbyUtil.startDerbyInServerMode(getHostAddress(), getPort(), getUserName(), getPassword());
-
-        waitTillServerStarts();
-
-        /*
-         * String createTable = "CREATE TABLE CREDENTIALS\n" + "(\n" + "        GATEWAY_NAME VARCHAR(256) NOT NULL,\n" +
-         * "        COMMUNITY_USER_NAME VARCHAR(256) NOT NULL,\n" + "        CREDENTIAL BLOB NOT NULL,\n" +
-         * "        PRIVATE_KEY BLOB NOT NULL,\n" + "        NOT_BEFORE VARCHAR(256) NOT NULL,\n" +
-         * "        NOT_AFTER VARCHAR(256) NOT NULL,\n" + "        LIFETIME INTEGER NOT NULL,\n" +
-         * "        REQUESTING_PORTAL_USER_NAME VARCHAR(256) NOT NULL,\n" +
-         * "        REQUESTED_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00',\n" +
-         * "        PRIMARY KEY (GATEWAY_NAME, COMMUNITY_USER_NAME)\n" + ")";
-         */
-        // Adding description field as per pull request https://github.com/apache/airavata/pull/54
-        String createTable = "CREATE TABLE CREDENTIALS\n" + "(\n"
-                + "        GATEWAY_ID VARCHAR(256) NOT NULL,\n"
-                + "        TOKEN_ID VARCHAR(256) NOT NULL,\n"
-                + // Actual token used to identify the credential
-                "        CREDENTIAL BLOB NOT NULL,\n" + "        PORTAL_USER_ID VARCHAR(256) NOT NULL,\n"
-                + "        TIME_PERSISTED TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n"
-                + "        DESCRIPTION VARCHAR(500),\n"
-                + "        PRIMARY KEY (GATEWAY_ID, TOKEN_ID)\n" + ")";
-
-        String dropTable = "drop table CREDENTIALS";
-
-        try {
-            executeSQL(dropTable);
-        } catch (Exception e) {
-        }
-
-        executeSQL(createTable);
-
-    }
-
-    @AfterClass
-    public static void shutDownDatabase() throws Exception {
-        DerbyUtil.stopDerbyServer();
-    }
-
-    @Before
-    public void setUp() throws Exception {
-
-        credentialsDAO = new CredentialsDAO();
-
-        x509Certificates = new X509Certificate[1];
-
-        // Cleanup tables;
-        Connection connection = getConnection();
-
-        try {
-            DBUtil.truncate("credentials", connection);
-        } finally {
-            connection.close();
-        }
-
-        initializeKeys();
-    }
-
-    private void initializeKeys() throws Exception {
-        KeyStore ks = KeyStore.getInstance("JKS");
-        char[] password = "password".toCharArray();
-
-        String baseDirectory = System.getProperty("credential.module.directory");
-
-        String keyStorePath = "src" + File.separator + "test" + File.separator + "resources" + File.separator
-                + "keystore.jks";
-
-        if (baseDirectory != null) {
-            keyStorePath = baseDirectory + File.separator + keyStorePath;
-        } else {
-            keyStorePath = "modules" + File.separator + "credential-store" + File.separator + keyStorePath;
-        }
-
-        File keyStoreFile = new File(keyStorePath);
-        if (!keyStoreFile.exists()) {
-            logger.error("Unable to read keystore file " + keyStoreFile);
-            throw new RuntimeException("Unable to read keystore file " + keyStoreFile);
-
-        }
-
-        java.io.FileInputStream fis = null;
-        try {
-            fis = new java.io.FileInputStream(keyStorePath);
-            ks.load(fis, password);
-        } finally {
-            if (fis != null) {
-                fis.close();
-            }
-        }
-
-        fis.close();
-
-        privateKey = (PrivateKey) ks.getKey("selfsigned", password);
-        x509Certificates[0] = (X509Certificate) ks.getCertificate("selfsigned");
-
-    }
-
-
-//    @Test Change the properties in ServerProperties file and give the correct path to run the test
-    public void testSSHSummary() throws Exception{
-        try{
-            String jdbcURL = ServerSettings.getCredentialStoreDBURL();
-            String jdbcDriver = ServerSettings.getCredentialStoreDBDriver();
-            String userName = ServerSettings.getCredentialStoreDBUser();
-            String password = ServerSettings.getCredentialStoreDBPassword();
-            String gatewayId = "phasta";
-            String privateKeyPath = "/home/abhandar/Documents/Airavata/keys/id_rsa_airavata";
-            String pubKeyPath = "/home/abhandar/Documents/Airavata/keys/id_rsa_airavata.pub";
-            DBUtil dbUtil = new DBUtil(jdbcURL, userName, password, jdbcDriver);
-            SSHCredentialWriter writer = new SSHCredentialWriter(dbUtil);
-            SSHCredential sshCredential = new SSHCredential();
-            sshCredential.setGateway(gatewayId);
-            String token = TokenGenerator.generateToken(gatewayId, null);
-            sshCredential.setToken(token);
-            sshCredential.setPortalUserName("phasta");
-            sshCredential.setDescription("dummy creds for testing");
-            FileInputStream privateKeyStream = new FileInputStream(privateKeyPath);
-            File filePri = new File(privateKeyPath);
-            byte[] bFilePri = new byte[(int) filePri.length()];
-            privateKeyStream.read(bFilePri);
-            FileInputStream pubKeyStream = new FileInputStream(pubKeyPath);
-            File filePub = new File(pubKeyPath);
-            byte[] bFilePub = new byte[(int) filePub.length()];
-            pubKeyStream.read(bFilePub);
-            privateKeyStream.close();
-            pubKeyStream.close();
-            sshCredential.setPrivateKey(bFilePri);
-            sshCredential.setPublicKey(bFilePub);
-            sshCredential.setPassphrase("ultrascan");
-            writer.writeCredentials(sshCredential);
-            Assert.assertEquals(token, sshCredential.getToken());
-        }catch (Exception ex){
-            ex.printStackTrace();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/credential-store/credential-store-service/src/test/java/org/apache/airavata/credential/store/notifier/impl/EmailNotifierTest.java
----------------------------------------------------------------------
diff --git a/modules/credential-store/credential-store-service/src/test/java/org/apache/airavata/credential/store/notifier/impl/EmailNotifierTest.java b/modules/credential-store/credential-store-service/src/test/java/org/apache/airavata/credential/store/notifier/impl/EmailNotifierTest.java
deleted file mode 100644
index 05d7a10..0000000
--- a/modules/credential-store/credential-store-service/src/test/java/org/apache/airavata/credential/store/notifier/impl/EmailNotifierTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- *
- * 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() {
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/credential-store/credential-store-service/src/test/java/org/apache/airavata/credential/store/store/impl/db/CommunityUserDAOTest.java
----------------------------------------------------------------------
diff --git a/modules/credential-store/credential-store-service/src/test/java/org/apache/airavata/credential/store/store/impl/db/CommunityUserDAOTest.java b/modules/credential-store/credential-store-service/src/test/java/org/apache/airavata/credential/store/store/impl/db/CommunityUserDAOTest.java
deleted file mode 100644
index 787cc54..0000000
--- a/modules/credential-store/credential-store-service/src/test/java/org/apache/airavata/credential/store/store/impl/db/CommunityUserDAOTest.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- *
- * 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.store.impl.db;
-
-import org.apache.airavata.common.utils.DBUtil;
-import org.apache.airavata.common.utils.DatabaseTestCases;
-import org.apache.airavata.common.utils.DerbyUtil;
-import org.apache.airavata.credential.store.credential.CommunityUser;
-import org.junit.*;
-
-import java.sql.Connection;
-import java.util.List;
-
-/**
- * Test for community user DAO.
- */
-public class CommunityUserDAOTest extends DatabaseTestCases {
-
-    private CommunityUserDAO communityUserDAO;
-
-    @BeforeClass
-    public static void setUpDatabase() throws Exception {
-
-        DerbyUtil.startDerbyInServerMode(getHostAddress(), getPort(), getUserName(), getPassword());
-
-        waitTillServerStarts();
-
-        String createTable = "CREATE TABLE COMMUNITY_USER\n" + "                (\n"
-                + "                        GATEWAY_ID VARCHAR(256) NOT NULL,\n"
-                + "                        COMMUNITY_USER_NAME VARCHAR(256) NOT NULL,\n"
-                + "                        TOKEN_ID VARCHAR(256) NOT NULL,\n"
-                + "                        COMMUNITY_USER_EMAIL VARCHAR(256) NOT NULL,\n"
-                + "                        PRIMARY KEY (GATEWAY_ID, COMMUNITY_USER_NAME, TOKEN_ID)\n"
-                + "                )";
-
-        String dropTable = "drop table COMMUNITY_USER";
-
-        try {
-            executeSQL(dropTable);
-        } catch (Exception e) {
-        }
-
-        executeSQL(createTable);
-
-    }
-
-    @AfterClass
-    public static void shutDownDatabase() throws Exception {
-        DerbyUtil.stopDerbyServer();
-    }
-
-    @Before
-    public void setUp() throws Exception {
-
-        communityUserDAO = new CommunityUserDAO();
-
-        Connection connection = getDbUtil().getConnection();
-
-        try {
-            DBUtil.truncate("community_user", connection);
-        } finally {
-            connection.close();
-        }
-
-    }
-
-    @Test
-    public void testAddCommunityUser() throws Exception {
-
-        Connection connection = getConnection();
-
-        try {
-
-            CommunityUser communityUser = new CommunityUser("gw1", "ogce", "ogce@sciencegateway.org");
-            communityUserDAO.addCommunityUser(communityUser, "Token1", connection);
-
-            communityUser = new CommunityUser("gw1", "ogce2", "ogce@sciencegateway.org");
-            communityUserDAO.addCommunityUser(communityUser, "Token2", connection);
-
-            CommunityUser user = communityUserDAO.getCommunityUser("gw1", "ogce", connection);
-            Assert.assertNotNull(user);
-            Assert.assertEquals("ogce@sciencegateway.org", user.getUserEmail());
-
-            user = communityUserDAO.getCommunityUser("gw1", "ogce2", connection);
-            Assert.assertNotNull(user);
-            Assert.assertEquals("ogce@sciencegateway.org", user.getUserEmail());
-
-            user = communityUserDAO.getCommunityUserByToken("gw1", "Token1", connection);
-            Assert.assertNotNull(user);
-            Assert.assertEquals("ogce", user.getUserName());
-            Assert.assertEquals("ogce@sciencegateway.org", user.getUserEmail());
-
-            user = communityUserDAO.getCommunityUserByToken("gw1", "Token2", connection);
-            Assert.assertNotNull(user);
-            Assert.assertEquals("ogce2", user.getUserName());
-            Assert.assertEquals("ogce@sciencegateway.org", user.getUserEmail());
-
-        } finally {
-            connection.close();
-        }
-
-    }
-
-    @Test
-    public void testDeleteCommunityUser() throws Exception {
-
-        Connection connection = getConnection();
-
-        try {
-            CommunityUser communityUser = new CommunityUser("gw1", "ogce", "ogce@sciencegateway.org");
-            communityUserDAO.addCommunityUser(communityUser, "Token1", connection);
-
-            CommunityUser user = communityUserDAO.getCommunityUser("gw1", "ogce", connection);
-            Assert.assertNotNull(user);
-
-            communityUser = new CommunityUser("gw1", "ogce", "ogce@sciencegateway.org");
-            communityUserDAO.deleteCommunityUser(communityUser, connection);
-
-            user = communityUserDAO.getCommunityUser("gw1", "ogce", connection);
-            Assert.assertNull(user);
-
-        } finally {
-            connection.close();
-        }
-    }
-
-    @Test
-    public void testDeleteCommunityUserByToken() throws Exception {
-
-        Connection connection = getConnection();
-
-        try {
-            CommunityUser communityUser = new CommunityUser("gw1", "ogce", "ogce@sciencegateway.org");
-            communityUserDAO.addCommunityUser(communityUser, "Token1", connection);
-
-            CommunityUser user = communityUserDAO.getCommunityUser("gw1", "ogce", connection);
-            Assert.assertNotNull(user);
-
-            communityUser = new CommunityUser("gw1", "ogce", "ogce@sciencegateway.org");
-            communityUserDAO.deleteCommunityUserByToken(communityUser, "Token1", connection);
-
-            user = communityUserDAO.getCommunityUser("gw1", "ogce", connection);
-            Assert.assertNull(user);
-
-        } finally {
-            connection.close();
-        }
-
-    }
-
-    @Test
-    public void testGetCommunityUsers() throws Exception {
-
-        Connection connection = getConnection();
-
-        try {
-            CommunityUser communityUser = new CommunityUser("gw1", "ogce", "ogce@sciencegateway.org");
-            communityUserDAO.addCommunityUser(communityUser, "Token1", connection);
-
-            CommunityUser user = communityUserDAO.getCommunityUser("gw1", "ogce", connection);
-            Assert.assertNotNull(user);
-            Assert.assertEquals("ogce@sciencegateway.org", user.getUserEmail());
-
-        } finally {
-            connection.close();
-        }
-
-    }
-
-    @Test
-    public void testGetCommunityUsersForGateway() throws Exception {
-
-        Connection connection = getConnection();
-
-        CommunityUser communityUser = new CommunityUser("gw1", "ogce", "ogce@sciencegateway.org");
-        communityUserDAO.addCommunityUser(communityUser, "Token1", connection);
-
-        communityUser = new CommunityUser("gw1", "ogce2", "ogce@sciencegateway.org");
-        communityUserDAO.addCommunityUser(communityUser, "Token2", connection);
-
-        List<CommunityUser> users = communityUserDAO.getCommunityUsers("gw1", connection);
-        Assert.assertNotNull(users);
-        Assert.assertEquals(2, users.size());
-
-        Assert.assertEquals(users.get(0).getUserName(), "ogce");
-        Assert.assertEquals(users.get(1).getUserName(), "ogce2");
-    }
-}

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/credential-store/credential-store-service/src/test/java/org/apache/airavata/credential/store/store/impl/db/CredentialsDAOTest.java
----------------------------------------------------------------------
diff --git a/modules/credential-store/credential-store-service/src/test/java/org/apache/airavata/credential/store/store/impl/db/CredentialsDAOTest.java b/modules/credential-store/credential-store-service/src/test/java/org/apache/airavata/credential/store/store/impl/db/CredentialsDAOTest.java
deleted file mode 100644
index 63efb46..0000000
--- a/modules/credential-store/credential-store-service/src/test/java/org/apache/airavata/credential/store/store/impl/db/CredentialsDAOTest.java
+++ /dev/null
@@ -1,431 +0,0 @@
-/*
- *
- * 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.store.impl.db;
-
-import junit.framework.Assert;
-import org.apache.airavata.common.utils.DBUtil;
-import org.apache.airavata.common.utils.DatabaseTestCases;
-import org.apache.airavata.common.utils.DerbyUtil;
-import org.apache.airavata.common.utils.KeyStorePasswordCallback;
-import org.apache.airavata.credential.store.credential.CommunityUser;
-import org.apache.airavata.credential.store.credential.Credential;
-import org.apache.airavata.credential.store.credential.CredentialOwnerType;
-import org.apache.airavata.credential.store.credential.impl.certificate.CertificateCredential;
-import org.apache.airavata.credential.store.store.CredentialStoreException;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.net.URL;
-import java.security.KeyStore;
-import java.security.PrivateKey;
-import java.security.cert.X509Certificate;
-import java.sql.Connection;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Test class for credential class
- */
-public class CredentialsDAOTest extends DatabaseTestCases {
-
-    private static final Logger logger = LoggerFactory.getLogger(CredentialsDAOTest.class);
-
-    private CredentialsDAO credentialsDAO;
-
-    private X509Certificate[] x509Certificates;
-    private PrivateKey privateKey;
-
-    @BeforeClass
-    public static void setUpDatabase() throws Exception {
-        DerbyUtil.startDerbyInServerMode(getHostAddress(), getPort(), getUserName(), getPassword());
-
-        waitTillServerStarts();
-
-        /*
-         * String createTable = "CREATE TABLE CREDENTIALS\n" + "(\n" + "        GATEWAY_NAME VARCHAR(256) NOT NULL,\n" +
-         * "        COMMUNITY_USER_NAME VARCHAR(256) NOT NULL,\n" + "        CREDENTIAL BLOB NOT NULL,\n" +
-         * "        PRIVATE_KEY BLOB NOT NULL,\n" + "        NOT_BEFORE VARCHAR(256) NOT NULL,\n" +
-         * "        NOT_AFTER VARCHAR(256) NOT NULL,\n" + "        LIFETIME INTEGER NOT NULL,\n" +
-         * "        REQUESTING_PORTAL_USER_NAME VARCHAR(256) NOT NULL,\n" +
-         * "        REQUESTED_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00',\n" +
-         * "        PRIMARY KEY (GATEWAY_NAME, COMMUNITY_USER_NAME)\n" + ")";
-         */
-        // Adding description field as per pull request https://github.com/apache/airavata/pull/54
-        String createTable = "CREATE TABLE CREDENTIALS\n" + "(\n"
-                + "        GATEWAY_ID VARCHAR(256) NOT NULL,\n"
-                + "        TOKEN_ID VARCHAR(256) NOT NULL,\n"
-                + // Actual token used to identify the credential
-                "        CREDENTIAL BLOB NOT NULL,\n" + "        PORTAL_USER_ID VARCHAR(256) NOT NULL,\n"
-                + "        TIME_PERSISTED TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n"
-                + "        DESCRIPTION VARCHAR(500),\n"
-                + "        CREDENTIAL_OWNER_TYPE VARCHAR(10) DEFAULT 'GATEWAY' NOT NULL,\n"
-                + "        PRIMARY KEY (GATEWAY_ID, TOKEN_ID)\n" + ")";
-
-        String dropTable = "drop table CREDENTIALS";
-
-        try {
-            executeSQL(dropTable);
-        } catch (Exception e) {
-        }
-
-        executeSQL(createTable);
-
-    }
-
-    @AfterClass
-    public static void shutDownDatabase() throws Exception {
-        DerbyUtil.stopDerbyServer();
-    }
-
-    @Before
-    public void setUp() throws Exception {
-
-        credentialsDAO = new CredentialsDAO();
-
-        x509Certificates = new X509Certificate[1];
-
-        // Cleanup tables;
-        Connection connection = getConnection();
-
-        try {
-            DBUtil.truncate("credentials", connection);
-        } finally {
-            connection.close();
-        }
-
-        initializeKeys();
-    }
-
-    private void initializeKeys() throws Exception {
-        KeyStore ks = KeyStore.getInstance("JKS");
-        char[] password = "password".toCharArray();
-
-        String baseDirectory = System.getProperty("credential.module.directory");
-
-        String keyStorePath = "src" + File.separator + "test" + File.separator + "resources" + File.separator
-                + "keystore.jks";
-
-        if (baseDirectory != null) {
-            keyStorePath = baseDirectory + File.separator + keyStorePath;
-        } else {
-            keyStorePath = "modules" + File.separator + "credential-store" + File.separator + keyStorePath;
-        }
-
-        File keyStoreFile = new File(keyStorePath);
-        if (!keyStoreFile.exists()) {
-            logger.error("Unable to read keystore file " + keyStoreFile);
-            throw new RuntimeException("Unable to read keystore file " + keyStoreFile);
-
-        }
-
-        java.io.FileInputStream fis = null;
-        try {
-            fis = new java.io.FileInputStream(keyStorePath);
-            ks.load(fis, password);
-        } finally {
-            if (fis != null) {
-                fis.close();
-            }
-        }
-
-        fis.close();
-
-        privateKey = (PrivateKey) ks.getKey("selfsigned", password);
-        x509Certificates[0] = (X509Certificate) ks.getCertificate("selfsigned");
-
-    }
-
-    @Test
-    public void testKeyReading() throws Exception {
-        initializeKeys();
-        System.out.println(privateKey.getAlgorithm());
-        System.out.println(x509Certificates[0].getIssuerDN());
-
-        Assert.assertNotNull(privateKey);
-        Assert.assertNotNull(x509Certificates);
-    }
-
-    private CommunityUser getCommunityUser(String gateway, String name) {
-        return new CommunityUser(gateway, name, "amila@sciencegateway.org");
-    }
-
-    private void addTestCredentials() throws Exception {
-
-        Connection connection = getConnection();
-
-        try {
-            CertificateCredential certificateCredential = getTestCredentialObject();
-            credentialsDAO.addCredentials(certificateCredential.getCommunityUser().getGatewayName(),
-                    certificateCredential, connection);
-
-        } finally {
-            connection.close();
-        }
-    }
-
-    public CertificateCredential getTestCredentialObject() {
-
-        CertificateCredential certificateCredential = new CertificateCredential();
-        certificateCredential.setToken("tom");
-        certificateCredential.setCertificates(x509Certificates);
-        certificateCredential.setPrivateKey(privateKey);
-        certificateCredential.setCommunityUser(getCommunityUser("gw1", "tom"));
-        certificateCredential.setLifeTime(1000);
-        certificateCredential.setPortalUserName("jerry");
-        certificateCredential.setNotBefore("13 OCT 2012 5:34:23");
-        certificateCredential.setNotAfter("14 OCT 2012 5:34:23");
-        certificateCredential.setCredentialOwnerType(CredentialOwnerType.GATEWAY);
-
-        return certificateCredential;
-
-    }
-
-    @Test
-    public void testSerialization() throws CredentialStoreException {
-
-        CertificateCredential certificateCredential = getTestCredentialObject();
-
-        CredentialsDAO credentialsDAO1 = new CredentialsDAO();
-
-        byte[] array = credentialsDAO1.convertObjectToByteArray(certificateCredential);
-        CertificateCredential readCertificateCredential = (CertificateCredential) credentialsDAO1
-                .convertByteArrayToObject(array);
-
-        checkEquality(certificateCredential.getCertificates(), readCertificateCredential.getCertificates());
-        Assert.assertEquals(certificateCredential.getCertificateRequestedTime(),
-                readCertificateCredential.getCertificateRequestedTime());
-        Assert.assertEquals(certificateCredential.getCommunityUser().getGatewayName(), readCertificateCredential
-                .getCommunityUser().getGatewayName());
-        Assert.assertEquals(certificateCredential.getCommunityUser().getUserEmail(), readCertificateCredential
-                .getCommunityUser().getUserEmail());
-        Assert.assertEquals(certificateCredential.getCommunityUser().getUserName(), readCertificateCredential
-                .getCommunityUser().getUserName());
-        Assert.assertEquals(certificateCredential.getLifeTime(), readCertificateCredential.getLifeTime());
-        Assert.assertEquals(certificateCredential.getNotAfter(), readCertificateCredential.getNotAfter());
-        Assert.assertEquals(certificateCredential.getNotBefore(), readCertificateCredential.getNotBefore());
-        Assert.assertEquals(certificateCredential.getPortalUserName(), readCertificateCredential.getPortalUserName());
-        Assert.assertEquals(certificateCredential.getCredentialOwnerType(), readCertificateCredential.getCredentialOwnerType());
-
-        PrivateKey newKey = readCertificateCredential.getPrivateKey();
-
-        Assert.assertNotNull(newKey);
-        Assert.assertEquals(privateKey.getClass(), newKey.getClass());
-
-        Assert.assertEquals(privateKey.getFormat(), newKey.getFormat());
-        Assert.assertEquals(privateKey.getAlgorithm(), newKey.getAlgorithm());
-        Assert.assertTrue(Arrays.equals(privateKey.getEncoded(), newKey.getEncoded()));
-    }
-
-    @Test
-    public void testSerializationWithEncryption() throws CredentialStoreException {
-
-        URL url = this.getClass().getClassLoader().getResource("mykeystore.jks");
-        String secretKeyAlias = "mykey";
-
-        assert url != null;
-
-        CertificateCredential certificateCredential = getTestCredentialObject();
-
-        CredentialsDAO credentialsDAO1 = new CredentialsDAO(url.getPath(), secretKeyAlias,
-                new TestACSKeyStoreCallback());
-
-        byte[] array = credentialsDAO1.convertObjectToByteArray(certificateCredential);
-        CertificateCredential readCertificateCredential = (CertificateCredential) credentialsDAO1
-                .convertByteArrayToObject(array);
-
-        checkEquality(certificateCredential.getCertificates(), readCertificateCredential.getCertificates());
-        Assert.assertEquals(certificateCredential.getCertificateRequestedTime(),
-                readCertificateCredential.getCertificateRequestedTime());
-        Assert.assertEquals(certificateCredential.getCommunityUser().getGatewayName(), readCertificateCredential
-                .getCommunityUser().getGatewayName());
-        Assert.assertEquals(certificateCredential.getCommunityUser().getUserEmail(), readCertificateCredential
-                .getCommunityUser().getUserEmail());
-        Assert.assertEquals(certificateCredential.getCommunityUser().getUserName(), readCertificateCredential
-                .getCommunityUser().getUserName());
-        Assert.assertEquals(certificateCredential.getLifeTime(), readCertificateCredential.getLifeTime());
-        Assert.assertEquals(certificateCredential.getNotAfter(), readCertificateCredential.getNotAfter());
-        Assert.assertEquals(certificateCredential.getNotBefore(), readCertificateCredential.getNotBefore());
-        Assert.assertEquals(certificateCredential.getPortalUserName(), readCertificateCredential.getPortalUserName());
-        Assert.assertEquals(certificateCredential.getCredentialOwnerType(), readCertificateCredential.getCredentialOwnerType());
-
-        PrivateKey newKey = readCertificateCredential.getPrivateKey();
-
-        Assert.assertNotNull(newKey);
-        Assert.assertEquals(privateKey.getClass(), newKey.getClass());
-
-        Assert.assertEquals(privateKey.getFormat(), newKey.getFormat());
-        Assert.assertEquals(privateKey.getAlgorithm(), newKey.getAlgorithm());
-        Assert.assertTrue(Arrays.equals(privateKey.getEncoded(), newKey.getEncoded()));
-    }
-
-    private class TestACSKeyStoreCallback implements KeyStorePasswordCallback {
-
-        @Override
-        public char[] getStorePassword() {
-            return "airavata".toCharArray();
-        }
-
-        @Override
-        public char[] getSecretKeyPassPhrase(String keyAlias) {
-            if (keyAlias.equals("mykey")) {
-                return "airavatasecretkey".toCharArray();
-            }
-
-            return null;
-        }
-    }
-
-    private void checkEquality(X509Certificate[] certificates1, X509Certificate[] certificates2) {
-
-        int i = 0;
-
-        for (X509Certificate certificate : certificates1) {
-            Assert.assertEquals(certificate, certificates2[i]);
-        }
-
-        Assert.assertEquals(certificates1.length, certificates2.length);
-
-    }
-
-    @Test
-    public void testAddCredentials() throws Exception {
-
-        addTestCredentials();
-
-        Connection connection = getConnection();
-
-        try {
-            CertificateCredential certificateCredential = (CertificateCredential) credentialsDAO.getCredential("gw1",
-                    "tom", connection);
-            //Test get gateway name
-            String gateway = credentialsDAO.getGatewayID("tom", connection);
-            Assert.assertNotNull(certificateCredential);
-            Assert.assertEquals("jerry", certificateCredential.getPortalUserName());
-            Assert.assertEquals("gw1", gateway);
-            checkEquality(x509Certificates, certificateCredential.getCertificates());
-            Assert.assertEquals(privateKey.getFormat(), certificateCredential.getPrivateKey().getFormat());
-        } finally {
-            connection.close();
-        }
-    }
-    
-    @Test
-    public void testDeleteCredentials() throws Exception {
-
-        addTestCredentials();
-
-        Connection connection = getConnection();
-
-        try {
-            CertificateCredential certificateCredential = (CertificateCredential) credentialsDAO.getCredential("gw1",
-                    "tom", connection);
-            Assert.assertNotNull(certificateCredential);
-
-            credentialsDAO.deleteCredentials("gw1", "tom", connection);
-
-            certificateCredential = (CertificateCredential) credentialsDAO.getCredential("gw1", "tom", connection);
-            Assert.assertNull(certificateCredential);
-
-        } finally {
-            connection.close();
-        }
-    }
-
-    @Test
-    public void testUpdateCredentials() throws Exception {
-
-        addTestCredentials();
-
-        Connection connection = getConnection();
-
-        try {
-            CommunityUser communityUser = getCommunityUser("gw1", "tom");
-            CertificateCredential certificateCredential = new CertificateCredential();
-            certificateCredential.setToken("tom");
-            certificateCredential.setCommunityUser(communityUser);
-            certificateCredential.setCertificates(x509Certificates);
-            // certificateCredential.setPrivateKey(privateKey);
-            certificateCredential.setPortalUserName("test2");
-            certificateCredential.setLifeTime(50);
-            certificateCredential.setNotBefore("15 OCT 2012 5:34:23");
-            certificateCredential.setNotAfter("16 OCT 2012 5:34:23");
-            certificateCredential.setCredentialOwnerType(CredentialOwnerType.USER);
-
-            credentialsDAO.updateCredentials(communityUser.getGatewayName(), certificateCredential, connection);
-
-            certificateCredential = (CertificateCredential) credentialsDAO.getCredential("gw1", "tom", connection);
-
-            Assert.assertEquals("CN=Airavata Project, OU=IU, O=Indiana University, L=Bloomington, ST=IN, C=US",
-                    certificateCredential.getCertificates()[0].getIssuerDN().toString());
-            // Assert.assertNotNull(certificateCredential.getPrivateKey());
-            Assert.assertEquals("test2", certificateCredential.getPortalUserName());
-            Assert.assertEquals(CredentialOwnerType.USER, certificateCredential.getCredentialOwnerType());
-
-        } finally {
-            connection.close();
-        }
-
-    }
-
-    @Test
-    public void testGetCredentials() throws Exception {
-
-        addTestCredentials();
-
-        Connection connection = getConnection();
-
-        try {
-
-            CertificateCredential certificateCredential = (CertificateCredential) credentialsDAO.getCredential("gw1",
-                    "tom", connection);
-            Assert.assertEquals("CN=Airavata Project, OU=IU, O=Indiana University, L=Bloomington, ST=IN, C=US",
-                    certificateCredential.getCertificates()[0].getIssuerDN().toString());
-            // Assert.assertNotNull(certificateCredential.getPrivateKey());
-
-        } finally {
-            connection.close();
-        }
-    }
-
-    @Test
-    public void testGetGatewayCredentials() throws Exception {
-
-        addTestCredentials();
-
-        Connection connection = getConnection();
-
-        try {
-            List<Credential> list = credentialsDAO.getCredentials("gw1", connection);
-
-            Assert.assertEquals(1, list.size());
-        } finally {
-            connection.close();
-        }
-
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/credential-store/credential-store-service/src/test/java/org/apache/airavata/credential/store/store/impl/db/SSHCredentialTest.java
----------------------------------------------------------------------
diff --git a/modules/credential-store/credential-store-service/src/test/java/org/apache/airavata/credential/store/store/impl/db/SSHCredentialTest.java b/modules/credential-store/credential-store-service/src/test/java/org/apache/airavata/credential/store/store/impl/db/SSHCredentialTest.java
deleted file mode 100644
index e160910..0000000
--- a/modules/credential-store/credential-store-service/src/test/java/org/apache/airavata/credential/store/store/impl/db/SSHCredentialTest.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- *
- * 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.store.impl.db;
-
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.DBUtil;
-import org.apache.airavata.credential.store.credential.impl.ssh.SSHCredential;
-import org.apache.airavata.credential.store.store.CredentialStoreException;
-import org.apache.airavata.credential.store.store.impl.SSHCredentialWriter;
-import org.apache.airavata.credential.store.util.TokenGenerator;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-
-public class SSHCredentialTest {
-
-    public static void main(String[] args) {
-        String jdbcURL = "jdbc:mysql://gw85.iu.xsede.org:3306/airavata_gw119";
-        String jdbcDriver = "com.mysql.jdbc.Driver";
-        String userName = "gtaDevUser";
-        String password = "gtaDevPWD";
-        String gatewayId = "phasta";
-        String privateKeyPath = "/Users/chathuri/Desktop/ssh_gw111/id_rsa";
-        String pubKeyPath = "/Users/chathuri/Desktop/ssh_gw111/id_rsa.pub";
-
-        try {
-            DBUtil dbUtil = new DBUtil(jdbcURL, userName, password, jdbcDriver);
-            SSHCredentialWriter writer = new SSHCredentialWriter(dbUtil);
-            SSHCredential sshCredential = new SSHCredential();
-            sshCredential.setGateway(gatewayId);
-            String token = TokenGenerator.generateToken(gatewayId, null);
-            sshCredential.setToken(token);
-            sshCredential.setPortalUserName("phasta");
-            sshCredential.setDescription("dummy creds for testing");
-            FileInputStream privateKeyStream = new FileInputStream(privateKeyPath);
-            File filePri = new File(privateKeyPath);
-            byte[] bFilePri = new byte[(int) filePri.length()];
-            privateKeyStream.read(bFilePri);
-            FileInputStream pubKeyStream = new FileInputStream(pubKeyPath);
-            File filePub = new File(pubKeyPath);
-            byte[] bFilePub = new byte[(int) filePub.length()];
-            pubKeyStream.read(bFilePub);
-            privateKeyStream.close();
-            pubKeyStream.close();
-            sshCredential.setPrivateKey(bFilePri);
-            sshCredential.setPublicKey(bFilePub);
-            sshCredential.setPassphrase("ultrascan");
-            writer.writeCredentials(sshCredential);
-            System.out.println(token);
-        } catch (ClassNotFoundException e) {
-            e.printStackTrace();
-        } catch (InstantiationException e) {
-            e.printStackTrace();
-        } catch (IllegalAccessException e) {
-            e.printStackTrace();
-        } catch (ApplicationSettingsException e) {
-            e.printStackTrace();
-        } catch (CredentialStoreException e) {
-            e.printStackTrace();
-        } catch (FileNotFoundException e) {
-            e.printStackTrace();
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-
-
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/credential-store/credential-store-service/src/test/java/org/apache/airavata/credential/store/util/ConfigurationReaderTest.java
----------------------------------------------------------------------
diff --git a/modules/credential-store/credential-store-service/src/test/java/org/apache/airavata/credential/store/util/ConfigurationReaderTest.java b/modules/credential-store/credential-store-service/src/test/java/org/apache/airavata/credential/store/util/ConfigurationReaderTest.java
deleted file mode 100644
index 7a95e3e..0000000
--- a/modules/credential-store/credential-store-service/src/test/java/org/apache/airavata/credential/store/util/ConfigurationReaderTest.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.credential.store.util;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-/**
- * User: AmilaJ (amilaj@apache.org)
- * Date: 8/25/13
- * Time: 10:28 AM
- */
-
-public class ConfigurationReaderTest extends TestCase {
-    public void setUp() throws Exception {
-        super.setUp();
-
-    }
-
-    public void testGetSuccessUrl() throws Exception {
-
-        ConfigurationReader configurationReader = new ConfigurationReader();
-        System.out.println(configurationReader.getSuccessUrl());
-        Assert.assertEquals("/credential-store/success.jsp", configurationReader.getSuccessUrl());
-    }
-
-    public void testGetErrorUrl() throws Exception {
-
-        ConfigurationReader configurationReader = new ConfigurationReader();
-        Assert.assertEquals("/credential-store/error.jsp", configurationReader.getErrorUrl());
-
-    }
-
-    public void testRedirectUrl() throws Exception {
-
-        ConfigurationReader configurationReader = new ConfigurationReader();
-        Assert.assertEquals("/credential-store/show-redirect.jsp", configurationReader.getPortalRedirectUrl());
-    }
-}

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/credential-store/credential-store-service/src/test/java/org/apache/airavata/credential/store/util/TokenGeneratorTest.java
----------------------------------------------------------------------
diff --git a/modules/credential-store/credential-store-service/src/test/java/org/apache/airavata/credential/store/util/TokenGeneratorTest.java b/modules/credential-store/credential-store-service/src/test/java/org/apache/airavata/credential/store/util/TokenGeneratorTest.java
deleted file mode 100644
index 57b52ae..0000000
--- a/modules/credential-store/credential-store-service/src/test/java/org/apache/airavata/credential/store/util/TokenGeneratorTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.credential.store.util;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-/**
- * User: AmilaJ (amilaj@apache.org)
- * Date: 8/5/13
- * Time: 4:20 PM
- */
-
-public class    TokenGeneratorTest extends TestCase {
-
-    public void testGenerateToken() throws Exception {
-
-        String token = TokenGenerator.generateToken("gw1", "admin");
-        Assert.assertNotNull(token);
-        System.out.println(token);
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/credential-store/credential-store-service/src/test/resources/credential-store/client.xml
----------------------------------------------------------------------
diff --git a/modules/credential-store/credential-store-service/src/test/resources/credential-store/client.xml b/modules/credential-store/credential-store-service/src/test/resources/credential-store/client.xml
deleted file mode 100644
index 8b934e6..0000000
--- a/modules/credential-store/credential-store-service/src/test/resources/credential-store/client.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--Licensed to the Apache Software
-	Foundation (ASF) under one or more contributor license agreements. See the
-	NOTICE file distributed with this work for additional information regarding
-	copyright ownership. The ASF licenses this file to you under the Apache License,
-	Version 2.0 (theÏ "License"); you may not use this file except in compliance
-	with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-	Unless required by applicable law or agreed to in writing, software distributed
-	under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
-	OR CONDITIONS OF ANY ~ KIND, either express or implied. See the License for
-	the specific language governing permissions and limitations under the License. -->
-
-<config>
-    <client name="acs">
-        <logging
-                logFileName="../logs/oa4mp.log"
-                logName="oa4mp"
-                logSize="1000000"
-                logFileCount="2"
-                debug="true"/>
-        <id>myproxy:oa4mp,2012:/client/24c45c2eb65d93231d02d423e94d0362</id>
-        <serviceUri>https://oa4mp.xsede.org/oauth</serviceUri>
-        <callbackUri>https://localhost:8443/airavata/callback</callbackUri>
-        <lifetime>864000</lifetime>
-        <publicKeyFile>../webapps/airavata/WEB-INF/classes/credential-store/oauth-pubkey.pem</publicKeyFile>
-        <privateKeyFile>../webapps/airavata/WEB-INF/classes/credential-store/oauth-privkey.pk8</privateKeyFile>
-    </client>
-
-    <credential-store>
-        <successUri>/credential-store/success.jsp</successUri>
-        <errorUri>/credential-store/error.jsp</errorUri>
-        <redirectUri>/credential-store/show-redirect.jsp</redirectUri>
-    </credential-store>
-
-</config>

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/credential-store/credential-store-service/src/test/resources/keystore.jks
----------------------------------------------------------------------
diff --git a/modules/credential-store/credential-store-service/src/test/resources/keystore.jks b/modules/credential-store/credential-store-service/src/test/resources/keystore.jks
deleted file mode 100644
index 14cf022..0000000
Binary files a/modules/credential-store/credential-store-service/src/test/resources/keystore.jks and /dev/null differ

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/credential-store/credential-store-service/src/test/resources/mykeystore.jks
----------------------------------------------------------------------
diff --git a/modules/credential-store/credential-store-service/src/test/resources/mykeystore.jks b/modules/credential-store/credential-store-service/src/test/resources/mykeystore.jks
deleted file mode 100644
index 335ebf8..0000000
Binary files a/modules/credential-store/credential-store-service/src/test/resources/mykeystore.jks and /dev/null differ

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/credential-store/credential-store-stubs/pom.xml
----------------------------------------------------------------------
diff --git a/modules/credential-store/credential-store-stubs/pom.xml b/modules/credential-store/credential-store-stubs/pom.xml
deleted file mode 100644
index 5c9f92a..0000000
--- a/modules/credential-store/credential-store-stubs/pom.xml
+++ /dev/null
@@ -1,79 +0,0 @@
-<?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">
-
-    <modelVersion>4.0.0</modelVersion>
-
-    <parent>
-        <artifactId>credential-store</artifactId>
-        <groupId>org.apache.airavata</groupId>
-        <version>0.17-SNAPSHOT</version>
-        <relativePath>../pom.xml</relativePath>
-    </parent>
-
-    <name>Credential Store CPI Stubs</name>
-    <artifactId>airavata-credential-store-stubs</artifactId>
-    <packaging>jar</packaging>
-    <url>http://airavata.apache.org/</url>
-
-    <dependencies>
-        <dependency>
-            <groupId>org.apache.thrift</groupId>
-            <artifactId>libthrift</artifactId>
-            <version>${thrift.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-log4j12</artifactId>
-            <version>${org.slf4j.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.airavata</groupId>
-            <artifactId>airavata-commons</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.airavata</groupId>
-            <artifactId>airavata-server-configuration</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-    </dependencies>
-
-    <properties>
-        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
-    </properties>
-
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>com.google.code.maven-replacer-plugin</groupId>
-                <artifactId>replacer</artifactId>
-                <version>${maven.replacer.plugin.version}</version>
-                <executions>
-                    <execution>
-                        <phase>generate-sources</phase>
-                        <goals>
-                            <goal>replace</goal>
-                        </goals>
-                    </execution>
-                </executions>
-                <configuration>
-                    <includes>
-                        <include>${basedir}/src/main/java/org/apache/airavata/**/*.java</include>
-                    </includes>
-                    <token>, date = ".*"</token>
-                    <value> </value>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
-</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/client/CredentialStoreClientFactory.java
----------------------------------------------------------------------
diff --git a/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/client/CredentialStoreClientFactory.java b/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/client/CredentialStoreClientFactory.java
deleted file mode 100644
index 1e2fb76..0000000
--- a/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/client/CredentialStoreClientFactory.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- *
- * 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.client;
-
-import org.apache.airavata.credential.store.cpi.CredentialStoreService;
-import org.apache.airavata.credential.store.exception.CredentialStoreException;
-import org.apache.thrift.protocol.TBinaryProtocol;
-import org.apache.thrift.protocol.TProtocol;
-import org.apache.thrift.transport.TSocket;
-import org.apache.thrift.transport.TTransport;
-import org.apache.thrift.transport.TTransportException;
-
-public class CredentialStoreClientFactory {
-
-    public static CredentialStoreService.Client createAiravataCSClient(String serverHost, int serverPort) throws CredentialStoreException {
-        try {
-            TTransport transport = new TSocket(serverHost, serverPort);
-            transport.open();
-            TProtocol protocol = new TBinaryProtocol(transport);
-            return new CredentialStoreService.Client(protocol);
-        } catch (TTransportException e) {
-            throw new CredentialStoreException("Unable to connect to the credential store server at " + serverHost + ":" + serverPort);
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/client/TestSSLClient.java
----------------------------------------------------------------------
diff --git a/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/client/TestSSLClient.java b/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/client/TestSSLClient.java
deleted file mode 100644
index 39d56be..0000000
--- a/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/client/TestSSLClient.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- *
- * 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.client;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.AiravataUtils;
-import org.apache.airavata.common.utils.Constants;
-import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.airavata.credential.store.cpi.CredentialStoreService;
-import org.apache.airavata.credential.store.datamodel.CertificateCredential;
-import org.apache.airavata.credential.store.datamodel.CommunityUser;
-import org.apache.airavata.credential.store.datamodel.SSHCredential;
-import org.apache.thrift.TException;
-import org.apache.thrift.protocol.TBinaryProtocol;
-import org.apache.thrift.protocol.TProtocol;
-import org.apache.thrift.transport.TSSLTransportFactory;
-import org.apache.thrift.transport.TSocket;
-import org.apache.thrift.transport.TTransport;
-import org.apache.thrift.transport.TTransportException;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.cert.CertificateException;
-import java.security.cert.X509Certificate;
-import java.util.Map;
-
-import org.apache.commons.codec.binary.Base64;
-
-public class TestSSLClient {
-    private void invoke() {
-//        TTransport transport;
-        try {
-
-//            TSSLTransportFactory.TSSLTransportParameters params =
-//                    new TSSLTransportFactory.TSSLTransportParameters();
-//            String keystorePath = ServerSettings.getCredentialStoreThriftServerKeyStorePath();
-//            String keystorePWD = ServerSettings.getCredentialStoreThriftServerKeyStorePassword();
-//            params.setTrustStore(keystorePath, keystorePWD);
-            final int serverPort = Integer.parseInt(ServerSettings.getCredentialStoreServerPort());
-            final String serverHost = ServerSettings.getCredentialStoreServerHost();
-            TTransport transport = new TSocket(serverHost, serverPort);
-            transport.open();
-            TProtocol protocol = new TBinaryProtocol(transport);
-//            transport = TSSLTransportFactory.getClientSocket(serverHost, serverPort, 10000, params);
-//            TProtocol protocol = new TBinaryProtocol(transport);
-
-            CredentialStoreService.Client client = new CredentialStoreService.Client(protocol);
-            testSSHCredential(client);
-            testCertificateCredential(client);
-            transport.close();
-        } catch (TTransportException e) {
-            e.printStackTrace();
-        }catch (ApplicationSettingsException e) {
-            e.printStackTrace();
-        }
-    }
-
-    public static void testSSHCredential (CredentialStoreService.Client client){
-        try {
-            SSHCredential sshCredential = new SSHCredential();
-            sshCredential.setUsername("test");
-            sshCredential.setGatewayId("testGateway");
-            sshCredential.setPassphrase("mypassphrase");
-            String token = client.addSSHCredential(sshCredential);
-            System.out.println("SSH Token :" + token);
-            SSHCredential credential = client.getSSHCredential(token, "testGateway");
-            Map<String, String> allSSHKeysForGateway = client.getAllSSHKeysForGateway(sshCredential.getGatewayId());
-            System.out.println("private key : " + credential.getPrivateKey());
-            System.out.println("public key : " + credential.getPublicKey());
-        }catch (TTransportException e) {
-            e.printStackTrace();
-        } catch (TException e) {
-            e.printStackTrace();
-        }
-    }
-
-    public static void testCertificateCredential (CredentialStoreService.Client client){
-        try {
-            CertificateCredential certificateCredential = new CertificateCredential();
-            CommunityUser communityUser = new CommunityUser("testGateway", "test", "test@ddsd");
-            certificateCredential.setCommunityUser(communityUser);
-            X509Certificate[] x509Certificates = new X509Certificate[1];
-            KeyStore ks = KeyStore.getInstance("JKS");
-            File keyStoreFile = new File("/Users/smarru/code/airavata-master/modules/configuration/server/src/main/resources/airavata.jks");
-            FileInputStream fis = new FileInputStream(keyStoreFile);
-            char[] password = "airavata".toCharArray();
-            ks.load(fis,password);
-            x509Certificates[0] = (X509Certificate) ks.getCertificate("airavata");
-            Base64 encoder = new Base64(64);
-            String cert_begin = "-----BEGIN CERTIFICATE-----\n";
-            String end_cert = "-----END CERTIFICATE-----";
-            byte[] derCert = x509Certificates[0].getEncoded();
-            String pemCertPre = new String(encoder.encode(derCert));
-            String pemCert = cert_begin + pemCertPre + end_cert;
-            certificateCredential.setX509Cert(pemCert);
-            String token = client.addCertificateCredential(certificateCredential);
-            System.out.println("Certificate Token :" + token);
-            CertificateCredential credential = client.getCertificateCredential(token, "testGateway");
-            System.out.println("certificate : " + credential.getX509Cert());
-            System.out.println("gateway name  : " + credential.getCommunityUser().getGatewayName());
-        }catch (TTransportException e) {
-            e.printStackTrace();
-        } catch (TException e) {
-            e.printStackTrace();
-        } catch (KeyStoreException e) {
-            e.printStackTrace();
-        } catch (FileNotFoundException e) {
-            e.printStackTrace();
-        } catch (NoSuchAlgorithmException e) {
-            e.printStackTrace();
-        } catch (CertificateException e) {
-            e.printStackTrace();
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-    }
-
-    public static void main(String[] args) {
-        TestSSLClient c = new TestSSLClient();
-        c.invoke();
-
-    }
-}


Mime
View raw message