airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From machris...@apache.org
Subject [airavata-custos] 08/24: Adding AWS key store feature
Date Fri, 11 Oct 2019 20:42:15 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit 05361dbdc29b85584d1f8a9708c06c605f4386c0
Author: Dimuthu Wannipurage <dimuthu.upeksha2@gmail.com>
AuthorDate: Tue Jul 9 16:37:28 2019 -0400

    Adding AWS key store feature
---
 .../api/controllers/AWSCredentialController.java   | 33 ++++++++++++++++++++++
 .../api/controllers/SSHCredentialsController.java  |  5 ++--
 .../credential/api/resources/AWSCredntial.java     | 22 +++++++++++++++
 .../credentials/aws/AWSCredentialEntity.java       | 29 +++++++++++++++++++
 4 files changed, 87 insertions(+), 2 deletions(-)

diff --git a/credential-store/credential-api/src/main/java/org/apache/custos/credential/api/controllers/AWSCredentialController.java
b/credential-store/credential-api/src/main/java/org/apache/custos/credential/api/controllers/AWSCredentialController.java
new file mode 100644
index 0000000..1b757be
--- /dev/null
+++ b/credential-store/credential-api/src/main/java/org/apache/custos/credential/api/controllers/AWSCredentialController.java
@@ -0,0 +1,33 @@
+package org.apache.custos.credential.api.controllers;
+
+import org.apache.airavata.custos.credentials.aws.AWSCredentialEntity;
+import org.apache.airavata.custos.credentials.ssh.SSHCredentialEntity;
+import org.apache.airavata.custos.vault.VaultManager;
+import org.apache.custos.credential.api.resources.AWSCredntial;
+import org.apache.custos.credential.api.resources.SSHCredential;
+import org.dozer.DozerBeanMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+@RestController
+@RequestMapping("/aws")
+public class AWSCredentialController {
+    @Autowired
+    private VaultManager vaultManager;
+
+    @Autowired
+    private DozerBeanMapper mapper;
+
+    @RequestMapping(value = "/{gateway}/{token}", method = RequestMethod.GET)
+    public AWSCredntial getAWSCredential(@PathVariable("gateway") String gateway, @PathVariable("token")
String token) throws Exception {
+        AWSCredentialEntity credentialEntity = vaultManager.getCredentialEntity(AWSCredentialEntity.class,
token, gateway);
+        return mapper.map(credentialEntity, AWSCredntial.class);
+    }
+
+    @RequestMapping(value = "/{gateway}", method = RequestMethod.POST)
+    public String createAWSCredential(@RequestBody AWSCredntial credntial, @PathVariable("gateway")
String gateway) throws Exception {
+        AWSCredentialEntity credentialEntity = mapper.map(credntial, AWSCredentialEntity.class);
+        String token = vaultManager.saveCredentialEntity(credentialEntity, gateway);
+        return token;
+    }
+}
diff --git a/credential-store/credential-api/src/main/java/org/apache/custos/credential/api/controllers/SSHCredentialsController.java
b/credential-store/credential-api/src/main/java/org/apache/custos/credential/api/controllers/SSHCredentialsController.java
index 8250687..dbd8c94 100644
--- a/credential-store/credential-api/src/main/java/org/apache/custos/credential/api/controllers/SSHCredentialsController.java
+++ b/credential-store/credential-api/src/main/java/org/apache/custos/credential/api/controllers/SSHCredentialsController.java
@@ -8,6 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 @RestController
+@RequestMapping("/ssh")
 public class SSHCredentialsController {
 
     @Autowired
@@ -16,13 +17,13 @@ public class SSHCredentialsController {
     @Autowired
     private DozerBeanMapper mapper;
 
-    @RequestMapping(value = "/ssh/{gateway}/{token}", method = RequestMethod.GET)
+    @RequestMapping(value = "/{gateway}/{token}", method = RequestMethod.GET)
     public SSHCredential getSSHCredential(@PathVariable("gateway") String gateway, @PathVariable("token")
String token) throws Exception {
         SSHCredentialEntity credentialEntity = vaultManager.getCredentialEntity(SSHCredentialEntity.class,
token, gateway);
         return mapper.map(credentialEntity, SSHCredential.class);
     }
 
-    @RequestMapping(value = "/ssh/{gateway}", method = RequestMethod.POST)
+    @RequestMapping(value = "/{gateway}", method = RequestMethod.POST)
     public String createSSHCredential(@RequestBody SSHCredential sshCredential, @PathVariable("gateway")
String gateway) throws Exception {
         SSHCredentialEntity credentialEntity = mapper.map(sshCredential, SSHCredentialEntity.class);
         String token = vaultManager.saveCredentialEntity(credentialEntity, gateway);
diff --git a/credential-store/credential-api/src/main/java/org/apache/custos/credential/api/resources/AWSCredntial.java
b/credential-store/credential-api/src/main/java/org/apache/custos/credential/api/resources/AWSCredntial.java
new file mode 100644
index 0000000..befab46
--- /dev/null
+++ b/credential-store/credential-api/src/main/java/org/apache/custos/credential/api/resources/AWSCredntial.java
@@ -0,0 +1,22 @@
+package org.apache.custos.credential.api.resources;
+
+public class AWSCredntial {
+    private String accessKey;
+    private String secretKey;
+
+    public String getAccessKey() {
+        return accessKey;
+    }
+
+    public void setAccessKey(String accessKey) {
+        this.accessKey = accessKey;
+    }
+
+    public String getSecretKey() {
+        return secretKey;
+    }
+
+    public void setSecretKey(String secretKey) {
+        this.secretKey = secretKey;
+    }
+}
diff --git a/credential-store/credential-core/src/main/java/org/apache/airavata/custos/credentials/aws/AWSCredentialEntity.java
b/credential-store/credential-core/src/main/java/org/apache/airavata/custos/credentials/aws/AWSCredentialEntity.java
new file mode 100644
index 0000000..5991264
--- /dev/null
+++ b/credential-store/credential-core/src/main/java/org/apache/airavata/custos/credentials/aws/AWSCredentialEntity.java
@@ -0,0 +1,29 @@
+package org.apache.airavata.custos.credentials.aws;
+
+import org.apache.airavata.custos.credentials.BaseCredentialEntity;
+import org.apache.airavata.custos.vault.annotations.VaultPath;
+
+public class AWSCredentialEntity extends BaseCredentialEntity {
+
+    @VaultPath(path = "secret/aws/{gateway}/{token}", name = "access_key_id", required =
true)
+    private String accessKey;
+
+    @VaultPath(path = "secret/aws/{gateway}/{token}", name = "secret_access_key")
+    private String secretKey;
+
+    public String getAccessKey() {
+        return accessKey;
+    }
+
+    public void setAccessKey(String accessKey) {
+        this.accessKey = accessKey;
+    }
+
+    public String getSecretKey() {
+        return secretKey;
+    }
+
+    public void setSecretKey(String secretKey) {
+        this.secretKey = secretKey;
+    }
+}


Mime
View raw message