yuqi1129 commented on code in PR #10081:
URL: https://github.com/apache/gravitino/pull/10081#discussion_r3218661106


##########
core/src/main/java/org/apache/gravitino/connector/BaseCatalog.java:
##########
@@ -445,6 +454,49 @@ public Map<String, String> properties() {
     return properties;
   }
 
+  /**
+   * Retrieves the properties of the catalog including credential providers. 
Subclasses should
+   * override this method to inject auto-detected credential provider names 
into the properties map
+   * before the {@link CatalogCredentialManager} is initialized. The default 
implementation returns
+   * {@link #properties()} unchanged.
+   *
+   * @return A map of properties including credential providers.
+   */
+  public Map<String, String> propertiesWithCredentialProviders() {
+    return properties();
+  }
+
+  /**
+   * Detects storage credential providers (S3, OSS, Azure) from catalog 
properties and appends them
+   * to the provided list. Subclasses can call this method in their {@link
+   * #propertiesWithCredentialProviders()} implementation to avoid duplicating 
storage credential
+   * detection logic.
+   *
+   * @param properties The catalog properties map to scan for storage 
credentials.
+   * @param credentialProviders The list to append detected storage credential 
providers to.
+   */
+  @Evolving
+  protected void addStorageCredentialProviders(
+      Map<String, String> properties, List<String> credentialProviders) {
+    String s3AccessKeyId = 
properties.get(S3Properties.GRAVITINO_S3_ACCESS_KEY_ID);
+    String s3SecretAccessKey = 
properties.get(S3Properties.GRAVITINO_S3_SECRET_ACCESS_KEY);
+    if (StringUtils.isNotBlank(s3AccessKeyId) && 
StringUtils.isNotBlank(s3SecretAccessKey)) {
+      
credentialProviders.add(S3SecretKeyCredential.S3_SECRET_KEY_CREDENTIAL_TYPE);
+    }
+
+    String ossAccessKeyId = 
properties.get(OSSProperties.GRAVITINO_OSS_ACCESS_KEY_ID);
+    String ossSecretAccessKey = 
properties.get(OSSProperties.GRAVITINO_OSS_ACCESS_KEY_SECRET);
+    if (StringUtils.isNotBlank(ossAccessKeyId) && 
StringUtils.isNotBlank(ossSecretAccessKey)) {
+      
credentialProviders.add(OSSSecretKeyCredential.OSS_SECRET_KEY_CREDENTIAL_TYPE);
+    }
+
+    String azureAccountName = 
properties.get(AzureProperties.GRAVITINO_AZURE_STORAGE_ACCOUNT_NAME);
+    String azureAccountKey = 
properties.get(AzureProperties.GRAVITINO_AZURE_STORAGE_ACCOUNT_KEY);
+    if (StringUtils.isNotBlank(azureAccountName) && 
StringUtils.isNotBlank(azureAccountKey)) {
+      
credentialProviders.add(AzureAccountKeyCredential.AZURE_ACCOUNT_KEY_CREDENTIAL_TYPE);
+    }

Review Comment:
   How do we handle GCS here?



-- 
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