You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sh...@apache.org on 2015/03/19 20:11:34 UTC

[16/50] [abbrv] airavata git commit: Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/airavata

Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/airavata


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

Branch: refs/heads/new-workflow-design
Commit: 565b5a3f4ec2a5e34334c2a63ee428a7ca3d0085
Parents: 5ff650f 9d80cf2
Author: Lahiru Gunathilake <gl...@gmail.com>
Authored: Sat Mar 7 00:37:31 2015 -0500
Committer: Lahiru Gunathilake <gl...@gmail.com>
Committed: Sat Mar 7 00:37:31 2015 -0500

----------------------------------------------------------------------
 .../common/utils/DatabaseTestCases.java         |   2 +-
 .../main/resources/airavata-client.properties   |   2 +-
 .../main/resources/airavata-server.properties   |   6 +-
 .../credential/store/client/TestSSLClient.java  | 140 -------------------
 .../store/store/impl/db/SSHCredentialTest.java  |   2 +-
 .../credential-store-stubs/pom.xml              |   5 +
 .../credential/store/client/TestSSLClient.java  | 140 +++++++++++++++++++
 .../main/resources/airavata-server.properties   |   4 +-
 .../src/test/resources/jdbc-authenticator.xml   |   2 +-
 .../test/resources/session-authenticator.xml    |   2 +-
 tools/registry-tool/README                      |   2 +-
 11 files changed, 156 insertions(+), 151 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/565b5a3f/modules/credential-store/credential-store-service/src/test/java/org/apache/airavata/credential/store/store/impl/db/SSHCredentialTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/airavata/blob/565b5a3f/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/client/TestSSLClient.java
----------------------------------------------------------------------
diff --cc modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/client/TestSSLClient.java
index 0000000,cc5ebb6..1d9f4d9
mode 000000,100644..100644
--- 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
@@@ -1,0 -1,140 +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);
++            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();
+ 
+     }
+ }