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


##########
iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergTableOperations.java:
##########
@@ -210,4 +247,47 @@ private String 
SerializeUpdateTableRequest(UpdateTableRequest updateTableRequest
       return updateTableRequest.toString();
     }
   }
+
+  private LoadTableResponse injectCredentialConfig(
+      String prefix, LoadTableResponse loadTableResponse) {
+    CredentialProvider credentialProvider =
+        icebergCatalogWrapperManager.getCredentialProvider(prefix);
+    if (credentialProvider == null) {
+      throw new NotSupportedException(
+          "Doesn't support credential vending, please add "
+              + CredentialConstants.CREDENTIAL_PROVIDER_TYPE
+              + " to the catalog configurations");
+    }
+    Credential credential =
+        CredentialUtils.vendCredential(
+            credentialProvider, loadTableResponse.tableMetadata().location());
+    if (credential == null) {
+      throw new ServiceUnavailableException(
+          "Couldn't generate credential for %s", 
credentialProvider.credentialType());
+    }
+    Map<String, String> credentialConfig = 
CredentialPropertyUtils.toIcebergProperties(credential);
+    return LoadTableResponse.builder()
+        .withTableMetadata(loadTableResponse.tableMetadata())
+        .addAllConfig(loadTableResponse.config())
+        .addAllConfig(credentialConfig)
+        .build();
+  }
+
+  private boolean isCredentialVending(String accessDelegation) {
+    if (StringUtils.isBlank(accessDelegation)) {
+      return false;
+    }
+    if ("vended-credentials".equalsIgnoreCase(accessDelegation)) {
+      return true;
+    } else if ("remote-signing".equalsIgnoreCase(accessDelegation)) {
+      throw new UnsupportedOperationException(
+          "Gravitino IcebergRESTServer doesn't support remote signing");
+    } else {
+      throw new IllegalArgumentException(
+          X_ICEBERG_ACCESS_DELEGATION
+              + ": "
+              + accessDelegation
+              + " is illegal, Iceberg REST spec 
supports:[vended-credentials,remote-signing], Gravitino Iceberg REST server 
supports: vended-credentials");

Review Comment:
   This line is too long, it should be no longer than 100 chars.



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