iting0321 commented on code in PR #3750:
URL: https://github.com/apache/polaris/pull/3750#discussion_r2804171634


##########
runtime/service/src/main/java/org/apache/polaris/service/catalog/AccessDelegationModeResolver.java:
##########
@@ -0,0 +1,222 @@
+/*
+ * 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 static 
org.apache.polaris.service.catalog.AccessDelegationMode.REMOTE_SIGNING;
+import static org.apache.polaris.service.catalog.AccessDelegationMode.UNKNOWN;
+import static 
org.apache.polaris.service.catalog.AccessDelegationMode.VENDED_CREDENTIALS;
+
+import jakarta.annotation.Nonnull;
+import jakarta.annotation.Nullable;
+import java.util.EnumSet;
+import org.apache.polaris.core.config.FeatureConfiguration;
+import org.apache.polaris.core.config.RealmConfig;
+import org.apache.polaris.core.entity.CatalogEntity;
+import org.apache.polaris.core.storage.PolarisStorageConfigurationInfo;
+import org.apache.polaris.core.storage.aws.AwsStorageConfigurationInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Resolves the optimal {@link AccessDelegationMode} to use based on the 
client's requested modes
+ * and the catalog's capabilities.
+ *
+ * <p>The selection algorithm is:
+ *
+ * <ol>
+ *   <li>If no delegation mode is requested, use {@link 
AccessDelegationMode#UNKNOWN}
+ *   <li>If exactly one delegation mode is requested, use that mode (if 
supported)
+ *   <li>If the requested modes include both {@link 
AccessDelegationMode#VENDED_CREDENTIALS} and
+ *       {@link AccessDelegationMode#REMOTE_SIGNING}:
+ *       <ol>
+ *         <li>Check if STS is available for the catalog's storage 
configuration
+ *         <li>If STS is available and credential subscoping is not skipped, 
use {@link
+ *             AccessDelegationMode#VENDED_CREDENTIALS}
+ *         <li>Otherwise, use {@link AccessDelegationMode#REMOTE_SIGNING}
+ *       </ol>
+ *   <li>Otherwise, throw an error for unsupported mode combinations
+ * </ol>
+ *
+ * <p>This resolver improves upon the simple mode selection by considering:
+ *
+ * <ul>
+ *   <li>STS availability from the catalog's {@link 
AwsStorageConfigurationInfo}
+ *   <li>The {@link 
FeatureConfiguration#SKIP_CREDENTIAL_SUBSCOPING_INDIRECTION} setting
+ * </ul>
+ */
+public class AccessDelegationModeResolver {

Review Comment:
   Yes, I agree. I turned `AccessDelegationModeResolver` into interface and 
added `DefaultAccessDelegationModeResolver.java` for CDI bean implementation. 



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