You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by di...@apache.org on 2019/12/11 22:35:51 UTC

[airavata-mft] branch master updated: Framework for Secret Service

This is an automated email from the ASF dual-hosted git repository.

dimuthuupe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-mft.git


The following commit(s) were added to refs/heads/master by this push:
     new c43aacb  Framework for Secret Service
c43aacb is described below

commit c43aacbe0aea828da10d68c6a889328cd98ac031
Author: Dimuthu Wannipurage <di...@gmail.com>
AuthorDate: Wed Dec 11 17:35:37 2019 -0500

    Framework for Secret Service
---
 services/pom.xml                                   | 13 +++++++
 services/resource-service/pom.xml                  | 12 ------
 services/{ => secret-service/client}/pom.xml       | 15 +++++---
 .../mft/secret/client/SecretServiceClient.java     | 12 ++++++
 services/{ => secret-service}/pom.xml              |  9 +++--
 services/{ => secret-service/server}/pom.xml       | 16 ++++----
 .../secret/server/SecretServiceApplication.java    | 11 ++++++
 .../server/handler/SecretServiceHandler.java       | 21 +++++++++++
 .../src/main/resources/application.properties      |  2 +
 services/secret-service/stub/pom.xml               | 43 ++++++++++++++++++++++
 .../stub/src/main/proto/SecretService.proto        | 26 +++++++++++++
 11 files changed, 151 insertions(+), 29 deletions(-)

diff --git a/services/pom.xml b/services/pom.xml
index 625641f..6674fd4 100644
--- a/services/pom.xml
+++ b/services/pom.xml
@@ -11,9 +11,22 @@
     <packaging>pom</packaging>
     <modules>
         <module>resource-service</module>
+        <module>secret-service</module>
     </modules>
 
     <artifactId>mft-services</artifactId>
 
+    <dependencies>
+        <dependency>
+            <groupId>com.google.protobuf</groupId>
+            <artifactId>protobuf-java</artifactId>
+            <version>3.4.0</version>
+        </dependency>
+        <dependency>
+            <groupId>io.github.lognet</groupId>
+            <artifactId>grpc-spring-boot-starter</artifactId>
+            <version>3.5.0</version>
+        </dependency>
+    </dependencies>
 
 </project>
\ No newline at end of file
diff --git a/services/resource-service/pom.xml b/services/resource-service/pom.xml
index 0299549..1a8fa30 100644
--- a/services/resource-service/pom.xml
+++ b/services/resource-service/pom.xml
@@ -17,17 +17,5 @@
         <module>server</module>
         <module>client</module>
     </modules>
-    <dependencies>
-        <dependency>
-            <groupId>com.google.protobuf</groupId>
-            <artifactId>protobuf-java</artifactId>
-            <version>3.4.0</version>
-        </dependency>
-        <dependency>
-            <groupId>io.github.lognet</groupId>
-            <artifactId>grpc-spring-boot-starter</artifactId>
-            <version>3.5.0</version>
-        </dependency>
-    </dependencies>
 
 </project>
\ No newline at end of file
diff --git a/services/pom.xml b/services/secret-service/client/pom.xml
similarity index 54%
copy from services/pom.xml
copy to services/secret-service/client/pom.xml
index 625641f..023ca59 100644
--- a/services/pom.xml
+++ b/services/secret-service/client/pom.xml
@@ -3,17 +3,20 @@
          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">
     <parent>
-        <artifactId>airavata-mft</artifactId>
+        <artifactId>mft-secret-service</artifactId>
         <groupId>org.apache.airavata</groupId>
         <version>0.01-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
-    <packaging>pom</packaging>
-    <modules>
-        <module>resource-service</module>
-    </modules>
 
-    <artifactId>mft-services</artifactId>
+    <artifactId>mft-secret-service-client</artifactId>
 
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.airavata</groupId>
+            <artifactId>mft-secret-service-stub</artifactId>
+            <version>0.01-SNAPSHOT</version>
+        </dependency>
+    </dependencies>
 
 </project>
\ No newline at end of file
diff --git a/services/secret-service/client/src/main/java/org/apache/airavata/mft/secret/client/SecretServiceClient.java b/services/secret-service/client/src/main/java/org/apache/airavata/mft/secret/client/SecretServiceClient.java
new file mode 100644
index 0000000..bdb11d2
--- /dev/null
+++ b/services/secret-service/client/src/main/java/org/apache/airavata/mft/secret/client/SecretServiceClient.java
@@ -0,0 +1,12 @@
+package org.apache.airavata.mft.secret.client;
+
+import io.grpc.ManagedChannel;
+import io.grpc.ManagedChannelBuilder;
+import org.apache.airavata.mft.secret.service.SecretServiceGrpc;
+
+public class SecretServiceClient {
+    public static SecretServiceGrpc.SecretServiceBlockingStub buildClient(String hostName, int port) {
+        ManagedChannel channel = ManagedChannelBuilder.forAddress(hostName, port).usePlaintext().build();
+        return SecretServiceGrpc.newBlockingStub(channel);
+    }
+}
diff --git a/services/pom.xml b/services/secret-service/pom.xml
similarity index 70%
copy from services/pom.xml
copy to services/secret-service/pom.xml
index 625641f..2736a1b 100644
--- a/services/pom.xml
+++ b/services/secret-service/pom.xml
@@ -3,17 +3,18 @@
          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">
     <parent>
-        <artifactId>airavata-mft</artifactId>
+        <artifactId>mft-services</artifactId>
         <groupId>org.apache.airavata</groupId>
         <version>0.01-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <packaging>pom</packaging>
     <modules>
-        <module>resource-service</module>
+        <module>stub</module>
+        <module>client</module>
+        <module>server</module>
     </modules>
-
-    <artifactId>mft-services</artifactId>
+    <artifactId>mft-secret-service</artifactId>
 
 
 </project>
\ No newline at end of file
diff --git a/services/pom.xml b/services/secret-service/server/pom.xml
similarity index 54%
copy from services/pom.xml
copy to services/secret-service/server/pom.xml
index 625641f..1da010f 100644
--- a/services/pom.xml
+++ b/services/secret-service/server/pom.xml
@@ -3,17 +3,19 @@
          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">
     <parent>
-        <artifactId>airavata-mft</artifactId>
+        <artifactId>mft-secret-service</artifactId>
         <groupId>org.apache.airavata</groupId>
         <version>0.01-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
-    <packaging>pom</packaging>
-    <modules>
-        <module>resource-service</module>
-    </modules>
-
-    <artifactId>mft-services</artifactId>
 
+    <artifactId>mft-secret-service-server</artifactId>
 
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.airavata</groupId>
+            <artifactId>mft-secret-service-stub</artifactId>
+            <version>0.01-SNAPSHOT</version>
+        </dependency>
+    </dependencies>
 </project>
\ No newline at end of file
diff --git a/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/SecretServiceApplication.java b/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/SecretServiceApplication.java
new file mode 100644
index 0000000..739cc53
--- /dev/null
+++ b/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/SecretServiceApplication.java
@@ -0,0 +1,11 @@
+package org.apache.airavata.mft.secret.server;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class SecretServiceApplication {
+    public static void main(String args[]) {
+        SpringApplication.run(SecretServiceApplication.class, args);
+    }
+}
diff --git a/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/handler/SecretServiceHandler.java b/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/handler/SecretServiceHandler.java
new file mode 100644
index 0000000..0ed822e
--- /dev/null
+++ b/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/handler/SecretServiceHandler.java
@@ -0,0 +1,21 @@
+package org.apache.airavata.mft.secret.server.handler;
+
+import io.grpc.stub.StreamObserver;
+import org.apache.airavata.mft.secret.service.SCPSecret;
+import org.apache.airavata.mft.secret.service.SCPSecretRequest;
+import org.apache.airavata.mft.secret.service.SecretServiceGrpc;
+import org.lognet.springboot.grpc.GRpcService;
+
+@GRpcService
+public class SecretServiceHandler extends SecretServiceGrpc.SecretServiceImplBase {
+    @Override
+    public void getSCPSecret(SCPSecretRequest request, StreamObserver<SCPSecret> responseObserver) {
+        SCPSecret.Builder builder = SCPSecret.newBuilder()
+                .setPrivateKey("private")
+                .setPrivateKey("pubKey")
+                .setPassphrase("pass")
+                .setSecretId("sec1");
+        responseObserver.onNext(builder.build());
+        responseObserver.onCompleted();
+    }
+}
diff --git a/services/secret-service/server/src/main/resources/application.properties b/services/secret-service/server/src/main/resources/application.properties
new file mode 100644
index 0000000..1d02f20
--- /dev/null
+++ b/services/secret-service/server/src/main/resources/application.properties
@@ -0,0 +1,2 @@
+server.port=8081
+grpc.port=7003
\ No newline at end of file
diff --git a/services/secret-service/stub/pom.xml b/services/secret-service/stub/pom.xml
new file mode 100644
index 0000000..4136a44
--- /dev/null
+++ b/services/secret-service/stub/pom.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+    <parent>
+        <artifactId>mft-secret-service</artifactId>
+        <groupId>org.apache.airavata</groupId>
+        <version>0.01-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>mft-secret-service-stub</artifactId>
+
+    <build>
+        <extensions>
+            <extension>
+                <groupId>kr.motd.maven</groupId>
+                <artifactId>os-maven-plugin</artifactId>
+                <version>${os.maven.plugin}</version>
+            </extension>
+        </extensions>
+        <plugins>
+            <plugin>
+                <groupId>org.xolstice.maven.plugins</groupId>
+                <artifactId>protobuf-maven-plugin</artifactId>
+                <version>${protobuf.maven.plugin}</version>
+                <configuration>
+                    <protocArtifact>com.google.protobuf:protoc:3.0.2:exe:${os.detected.classifier}</protocArtifact>
+                    <pluginId>grpc-java</pluginId>
+                    <pluginArtifact>io.grpc:protoc-gen-grpc-java:1.0.1:exe:${os.detected.classifier}</pluginArtifact>
+                </configuration>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>compile</goal>
+                            <goal>compile-custom</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>
\ No newline at end of file
diff --git a/services/secret-service/stub/src/main/proto/SecretService.proto b/services/secret-service/stub/src/main/proto/SecretService.proto
new file mode 100644
index 0000000..f2d0cc7
--- /dev/null
+++ b/services/secret-service/stub/src/main/proto/SecretService.proto
@@ -0,0 +1,26 @@
+syntax = "proto3";
+
+option java_multiple_files = true;
+package org.apache.airavata.mft.secret.service;
+
+import "google/api/annotations.proto";
+
+message SCPSecret {
+    string secretId = 1;
+    string privateKey = 2;
+    string publicKey = 3;
+    string passphrase = 4;
+}
+
+message SCPSecretRequest {
+    string resourceId = 1;
+    string authzToken = 2;
+}
+
+service  SecretService {
+    rpc getSCPSecret (SCPSecretRequest) returns (SCPSecret) {
+        option (google.api.http) = {
+           get: "/v1.0/secret/scp"
+        };
+    }
+}
\ No newline at end of file