flyrain commented on code in PR #211:
URL: https://github.com/apache/polaris/pull/211#discussion_r1731951679


##########
polaris-service/src/main/java/org/apache/polaris/service/catalog/AccessDelegationMode.java:
##########
@@ -0,0 +1,65 @@
+/*
+ * 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.polaris.service.catalog;
+
+import com.google.common.base.Functions;
+import java.util.Arrays;
+import java.util.EnumSet;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * Represents access mechanisms defined in the Iceberg REST API specification 
(values for the {@code
+ * X-Iceberg-Access-Delegation} header).
+ */
+public enum AccessDelegationMode {
+  UNKNOWN("unknown"),
+  VENDED_CREDENTIALS("vended-credentials"),
+  REMOTE_SIGNING("remote-signing"),
+  ;
+
+  AccessDelegationMode(String protocolValue) {
+    this.protocolValue = protocolValue;
+  }
+
+  private String protocolValue;

Review Comment:
   Can we make it final?



##########
polaris-service/src/main/java/org/apache/polaris/service/catalog/IcebergCatalogAdapter.java:
##########
@@ -171,28 +173,39 @@ public Response updateProperties(
         .build();
   }
 
+  private EnumSet<AccessDelegationMode> parseAccessDelegationModes(String 
accessDelegationMode) {
+    EnumSet<AccessDelegationMode> delegationModes =
+        AccessDelegationMode.fromProtocolValuesList(accessDelegationMode);
+    if (!delegationModes.isEmpty() && 
!delegationModes.contains(VENDED_CREDENTIALS)) {
+      throw new IllegalArgumentException(
+          "Unsupported access delegation mode: " + accessDelegationMode);
+    }

Review Comment:
   Minor suggestion: using `Preconditions.checkArgument()`?



##########
polaris-service/src/main/java/org/apache/polaris/service/catalog/IcebergCatalogAdapter.java:
##########
@@ -171,28 +173,39 @@ public Response updateProperties(
         .build();
   }
 
+  private EnumSet<AccessDelegationMode> parseAccessDelegationModes(String 
accessDelegationMode) {
+    EnumSet<AccessDelegationMode> delegationModes =
+        AccessDelegationMode.fromProtocolValuesList(accessDelegationMode);
+    if (!delegationModes.isEmpty() && 
!delegationModes.contains(VENDED_CREDENTIALS)) {
+      throw new IllegalArgumentException(
+          "Unsupported access delegation mode: " + accessDelegationMode);
+    }

Review Comment:
   Also I think we shouldn't throw in case of empty, as the callers will do 
something differently for empty `delegationModes`. 
   
https://github.com/polaris-catalog/polaris/blob/main/polaris-service/src/main/java/org/apache/polaris/service/catalog/IcebergCatalogAdapter.java#L197-L197



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