airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chath...@apache.org
Subject airavata git commit: fixing issues with gateway registering and credential store token retrieving
Date Wed, 09 Dec 2015 16:46:30 GMT
Repository: airavata
Updated Branches:
  refs/heads/master e32f941b4 -> e8adfe18e


fixing issues with gateway registering and credential store token retrieving


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

Branch: refs/heads/master
Commit: e8adfe18ede3081e60eb1afb107a67c01eaf3776
Parents: e32f941
Author: Chathuri Wimalasena <chathuri@apache.org>
Authored: Wed Dec 9 11:46:23 2015 -0500
Committer: Chathuri Wimalasena <chathuri@apache.org>
Committed: Wed Dec 9 11:46:23 2015 -0500

----------------------------------------------------------------------
 .../server/handler/AiravataServerHandler.java   |  1 +
 .../server/CredentialStoreServerHandler.java    | 34 ++++++++++++--------
 .../credential-store-stubs/pom.xml              |  5 +++
 .../credential/store/client/TestSSLClient.java  | 22 +++++++++----
 .../catalog/impl/GwyResourceProfileImpl.java    |  4 ++-
 .../resources/GatewayProfileResource.java       |  8 +++--
 6 files changed, 50 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/e8adfe18/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
index c0646ff..4e12631 100644
--- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
+++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
@@ -112,6 +112,7 @@ public class AiravataServerHandler implements Airavata.Iface {
 
         try {
             experimentCatalog = RegistryFactory.getDefaultExpCatalog();
+            appCatalog = RegistryFactory.getAppCatalog();
             if (!validateString(gateway.getGatewayId())){
                 logger.error("Gateway id cannot be empty...");
                 throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);

http://git-wip-us.apache.org/repos/asf/airavata/blob/e8adfe18/modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/server/CredentialStoreServerHandler.java
----------------------------------------------------------------------
diff --git a/modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/server/CredentialStoreServerHandler.java
b/modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/server/CredentialStoreServerHandler.java
index 8ffea58..750f9e0 100644
--- a/modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/server/CredentialStoreServerHandler.java
+++ b/modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/server/CredentialStoreServerHandler.java
@@ -207,13 +207,16 @@ public class CredentialStoreServerHandler implements CredentialStoreService.Ifac
         try {
             List<Credential> allCredentials = credentialReader.getAllCredentials();
             if (allCredentials != null && !allCredentials.isEmpty()){
-                for (Credential credential : allCredentials){
-                    if (credential.getPortalUserName().equals(username)){
-                        if (credential instanceof org.apache.airavata.credential.store.credential.impl.ssh.SSHCredential){
-                            org.apache.airavata.credential.store.credential.impl.ssh.SSHCredential
sshCredential = (org.apache.airavata.credential.store.credential.impl.ssh.SSHCredential)credential;
-                            byte[] publicKey = sshCredential.getPublicKey();
-                            if (publicKey != null){
-                                sshKeyMap.put(sshCredential.getToken(), new String(publicKey));
+                for (Credential credential : allCredentials) {
+                    if (credential instanceof org.apache.airavata.credential.store.credential.impl.ssh.SSHCredential)
{
+                        org.apache.airavata.credential.store.credential.impl.ssh.SSHCredential
sshCredential = (org.apache.airavata.credential.store.credential.impl.ssh.SSHCredential) credential;
+                        String portalUserName = sshCredential.getPortalUserName();
+                        if (portalUserName != null){
+                            if (portalUserName.equals(username)) {
+                                byte[] publicKey = sshCredential.getPublicKey();
+                                if (publicKey != null) {
+                                    sshKeyMap.put(sshCredential.getToken(), new String(publicKey));
+                                }
                             }
                         }
                     }
@@ -232,13 +235,16 @@ public class CredentialStoreServerHandler implements CredentialStoreService.Ifac
         try {
             List<Credential> allCredentials = credentialReader.getAllCredentials();
             if (allCredentials != null && !allCredentials.isEmpty()){
-                for (Credential credential : allCredentials){
-                    if (credential.getGatewayId().equals(gatewayId)){
-                        if (credential instanceof org.apache.airavata.credential.store.credential.impl.ssh.SSHCredential){
-                            org.apache.airavata.credential.store.credential.impl.ssh.SSHCredential
sshCredential = (org.apache.airavata.credential.store.credential.impl.ssh.SSHCredential)credential;
-                            byte[] publicKey = sshCredential.getPublicKey();
-                            if (publicKey != null){
-                                sshKeyMap.put(sshCredential.getToken(), new String(publicKey));
+                for (Credential credential : allCredentials) {
+                    if (credential instanceof org.apache.airavata.credential.store.credential.impl.ssh.SSHCredential)
{
+                        org.apache.airavata.credential.store.credential.impl.ssh.SSHCredential
sshCredential = (org.apache.airavata.credential.store.credential.impl.ssh.SSHCredential) credential;
+                        String gateway = sshCredential.getGateway();
+                        if (gateway != null){
+                            if (gateway.equals(gatewayId)) {
+                                byte[] publicKey = sshCredential.getPublicKey();
+                                if (publicKey != null) {
+                                    sshKeyMap.put(sshCredential.getToken(), new String(publicKey));
+                                }
                             }
                         }
                     }

http://git-wip-us.apache.org/repos/asf/airavata/blob/e8adfe18/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
index 32a4f64..911dce9 100644
--- a/modules/credential-store/credential-store-stubs/pom.xml
+++ b/modules/credential-store/credential-store-stubs/pom.xml
@@ -40,6 +40,11 @@
             <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>

http://git-wip-us.apache.org/repos/asf/airavata/blob/e8adfe18/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
index 0707348..39d56be 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
@@ -32,6 +32,7 @@ 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;
 
@@ -44,21 +45,27 @@ 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;
+//        TTransport transport;
         try {
-            TSSLTransportFactory.TSSLTransportParameters params =
-                    new TSSLTransportFactory.TSSLTransportParameters();
-            String keystorePath = ServerSettings.getCredentialStoreThriftServerKeyStorePath();
-            String keystorePWD = ServerSettings.getCredentialStoreThriftServerKeyStorePassword();
-            params.setTrustStore(keystorePath, keystorePWD);
+
+//            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();
-            transport = TSSLTransportFactory.getClientSocket(serverHost, serverPort, 10000,
params);
+            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);
@@ -80,6 +87,7 @@ public class TestSSLClient {
             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) {

http://git-wip-us.apache.org/repos/asf/airavata/blob/e8adfe18/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/GwyResourceProfileImpl.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/GwyResourceProfileImpl.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/GwyResourceProfileImpl.java
index b005b09..29b3101 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/GwyResourceProfileImpl.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/GwyResourceProfileImpl.java
@@ -46,7 +46,9 @@ public class GwyResourceProfileImpl implements GwyResourceProfile {
             if (!gatewayProfile.getGatewayID().equals("")){
                 profileResource.setGatewayID(gatewayProfile.getGatewayID());
             }
-            profileResource.setCredentialStoreToken(gatewayProfile.getCredentialStoreToken());
+            if (gatewayProfile.getCredentialStoreToken()!= null){
+                profileResource.setCredentialStoreToken(gatewayProfile.getCredentialStoreToken());
+            }
 //            profileResource.setGatewayID(gatewayProfile.getGatewayID());
             profileResource.save();
             List<ComputeResourcePreference> computeResourcePreferences = gatewayProfile.getComputeResourcePreferences();

http://git-wip-us.apache.org/repos/asf/airavata/blob/e8adfe18/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GatewayProfileResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GatewayProfileResource.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GatewayProfileResource.java
index 7d92dcb..725c72f 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GatewayProfileResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GatewayProfileResource.java
@@ -275,13 +275,17 @@ public class GatewayProfileResource extends AppCatAbstractResource {
             em.getTransaction().begin();
             if (existingGatewayProfile != null) {
                 existingGatewayProfile.setUpdateTime(AiravataUtils.getCurrentTimestamp());
-                existingGatewayProfile.setCredentialStoreToken(credentialStoreToken);
+                if (credentialStoreToken != null){
+                    existingGatewayProfile.setCredentialStoreToken(credentialStoreToken);
+                }
                 em.merge(existingGatewayProfile);
             } else {
                 GatewayProfile gatewayProfile = new GatewayProfile();
                 gatewayProfile.setGatewayID(gatewayID);
                 gatewayProfile.setCreationTime(AiravataUtils.getCurrentTimestamp());
-                gatewayProfile.setCredentialStoreToken(credentialStoreToken);
+                if (credentialStoreToken != null){
+                    gatewayProfile.setCredentialStoreToken(credentialStoreToken);
+                }
                 em.persist(gatewayProfile);
             }
             em.getTransaction().commit();


Mime
View raw message