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-data-lake.git


The following commit(s) were added to refs/heads/master by this push:
     new dfb3dd0  Using user access token for file download request
dfb3dd0 is described below

commit dfb3dd0a3afac2e817831463428af1d60e18c554
Author: Dimuthu Wannipurage <[email protected]>
AuthorDate: Tue Aug 10 13:01:32 2021 -0400

    Using user access token for file download request
---
 .../orchestrator/handlers/mft/MFTRequestHandler.java       | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git 
a/data-orchestrator/data-orchestrator-service/data-orchestrator-api-server/src/main/java/org/apache/airavata/datalake/orchestrator/handlers/mft/MFTRequestHandler.java
 
b/data-orchestrator/data-orchestrator-service/data-orchestrator-api-server/src/main/java/org/apache/airavata/datalake/orchestrator/handlers/mft/MFTRequestHandler.java
index 0b11056..20045c1 100644
--- 
a/data-orchestrator/data-orchestrator-service/data-orchestrator-api-server/src/main/java/org/apache/airavata/datalake/orchestrator/handlers/mft/MFTRequestHandler.java
+++ 
b/data-orchestrator/data-orchestrator-service/data-orchestrator-api-server/src/main/java/org/apache/airavata/datalake/orchestrator/handlers/mft/MFTRequestHandler.java
@@ -33,10 +33,7 @@ import org.apache.custos.clients.CustosClientProvider;
 import org.apache.custos.identity.management.client.IdentityManagementClient;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.web.bind.annotation.CrossOrigin;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
 
@@ -58,7 +55,8 @@ public class MFTRequestHandler {
     private int drmsPort;
 
     @GetMapping("/mftdownload/{resourceid}")
-    public MFTDownloadResponse mftDownload(@PathVariable String resourceid) 
throws Exception {
+    public MFTDownloadResponse mftDownload(@RequestHeader("Authorization") 
String authTokenStr,
+                                           @PathVariable String resourceid) 
throws Exception {
 
         logger.info("MFT download request to resource {}", resourceid);
         MFTApiServiceGrpc.MFTApiServiceBlockingStub mftClient = 
MFTApiClient.buildClient(mftHost, mftPort);
@@ -67,8 +65,8 @@ public class MFTRequestHandler {
         ResourceServiceGrpc.ResourceServiceBlockingStub resourceClient = 
ResourceServiceGrpc.newBlockingStub(channel);
         StoragePreferenceServiceGrpc.StoragePreferenceServiceBlockingStub 
stoPrefClient = StoragePreferenceServiceGrpc.newBlockingStub(channel);
 
-        String accessToken = getAccessToken();
-        DRMSServiceAuthToken authToken = 
DRMSServiceAuthToken.newBuilder().setAccessToken(accessToken).build();
+        logger.info("Using auth token {}", authTokenStr);
+        DRMSServiceAuthToken authToken = 
DRMSServiceAuthToken.newBuilder().setAccessToken(authTokenStr).build();
         ResourceFetchResponse resourceFetchResponse = 
resourceClient.fetchResource(ResourceFetchRequest.newBuilder()
                 .setResourceId(resourceid)
                 .setAuthToken(authToken).build());
@@ -127,7 +125,7 @@ public class MFTRequestHandler {
         }
 
         downloadRequest.setMftAuthorizationToken(AuthToken.newBuilder()
-                
.setUserTokenAuth(UserTokenAuth.newBuilder().setToken(accessToken).build()).build());
+                
.setUserTokenAuth(UserTokenAuth.newBuilder().setToken(authTokenStr).build()).build());
 
         HttpDownloadApiResponse downloadResponse = 
mftClient.submitHttpDownload(downloadRequest.build());
 

Reply via email to