airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shame...@apache.org
Subject [09/50] [abbrv] airavata git commit: Moving credential store client to stubs module.
Date Thu, 19 Mar 2015 19:11:27 GMT
Moving credential store client to stubs module.


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

Branch: refs/heads/new-workflow-design
Commit: 52f1e758ee7c8a0ac757d45a8b67f7d6e9ab4c70
Parents: e9468ca
Author: Suresh Marru <smarru@apache.org>
Authored: Fri Mar 6 14:15:26 2015 -0500
Committer: Suresh Marru <smarru@apache.org>
Committed: Fri Mar 6 14:15:26 2015 -0500

----------------------------------------------------------------------
 .../credential/store/client/TestSSLClient.java  | 140 -------------------
 .../credential/store/client/TestSSLClient.java  | 140 +++++++++++++++++++
 2 files changed, 140 insertions(+), 140 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/52f1e758/modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/client/TestSSLClient.java
----------------------------------------------------------------------
diff --git a/modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/client/TestSSLClient.java
b/modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/client/TestSSLClient.java
deleted file mode 100644
index cc5ebb6..0000000
--- a/modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/client/TestSSLClient.java
+++ /dev/null
@@ -1,140 +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.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 org.apache.commons.codec.binary.Base64;
-
-public class TestSSLClient {
-    private void invoke() {
-        TTransport transport;
-        try {
-            AiravataUtils.setExecutionAsServer();
-            TSSLTransportFactory.TSSLTransportParameters params =
-                    new TSSLTransportFactory.TSSLTransportParameters();
-            String keystorePath = ServerSettings.getCredentialStoreThriftServerKeyStorePath();
-            String keystorePWD = ServerSettings.getCredentialStoreThriftServerKeyStorePassword();
-            params.setTrustStore(keystorePath, keystorePWD);
-            final int serverPort = Integer.parseInt(ServerSettings.getSetting(Constants.CREDENTIAL_SERVER_PORT,
"8960"));
-            final String serverHost = ServerSettings.getSetting(Constants.CREDENTIAL_SERVER_HOST,
null);
-
-            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");
-            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();
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/52f1e758/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
new file mode 100644
index 0000000..cc5ebb6
--- /dev/null
+++ b/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/client/TestSSLClient.java
@@ -0,0 +1,140 @@
+/*
+ *
+ * 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.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 org.apache.commons.codec.binary.Base64;
+
+public class TestSSLClient {
+    private void invoke() {
+        TTransport transport;
+        try {
+            AiravataUtils.setExecutionAsServer();
+            TSSLTransportFactory.TSSLTransportParameters params =
+                    new TSSLTransportFactory.TSSLTransportParameters();
+            String keystorePath = ServerSettings.getCredentialStoreThriftServerKeyStorePath();
+            String keystorePWD = ServerSettings.getCredentialStoreThriftServerKeyStorePassword();
+            params.setTrustStore(keystorePath, keystorePWD);
+            final int serverPort = Integer.parseInt(ServerSettings.getSetting(Constants.CREDENTIAL_SERVER_PORT,
"8960"));
+            final String serverHost = ServerSettings.getSetting(Constants.CREDENTIAL_SERVER_HOST,
null);
+
+            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");
+            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