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

[airavata-custos] 05/24: Dozer mapping to map between credential entity and resources

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 1af4ad183c66596ee73428a98b5fcf1663734305
Author: Dimuthu Wannipurage <di...@gmail.com>
AuthorDate: Tue Jul 9 01:48:59 2019 -0400

    Dozer mapping to map between credential entity and resources
---
 credential-store/credential-api/pom.xml                      |  8 +++++++-
 .../credential/api/controllers/SSHCredentialsController.java | 12 +++++-------
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/credential-store/credential-api/pom.xml b/credential-store/credential-api/pom.xml
index 024f783..817ef74 100644
--- a/credential-store/credential-api/pom.xml
+++ b/credential-store/credential-api/pom.xml
@@ -19,7 +19,13 @@
         <dependency>
             <groupId>net.sf.dozer</groupId>
             <artifactId>dozer</artifactId>
-            <version>5.5.1</version>
+            <version>5.4.0</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>slf4j-log4j12</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
         <dependency>
             <groupId>org.apache.airavata.custos</groupId>
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 e78a489..b949526 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
@@ -3,10 +3,11 @@ package org.apache.custos.credential.api.controllers;
 import org.apache.airavata.custos.credentials.ssh.SSHCredentialEntity;
 import org.apache.airavata.custos.vault.VaultManager;
 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.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
 @RestController
@@ -15,14 +16,11 @@ public class SSHCredentialsController {
     @Autowired
     private VaultManager vaultManager;
 
+    final private DozerBeanMapper mapper = new DozerBeanMapper();
 
-    @RequestMapping("/ssh/{gateway}/{token}")
+    @RequestMapping(value = "/ssh/{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);
-        SSHCredential resource = new SSHCredential();
-        resource.setPassphrase(credentialEntity.getPassphrase());
-        resource.setPrivateKey(credentialEntity.getPrivateKey());
-        resource.setPublicKey(credentialEntity.getPublicKey());
-        return resource;
+        return mapper.map(credentialEntity, SSHCredential.class);
     }
 }