jerryshao commented on code in PR #5974:
URL: https://github.com/apache/gravitino/pull/5974#discussion_r1906643698


##########
bundles/azure/src/main/java/org/apache/gravitino/abs/fs/AzureFileSystemProvider.java:
##########
@@ -58,15 +64,49 @@ public FileSystem getFileSystem(@Nonnull Path path, 
@Nonnull Map<String, String>
           config.get(AzureProperties.GRAVITINO_AZURE_STORAGE_ACCOUNT_KEY));
     }
 
-    if (!config.containsKey(ABFS_IMPL_KEY)) {
+    if (!hadoopConfMap.containsKey(ABFS_IMPL_KEY)) {
       configuration.set(ABFS_IMPL_KEY, ABFS_IMPL);
     }
 
     hadoopConfMap.forEach(configuration::set);
 
+    if (enableCredentialProvidedByGravitino(hadoopConfMap)) {
+      try {
+        AzureSasCredentialsProvider azureSasCredentialsProvider = new 
AzureSasCredentialsProvider();
+        azureSasCredentialsProvider.initialize(configuration, null);
+        String sas = azureSasCredentialsProvider.getSASToken(null, null, null, 
null);
+        if (sas != null) {
+          String accountName =
+              String.format(
+                  "%s.dfs.core.windows.net",
+                  
config.get(AzureProperties.GRAVITINO_AZURE_STORAGE_ACCOUNT_NAME));
+
+          configuration.set(
+              FS_AZURE_ACCOUNT_AUTH_TYPE_PROPERTY_NAME + "." + accountName, 
AuthType.SAS.name());
+          configuration.set(
+              FS_AZURE_SAS_TOKEN_PROVIDER_TYPE + "." + accountName,
+              AzureSasCredentialsProvider.class.getName());
+          configuration.set(FS_AZURE_ACCOUNT_IS_HNS_ENABLED, "true");
+        } else if (azureSasCredentialsProvider.getAzureStorageAccountKey() != 
null
+            && azureSasCredentialsProvider.getAzureStorageAccountName() != 
null) {
+          configuration.set(
+              String.format(
+                  "fs.azure.account.key.%s.dfs.core.windows.net",
+                  azureSasCredentialsProvider.getAzureStorageAccountName()),
+              azureSasCredentialsProvider.getAzureStorageAccountKey());
+        }
+      } catch (Exception e) {
+        throw new IOException("Failed to get SAS token from 
AzureSasCredentialsProvider", e);
+      }
+    }
+
     return FileSystem.get(path.toUri(), configuration);
   }
 
+  private boolean enableCredentialProvidedByGravitino(Map<String, String> 
config) {

Review Comment:
   The method name is too long and hard to understand, can you simplify the 
name?



##########
catalogs/hadoop-common/src/main/java/org/apache/gravitino/catalog/hadoop/fs/GravitinoFileSystemCredentialProvider.java:
##########
@@ -0,0 +1,38 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.gravitino.catalog.hadoop.fs;
+
+import org.apache.gravitino.credential.Credential;
+import org.apache.hadoop.conf.Configurable;
+
+/** Interface for providing credentials for Gravitino Virtual File System. */
+public interface GravitinoFileSystemCredentialProvider extends Configurable {

Review Comment:
   It's weird that this `provider` is inherited from `Configurable`, what is 
the purpose? Also why do you use `Credential`, nor `Credentials`?



##########
catalogs/hadoop-common/src/main/java/org/apache/gravitino/catalog/hadoop/fs/GravitinoFileSystemCredentialProvider.java:
##########
@@ -0,0 +1,38 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.gravitino.catalog.hadoop.fs;
+
+import org.apache.gravitino.credential.Credential;
+import org.apache.hadoop.conf.Configurable;
+
+/** Interface for providing credentials for Gravitino Virtual File System. */
+public interface GravitinoFileSystemCredentialProvider extends Configurable {
+
+  String GVFS_CREDENTIAL_PROVIDER = "fs.gvfs.credential.provider";
+
+  String GVFS_CREDENTIAL_PROVIDER_PATH = "fs.gvfs.virtual.path";

Review Comment:
   What is the usage of this configuration?



##########
clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/GravitinoVirtualFileSystem.java:
##########
@@ -410,6 +338,24 @@ private FilesetContextPair getFilesetContext(Path 
virtualPath, FilesetDataOperat
     return new FilesetContextPair(new Path(actualFileLocation), fs);
   }
 
+  private boolean enableGravitinoCredentialProvider(

Review Comment:
   using `credentialVended`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to