World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#7556] [#7740] [#7741] feat(iceberg): add authz for table operations in Iceberg REST server (#9192)
FANNG12ac05c2dfc0
diff --git a/flink-connector/flink/src/test/java/org/apache/gravitino/flink/connector/integration/test/FlinkEnvIT.java b/flink-connector/flink/src/test/java/org/apache/gravitino/flink/connector/integration/test/FlinkEnvIT.javaindex ca79144f5b..1bafa9d4b9 100644--- a/flink-connector/flink/src/test/java/org/apache/gravitino/flink/connector/integration/test/FlinkEnvIT.java+++ b/flink-connector/flink/src/test/java/org/apache/gravitino/flink/connector/integration/test/FlinkEnvIT.java@@ -44,7 +44,6 @@ import org.apache.gravitino.flink.connector.store.GravitinoCatalogStoreFactoryOpimport org.apache.gravitino.integration.test.container.ContainerSuite;import org.apache.gravitino.integration.test.container.HiveContainer;import org.apache.gravitino.integration.test.util.BaseIT;-import org.apache.gravitino.server.web.JettyServerConfig;import org.apache.hadoop.fs.FileSystem;import org.junit.jupiter.api.AfterAll;import org.junit.jupiter.api.BeforeAll;@@ -76,7 +75,8 @@ public abstract class FlinkEnvIT extends BaseIT {protected String icebergRestServiceUri;@BeforeAll- void startUp() throws Exception {+ @Override+ public void startIntegrationTest() throws Exception {initHiveEnv();if (lakeHouseIcebergProvider.equalsIgnoreCase(getProvider())) {initIcebergRestServiceEnv();@@ -92,12 +92,17 @@ public abstract class FlinkEnvIT extends BaseIT {}@AfterAll- void stop() throws Exception {- stopCatalogEnv();- stopFlinkEnv();- stopHdfsEnv();- super.stopIntegrationTest();- LOG.info("Stop Flink env successfully.");+ @Override+ public void stopIntegrationTest() {+ try {+ stopCatalogEnv();+ stopFlinkEnv();+ stopHdfsEnv();+ super.stopIntegrationTest();+ LOG.info("Stop Flink env successfully.");+ } catch (Exception e) {+ throw new RuntimeException(e);+ }}protected void initCatalogEnv() throws Exception {}@@ -263,12 +268,4 @@ public abstract class FlinkEnvIT extends BaseIT {TestUtils.assertTableResult(deleteResult, ResultKind.SUCCESS);}}-- private String getIcebergRestServiceUri() {- JettyServerConfig jettyServerConfig =- JettyServerConfig.fromConfig(- serverConfig, String.format("gravitino.%s.", icebergRestServiceName));- return String.format(- "http://%s:%d/iceberg/", jettyServerConfig.getHost(), jettyServerConfig.getHttpPort());- }}diff --git a/iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/utils/IcebergIdentifierUtils.java b/iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/utils/IcebergIdentifierUtils.javanew file mode 100644index 0000000000..f90b0b0999--- /dev/null+++ b/iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/utils/IcebergIdentifierUtils.java@@ -0,0 +1,39 @@+/*+ * 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.iceberg.common.utils;++import org.apache.gravitino.NameIdentifier;+import org.apache.iceberg.catalog.Namespace;+import org.apache.iceberg.catalog.TableIdentifier;++public class IcebergIdentifierUtils {+ public static NameIdentifier toGravitinoTableIdentifier(+ String metalake, String catalogName, TableIdentifier icebergTableIdentifier) {+ return NameIdentifier.of(+ metalake,+ catalogName,+ icebergTableIdentifier.namespace().level(0),+ icebergTableIdentifier.name());+ }++ public static NameIdentifier toGravitinoSchemaIdentifier(+ String metalake, String catalogName, Namespace icebergNamespace) {+ return NameIdentifier.of(metalake, catalogName, icebergNamespace.level(0));+ }+}diff --git a/iceberg/iceberg-common/src/test/java/org/apache/gravitino/iceberg/common/utils/TestIcebergIdentifierUtils.java b/iceberg/iceberg-common/src/test/java/org/apache/gravitino/iceberg/common/utils/TestIcebergIdentifierUtils.javanew file mode 100644index 0000000000..4f609a5860--- /dev/null+++ b/iceberg/iceberg-common/src/test/java/org/apache/gravitino/iceberg/common/utils/TestIcebergIdentifierUtils.java@@ -0,0 +1,53 @@+/*+ * 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.iceberg.common.utils;++import static org.junit.jupiter.api.Assertions.assertEquals;++import org.apache.gravitino.NameIdentifier;+import org.apache.iceberg.catalog.Namespace;+import org.apache.iceberg.catalog.TableIdentifier;+import org.junit.jupiter.api.Test;++class TestIcebergIdentifierUtils {++ @Test+ void toGravitinoTableIdentifierConvertsCorrectly() {+ TableIdentifier icebergTableIdentifier = TableIdentifier.of(Namespace.of("db"), "table");+ NameIdentifier result =+ IcebergIdentifierUtils.toGravitinoTableIdentifier(+ "metalake", "catalog", icebergTableIdentifier);++ assertEquals("metalake", result.namespace().level(0));+ assertEquals("catalog", result.namespace().level(1));+ assertEquals("db", result.namespace().level(2));+ assertEquals("table", result.name());+ }++ @Test+ void toGravitinoSchemaIdentifierConvertsCorrectly() {+ Namespace icebergNamespace = Namespace.of("db");+ NameIdentifier result =+ IcebergIdentifierUtils.toGravitinoSchemaIdentifier("metalake", "catalog", icebergNamespace);++ assertEquals("metalake", result.namespace().level(0));+ assertEquals("catalog", result.namespace().level(1));+ assertEquals("db", result.name());+ }+}diff --git a/iceberg/iceberg-rest-server/build.gradle.kts b/iceberg/iceberg-rest-server/build.gradle.ktsindex 345dc21e5b..62c8f63f41 100644--- a/iceberg/iceberg-rest-server/build.gradle.kts+++ b/iceberg/iceberg-rest-server/build.gradle.kts@@ -52,13 +52,20 @@ dependencies {implementation(libs.bundles.metrics)implementation(libs.bundles.prometheus)implementation(libs.caffeine)+ implementation(libs.commons.dbcp2)implementation(libs.commons.lang3)+ implementation(libs.concurrent.trees)implementation(libs.guava)implementation(libs.jackson.annotations)implementation(libs.jackson.databind)implementation(libs.jackson.datatype.jdk8)implementation(libs.jackson.datatype.jsr310)+ implementation(libs.jcasbin) {+ exclude(group = "com.fasterxml.jackson.core", module = "jackson-databind")+ }implementation(libs.metrics.jersey2)+ implementation(libs.mybatis)+ implementation(libs.ognl)annotationProcessor(libs.lombok)compileOnly(libs.lombok)@@ -69,6 +76,7 @@ dependencies {testImplementation(project(":bundles:gcp", configuration = "shadow"))testImplementation(project(":bundles:azure", configuration = "shadow"))testImplementation(project(":integration-test-common", "testArtifacts"))+ testImplementation(project(":server"))testImplementation("org.scala-lang.modules:scala-collection-compat_$scalaVersion:$scalaCollectionCompatVersion")testImplementation("org.apache.iceberg:iceberg-spark-runtime-${sparkMajorVersion}_$scalaVersion:$icebergVersion")@@ -97,9 +105,12 @@ dependencies {testImplementation(libs.junit.jupiter.api)testImplementation(libs.junit.jupiter.params)testImplementation(libs.mockito.core)+ testImplementation(libs.mysql.driver)+ testImplementation(libs.postgresql.driver)testImplementation(libs.sqlite.jdbc)testImplementation(libs.slf4j.api)testImplementation(libs.testcontainers)+ testImplementation(libs.testcontainers.postgresql)// Add Hadoop 3.3+ dependencies since Spark's Hadoop is excluded// Required for Iceberg 1.10+ which uses newer Hadoop APIs like FileSystem.openFile()diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/RESTService.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/RESTService.javaindex aa19aef777..47ed82fea6 100644--- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/RESTService.java+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/RESTService.java@@ -21,17 +21,22 @@ package org.apache.gravitino.iceberg;import com.google.common.collect.Lists;import java.util.List;import java.util.Map;+import javax.inject.Singleton;import javax.servlet.Servlet;+import org.apache.gravitino.Configs;import org.apache.gravitino.GravitinoEnv;import org.apache.gravitino.auxiliary.GravitinoAuxiliaryService;import org.apache.gravitino.iceberg.common.IcebergConfig;import org.apache.gravitino.iceberg.service.IcebergCatalogWrapperManager;import org.apache.gravitino.iceberg.service.IcebergExceptionMapper;import org.apache.gravitino.iceberg.service.IcebergObjectMapperProvider;+import org.apache.gravitino.iceberg.service.authorization.IcebergRESTServerContext;import org.apache.gravitino.iceberg.service.dispatcher.IcebergNamespaceEventDispatcher;+import org.apache.gravitino.iceberg.service.dispatcher.IcebergNamespaceHookDispatcher;import org.apache.gravitino.iceberg.service.dispatcher.IcebergNamespaceOperationDispatcher;import org.apache.gravitino.iceberg.service.dispatcher.IcebergNamespaceOperationExecutor;import org.apache.gravitino.iceberg.service.dispatcher.IcebergTableEventDispatcher;+import org.apache.gravitino.iceberg.service.dispatcher.IcebergTableHookDispatcher;import org.apache.gravitino.iceberg.service.dispatcher.IcebergTableOperationDispatcher;import org.apache.gravitino.iceberg.service.dispatcher.IcebergTableOperationExecutor;import org.apache.gravitino.iceberg.service.dispatcher.IcebergViewEventDispatcher;@@ -46,6 +51,8 @@ import org.apache.gravitino.metrics.source.MetricsSource;import org.apache.gravitino.server.web.HttpServerMetricsSource;import org.apache.gravitino.server.web.JettyServer;import org.apache.gravitino.server.web.JettyServerConfig;+import org.apache.gravitino.server.web.filter.IcebergRESTAuthInterceptionService;+import org.glassfish.hk2.api.InterceptionService;import org.glassfish.hk2.utilities.binding.AbstractBinder;import org.glassfish.jersey.jackson.JacksonFeature;import org.glassfish.jersey.server.ResourceConfig;@@ -88,28 +95,45 @@ public class RESTService implements GravitinoAuxiliaryService {configProvider.initialize(configProperties);String metalakeName = configProvider.getMetalakeName();+ Boolean enableAuth = GravitinoEnv.getInstance().config().get(Configs.ENABLE_AUTHORIZATION);+ IcebergRESTServerContext authorizationContext =+ IcebergRESTServerContext.create(configProvider, enableAuth);+EventBus eventBus = GravitinoEnv.getInstance().eventBus();this.icebergCatalogWrapperManager =new IcebergCatalogWrapperManager(configProperties, configProvider);this.icebergMetricsManager = new IcebergMetricsManager(icebergConfig);- IcebergTableOperationExecutor icebergTableOperationExecutor =+ IcebergTableOperationDispatcher icebergTableOperationDispatcher =new IcebergTableOperationExecutor(icebergCatalogWrapperManager);+ if (authorizationContext.isAuthorizationEnabled()) {+ icebergTableOperationDispatcher =+ new IcebergTableHookDispatcher(icebergTableOperationDispatcher);+ }IcebergTableEventDispatcher icebergTableEventDispatcher =- new IcebergTableEventDispatcher(icebergTableOperationExecutor, eventBus, metalakeName);+ new IcebergTableEventDispatcher(icebergTableOperationDispatcher, eventBus, metalakeName);IcebergViewOperationExecutor icebergViewOperationExecutor =new IcebergViewOperationExecutor(icebergCatalogWrapperManager);IcebergViewEventDispatcher icebergViewEventDispatcher =new IcebergViewEventDispatcher(icebergViewOperationExecutor, eventBus, metalakeName);- IcebergNamespaceOperationExecutor icebergNamespaceOperationExecutor =++ IcebergNamespaceOperationDispatcher namespaceOperationDispatcher =new IcebergNamespaceOperationExecutor(icebergCatalogWrapperManager);+ if (authorizationContext.isAuthorizationEnabled()) {+ namespaceOperationDispatcher =+ new IcebergNamespaceHookDispatcher(namespaceOperationDispatcher);+ }IcebergNamespaceEventDispatcher icebergNamespaceEventDispatcher =- new IcebergNamespaceEventDispatcher(- icebergNamespaceOperationExecutor, eventBus, metalakeName);+ new IcebergNamespaceEventDispatcher(namespaceOperationDispatcher, eventBus, metalakeName);config.register(new AbstractBinder() {@Overrideprotected void configure() {+ if (authorizationContext.isAuthorizationEnabled()) {+ bind(IcebergRESTAuthInterceptionService.class)+ .to(InterceptionService.class)+ .in(Singleton.class);+ }bind(icebergCatalogWrapperManager).to(IcebergCatalogWrapperManager.class).ranked(1);bind(icebergMetricsManager).to(IcebergMetricsManager.class).ranked(1);bind(icebergTableEventDispatcher).to(IcebergTableOperationDispatcher.class).ranked(1);diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/server/GravitinoIcebergRESTServer.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/server/GravitinoIcebergRESTServer.javaindex 35fe05ce3a..f3e68c3e36 100644--- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/server/GravitinoIcebergRESTServer.java+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/server/GravitinoIcebergRESTServer.java@@ -18,7 +18,8 @@*/package org.apache.gravitino.iceberg.server;-import org.apache.gravitino.Config;+import com.google.common.base.Preconditions;+import org.apache.gravitino.Configs;import org.apache.gravitino.GravitinoEnv;import org.apache.gravitino.iceberg.RESTService;import org.apache.gravitino.iceberg.common.IcebergConfig;@@ -33,12 +34,12 @@ public class GravitinoIcebergRESTServer {public static final String CONF_FILE = "gravitino-iceberg-rest-server.conf";- private final Config serverConfig;+ private final ServerConfig serverConfig;private RESTService icebergRESTService;private GravitinoEnv gravitinoEnv;- public GravitinoIcebergRESTServer(Config config) {+ public GravitinoIcebergRESTServer(ServerConfig config) {this.serverConfig = config;this.gravitinoEnv = GravitinoEnv.getInstance();this.icebergRESTService = new RESTService();@@ -69,6 +70,9 @@ public class GravitinoIcebergRESTServer {LOG.info("Starting Gravitino Iceberg REST Server");String confPath = System.getenv("GRAVITINO_TEST") == null ? "" : args[0];ServerConfig serverConfig = ServerConfig.loadConfig(confPath, CONF_FILE);+ Preconditions.checkArgument(+ !serverConfig.get(Configs.ENABLE_AUTHORIZATION),+ "Iceberg REST server standalone mode doesn't support authorization.");GravitinoIcebergRESTServer icebergRESTServer = new GravitinoIcebergRESTServer(serverConfig);icebergRESTServer.initialize();diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/IcebergCatalogWrapperManager.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/IcebergCatalogWrapperManager.javaindex 1958d857e6..d827e601ed 100644--- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/IcebergCatalogWrapperManager.java+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/IcebergCatalogWrapperManager.java@@ -74,7 +74,7 @@ public class IcebergCatalogWrapperManager implements AutoCloseable {* @return the instance of IcebergCatalogWrapper.*/public CatalogWrapperForREST getOps(String rawPrefix) {- String catalogName = IcebergRestUtils.getCatalogName(rawPrefix);+ String catalogName = IcebergRESTUtils.getCatalogName(rawPrefix);return getCatalogWrapper(catalogName);}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/IcebergExceptionMapper.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/IcebergExceptionMapper.javaindex 3a301ac2c2..c1a443b24e 100644--- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/IcebergExceptionMapper.java+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/IcebergExceptionMapper.java@@ -76,7 +76,7 @@ public class IcebergExceptionMapper implements ExceptionMapper<Exception> {return toRESTResponse(ex);}- public static Response toRESTResponse(Exception ex) {+ public static Response toRESTResponse(Throwable ex) {int status =EXCEPTION_ERROR_CODES.getOrDefault(ex.getClass(), Status.INTERNAL_SERVER_ERROR.getStatusCode());@@ -89,6 +89,6 @@ public class IcebergExceptionMapper implements ExceptionMapper<Exception> {ex.getClass(),ex.getMessage());}- return IcebergRestUtils.errorResponse(ex, status);+ return IcebergRESTUtils.errorResponse(ex, status);}}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/IcebergRestUtils.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/IcebergRESTUtils.javasimilarity index 94%rename from iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/IcebergRestUtils.javarename to iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/IcebergRESTUtils.javaindex cecda88457..84ea56cc37 100644--- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/IcebergRestUtils.java+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/IcebergRESTUtils.java@@ -35,14 +35,14 @@ import javax.ws.rs.core.Response;import javax.ws.rs.core.Response.Status;import org.apache.commons.lang3.StringUtils;import org.apache.gravitino.NameIdentifier;-import org.apache.gravitino.catalog.lakehouse.iceberg.IcebergConstants;+import org.apache.gravitino.iceberg.service.authorization.IcebergRESTServerContext;import org.apache.iceberg.catalog.Namespace;import org.apache.iceberg.catalog.TableIdentifier;import org.apache.iceberg.rest.responses.ErrorResponse;-public class IcebergRestUtils {+public class IcebergRESTUtils {- private IcebergRestUtils() {}+ private IcebergRESTUtils() {}public static <T> Response ok(T t) {return Response.status(Response.Status.OK).entity(t).type(MediaType.APPLICATION_JSON).build();@@ -60,7 +60,7 @@ public class IcebergRestUtils {return Response.status(Status.NOT_FOUND).build();}- public static Response errorResponse(Exception ex, int httpStatus) {+ public static Response errorResponse(Throwable ex, int httpStatus) {ErrorResponse errorResponse =ErrorResponse.builder().responseCode(httpStatus)@@ -100,7 +100,7 @@ public class IcebergRestUtils {public static String getCatalogName(String rawPrefix) {String catalogName = normalizePrefix(rawPrefix);if (StringUtils.isBlank(catalogName)) {- return IcebergConstants.ICEBERG_REST_DEFAULT_CATALOG;+ return IcebergRESTServerContext.getInstance().defaultCatalogName();}return catalogName;}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/authorization/IcebergRESTServerContext.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/authorization/IcebergRESTServerContext.javanew file mode 100644index 0000000000..ad14e6e3b8--- /dev/null+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/authorization/IcebergRESTServerContext.java@@ -0,0 +1,71 @@+/*+ * 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.iceberg.service.authorization;++import com.google.common.base.Preconditions;+import org.apache.gravitino.iceberg.service.provider.DynamicIcebergConfigProvider;+import org.apache.gravitino.iceberg.service.provider.IcebergConfigProvider;++public class IcebergRESTServerContext {+ private boolean isAuthorizationEnabled;+ private String metalakeName;+ private String defaultCatalogName;++ private IcebergRESTServerContext(+ Boolean isAuthorizationEnabled, String metalakeName, String defaultCatalogName) {+ this.isAuthorizationEnabled = isAuthorizationEnabled;+ this.metalakeName = metalakeName;+ this.defaultCatalogName = defaultCatalogName;+ }++ private static class InstanceHolder {+ private static IcebergRESTServerContext INSTANCE;+ }++ public static IcebergRESTServerContext create(+ IcebergConfigProvider configProvider, Boolean enableAuth) {+ if (enableAuth) {+ Preconditions.checkArgument(+ configProvider instanceof DynamicIcebergConfigProvider,+ "Please enable dynamic config provider if using authorization.");+ }+ InstanceHolder.INSTANCE =+ new IcebergRESTServerContext(+ enableAuth, configProvider.getMetalakeName(), configProvider.getDefaultCatalogName());+ return InstanceHolder.INSTANCE;+ }++ public static IcebergRESTServerContext getInstance() {+ Preconditions.checkState(InstanceHolder.INSTANCE != null, "Not initialized");+ return InstanceHolder.INSTANCE;+ }++ public boolean isAuthorizationEnabled() {+ return isAuthorizationEnabled;+ }++ public String metalakeName() {+ return metalakeName;+ }++ public String defaultCatalogName() {+ return defaultCatalogName;+ }+}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergNamespaceEventDispatcher.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergNamespaceEventDispatcher.javaindex 4cba4499a7..1329da2ddf 100644--- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergNamespaceEventDispatcher.java+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergNamespaceEventDispatcher.java@@ -21,7 +21,7 @@ package org.apache.gravitino.iceberg.service.dispatcher;import java.util.Optional;import org.apache.gravitino.NameIdentifier;-import org.apache.gravitino.iceberg.service.IcebergRestUtils;+import org.apache.gravitino.iceberg.service.IcebergRESTUtils;import org.apache.gravitino.listener.EventBus;import org.apache.gravitino.listener.api.event.BaseEvent;import org.apache.gravitino.listener.api.event.IcebergCreateNamespaceEvent;@@ -81,7 +81,7 @@ public class IcebergNamespaceEventDispatcher implements IcebergNamespaceOperatiopublic CreateNamespaceResponse createNamespace(IcebergRequestContext context, CreateNamespaceRequest createRequest) {NameIdentifier nameIdentifier =- IcebergRestUtils.getGravitinoNameIdentifier(+ IcebergRESTUtils.getGravitinoNameIdentifier(metalakeName, context.catalogName(), createRequest.namespace());Optional<BaseEvent> transformedEvent =@@ -117,7 +117,7 @@ public class IcebergNamespaceEventDispatcher implements IcebergNamespaceOperatioNamespace namespace,UpdateNamespacePropertiesRequest updateRequest) {NameIdentifier nameIdentifier =- IcebergRestUtils.getGravitinoNameIdentifier(metalakeName, context.catalogName(), namespace);+ IcebergRESTUtils.getGravitinoNameIdentifier(metalakeName, context.catalogName(), namespace);Optional<BaseEvent> transformedEvent =eventBus.dispatchEvent(@@ -152,7 +152,7 @@ public class IcebergNamespaceEventDispatcher implements IcebergNamespaceOperatio@Overridepublic void dropNamespace(IcebergRequestContext context, Namespace namespace) {NameIdentifier nameIdentifier =- IcebergRestUtils.getGravitinoNameIdentifier(metalakeName, context.catalogName(), namespace);+ IcebergRESTUtils.getGravitinoNameIdentifier(metalakeName, context.catalogName(), namespace);eventBus.dispatchEvent(new IcebergDropNamespacePreEvent(context, nameIdentifier));try {@@ -168,7 +168,7 @@ public class IcebergNamespaceEventDispatcher implements IcebergNamespaceOperatio@Overridepublic GetNamespaceResponse loadNamespace(IcebergRequestContext context, Namespace namespace) {NameIdentifier nameIdentifier =- IcebergRestUtils.getGravitinoNameIdentifier(metalakeName, context.catalogName(), namespace);+ IcebergRESTUtils.getGravitinoNameIdentifier(metalakeName, context.catalogName(), namespace);eventBus.dispatchEvent(new IcebergLoadNamespacePreEvent(context, nameIdentifier));GetNamespaceResponse getResponse;@@ -187,7 +187,7 @@ public class IcebergNamespaceEventDispatcher implements IcebergNamespaceOperatiopublic ListNamespacesResponse listNamespaces(IcebergRequestContext context, Namespace parentNamespace) {NameIdentifier nameIdentifier =- IcebergRestUtils.getGravitinoNameIdentifier(+ IcebergRESTUtils.getGravitinoNameIdentifier(metalakeName, context.catalogName(), parentNamespace);eventBus.dispatchEvent(new IcebergListNamespacesPreEvent(context, nameIdentifier));@@ -206,7 +206,7 @@ public class IcebergNamespaceEventDispatcher implements IcebergNamespaceOperatio@Overridepublic boolean namespaceExists(IcebergRequestContext context, Namespace namespace) {NameIdentifier nameIdentifier =- IcebergRestUtils.getGravitinoNameIdentifier(metalakeName, context.catalogName(), namespace);+ IcebergRESTUtils.getGravitinoNameIdentifier(metalakeName, context.catalogName(), namespace);eventBus.dispatchEvent(new IcebergNamespaceExistsPreEvent(context, nameIdentifier));boolean isExists;@@ -228,7 +228,7 @@ public class IcebergNamespaceEventDispatcher implements IcebergNamespaceOperatioRegisterTableRequest registerTableRequest) {TableIdentifier tableIdentifier = TableIdentifier.of(namespace, registerTableRequest.name());NameIdentifier nameIdentifier =- IcebergRestUtils.getGravitinoNameIdentifier(+ IcebergRESTUtils.getGravitinoNameIdentifier(metalakeName, context.catalogName(), tableIdentifier);eventBus.dispatchEvent(diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergNamespaceHookDispatcher.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergNamespaceHookDispatcher.javanew file mode 100644index 0000000000..2eb60fc321--- /dev/null+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergNamespaceHookDispatcher.java@@ -0,0 +1,128 @@+/*+ * 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.iceberg.service.dispatcher;++import org.apache.gravitino.Entity;+import org.apache.gravitino.GravitinoEnv;+import org.apache.gravitino.NameIdentifier;+import org.apache.gravitino.authorization.AuthorizationUtils;+import org.apache.gravitino.authorization.Owner;+import org.apache.gravitino.authorization.OwnerDispatcher;+import org.apache.gravitino.catalog.SchemaDispatcher;+import org.apache.gravitino.iceberg.common.utils.IcebergIdentifierUtils;+import org.apache.gravitino.iceberg.service.authorization.IcebergRESTServerContext;+import org.apache.gravitino.listener.api.event.IcebergRequestContext;+import org.apache.gravitino.utils.NameIdentifierUtil;+import org.apache.iceberg.catalog.Namespace;+import org.apache.iceberg.rest.requests.CreateNamespaceRequest;+import org.apache.iceberg.rest.requests.RegisterTableRequest;+import org.apache.iceberg.rest.requests.UpdateNamespacePropertiesRequest;+import org.apache.iceberg.rest.responses.CreateNamespaceResponse;+import org.apache.iceberg.rest.responses.GetNamespaceResponse;+import org.apache.iceberg.rest.responses.ListNamespacesResponse;+import org.apache.iceberg.rest.responses.LoadTableResponse;+import org.apache.iceberg.rest.responses.UpdateNamespacePropertiesResponse;++/**+ * {@code IcebergSchemaHookDispatcher} is a decorator for {@link+ * IcebergNamespaceOperationDispatcher} that not only delegates namespace operations to the+ * underlying dispatcher but also executes some hook operations before or after the underlying+ * operations.+ */+public class IcebergNamespaceHookDispatcher implements IcebergNamespaceOperationDispatcher {+ private final IcebergNamespaceOperationDispatcher dispatcher;+ private final String metalake;++ public IcebergNamespaceHookDispatcher(IcebergNamespaceOperationDispatcher dispatcher) {+ this.dispatcher = dispatcher;+ this.metalake = IcebergRESTServerContext.getInstance().metalakeName();+ }++ @Override+ public CreateNamespaceResponse createNamespace(+ IcebergRequestContext context, CreateNamespaceRequest createRequest) {+ AuthorizationUtils.checkCurrentUser(metalake, context.userName());++ CreateNamespaceResponse response = dispatcher.createNamespace(context, createRequest);++ importSchema(context.catalogName(), createRequest.namespace());+ setSchemaOwner(context.catalogName(), createRequest.namespace(), context.userName());++ return response;+ }++ @Override+ public UpdateNamespacePropertiesResponse updateNamespace(+ IcebergRequestContext context,+ Namespace namespace,+ UpdateNamespacePropertiesRequest updateRequest) {+ return dispatcher.updateNamespace(context, namespace, updateRequest);+ }++ @Override+ public void dropNamespace(IcebergRequestContext context, Namespace namespace) {+ dispatcher.dropNamespace(context, namespace);+ }++ @Override+ public GetNamespaceResponse loadNamespace(IcebergRequestContext context, Namespace namespace) {+ return dispatcher.loadNamespace(context, namespace);+ }++ @Override+ public ListNamespacesResponse listNamespaces(+ IcebergRequestContext context, Namespace parentNamespace) {+ return dispatcher.listNamespaces(context, parentNamespace);+ }++ @Override+ public boolean namespaceExists(IcebergRequestContext context, Namespace namespace) {+ return dispatcher.namespaceExists(context, namespace);+ }++ @Override+ public LoadTableResponse registerTable(+ IcebergRequestContext context,+ Namespace namespace,+ RegisterTableRequest registerTableRequest) {+ return dispatcher.registerTable(context, namespace, registerTableRequest);+ }++ private void importSchema(String catalogName, Namespace namespace) {+ SchemaDispatcher schemaDispatcher = GravitinoEnv.getInstance().schemaDispatcher();+ if (schemaDispatcher != null) {+ schemaDispatcher.loadSchema(+ IcebergIdentifierUtils.toGravitinoSchemaIdentifier(metalake, catalogName, namespace));+ }+ }++ private void setSchemaOwner(String catalogName, Namespace namespace, String user) {+ NameIdentifier schemaIdentifier =+ IcebergIdentifierUtils.toGravitinoSchemaIdentifier(metalake, catalogName, namespace);+ // Set the creator as the owner of the namespace+ OwnerDispatcher ownerManager = GravitinoEnv.getInstance().ownerDispatcher();+ if (ownerManager != null) {+ ownerManager.setOwner(+ metalake,+ NameIdentifierUtil.toMetadataObject(schemaIdentifier, Entity.EntityType.SCHEMA),+ user,+ Owner.Type.USER);+ }+ }+}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergTableEventDispatcher.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergTableEventDispatcher.javaindex 0bcf8a3c5f..eaa0440140 100644--- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergTableEventDispatcher.java+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergTableEventDispatcher.java@@ -21,7 +21,7 @@ package org.apache.gravitino.iceberg.service.dispatcher;import java.util.Optional;import org.apache.gravitino.NameIdentifier;-import org.apache.gravitino.iceberg.service.IcebergRestUtils;+import org.apache.gravitino.iceberg.service.IcebergRESTUtils;import org.apache.gravitino.listener.EventBus;import org.apache.gravitino.listener.api.event.BaseEvent;import org.apache.gravitino.listener.api.event.IcebergCreateTableEvent;@@ -83,7 +83,7 @@ public class IcebergTableEventDispatcher implements IcebergTableOperationDispatcIcebergRequestContext context, Namespace namespace, CreateTableRequest createTableRequest) {TableIdentifier tableIdentifier = TableIdentifier.of(namespace, createTableRequest.name());NameIdentifier nameIdentifier =- IcebergRestUtils.getGravitinoNameIdentifier(+ IcebergRESTUtils.getGravitinoNameIdentifier(metalakeName, context.catalogName(), tableIdentifier);Optional<BaseEvent> transformedEvent =eventBus.dispatchEvent(@@ -116,7 +116,7 @@ public class IcebergTableEventDispatcher implements IcebergTableOperationDispatcTableIdentifier tableIdentifier,UpdateTableRequest updateTableRequest) {NameIdentifier gravitinoNameIdentifier =- IcebergRestUtils.getGravitinoNameIdentifier(+ IcebergRESTUtils.getGravitinoNameIdentifier(metalakeName, context.catalogName(), tableIdentifier);Optional<BaseEvent> transformedEvent =eventBus.dispatchEvent(@@ -147,7 +147,7 @@ public class IcebergTableEventDispatcher implements IcebergTableOperationDispatcpublic void dropTable(IcebergRequestContext context, TableIdentifier tableIdentifier, boolean purgeRequested) {NameIdentifier gravitinoNameIdentifier =- IcebergRestUtils.getGravitinoNameIdentifier(+ IcebergRESTUtils.getGravitinoNameIdentifier(metalakeName, context.catalogName(), tableIdentifier);eventBus.dispatchEvent(new IcebergDropTablePreEvent(context, gravitinoNameIdentifier, purgeRequested));@@ -166,7 +166,7 @@ public class IcebergTableEventDispatcher implements IcebergTableOperationDispatcpublic LoadTableResponse loadTable(IcebergRequestContext context, TableIdentifier tableIdentifier) {NameIdentifier gravitinoNameIdentifier =- IcebergRestUtils.getGravitinoNameIdentifier(+ IcebergRESTUtils.getGravitinoNameIdentifier(metalakeName, context.catalogName(), tableIdentifier);eventBus.dispatchEvent(new IcebergLoadTablePreEvent(context, gravitinoNameIdentifier));LoadTableResponse loadTableResponse;@@ -184,7 +184,7 @@ public class IcebergTableEventDispatcher implements IcebergTableOperationDispatc@Overridepublic ListTablesResponse listTable(IcebergRequestContext context, Namespace namespace) {NameIdentifier gravitinoNameIdentifier =- IcebergRestUtils.getGravitinoNameIdentifier(metalakeName, context.catalogName(), namespace);+ IcebergRESTUtils.getGravitinoNameIdentifier(metalakeName, context.catalogName(), namespace);eventBus.dispatchEvent(new IcebergListTablePreEvent(context, gravitinoNameIdentifier));ListTablesResponse listTablesResponse;try {@@ -200,7 +200,7 @@ public class IcebergTableEventDispatcher implements IcebergTableOperationDispatc@Overridepublic boolean tableExists(IcebergRequestContext context, TableIdentifier tableIdentifier) {NameIdentifier gravitinoNameIdentifier =- IcebergRestUtils.getGravitinoNameIdentifier(+ IcebergRESTUtils.getGravitinoNameIdentifier(metalakeName, context.catalogName(), tableIdentifier);eventBus.dispatchEvent(new IcebergTableExistsPreEvent(context, gravitinoNameIdentifier));boolean isExists;@@ -219,7 +219,7 @@ public class IcebergTableEventDispatcher implements IcebergTableOperationDispatcpublic void renameTable(IcebergRequestContext context, RenameTableRequest renameTableRequest) {TableIdentifier sourceTable = renameTableRequest.source();NameIdentifier gravitinoNameIdentifier =- IcebergRestUtils.getGravitinoNameIdentifier(+ IcebergRESTUtils.getGravitinoNameIdentifier(metalakeName, context.catalogName(), sourceTable);eventBus.dispatchEvent(new IcebergRenameTablePreEvent(context, gravitinoNameIdentifier, renameTableRequest));@@ -247,7 +247,7 @@ public class IcebergTableEventDispatcher implements IcebergTableOperationDispatcpublic LoadCredentialsResponse getTableCredentials(IcebergRequestContext context, TableIdentifier tableIdentifier) {NameIdentifier gravitinoNameIdentifier =- IcebergRestUtils.getGravitinoNameIdentifier(+ IcebergRESTUtils.getGravitinoNameIdentifier(metalakeName, context.catalogName(), tableIdentifier);eventBus.dispatchEvent(new IcebergLoadTableCredentialPreEvent(context, gravitinoNameIdentifier));diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergTableHookDispatcher.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergTableHookDispatcher.javanew file mode 100644index 0000000000..0d39eeed7e--- /dev/null+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergTableHookDispatcher.java@@ -0,0 +1,127 @@+/*+ * 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.iceberg.service.dispatcher;++import org.apache.gravitino.Entity;+import org.apache.gravitino.GravitinoEnv;+import org.apache.gravitino.authorization.AuthorizationUtils;+import org.apache.gravitino.authorization.Owner;+import org.apache.gravitino.authorization.OwnerDispatcher;+import org.apache.gravitino.catalog.TableDispatcher;+import org.apache.gravitino.iceberg.common.utils.IcebergIdentifierUtils;+import org.apache.gravitino.iceberg.service.authorization.IcebergRESTServerContext;+import org.apache.gravitino.listener.api.event.IcebergRequestContext;+import org.apache.gravitino.utils.NameIdentifierUtil;+import org.apache.iceberg.catalog.Namespace;+import org.apache.iceberg.catalog.TableIdentifier;+import org.apache.iceberg.rest.requests.CreateTableRequest;+import org.apache.iceberg.rest.requests.RenameTableRequest;+import org.apache.iceberg.rest.requests.UpdateTableRequest;+import org.apache.iceberg.rest.responses.ListTablesResponse;+import org.apache.iceberg.rest.responses.LoadCredentialsResponse;+import org.apache.iceberg.rest.responses.LoadTableResponse;++public class IcebergTableHookDispatcher implements IcebergTableOperationDispatcher {++ private final IcebergTableOperationDispatcher dispatcher;+ private String metalake;++ public IcebergTableHookDispatcher(IcebergTableOperationDispatcher dispatcher) {+ this.dispatcher = dispatcher;+ this.metalake = IcebergRESTServerContext.getInstance().metalakeName();+ }++ @Override+ public LoadTableResponse createTable(+ IcebergRequestContext context, Namespace namespace, CreateTableRequest createTableRequest) {+ AuthorizationUtils.checkCurrentUser(metalake, context.userName());++ LoadTableResponse response = dispatcher.createTable(context, namespace, createTableRequest);+ importTable(context.catalogName(), namespace, createTableRequest.name());+ setTableOwner(context.catalogName(), namespace, createTableRequest.name(), context.userName());++ return response;+ }++ @Override+ public LoadTableResponse updateTable(+ IcebergRequestContext context,+ TableIdentifier tableIdentifier,+ UpdateTableRequest updateTableRequest) {+ return dispatcher.updateTable(context, tableIdentifier, updateTableRequest);+ }++ @Override+ public void dropTable(+ IcebergRequestContext context, TableIdentifier tableIdentifier, boolean purgeRequested) {+ dispatcher.dropTable(context, tableIdentifier, purgeRequested);+ }++ @Override+ public LoadTableResponse loadTable(+ IcebergRequestContext context, TableIdentifier tableIdentifier) {+ return dispatcher.loadTable(context, tableIdentifier);+ }++ @Override+ public ListTablesResponse listTable(IcebergRequestContext context, Namespace namespace) {+ return dispatcher.listTable(context, namespace);+ }++ @Override+ public boolean tableExists(IcebergRequestContext context, TableIdentifier tableIdentifier) {+ return dispatcher.tableExists(context, tableIdentifier);+ }++ @Override+ public void renameTable(IcebergRequestContext context, RenameTableRequest renameTableRequest) {+ dispatcher.renameTable(context, renameTableRequest);+ }++ @Override+ public LoadCredentialsResponse getTableCredentials(+ IcebergRequestContext context, TableIdentifier tableIdentifier) {+ return dispatcher.getTableCredentials(context, tableIdentifier);+ }++ private void importTable(String catalogName, Namespace namespace, String tableName) {+ TableDispatcher tableDispatcher = GravitinoEnv.getInstance().tableDispatcher();+ if (tableDispatcher != null) {+ tableDispatcher.loadTable(+ IcebergIdentifierUtils.toGravitinoTableIdentifier(+ metalake, catalogName, TableIdentifier.of(namespace, tableName)));+ }+ }++ private void setTableOwner(+ String catalogName, Namespace namespace, String tableName, String user) {+ // Set the creator as the owner of the table.+ OwnerDispatcher ownerManager = GravitinoEnv.getInstance().ownerDispatcher();+ if (ownerManager != null) {+ ownerManager.setOwner(+ metalake,+ NameIdentifierUtil.toMetadataObject(+ IcebergIdentifierUtils.toGravitinoTableIdentifier(+ metalake, catalogName, TableIdentifier.of(namespace, tableName)),+ Entity.EntityType.TABLE),+ user,+ Owner.Type.USER);+ }+ }+}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergViewEventDispatcher.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergViewEventDispatcher.javaindex 761021e441..0c3d78f4e4 100644--- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergViewEventDispatcher.java+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergViewEventDispatcher.java@@ -21,7 +21,7 @@ package org.apache.gravitino.iceberg.service.dispatcher;import java.util.Optional;import org.apache.gravitino.NameIdentifier;-import org.apache.gravitino.iceberg.service.IcebergRestUtils;+import org.apache.gravitino.iceberg.service.IcebergRESTUtils;import org.apache.gravitino.listener.EventBus;import org.apache.gravitino.listener.api.event.BaseEvent;import org.apache.gravitino.listener.api.event.IcebergCreateViewEvent;@@ -79,7 +79,7 @@ public class IcebergViewEventDispatcher implements IcebergViewOperationDispatcheIcebergRequestContext context, Namespace namespace, CreateViewRequest createViewRequest) {TableIdentifier viewIdentifier = TableIdentifier.of(namespace, createViewRequest.name());NameIdentifier nameIdentifier =- IcebergRestUtils.getGravitinoNameIdentifier(+ IcebergRESTUtils.getGravitinoNameIdentifier(metalakeName, context.catalogName(), viewIdentifier);Optional<BaseEvent> transformedEvent =eventBus.dispatchEvent(@@ -109,7 +109,7 @@ public class IcebergViewEventDispatcher implements IcebergViewOperationDispatcheTableIdentifier viewIdentifier,UpdateTableRequest replaceViewRequest) {NameIdentifier gravitinoNameIdentifier =- IcebergRestUtils.getGravitinoNameIdentifier(+ IcebergRESTUtils.getGravitinoNameIdentifier(metalakeName, context.catalogName(), viewIdentifier);Optional<BaseEvent> transformedEvent =eventBus.dispatchEvent(@@ -139,7 +139,7 @@ public class IcebergViewEventDispatcher implements IcebergViewOperationDispatche@Overridepublic void dropView(IcebergRequestContext context, TableIdentifier viewIdentifier) {NameIdentifier gravitinoNameIdentifier =- IcebergRestUtils.getGravitinoNameIdentifier(+ IcebergRESTUtils.getGravitinoNameIdentifier(metalakeName, context.catalogName(), viewIdentifier);eventBus.dispatchEvent(new IcebergDropViewPreEvent(context, gravitinoNameIdentifier));try {@@ -154,7 +154,7 @@ public class IcebergViewEventDispatcher implements IcebergViewOperationDispatche@Overridepublic LoadViewResponse loadView(IcebergRequestContext context, TableIdentifier viewIdentifier) {NameIdentifier gravitinoNameIdentifier =- IcebergRestUtils.getGravitinoNameIdentifier(+ IcebergRESTUtils.getGravitinoNameIdentifier(metalakeName, context.catalogName(), viewIdentifier);eventBus.dispatchEvent(new IcebergLoadViewPreEvent(context, gravitinoNameIdentifier));LoadViewResponse loadViewResponse;@@ -172,7 +172,7 @@ public class IcebergViewEventDispatcher implements IcebergViewOperationDispatche@Overridepublic ListTablesResponse listView(IcebergRequestContext context, Namespace namespace) {NameIdentifier gravitinoNameIdentifier =- IcebergRestUtils.getGravitinoNameIdentifier(metalakeName, context.catalogName(), namespace);+ IcebergRESTUtils.getGravitinoNameIdentifier(metalakeName, context.catalogName(), namespace);eventBus.dispatchEvent(new IcebergListViewPreEvent(context, gravitinoNameIdentifier));ListTablesResponse listViewsResponse;try {@@ -188,7 +188,7 @@ public class IcebergViewEventDispatcher implements IcebergViewOperationDispatche@Overridepublic boolean viewExists(IcebergRequestContext context, TableIdentifier viewIdentifier) {NameIdentifier gravitinoNameIdentifier =- IcebergRestUtils.getGravitinoNameIdentifier(+ IcebergRESTUtils.getGravitinoNameIdentifier(metalakeName, context.catalogName(), viewIdentifier);eventBus.dispatchEvent(new IcebergViewExistsPreEvent(context, gravitinoNameIdentifier));boolean isExists;@@ -207,7 +207,7 @@ public class IcebergViewEventDispatcher implements IcebergViewOperationDispatchepublic void renameView(IcebergRequestContext context, RenameTableRequest renameViewRequest) {TableIdentifier sourceView = renameViewRequest.source();NameIdentifier gravitinoNameIdentifier =- IcebergRestUtils.getGravitinoNameIdentifier(+ IcebergRESTUtils.getGravitinoNameIdentifier(metalakeName, context.catalogName(), sourceView);eventBus.dispatchEvent(new IcebergRenameViewPreEvent(context, gravitinoNameIdentifier, renameViewRequest));diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/metrics/IcebergMetricsManager.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/metrics/IcebergMetricsManager.javaindex 67b7353838..816b6caab2 100644--- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/metrics/IcebergMetricsManager.java+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/metrics/IcebergMetricsManager.java@@ -30,7 +30,7 @@ import java.util.concurrent.ScheduledExecutorService;import java.util.concurrent.ScheduledThreadPoolExecutor;import java.util.concurrent.TimeUnit;import org.apache.gravitino.iceberg.common.IcebergConfig;-import org.apache.gravitino.iceberg.service.IcebergRestUtils;+import org.apache.gravitino.iceberg.service.IcebergRESTUtils;import org.apache.iceberg.catalog.Namespace;import org.apache.iceberg.metrics.MetricsReport;import org.slf4j.Logger;@@ -98,7 +98,7 @@ public class IcebergMetricsManager {() -> {Instant now = Instant.now();Instant expireTime =- IcebergRestUtils.calculateNewTimestamp(now, -24 * retainDays);+ IcebergRESTUtils.calculateNewTimestamp(now, -24 * retainDays);LOG.info("Try clean Iceberg expired metrics, {}.", expireTime);try {icebergMetricsStore.clean(expireTime);diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/provider/DynamicIcebergConfigProvider.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/provider/DynamicIcebergConfigProvider.javaindex eed2963ff4..bb5bff97eb 100644--- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/provider/DynamicIcebergConfigProvider.java+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/provider/DynamicIcebergConfigProvider.java@@ -27,6 +27,7 @@ import java.util.Map;import java.util.Optional;import org.apache.commons.lang3.StringUtils;import org.apache.gravitino.Catalog;+import org.apache.gravitino.GravitinoEnv;import org.apache.gravitino.auth.AuthProperties;import org.apache.gravitino.catalog.lakehouse.iceberg.IcebergConstants;import org.apache.gravitino.client.DefaultOAuth2TokenProvider;@@ -34,6 +35,7 @@ import org.apache.gravitino.client.GravitinoClient;import org.apache.gravitino.client.GravitinoClient.ClientBuilder;import org.apache.gravitino.exceptions.NoSuchCatalogException;import org.apache.gravitino.iceberg.common.IcebergConfig;+import org.apache.gravitino.server.web.JettyServerConfig;import org.apache.gravitino.utils.MapUtils;/**@@ -56,6 +58,13 @@ public class DynamicIcebergConfigProvider implements IcebergConfigProvider {public void initialize(Map<String, String> properties) {String uri = properties.get(IcebergConstants.GRAVITINO_URI);String metalake = properties.get(IcebergConstants.GRAVITINO_METALAKE);+ if (StringUtils.isBlank(uri)) {+ JettyServerConfig config =+ JettyServerConfig.fromConfig(+ GravitinoEnv.getInstance().config(),+ JettyServerConfig.GRAVITINO_SERVER_CONFIG_PREFIX);+ uri = String.format("http://%s:%d", config.getHost(), config.getHttpPort());+ }Preconditions.checkArgument(StringUtils.isNotBlank(uri), IcebergConstants.GRAVITINO_URI + " is blank");@@ -128,6 +137,11 @@ public class DynamicIcebergConfigProvider implements IcebergConfigProvider {return new IcebergConfig(properties);}+ @Override+ public String getDefaultCatalogName() {+ return defaultDynamicCatalogName.orElse(IcebergConstants.ICEBERG_REST_DEFAULT_CATALOG);+ }+// client is lazy loaded because the Gravitino server may not be started yet when the provider is// initialized.private GravitinoClient getGravitinoClient() {diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/provider/IcebergConfigProvider.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/provider/IcebergConfigProvider.javaindex 55d9793fba..003a33319d 100644--- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/provider/IcebergConfigProvider.java+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/provider/IcebergConfigProvider.java@@ -54,4 +54,13 @@ public interface IcebergConfigProvider extends Closeable {default String getMetalakeName() {return IcebergConstants.ICEBERG_REST_DEFAULT_METALAKE;}++ /**+ * Get default catalog name.+ *+ * @return the name of default catalog.+ */+ default String getDefaultCatalogName() {+ return IcebergConstants.ICEBERG_REST_DEFAULT_CATALOG;+ }}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergConfigOperations.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergConfigOperations.javaindex 2e075f1f33..6770847d39 100644--- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergConfigOperations.java+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergConfigOperations.java@@ -41,7 +41,7 @@ import org.apache.commons.lang3.StringUtils;import org.apache.gravitino.catalog.lakehouse.iceberg.IcebergConstants;import org.apache.gravitino.iceberg.service.CatalogWrapperForREST;import org.apache.gravitino.iceberg.service.IcebergCatalogWrapperManager;-import org.apache.gravitino.iceberg.service.IcebergRestUtils;+import org.apache.gravitino.iceberg.service.IcebergRESTUtils;import org.apache.gravitino.metrics.MetricNames;import org.apache.iceberg.rest.Endpoint;import org.apache.iceberg.rest.responses.ConfigResponse;@@ -106,7 +106,7 @@ public class IcebergConfigOperations {if (StringUtils.isNotBlank(warehouse)) {builder.withDefault("prefix", warehouse);}- return IcebergRestUtils.ok(builder.build());+ return IcebergRESTUtils.ok(builder.build());}private List<Endpoint> getEndpoints(boolean supportsViewOperations) {diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergNamespaceOperations.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergNamespaceOperations.javaindex aa77c4d48d..9742e8049b 100644--- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergNamespaceOperations.java+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergNamespaceOperations.java@@ -41,7 +41,7 @@ import javax.ws.rs.core.MediaType;import javax.ws.rs.core.Response;import org.apache.gravitino.iceberg.service.IcebergExceptionMapper;import org.apache.gravitino.iceberg.service.IcebergObjectMapper;-import org.apache.gravitino.iceberg.service.IcebergRestUtils;+import org.apache.gravitino.iceberg.service.IcebergRESTUtils;import org.apache.gravitino.iceberg.service.dispatcher.IcebergNamespaceOperationDispatcher;import org.apache.gravitino.listener.api.event.IcebergRequestContext;import org.apache.gravitino.metrics.MetricNames;@@ -85,7 +85,7 @@ public class IcebergNamespaceOperations {public Response listNamespaces(@DefaultValue("") @Encoded() @QueryParam("parent") String parent,@PathParam("prefix") String prefix) {- String catalogName = IcebergRestUtils.getCatalogName(prefix);+ String catalogName = IcebergRESTUtils.getCatalogName(prefix);Namespace parentNamespace =parent.isEmpty() ? Namespace.empty() : RESTUtil.decodeNamespace(parent);LOG.info(@@ -98,7 +98,7 @@ public class IcebergNamespaceOperations {new IcebergRequestContext(httpServletRequest(), catalogName);ListNamespacesResponse response =namespaceOperationDispatcher.listNamespaces(context, parentNamespace);- return IcebergRestUtils.ok(response);+ return IcebergRESTUtils.ok(response);});} catch (Exception e) {return IcebergExceptionMapper.toRESTResponse(e);@@ -112,7 +112,7 @@ public class IcebergNamespaceOperations {@ResponseMetered(name = "load-namespace", absolute = true)public Response loadNamespace(@PathParam("prefix") String prefix, @Encoded() @PathParam("namespace") String namespace) {- String catalogName = IcebergRestUtils.getCatalogName(prefix);+ String catalogName = IcebergRESTUtils.getCatalogName(prefix);Namespace icebergNS = RESTUtil.decodeNamespace(namespace);LOG.info("Load Iceberg namespace, catalog: {}, namespace: {}", catalogName, icebergNS);try {@@ -123,7 +123,7 @@ public class IcebergNamespaceOperations {new IcebergRequestContext(httpServletRequest(), catalogName);GetNamespaceResponse getNamespaceResponse =namespaceOperationDispatcher.loadNamespace(context, icebergNS);- return IcebergRestUtils.ok(getNamespaceResponse);+ return IcebergRESTUtils.ok(getNamespaceResponse);});} catch (Exception e) {return IcebergExceptionMapper.toRESTResponse(e);@@ -137,7 +137,7 @@ public class IcebergNamespaceOperations {@ResponseMetered(name = "namespace-exists", absolute = true)public Response namespaceExists(@PathParam("prefix") String prefix, @Encoded() @PathParam("namespace") String namespace) {- String catalogName = IcebergRestUtils.getCatalogName(prefix);+ String catalogName = IcebergRESTUtils.getCatalogName(prefix);Namespace icebergNS = RESTUtil.decodeNamespace(namespace);LOG.info("Check Iceberg namespace exists, catalog: {}, namespace: {}", catalogName, icebergNS);try {@@ -148,9 +148,9 @@ public class IcebergNamespaceOperations {new IcebergRequestContext(httpServletRequest(), catalogName);boolean exists = namespaceOperationDispatcher.namespaceExists(context, icebergNS);if (exists) {- return IcebergRestUtils.noContent();+ return IcebergRESTUtils.noContent();} else {- return IcebergRestUtils.notExists();+ return IcebergRESTUtils.notExists();}});} catch (Exception e) {@@ -166,7 +166,7 @@ public class IcebergNamespaceOperations {public Response dropNamespace(@PathParam("prefix") String prefix, @Encoded() @PathParam("namespace") String namespace) {// todo check if table exists in namespace after table ops is added- String catalogName = IcebergRestUtils.getCatalogName(prefix);+ String catalogName = IcebergRESTUtils.getCatalogName(prefix);Namespace icebergNS = RESTUtil.decodeNamespace(namespace);LOG.info("Drop Iceberg namespace, catalog: {}, namespace: {}", catalogName, icebergNS);try {@@ -176,7 +176,7 @@ public class IcebergNamespaceOperations {IcebergRequestContext context =new IcebergRequestContext(httpServletRequest(), catalogName);namespaceOperationDispatcher.dropNamespace(context, icebergNS);- return IcebergRestUtils.noContent();+ return IcebergRESTUtils.noContent();});} catch (Exception e) {return IcebergExceptionMapper.toRESTResponse(e);@@ -189,7 +189,7 @@ public class IcebergNamespaceOperations {@ResponseMetered(name = "create-namespace", absolute = true)public Response createNamespace(@PathParam("prefix") String prefix, CreateNamespaceRequest createNamespaceRequest) {- String catalogName = IcebergRestUtils.getCatalogName(prefix);+ String catalogName = IcebergRESTUtils.getCatalogName(prefix);LOG.info("Create Iceberg namespace, catalog: {}, createNamespaceRequest: {}",catalogName,@@ -202,7 +202,7 @@ public class IcebergNamespaceOperations {new IcebergRequestContext(httpServletRequest(), catalogName);CreateNamespaceResponse createNamespaceResponse =namespaceOperationDispatcher.createNamespace(context, createNamespaceRequest);- return IcebergRestUtils.ok(createNamespaceResponse);+ return IcebergRESTUtils.ok(createNamespaceResponse);});} catch (Exception e) {return IcebergExceptionMapper.toRESTResponse(e);@@ -218,7 +218,7 @@ public class IcebergNamespaceOperations {@PathParam("prefix") String prefix,@Encoded() @PathParam("namespace") String namespace,UpdateNamespacePropertiesRequest updateNamespacePropertiesRequest) {- String catalogName = IcebergRestUtils.getCatalogName(prefix);+ String catalogName = IcebergRESTUtils.getCatalogName(prefix);Namespace icebergNS = RESTUtil.decodeNamespace(namespace);LOG.info("Update Iceberg namespace, catalog: {}, namespace: {}, updateNamespacePropertiesRequest: {}",@@ -234,7 +234,7 @@ public class IcebergNamespaceOperations {UpdateNamespacePropertiesResponse updateNamespacePropertiesResponse =namespaceOperationDispatcher.updateNamespace(context, icebergNS, updateNamespacePropertiesRequest);- return IcebergRestUtils.ok(updateNamespacePropertiesResponse);+ return IcebergRESTUtils.ok(updateNamespacePropertiesResponse);});} catch (Exception e) {return IcebergExceptionMapper.toRESTResponse(e);@@ -250,7 +250,7 @@ public class IcebergNamespaceOperations {@PathParam("prefix") String prefix,@Encoded() @PathParam("namespace") String namespace,RegisterTableRequest registerTableRequest) {- String catalogName = IcebergRestUtils.getCatalogName(prefix);+ String catalogName = IcebergRESTUtils.getCatalogName(prefix);Namespace icebergNS = RESTUtil.decodeNamespace(namespace);LOG.info("Register Iceberg table, catalog: {}, namespace: {}, registerTableRequest: {}",@@ -266,7 +266,7 @@ public class IcebergNamespaceOperations {LoadTableResponse loadTableResponse =namespaceOperationDispatcher.registerTable(context, icebergNS, registerTableRequest);- return IcebergRestUtils.ok(loadTableResponse);+ return IcebergRESTUtils.ok(loadTableResponse);});} catch (Exception e) {return IcebergExceptionMapper.toRESTResponse(e);diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergTableOperations.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergTableOperations.javaindex e42d318790..8eaa095d0b 100644--- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergTableOperations.java+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergTableOperations.java@@ -23,6 +23,8 @@ import com.codahale.metrics.annotation.Timed;import com.fasterxml.jackson.core.JsonProcessingException;import com.fasterxml.jackson.databind.ObjectMapper;import com.google.common.annotations.VisibleForTesting;+import java.util.ArrayList;+import java.util.List;import javax.inject.Inject;import javax.servlet.http.HttpServletRequest;import javax.ws.rs.Consumes;@@ -41,13 +43,24 @@ import javax.ws.rs.core.Context;import javax.ws.rs.core.MediaType;import javax.ws.rs.core.Response;import org.apache.commons.lang3.StringUtils;+import org.apache.gravitino.Entity;+import org.apache.gravitino.Entity.EntityType;+import org.apache.gravitino.MetadataObject;+import org.apache.gravitino.NameIdentifier;import org.apache.gravitino.iceberg.service.IcebergExceptionMapper;import org.apache.gravitino.iceberg.service.IcebergObjectMapper;-import org.apache.gravitino.iceberg.service.IcebergRestUtils;+import org.apache.gravitino.iceberg.service.IcebergRESTUtils;+import org.apache.gravitino.iceberg.service.authorization.IcebergRESTServerContext;import org.apache.gravitino.iceberg.service.dispatcher.IcebergTableOperationDispatcher;import org.apache.gravitino.iceberg.service.metrics.IcebergMetricsManager;import org.apache.gravitino.listener.api.event.IcebergRequestContext;import org.apache.gravitino.metrics.MetricNames;+import org.apache.gravitino.server.authorization.MetadataFilterHelper;+import org.apache.gravitino.server.authorization.annotations.AuthorizationExpression;+import org.apache.gravitino.server.authorization.annotations.AuthorizationMetadata;+import org.apache.gravitino.server.authorization.annotations.IcebergAuthorizationMetadata;+import org.apache.gravitino.server.authorization.annotations.IcebergAuthorizationMetadata.RequestType;+import org.apache.gravitino.server.authorization.expression.AuthorizationExpressionConstants;import org.apache.gravitino.server.web.Utils;import org.apache.iceberg.catalog.Namespace;import org.apache.iceberg.catalog.TableIdentifier;@@ -91,9 +104,14 @@ public class IcebergTableOperations {@Produces(MediaType.APPLICATION_JSON)@Timed(name = "list-table." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)@ResponseMetered(name = "list-table", absolute = true)+ @AuthorizationExpression(+ expression = AuthorizationExpressionConstants.loadSchemaAuthorizationExpression,+ accessMetadataType = MetadataObject.Type.SCHEMA)public Response listTable(- @PathParam("prefix") String prefix, @Encoded() @PathParam("namespace") String namespace) {- String catalogName = IcebergRestUtils.getCatalogName(prefix);+ @AuthorizationMetadata(type = Entity.EntityType.CATALOG) @PathParam("prefix") String prefix,+ @AuthorizationMetadata(type = EntityType.SCHEMA) @Encoded() @PathParam("namespace")+ String namespace) {+ String catalogName = IcebergRESTUtils.getCatalogName(prefix);Namespace icebergNS = RESTUtil.decodeNamespace(namespace);LOG.info("List Iceberg tables, catalog: {}, namespace: {}", catalogName, icebergNS);try {@@ -104,7 +122,14 @@ public class IcebergTableOperations {new IcebergRequestContext(httpServletRequest(), catalogName);ListTablesResponse listTablesResponse =tableOperationDispatcher.listTable(context, icebergNS);- return IcebergRestUtils.ok(listTablesResponse);++ IcebergRESTServerContext authContext = IcebergRESTServerContext.getInstance();+ if (authContext.isAuthorizationEnabled()) {+ listTablesResponse =+ filterListTablesResponse(+ listTablesResponse, authContext.metalakeName(), catalogName);+ }+ return IcebergRESTUtils.ok(listTablesResponse);});} catch (Exception e) {return IcebergExceptionMapper.toRESTResponse(e);@@ -115,13 +140,20 @@ public class IcebergTableOperations {@Produces(MediaType.APPLICATION_JSON)@Timed(name = "create-table." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)@ResponseMetered(name = "create-table", absolute = true)+ @AuthorizationExpression(+ expression =+ "ANY(OWNER, METALAKE, CATALOG) || "+ + "SCHEMA_OWNER_WITH_USE_CATALOG || "+ + "ANY_USE_CATALOG && ANY_USE_SCHEMA && ANY_CREATE_TABLE",+ accessMetadataType = MetadataObject.Type.SCHEMA)public Response createTable(- @PathParam("prefix") String prefix,- @Encoded() @PathParam("namespace") String namespace,+ @AuthorizationMetadata(type = Entity.EntityType.CATALOG) @PathParam("prefix") String prefix,+ @AuthorizationMetadata(type = Entity.EntityType.SCHEMA) @Encoded() @PathParam("namespace")+ String namespace,CreateTableRequest createTableRequest,@HeaderParam(X_ICEBERG_ACCESS_DELEGATION) String accessDelegation) {boolean isCredentialVending = isCredentialVending(accessDelegation);- String catalogName = IcebergRestUtils.getCatalogName(prefix);+ String catalogName = IcebergRESTUtils.getCatalogName(prefix);Namespace icebergNS = RESTUtil.decodeNamespace(namespace);LOG.info("Create Iceberg table, catalog: {}, namespace: {}, create table request: {}, "@@ -139,7 +171,7 @@ public class IcebergTableOperations {new IcebergRequestContext(httpServletRequest(), catalogName, isCredentialVending);LoadTableResponse loadTableResponse =tableOperationDispatcher.createTable(context, icebergNS, createTableRequest);- return IcebergRestUtils.ok(loadTableResponse);+ return IcebergRESTUtils.ok(loadTableResponse);});} catch (Exception e) {return IcebergExceptionMapper.toRESTResponse(e);@@ -151,12 +183,19 @@ public class IcebergTableOperations {@Produces(MediaType.APPLICATION_JSON)@Timed(name = "update-table." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)@ResponseMetered(name = "update-table", absolute = true)+ @AuthorizationExpression(+ expression =+ "ANY(OWNER, METALAKE, CATALOG) || "+ + "SCHEMA_OWNER_WITH_USE_CATALOG || "+ + "ANY_USE_CATALOG && ANY_USE_SCHEMA && (TABLE::OWNER || ANY_MODIFY_TABLE)",+ accessMetadataType = MetadataObject.Type.TABLE)public Response updateTable(- @PathParam("prefix") String prefix,- @Encoded() @PathParam("namespace") String namespace,- @PathParam("table") String table,+ @AuthorizationMetadata(type = Entity.EntityType.CATALOG) @PathParam("prefix") String prefix,+ @AuthorizationMetadata(type = EntityType.SCHEMA) @Encoded() @PathParam("namespace")+ String namespace,+ @AuthorizationMetadata(type = Entity.EntityType.TABLE) @PathParam("table") String table,UpdateTableRequest updateTableRequest) {- String catalogName = IcebergRestUtils.getCatalogName(prefix);+ String catalogName = IcebergRESTUtils.getCatalogName(prefix);Namespace icebergNS = RESTUtil.decodeNamespace(namespace);if (LOG.isInfoEnabled()) {LOG.info(@@ -175,7 +214,7 @@ public class IcebergTableOperations {TableIdentifier tableIdentifier = TableIdentifier.of(icebergNS, table);LoadTableResponse loadTableResponse =tableOperationDispatcher.updateTable(context, tableIdentifier, updateTableRequest);- return IcebergRestUtils.ok(loadTableResponse);+ return IcebergRESTUtils.ok(loadTableResponse);});} catch (Exception e) {return IcebergExceptionMapper.toRESTResponse(e);@@ -187,12 +226,19 @@ public class IcebergTableOperations {@Produces(MediaType.APPLICATION_JSON)@Timed(name = "drop-table." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)@ResponseMetered(name = "drop-table", absolute = true)+ @AuthorizationExpression(+ expression =+ "ANY(OWNER, METALAKE, CATALOG) || "+ + "SCHEMA_OWNER_WITH_USE_CATALOG || "+ + "ANY_USE_CATALOG && ANY_USE_SCHEMA && TABLE::OWNER ",+ accessMetadataType = MetadataObject.Type.TABLE)public Response dropTable(- @PathParam("prefix") String prefix,- @Encoded() @PathParam("namespace") String namespace,- @PathParam("table") String table,+ @AuthorizationMetadata(type = Entity.EntityType.CATALOG) @PathParam("prefix") String prefix,+ @AuthorizationMetadata(type = EntityType.SCHEMA) @Encoded() @PathParam("namespace")+ String namespace,+ @AuthorizationMetadata(type = Entity.EntityType.TABLE) @PathParam("table") String table,@DefaultValue("false") @QueryParam("purgeRequested") boolean purgeRequested) {- String catalogName = IcebergRestUtils.getCatalogName(prefix);+ String catalogName = IcebergRESTUtils.getCatalogName(prefix);Namespace icebergNS = RESTUtil.decodeNamespace(namespace);LOG.info("Drop Iceberg table, catalog: {}, namespace: {}, table: {}, purgeRequested: {}",@@ -208,7 +254,7 @@ public class IcebergTableOperations {IcebergRequestContext context =new IcebergRequestContext(httpServletRequest(), catalogName);tableOperationDispatcher.dropTable(context, tableIdentifier, purgeRequested);- return IcebergRestUtils.noContent();+ return IcebergRESTUtils.noContent();});} catch (Exception e) {return IcebergExceptionMapper.toRESTResponse(e);@@ -220,13 +266,20 @@ public class IcebergTableOperations {@Produces(MediaType.APPLICATION_JSON)@Timed(name = "load-table." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)@ResponseMetered(name = "load-table", absolute = true)+ @AuthorizationExpression(+ expression =+ "ANY(OWNER, METALAKE, CATALOG) || "+ + "SCHEMA_OWNER_WITH_USE_CATALOG || "+ + "ANY_USE_CATALOG && ANY_USE_SCHEMA && (TABLE::OWNER || ANY_SELECT_TABLE|| ANY_MODIFY_TABLE)",+ accessMetadataType = MetadataObject.Type.TABLE)public Response loadTable(- @PathParam("prefix") String prefix,- @Encoded() @PathParam("namespace") String namespace,- @PathParam("table") String table,+ @AuthorizationMetadata(type = Entity.EntityType.CATALOG) @PathParam("prefix") String prefix,+ @AuthorizationMetadata(type = EntityType.SCHEMA) @Encoded() @PathParam("namespace")+ String namespace,+ @IcebergAuthorizationMetadata(type = RequestType.LOAD_TABLE) @PathParam("table") String table,@DefaultValue("all") @QueryParam("snapshots") String snapshots,@HeaderParam(X_ICEBERG_ACCESS_DELEGATION) String accessDelegation) {- String catalogName = IcebergRestUtils.getCatalogName(prefix);+ String catalogName = IcebergRESTUtils.getCatalogName(prefix);Namespace icebergNS = RESTUtil.decodeNamespace(namespace);boolean isCredentialVending = isCredentialVending(accessDelegation);LOG.info(@@ -247,7 +300,7 @@ public class IcebergTableOperations {new IcebergRequestContext(httpServletRequest(), catalogName, isCredentialVending);LoadTableResponse loadTableResponse =tableOperationDispatcher.loadTable(context, tableIdentifier);- return IcebergRestUtils.ok(loadTableResponse);+ return IcebergRESTUtils.ok(loadTableResponse);});} catch (Exception e) {return IcebergExceptionMapper.toRESTResponse(e);@@ -259,11 +312,18 @@ public class IcebergTableOperations {@Produces(MediaType.APPLICATION_JSON)@Timed(name = "table-exists." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)@ResponseMetered(name = "table-exists", absolute = true)+ @AuthorizationExpression(+ expression =+ "ANY(OWNER, METALAKE, CATALOG) || "+ + "SCHEMA_OWNER_WITH_USE_CATALOG || "+ + "ANY_USE_CATALOG && ANY_USE_SCHEMA && (TABLE::OWNER || ANY_SELECT_TABLE|| ANY_MODIFY_TABLE)",+ accessMetadataType = MetadataObject.Type.TABLE)public Response tableExists(- @PathParam("prefix") String prefix,- @Encoded() @PathParam("namespace") String namespace,- @PathParam("table") String table) {- String catalogName = IcebergRestUtils.getCatalogName(prefix);+ @AuthorizationMetadata(type = Entity.EntityType.CATALOG) @PathParam("prefix") String prefix,+ @AuthorizationMetadata(type = EntityType.SCHEMA) @Encoded() @PathParam("namespace")+ String namespace,+ @AuthorizationMetadata(type = Entity.EntityType.TABLE) @PathParam("table") String table) {+ String catalogName = IcebergRESTUtils.getCatalogName(prefix);Namespace icebergNS = RESTUtil.decodeNamespace(namespace);LOG.info("Check Iceberg table exists, catalog: {}, namespace: {}, table: {}",@@ -279,9 +339,9 @@ public class IcebergTableOperations {TableIdentifier tableIdentifier = TableIdentifier.of(icebergNS, table);boolean exists = tableOperationDispatcher.tableExists(context, tableIdentifier);if (exists) {- return IcebergRestUtils.noContent();+ return IcebergRESTUtils.noContent();} else {- return IcebergRestUtils.notExists();+ return IcebergRESTUtils.notExists();}});} catch (Exception e) {@@ -299,7 +359,7 @@ public class IcebergTableOperations {@Encoded() @PathParam("namespace") String namespace,@PathParam("table") String table,ReportMetricsRequest request) {- String catalogName = IcebergRestUtils.getCatalogName(prefix);+ String catalogName = IcebergRESTUtils.getCatalogName(prefix);Namespace icebergNS = RESTUtil.decodeNamespace(namespace);LOG.info("Report Iceberg table metrics, catalog: {}, namespace: {}, table: {}",@@ -313,9 +373,9 @@ public class IcebergTableOperations {boolean accepted =icebergMetricsManager.recordMetric(catalogName, icebergNS, request.report());if (accepted) {- return IcebergRestUtils.noContent();+ return IcebergRESTUtils.noContent();} else {- return IcebergRestUtils.errorResponse(+ return IcebergRESTUtils.errorResponse(new RuntimeException("Metrics service unavailable: queue full or service closed"),Response.Status.SERVICE_UNAVAILABLE.getStatusCode());}@@ -349,7 +409,7 @@ public class IcebergTableOperations {@PathParam("prefix") String prefix,@Encoded() @PathParam("namespace") String namespace,@PathParam("table") String table) {- String catalogName = IcebergRestUtils.getCatalogName(prefix);+ String catalogName = IcebergRESTUtils.getCatalogName(prefix);Namespace icebergNS = RESTUtil.decodeNamespace(namespace);LOG.info("Get Iceberg table credentials, catalog: {}, namespace: {}, table: {}",@@ -368,7 +428,7 @@ public class IcebergTableOperations {// Get credentials using the table operation dispatcherLoadCredentialsResponse credentialsResponse =tableOperationDispatcher.getTableCredentials(context, tableIdentifier);- return IcebergRestUtils.ok(credentialsResponse);+ return IcebergRESTUtils.ok(credentialsResponse);});} catch (Exception e) {return IcebergExceptionMapper.toRESTResponse(e);@@ -394,4 +454,36 @@ public class IcebergTableOperations {+ "Gravitino Iceberg REST server supports: vended-credentials");}}++ private NameIdentifier[] toNameIdentifiers(+ ListTablesResponse listTablesResponse, String metalake, String catalogName) {+ List<TableIdentifier> identifiers = listTablesResponse.identifiers();+ NameIdentifier[] nameIdentifiers = new NameIdentifier[identifiers.size()];+ for (int i = 0; i < identifiers.size(); i++) {+ TableIdentifier identifier = identifiers.get(i);+ nameIdentifiers[i] =+ NameIdentifier.of(+ metalake, catalogName, identifier.namespace().level(0), identifier.name());+ }+ return nameIdentifiers;+ }++ private ListTablesResponse filterListTablesResponse(+ ListTablesResponse listTablesResponse, String metalake, String catalogName) {+ NameIdentifier[] idents =+ MetadataFilterHelper.filterByExpression(+ metalake,+ AuthorizationExpressionConstants.filterTableAuthorizationExpression,+ Entity.EntityType.TABLE,+ toNameIdentifiers(listTablesResponse, metalake, catalogName));+ List<TableIdentifier> filteredIdentifiers = new ArrayList<>();+ for (NameIdentifier ident : idents) {+ filteredIdentifiers.add(+ TableIdentifier.of(Namespace.of(ident.namespace().level(0)), ident.name()));+ }+ return ListTablesResponse.builder()+ .addAll(filteredIdentifiers)+ .nextPageToken(listTablesResponse.nextPageToken())+ .build();+ }}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergTableRenameOperations.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergTableRenameOperations.javaindex d1f079d1d6..09766912ac 100644--- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergTableRenameOperations.java+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergTableRenameOperations.java@@ -31,11 +31,17 @@ import javax.ws.rs.Produces;import javax.ws.rs.core.Context;import javax.ws.rs.core.MediaType;import javax.ws.rs.core.Response;+import org.apache.gravitino.Entity;+import org.apache.gravitino.MetadataObject;import org.apache.gravitino.iceberg.service.IcebergExceptionMapper;-import org.apache.gravitino.iceberg.service.IcebergRestUtils;+import org.apache.gravitino.iceberg.service.IcebergRESTUtils;import org.apache.gravitino.iceberg.service.dispatcher.IcebergTableOperationDispatcher;import org.apache.gravitino.listener.api.event.IcebergRequestContext;import org.apache.gravitino.metrics.MetricNames;+import org.apache.gravitino.server.authorization.annotations.AuthorizationExpression;+import org.apache.gravitino.server.authorization.annotations.AuthorizationMetadata;+import org.apache.gravitino.server.authorization.annotations.IcebergAuthorizationMetadata;+import org.apache.gravitino.server.authorization.annotations.IcebergAuthorizationMetadata.RequestType;import org.apache.gravitino.server.web.Utils;import org.apache.iceberg.rest.requests.RenameTableRequest;import org.slf4j.Logger;@@ -60,9 +66,17 @@ public class IcebergTableRenameOperations {@Produces(MediaType.APPLICATION_JSON)@Timed(name = "rename-table." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)@ResponseMetered(name = "rename-table", absolute = true)+ @AuthorizationExpression(+ expression =+ "ANY(OWNER, METALAKE, CATALOG) || "+ + "SCHEMA_OWNER_WITH_USE_CATALOG || "+ + "ANY_USE_CATALOG && ANY_USE_SCHEMA && (TABLE::OWNER || ANY_MODIFY_TABLE)",+ accessMetadataType = MetadataObject.Type.TABLE)public Response renameTable(- @PathParam("prefix") String prefix, RenameTableRequest renameTableRequest) {- String catalogName = IcebergRestUtils.getCatalogName(prefix);+ @AuthorizationMetadata(type = Entity.EntityType.CATALOG) @PathParam("prefix") String prefix,+ @IcebergAuthorizationMetadata(type = RequestType.RENAME_TABLE)+ RenameTableRequest renameTableRequest) {+ String catalogName = IcebergRESTUtils.getCatalogName(prefix);LOG.info("Rename Iceberg tables, catalog: {}, source: {}, destination: {}.",catalogName,@@ -75,7 +89,7 @@ public class IcebergTableRenameOperations {IcebergRequestContext context =new IcebergRequestContext(httpServletRequest(), catalogName);tableOperationDispatcher.renameTable(context, renameTableRequest);- return IcebergRestUtils.noContent();+ return IcebergRESTUtils.noContent();});} catch (Exception e) {return IcebergExceptionMapper.toRESTResponse(e);diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergViewOperations.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergViewOperations.javaindex 0cf4e37879..728a1a2ceb 100644--- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergViewOperations.java+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergViewOperations.java@@ -39,7 +39,7 @@ import javax.ws.rs.core.MediaType;import javax.ws.rs.core.Response;import org.apache.gravitino.iceberg.service.IcebergExceptionMapper;import org.apache.gravitino.iceberg.service.IcebergObjectMapper;-import org.apache.gravitino.iceberg.service.IcebergRestUtils;+import org.apache.gravitino.iceberg.service.IcebergRESTUtils;import org.apache.gravitino.iceberg.service.dispatcher.IcebergViewOperationDispatcher;import org.apache.gravitino.listener.api.event.IcebergRequestContext;import org.apache.gravitino.metrics.MetricNames;@@ -78,7 +78,7 @@ public class IcebergViewOperations {@ResponseMetered(name = "list-view", absolute = true)public Response listView(@PathParam("prefix") String prefix, @Encoded() @PathParam("namespace") String namespace) {- String catalogName = IcebergRestUtils.getCatalogName(prefix);+ String catalogName = IcebergRESTUtils.getCatalogName(prefix);Namespace icebergNS = RESTUtil.decodeNamespace(namespace);LOG.info("List Iceberg views, catalog: {}, namespace: {}", catalogName, icebergNS);try {@@ -89,7 +89,7 @@ public class IcebergViewOperations {new IcebergRequestContext(httpServletRequest(), catalogName);ListTablesResponse listTablesResponse =viewOperationDispatcher.listView(context, icebergNS);- return IcebergRestUtils.ok(listTablesResponse);+ return IcebergRESTUtils.ok(listTablesResponse);});} catch (Exception e) {return IcebergExceptionMapper.toRESTResponse(e);@@ -104,7 +104,7 @@ public class IcebergViewOperations {@PathParam("prefix") String prefix,@Encoded() @PathParam("namespace") String namespace,CreateViewRequest createViewRequest) {- String catalogName = IcebergRestUtils.getCatalogName(prefix);+ String catalogName = IcebergRESTUtils.getCatalogName(prefix);Namespace icebergNS = RESTUtil.decodeNamespace(namespace);LOG.info("Create Iceberg view, catalog: {}, namespace: {}, createViewRequest: {}",@@ -119,7 +119,7 @@ public class IcebergViewOperations {new IcebergRequestContext(httpServletRequest(), catalogName);LoadViewResponse loadViewResponse =viewOperationDispatcher.createView(context, icebergNS, createViewRequest);- return IcebergRestUtils.ok(loadViewResponse);+ return IcebergRESTUtils.ok(loadViewResponse);});} catch (Exception e) {return IcebergExceptionMapper.toRESTResponse(e);@@ -135,7 +135,7 @@ public class IcebergViewOperations {@PathParam("prefix") String prefix,@Encoded() @PathParam("namespace") String namespace,@PathParam("view") String view) {- String catalogName = IcebergRestUtils.getCatalogName(prefix);+ String catalogName = IcebergRESTUtils.getCatalogName(prefix);Namespace icebergNS = RESTUtil.decodeNamespace(namespace);LOG.info("Load Iceberg view, catalog: {}, namespace: {}, view: {}", catalogName, icebergNS, view);@@ -148,7 +148,7 @@ public class IcebergViewOperations {new IcebergRequestContext(httpServletRequest(), catalogName);LoadViewResponse loadViewResponse =viewOperationDispatcher.loadView(context, viewIdentifier);- return IcebergRestUtils.ok(loadViewResponse);+ return IcebergRESTUtils.ok(loadViewResponse);});} catch (Exception e) {return IcebergExceptionMapper.toRESTResponse(e);@@ -165,7 +165,7 @@ public class IcebergViewOperations {@Encoded() @PathParam("namespace") String namespace,@PathParam("view") String view,UpdateTableRequest replaceViewRequest) {- String catalogName = IcebergRestUtils.getCatalogName(prefix);+ String catalogName = IcebergRESTUtils.getCatalogName(prefix);Namespace icebergNS = RESTUtil.decodeNamespace(namespace);LOG.info("Replace Iceberg view, catalog: {}, namespace: {}, view: {}, replaceViewRequest: {}",@@ -182,7 +182,7 @@ public class IcebergViewOperations {TableIdentifier viewIdentifier = TableIdentifier.of(icebergNS, view);LoadViewResponse loadViewResponse =viewOperationDispatcher.replaceView(context, viewIdentifier, replaceViewRequest);- return IcebergRestUtils.ok(loadViewResponse);+ return IcebergRESTUtils.ok(loadViewResponse);});} catch (Exception e) {return IcebergExceptionMapper.toRESTResponse(e);@@ -198,7 +198,7 @@ public class IcebergViewOperations {@PathParam("prefix") String prefix,@Encoded() @PathParam("namespace") String namespace,@PathParam("view") String view) {- String catalogName = IcebergRestUtils.getCatalogName(prefix);+ String catalogName = IcebergRESTUtils.getCatalogName(prefix);Namespace icebergNS = RESTUtil.decodeNamespace(namespace);LOG.info("Drop Iceberg view, catalog: {}, namespace: {}, view: {}", catalogName, icebergNS, view);@@ -210,7 +210,7 @@ public class IcebergViewOperations {IcebergRequestContext context =new IcebergRequestContext(httpServletRequest(), catalogName);viewOperationDispatcher.dropView(context, viewIdentifier);- return IcebergRestUtils.noContent();+ return IcebergRESTUtils.noContent();});} catch (Exception e) {return IcebergExceptionMapper.toRESTResponse(e);@@ -226,7 +226,7 @@ public class IcebergViewOperations {@PathParam("prefix") String prefix,@Encoded() @PathParam("namespace") String namespace,@PathParam("view") String view) {- String catalogName = IcebergRestUtils.getCatalogName(prefix);+ String catalogName = IcebergRESTUtils.getCatalogName(prefix);Namespace icebergNS = RESTUtil.decodeNamespace(namespace);LOG.info("Check Iceberg view exists, catalog: {}, namespace: {}, view: {}",@@ -242,9 +242,9 @@ public class IcebergViewOperations {TableIdentifier viewIdentifier = TableIdentifier.of(icebergNS, view);boolean exists = viewOperationDispatcher.viewExists(context, viewIdentifier);if (exists) {- return IcebergRestUtils.noContent();+ return IcebergRESTUtils.noContent();} else {- return IcebergRestUtils.notExists();+ return IcebergRESTUtils.notExists();}});} catch (Exception e) {diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergViewRenameOperations.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergViewRenameOperations.javaindex cbdcb216eb..30c8b36bc3 100644--- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergViewRenameOperations.java+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergViewRenameOperations.java@@ -32,7 +32,7 @@ import javax.ws.rs.core.Context;import javax.ws.rs.core.MediaType;import javax.ws.rs.core.Response;import org.apache.gravitino.iceberg.service.IcebergExceptionMapper;-import org.apache.gravitino.iceberg.service.IcebergRestUtils;+import org.apache.gravitino.iceberg.service.IcebergRESTUtils;import org.apache.gravitino.iceberg.service.dispatcher.IcebergViewOperationDispatcher;import org.apache.gravitino.listener.api.event.IcebergRequestContext;import org.apache.gravitino.metrics.MetricNames;@@ -62,7 +62,7 @@ public class IcebergViewRenameOperations {@ResponseMetered(name = "rename-view", absolute = true)public Response renameView(@PathParam("prefix") String prefix, RenameTableRequest renameViewRequest) {- String catalogName = IcebergRestUtils.getCatalogName(prefix);+ String catalogName = IcebergRESTUtils.getCatalogName(prefix);LOG.info("Rename Iceberg view, catalog: {}, source: {}, destination: {}.",catalogName,@@ -75,7 +75,7 @@ public class IcebergViewRenameOperations {IcebergRequestContext context =new IcebergRequestContext(httpServletRequest(), catalogName);viewOperationDispatcher.renameView(context, renameViewRequest);- return IcebergRestUtils.noContent();+ return IcebergRESTUtils.noContent();});} catch (Exception e) {return IcebergExceptionMapper.toRESTResponse(e);diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergCreateNamespaceEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergCreateNamespaceEvent.javaindex 9bc1698ef1..d68ea2481b 100644--- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergCreateNamespaceEvent.java+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergCreateNamespaceEvent.java@@ -21,7 +21,7 @@ package org.apache.gravitino.listener.api.event;import org.apache.gravitino.NameIdentifier;import org.apache.gravitino.annotation.DeveloperApi;-import org.apache.gravitino.iceberg.service.IcebergRestUtils;+import org.apache.gravitino.iceberg.service.IcebergRESTUtils;import org.apache.iceberg.rest.requests.CreateNamespaceRequest;import org.apache.iceberg.rest.responses.CreateNamespaceResponse;@@ -39,10 +39,10 @@ public class IcebergCreateNamespaceEvent extends IcebergNamespaceEvent {CreateNamespaceResponse createNamespaceResponse) {super(icebergRequestContext, nameIdentifier);this.createNamespaceRequest =- IcebergRestUtils.cloneIcebergRESTObject(+ IcebergRESTUtils.cloneIcebergRESTObject(createNamespaceRequest, CreateNamespaceRequest.class);this.createNamespaceResponse =- IcebergRestUtils.cloneIcebergRESTObject(+ IcebergRESTUtils.cloneIcebergRESTObject(createNamespaceResponse, CreateNamespaceResponse.class);}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergCreateNamespaceFailureEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergCreateNamespaceFailureEvent.javaindex 850e33611d..c742e782f9 100644--- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergCreateNamespaceFailureEvent.java+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergCreateNamespaceFailureEvent.java@@ -21,7 +21,7 @@ package org.apache.gravitino.listener.api.event;import org.apache.gravitino.NameIdentifier;import org.apache.gravitino.annotation.DeveloperApi;-import org.apache.gravitino.iceberg.service.IcebergRestUtils;+import org.apache.gravitino.iceberg.service.IcebergRESTUtils;import org.apache.iceberg.rest.requests.CreateNamespaceRequest;/** Represent a failure event when creating Iceberg namespace failed. */@@ -36,7 +36,7 @@ public class IcebergCreateNamespaceFailureEvent extends IcebergNamespaceFailureEException e) {super(icebergRequestContext, nameIdentifier, e);this.createNamespaceRequest =- IcebergRestUtils.cloneIcebergRESTObject(+ IcebergRESTUtils.cloneIcebergRESTObject(createNamespaceRequest, CreateNamespaceRequest.class);}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergCreateTableEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergCreateTableEvent.javaindex 8a6fcf2e85..1ba2417310 100644--- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergCreateTableEvent.java+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergCreateTableEvent.java@@ -21,7 +21,7 @@ package org.apache.gravitino.listener.api.event;import org.apache.gravitino.NameIdentifier;import org.apache.gravitino.annotation.DeveloperApi;-import org.apache.gravitino.iceberg.service.IcebergRestUtils;+import org.apache.gravitino.iceberg.service.IcebergRESTUtils;import org.apache.iceberg.rest.requests.CreateTableRequest;import org.apache.iceberg.rest.responses.LoadTableResponse;@@ -39,9 +39,9 @@ public class IcebergCreateTableEvent extends IcebergTableEvent {LoadTableResponse loadTableResponse) {super(icebergRequestContext, resourceIdentifier);this.createTableRequest =- IcebergRestUtils.cloneIcebergRESTObject(createTableRequest, CreateTableRequest.class);+ IcebergRESTUtils.cloneIcebergRESTObject(createTableRequest, CreateTableRequest.class);this.loadTableResponse =- IcebergRestUtils.cloneIcebergRESTObject(loadTableResponse, LoadTableResponse.class);+ IcebergRESTUtils.cloneIcebergRESTObject(loadTableResponse, LoadTableResponse.class);}@Overridediff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergCreateTableFailureEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergCreateTableFailureEvent.javaindex a9af05328a..21c8e2862e 100644--- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergCreateTableFailureEvent.java+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergCreateTableFailureEvent.java@@ -21,7 +21,7 @@ package org.apache.gravitino.listener.api.event;import org.apache.gravitino.NameIdentifier;import org.apache.gravitino.annotation.DeveloperApi;-import org.apache.gravitino.iceberg.service.IcebergRestUtils;+import org.apache.gravitino.iceberg.service.IcebergRESTUtils;import org.apache.iceberg.rest.requests.CreateTableRequest;/** Represent a failure event when creating Iceberg table failed. */@@ -36,7 +36,7 @@ public class IcebergCreateTableFailureEvent extends IcebergTableFailureEvent {Exception e) {super(icebergRequestContext, nameIdentifier, e);this.createTableRequest =- IcebergRestUtils.cloneIcebergRESTObject(createTableRequest, CreateTableRequest.class);+ IcebergRESTUtils.cloneIcebergRESTObject(createTableRequest, CreateTableRequest.class);}@Overridediff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergCreateViewEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergCreateViewEvent.javaindex 2720eeb4cc..5179452301 100644--- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergCreateViewEvent.java+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergCreateViewEvent.java@@ -21,7 +21,7 @@ package org.apache.gravitino.listener.api.event;import org.apache.gravitino.NameIdentifier;import org.apache.gravitino.annotation.DeveloperApi;-import org.apache.gravitino.iceberg.service.IcebergRestUtils;+import org.apache.gravitino.iceberg.service.IcebergRESTUtils;import org.apache.iceberg.rest.requests.CreateViewRequest;import org.apache.iceberg.rest.responses.LoadViewResponse;@@ -39,9 +39,9 @@ public class IcebergCreateViewEvent extends IcebergViewEvent {LoadViewResponse loadViewResponse) {super(icebergRequestContext, viewIdentifier);this.createViewRequest =- IcebergRestUtils.cloneIcebergRESTObject(createViewRequest, CreateViewRequest.class);+ IcebergRESTUtils.cloneIcebergRESTObject(createViewRequest, CreateViewRequest.class);this.loadViewResponse =- IcebergRestUtils.cloneIcebergRESTObject(loadViewResponse, LoadViewResponse.class);+ IcebergRESTUtils.cloneIcebergRESTObject(loadViewResponse, LoadViewResponse.class);}public CreateViewRequest createViewRequest() {diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergCreateViewFailureEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergCreateViewFailureEvent.javaindex f571723d81..232418527f 100644--- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergCreateViewFailureEvent.java+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergCreateViewFailureEvent.java@@ -21,7 +21,7 @@ package org.apache.gravitino.listener.api.event;import org.apache.gravitino.NameIdentifier;import org.apache.gravitino.annotation.DeveloperApi;-import org.apache.gravitino.iceberg.service.IcebergRestUtils;+import org.apache.gravitino.iceberg.service.IcebergRESTUtils;import org.apache.iceberg.rest.requests.CreateViewRequest;/** Represent a failure event when creating Iceberg view failed. */@@ -36,7 +36,7 @@ public class IcebergCreateViewFailureEvent extends IcebergViewFailureEvent {Exception e) {super(icebergRequestContext, viewIdentifier, e);this.createViewRequest =- IcebergRestUtils.cloneIcebergRESTObject(createViewRequest, CreateViewRequest.class);+ IcebergRESTUtils.cloneIcebergRESTObject(createViewRequest, CreateViewRequest.class);}public CreateViewRequest createViewRequest() {diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergLoadNamespaceEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergLoadNamespaceEvent.javaindex dbfb5b77f6..1f7fe3b499 100644--- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergLoadNamespaceEvent.java+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergLoadNamespaceEvent.java@@ -21,7 +21,7 @@ package org.apache.gravitino.listener.api.event;import org.apache.gravitino.NameIdentifier;import org.apache.gravitino.annotation.DeveloperApi;-import org.apache.gravitino.iceberg.service.IcebergRestUtils;+import org.apache.gravitino.iceberg.service.IcebergRESTUtils;import org.apache.iceberg.rest.responses.GetNamespaceResponse;/** Represent an event after loading Iceberg namespace successfully. */@@ -35,7 +35,7 @@ public class IcebergLoadNamespaceEvent extends IcebergNamespaceEvent {GetNamespaceResponse getNamespaceResponse) {super(icebergRequestContext, nameIdentifier);this.getNamespaceResponse =- IcebergRestUtils.cloneIcebergRESTObject(getNamespaceResponse, GetNamespaceResponse.class);+ IcebergRESTUtils.cloneIcebergRESTObject(getNamespaceResponse, GetNamespaceResponse.class);}public GetNamespaceResponse getNamespaceResponse() {diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergLoadTableEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergLoadTableEvent.javaindex cf52152cf8..000169856a 100644--- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergLoadTableEvent.java+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergLoadTableEvent.java@@ -21,7 +21,7 @@ package org.apache.gravitino.listener.api.event;import org.apache.gravitino.NameIdentifier;import org.apache.gravitino.annotation.DeveloperApi;-import org.apache.gravitino.iceberg.service.IcebergRestUtils;+import org.apache.gravitino.iceberg.service.IcebergRESTUtils;import org.apache.iceberg.rest.responses.LoadTableResponse;/** Represent an event after loading Iceberg table successfully. */@@ -35,7 +35,7 @@ public class IcebergLoadTableEvent extends IcebergTableEvent {LoadTableResponse loadTableResponse) {super(icebergRequestContext, resourceIdentifier);this.loadTableResponse =- IcebergRestUtils.cloneIcebergRESTObject(loadTableResponse, LoadTableResponse.class);+ IcebergRESTUtils.cloneIcebergRESTObject(loadTableResponse, LoadTableResponse.class);}@Overridediff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergLoadViewEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergLoadViewEvent.javaindex 2ebf25767a..0709e43d45 100644--- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergLoadViewEvent.java+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergLoadViewEvent.java@@ -21,7 +21,7 @@ package org.apache.gravitino.listener.api.event;import org.apache.gravitino.NameIdentifier;import org.apache.gravitino.annotation.DeveloperApi;-import org.apache.gravitino.iceberg.service.IcebergRestUtils;+import org.apache.gravitino.iceberg.service.IcebergRESTUtils;import org.apache.iceberg.rest.responses.LoadViewResponse;/** Represent an event after loading Iceberg view successfully. */@@ -35,7 +35,7 @@ public class IcebergLoadViewEvent extends IcebergViewEvent {LoadViewResponse loadViewResponse) {super(icebergRequestContext, viewIdentifier);this.loadViewResponse =- IcebergRestUtils.cloneIcebergRESTObject(loadViewResponse, LoadViewResponse.class);+ IcebergRESTUtils.cloneIcebergRESTObject(loadViewResponse, LoadViewResponse.class);}public LoadViewResponse loadViewResponse() {diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergRegisterTableEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergRegisterTableEvent.javaindex 87b875079e..d892036a58 100644--- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergRegisterTableEvent.java+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergRegisterTableEvent.java@@ -21,7 +21,7 @@ package org.apache.gravitino.listener.api.event;import org.apache.gravitino.NameIdentifier;import org.apache.gravitino.annotation.DeveloperApi;-import org.apache.gravitino.iceberg.service.IcebergRestUtils;+import org.apache.gravitino.iceberg.service.IcebergRESTUtils;import org.apache.iceberg.rest.requests.RegisterTableRequest;import org.apache.iceberg.rest.responses.LoadTableResponse;@@ -39,9 +39,9 @@ public class IcebergRegisterTableEvent extends IcebergTableEvent {LoadTableResponse loadTableResponse) {super(icebergRequestContext, resourceIdentifier);this.registerTableRequest =- IcebergRestUtils.cloneIcebergRESTObject(registerTableRequest, RegisterTableRequest.class);+ IcebergRESTUtils.cloneIcebergRESTObject(registerTableRequest, RegisterTableRequest.class);this.loadTableResponse =- IcebergRestUtils.cloneIcebergRESTObject(loadTableResponse, LoadTableResponse.class);+ IcebergRESTUtils.cloneIcebergRESTObject(loadTableResponse, LoadTableResponse.class);}public RegisterTableRequest registerTableRequest() {diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergRegisterTableFailureEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergRegisterTableFailureEvent.javaindex 49770a3ba8..afdbec54e0 100644--- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergRegisterTableFailureEvent.java+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergRegisterTableFailureEvent.java@@ -21,7 +21,7 @@ package org.apache.gravitino.listener.api.event;import org.apache.gravitino.NameIdentifier;import org.apache.gravitino.annotation.DeveloperApi;-import org.apache.gravitino.iceberg.service.IcebergRestUtils;+import org.apache.gravitino.iceberg.service.IcebergRESTUtils;import org.apache.iceberg.rest.requests.RegisterTableRequest;/** Represent a failure event when registering Iceberg table failed. */@@ -36,7 +36,7 @@ public class IcebergRegisterTableFailureEvent extends IcebergTableFailureEvent {Exception e) {super(icebergRequestContext, nameIdentifier, e);this.registerTableRequest =- IcebergRestUtils.cloneIcebergRESTObject(registerTableRequest, RegisterTableRequest.class);+ IcebergRESTUtils.cloneIcebergRESTObject(registerTableRequest, RegisterTableRequest.class);}public RegisterTableRequest registerTableRequest() {diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergRenameTableEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergRenameTableEvent.javaindex 94d3ad2abb..2f38b1477e 100644--- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergRenameTableEvent.java+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergRenameTableEvent.java@@ -21,7 +21,7 @@ package org.apache.gravitino.listener.api.event;import org.apache.gravitino.NameIdentifier;import org.apache.gravitino.annotation.DeveloperApi;-import org.apache.gravitino.iceberg.service.IcebergRestUtils;+import org.apache.gravitino.iceberg.service.IcebergRESTUtils;import org.apache.iceberg.rest.requests.RenameTableRequest;/** Represent an event after rename Iceberg table successfully. */@@ -35,7 +35,7 @@ public class IcebergRenameTableEvent extends IcebergTableEvent {RenameTableRequest renameTableRequest) {super(icebergRequestContext, resourceIdentifier);this.renameTableRequest =- IcebergRestUtils.cloneIcebergRESTObject(renameTableRequest, RenameTableRequest.class);+ IcebergRESTUtils.cloneIcebergRESTObject(renameTableRequest, RenameTableRequest.class);}public RenameTableRequest renameTableRequest() {diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergRenameViewEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergRenameViewEvent.javaindex 00a32200a2..530db1da86 100644--- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergRenameViewEvent.java+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergRenameViewEvent.java@@ -21,7 +21,7 @@ package org.apache.gravitino.listener.api.event;import org.apache.gravitino.NameIdentifier;import org.apache.gravitino.annotation.DeveloperApi;-import org.apache.gravitino.iceberg.service.IcebergRestUtils;+import org.apache.gravitino.iceberg.service.IcebergRESTUtils;import org.apache.iceberg.rest.requests.RenameTableRequest;/** Represent an event after rename Iceberg view successfully. */@@ -35,7 +35,7 @@ public class IcebergRenameViewEvent extends IcebergViewEvent {RenameTableRequest renameViewRequest) {super(icebergRequestContext, viewIdentifier);this.renameViewRequest =- IcebergRestUtils.cloneIcebergRESTObject(renameViewRequest, RenameTableRequest.class);+ IcebergRESTUtils.cloneIcebergRESTObject(renameViewRequest, RenameTableRequest.class);}public RenameTableRequest renameViewRequest() {diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergReplaceViewEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergReplaceViewEvent.javaindex 7deba131e0..b894795eba 100644--- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergReplaceViewEvent.java+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergReplaceViewEvent.java@@ -21,7 +21,7 @@ package org.apache.gravitino.listener.api.event;import org.apache.gravitino.NameIdentifier;import org.apache.gravitino.annotation.DeveloperApi;-import org.apache.gravitino.iceberg.service.IcebergRestUtils;+import org.apache.gravitino.iceberg.service.IcebergRESTUtils;import org.apache.iceberg.rest.requests.UpdateTableRequest;import org.apache.iceberg.rest.responses.LoadViewResponse;@@ -39,9 +39,9 @@ public class IcebergReplaceViewEvent extends IcebergViewEvent {LoadViewResponse loadViewResponse) {super(icebergRequestContext, viewIdentifier);this.replaceViewRequest =- IcebergRestUtils.cloneIcebergRESTObject(replaceViewRequest, UpdateTableRequest.class);+ IcebergRESTUtils.cloneIcebergRESTObject(replaceViewRequest, UpdateTableRequest.class);this.loadViewResponse =- IcebergRestUtils.cloneIcebergRESTObject(loadViewResponse, LoadViewResponse.class);+ IcebergRESTUtils.cloneIcebergRESTObject(loadViewResponse, LoadViewResponse.class);}public UpdateTableRequest renameViewRequest() {diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergReplaceViewFailureEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergReplaceViewFailureEvent.javaindex 02e69e0cb0..336fb8760c 100644--- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergReplaceViewFailureEvent.java+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergReplaceViewFailureEvent.java@@ -21,7 +21,7 @@ package org.apache.gravitino.listener.api.event;import org.apache.gravitino.NameIdentifier;import org.apache.gravitino.annotation.DeveloperApi;-import org.apache.gravitino.iceberg.service.IcebergRestUtils;+import org.apache.gravitino.iceberg.service.IcebergRESTUtils;import org.apache.iceberg.rest.requests.UpdateTableRequest;/** Represent a failure event when updating Iceberg view failed. */@@ -36,7 +36,7 @@ public class IcebergReplaceViewFailureEvent extends IcebergViewFailureEvent {Exception e) {super(icebergRequestContext, viewIdentifier, e);this.replaceViewRequest =- IcebergRestUtils.cloneIcebergRESTObject(replaceViewRequest, UpdateTableRequest.class);+ IcebergRESTUtils.cloneIcebergRESTObject(replaceViewRequest, UpdateTableRequest.class);}public UpdateTableRequest replaceViewRequest() {diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergRequestContext.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergRequestContext.javaindex 9c84d91ab3..c6cf52661c 100644--- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergRequestContext.java+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergRequestContext.java@@ -21,7 +21,7 @@ package org.apache.gravitino.listener.api.event;import java.util.Map;import javax.servlet.http.HttpServletRequest;-import org.apache.gravitino.iceberg.service.IcebergRestUtils;+import org.apache.gravitino.iceberg.service.IcebergRESTUtils;import org.apache.gravitino.utils.PrincipalUtils;/** The general request context information for Iceberg REST operations. */@@ -59,7 +59,7 @@ public class IcebergRequestContext {HttpServletRequest httpRequest, String catalogName, boolean requestCredentialVending) {this.httpServletRequest = httpRequest;this.remoteHostName = httpRequest.getRemoteHost();- this.httpHeaders = IcebergRestUtils.getHttpHeaders(httpRequest);+ this.httpHeaders = IcebergRESTUtils.getHttpHeaders(httpRequest);this.catalogName = catalogName;this.userName = PrincipalUtils.getCurrentUserName();this.requestCredentialVending = requestCredentialVending;diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergUpdateNamespaceEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergUpdateNamespaceEvent.javaindex 5d6ab88b6d..dfd66e2ca5 100644--- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergUpdateNamespaceEvent.java+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergUpdateNamespaceEvent.java@@ -21,7 +21,7 @@ package org.apache.gravitino.listener.api.event;import org.apache.gravitino.NameIdentifier;import org.apache.gravitino.annotation.DeveloperApi;-import org.apache.gravitino.iceberg.service.IcebergRestUtils;+import org.apache.gravitino.iceberg.service.IcebergRESTUtils;import org.apache.iceberg.rest.requests.UpdateNamespacePropertiesRequest;import org.apache.iceberg.rest.responses.UpdateNamespacePropertiesResponse;@@ -39,10 +39,10 @@ public class IcebergUpdateNamespaceEvent extends IcebergNamespaceEvent {UpdateNamespacePropertiesResponse updateNamespacePropertiesResponse) {super(icebergRequestContext, nameIdentifier);this.updateNamespacePropertiesRequest =- IcebergRestUtils.cloneIcebergRESTObject(+ IcebergRESTUtils.cloneIcebergRESTObject(updateNamespacePropertiesRequest, UpdateNamespacePropertiesRequest.class);this.updateNamespacePropertiesResponse =- IcebergRestUtils.cloneIcebergRESTObject(+ IcebergRESTUtils.cloneIcebergRESTObject(updateNamespacePropertiesResponse, UpdateNamespacePropertiesResponse.class);}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergUpdateNamespaceFailureEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergUpdateNamespaceFailureEvent.javaindex 82e968667b..258a5b029a 100644--- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergUpdateNamespaceFailureEvent.java+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergUpdateNamespaceFailureEvent.java@@ -21,7 +21,7 @@ package org.apache.gravitino.listener.api.event;import org.apache.gravitino.NameIdentifier;import org.apache.gravitino.annotation.DeveloperApi;-import org.apache.gravitino.iceberg.service.IcebergRestUtils;+import org.apache.gravitino.iceberg.service.IcebergRESTUtils;import org.apache.iceberg.rest.requests.UpdateNamespacePropertiesRequest;/** Represent a failure event when updating Iceberg namespace failed. */@@ -36,7 +36,7 @@ public class IcebergUpdateNamespaceFailureEvent extends IcebergNamespaceFailureEException e) {super(icebergRequestContext, nameIdentifier, e);this.updateNamespacePropertiesRequest =- IcebergRestUtils.cloneIcebergRESTObject(+ IcebergRESTUtils.cloneIcebergRESTObject(updateNamespacePropertiesRequest, UpdateNamespacePropertiesRequest.class);}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergUpdateTableEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergUpdateTableEvent.javaindex 7eae3e19bc..159613c757 100644--- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergUpdateTableEvent.java+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergUpdateTableEvent.java@@ -21,7 +21,7 @@ package org.apache.gravitino.listener.api.event;import org.apache.gravitino.NameIdentifier;import org.apache.gravitino.annotation.DeveloperApi;-import org.apache.gravitino.iceberg.service.IcebergRestUtils;+import org.apache.gravitino.iceberg.service.IcebergRESTUtils;import org.apache.iceberg.rest.requests.UpdateTableRequest;import org.apache.iceberg.rest.responses.LoadTableResponse;@@ -39,9 +39,9 @@ public class IcebergUpdateTableEvent extends IcebergTableEvent {LoadTableResponse loadTableResponse) {super(icebergRequestContext, resourceIdentifier);this.updateTableRequest =- IcebergRestUtils.cloneIcebergRESTObject(updateTableRequest, UpdateTableRequest.class);+ IcebergRESTUtils.cloneIcebergRESTObject(updateTableRequest, UpdateTableRequest.class);this.loadTableResponse =- IcebergRestUtils.cloneIcebergRESTObject(loadTableResponse, LoadTableResponse.class);+ IcebergRESTUtils.cloneIcebergRESTObject(loadTableResponse, LoadTableResponse.class);}public UpdateTableRequest createTableRequest() {diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergUpdateTableFailureEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergUpdateTableFailureEvent.javaindex 94f6929814..21bc16cb92 100644--- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergUpdateTableFailureEvent.java+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergUpdateTableFailureEvent.java@@ -21,7 +21,7 @@ package org.apache.gravitino.listener.api.event;import org.apache.gravitino.NameIdentifier;import org.apache.gravitino.annotation.DeveloperApi;-import org.apache.gravitino.iceberg.service.IcebergRestUtils;+import org.apache.gravitino.iceberg.service.IcebergRESTUtils;import org.apache.iceberg.rest.requests.UpdateTableRequest;/** Represent a failure event when updating Iceberg table failed. */@@ -36,7 +36,7 @@ public class IcebergUpdateTableFailureEvent extends IcebergTableFailureEvent {Exception e) {super(icebergRequestContext, nameIdentifier, e);this.updateTableRequest =- IcebergRestUtils.cloneIcebergRESTObject(updateTableRequest, UpdateTableRequest.class);+ IcebergRESTUtils.cloneIcebergRESTObject(updateTableRequest, UpdateTableRequest.class);}public UpdateTableRequest updateTableRequest() {diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/server/authorization/annotations/IcebergAuthorizationMetadata.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/server/authorization/annotations/IcebergAuthorizationMetadata.javanew file mode 100644index 0000000000..85169eef92--- /dev/null+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/server/authorization/annotations/IcebergAuthorizationMetadata.java@@ -0,0 +1,41 @@+/*+ * 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.server.authorization.annotations;++import java.lang.annotation.ElementType;+import java.lang.annotation.Retention;+import java.lang.annotation.RetentionPolicy;+import java.lang.annotation.Target;++/** This annotation identify which parameters in the request are to be used for authorization. */+@Target({ElementType.PARAMETER, ElementType.FIELD})+@Retention(RetentionPolicy.RUNTIME)+public @interface IcebergAuthorizationMetadata {+ enum RequestType {+ LOAD_TABLE,+ RENAME_TABLE,+ }+ /**+ * The type of the parameter to be used for authorization.+ *+ * @return the type of the parameter to be used for authorization.+ */+ RequestType type();+}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/server/web/filter/BaseInterceptionService.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/server/web/filter/BaseInterceptionService.javanew file mode 100644index 0000000000..dbed2bff25--- /dev/null+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/server/web/filter/BaseInterceptionService.java@@ -0,0 +1,51 @@+/*+ * 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.server.web.filter;++import java.lang.reflect.Constructor;+import java.util.Collections;+import java.util.HashSet;+import java.util.List;+import java.util.Set;+import org.aopalliance.intercept.ConstructorInterceptor;+import org.glassfish.hk2.api.Descriptor;+import org.glassfish.hk2.api.Filter;+import org.glassfish.hk2.api.InterceptionService;++/** BaseInterceptionService defines some common logic for InterceptionService. */+public abstract class BaseInterceptionService implements InterceptionService {++ @Override+ public List<ConstructorInterceptor> getConstructorInterceptors(Constructor<?> constructor) {+ return Collections.emptyList();+ }++ public static class ClassListFilter implements Filter {+ private final Set<String> targetClasses;++ public ClassListFilter(Set<String> targetClasses) {+ this.targetClasses = new HashSet<>(targetClasses);+ }++ @Override+ public boolean matches(Descriptor descriptor) {+ String implementation = descriptor.getImplementation();+ return targetClasses.contains(implementation);+ }+ }+}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/server/web/filter/BaseMetadataAuthorizationMethodInterceptor.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/server/web/filter/BaseMetadataAuthorizationMethodInterceptor.javanew file mode 100644index 0000000000..d24e950391--- /dev/null+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/server/web/filter/BaseMetadataAuthorizationMethodInterceptor.java@@ -0,0 +1,114 @@+/*+ * 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.server.web.filter;++import java.lang.reflect.Method;+import java.lang.reflect.Parameter;+import java.util.Map;+import org.aopalliance.intercept.MethodInterceptor;+import org.aopalliance.intercept.MethodInvocation;+import org.apache.gravitino.Entity;+import org.apache.gravitino.MetadataObject;+import org.apache.gravitino.NameIdentifier;+import org.apache.gravitino.authorization.AuthorizationRequestContext;+import org.apache.gravitino.iceberg.service.IcebergExceptionMapper;+import org.apache.gravitino.server.authorization.annotations.AuthorizationExpression;+import org.apache.gravitino.server.authorization.expression.AuthorizationExpressionEvaluator;+import org.apache.gravitino.utils.PrincipalUtils;+import org.apache.iceberg.exceptions.ForbiddenException;+import org.slf4j.Logger;+import org.slf4j.LoggerFactory;++/**+ * Through dynamic proxy, obtain the annotations on the method and parameter list to perform+ * metadata authorization.+ */+@SuppressWarnings("FormatStringAnnotation")+public abstract class BaseMetadataAuthorizationMethodInterceptor implements MethodInterceptor {+ private static final Logger LOG =+ LoggerFactory.getLogger(BaseMetadataAuthorizationMethodInterceptor.class);++ protected abstract Map<Entity.EntityType, NameIdentifier> extractNameIdentifierFromParameters(+ Parameter[] parameters, Object[] args);++ protected boolean isExceptionPropagate(Exception e) {+ return false;+ }++ /**+ * Determine whether authorization is required and the rules via the authorization annotation ,+ * and obtain the metadata ID that requires authorization via the authorization annotation.+ *+ * @param methodInvocation methodInvocation with the Method object+ * @return the return result of the original method.+ * @throws Throwable throw an exception when authorization fails.+ */+ @Override+ public Object invoke(MethodInvocation methodInvocation) throws Throwable {+ try {+ Method method = methodInvocation.getMethod();+ Parameter[] parameters = method.getParameters();+ AuthorizationExpression expressionAnnotation =+ method.getAnnotation(AuthorizationExpression.class);+ if (expressionAnnotation != null) {+ String expression = expressionAnnotation.expression();+ Object[] args = methodInvocation.getArguments();+ Map<Entity.EntityType, NameIdentifier> metadataContext =+ extractNameIdentifierFromParameters(parameters, args);+ AuthorizationExpressionEvaluator authorizationExpressionEvaluator =+ new AuthorizationExpressionEvaluator(expression);+ boolean authorizeResult =+ authorizationExpressionEvaluator.evaluate(+ metadataContext, new AuthorizationRequestContext());+ if (!authorizeResult) {+ MetadataObject.Type type = expressionAnnotation.accessMetadataType();+ NameIdentifier accessMetadataName =+ metadataContext.get(Entity.EntityType.valueOf(type.name()));+ String currentUser = PrincipalUtils.getCurrentUserName();+ String methodName = method.getName();+ String notAuthzMessage =+ String.format(+ "User '%s' is not authorized to perform operation '%s' on metadata '%s' with expression '%s'",+ currentUser, methodName, accessMetadataName, expression);+ LOG.info(notAuthzMessage);+ return IcebergExceptionMapper.toRESTResponse(new ForbiddenException(notAuthzMessage));+ }+ }+ } catch (Exception ex) {+ if (isExceptionPropagate(ex)) {+ return IcebergExceptionMapper.toRESTResponse(ex);+ }+ String currentUser = PrincipalUtils.getCurrentUserName();+ String methodName = methodInvocation.getMethod().getName();++ String errorMessage =+ String.format(+ "Authorization failed due to system internal error, User: '%s', Operation: '%s'",+ currentUser, methodName);+ LOG.info(errorMessage, ex);+ return IcebergExceptionMapper.toRESTResponse(new RuntimeException(errorMessage, ex));+ }+ try {+ return methodInvocation.proceed();+ } catch (Throwable e) {+ return IcebergExceptionMapper.toRESTResponse(e);+ }+ }+}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/server/web/filter/IcebergMetadataAuthorizationMethodInterceptor.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/server/web/filter/IcebergMetadataAuthorizationMethodInterceptor.javanew file mode 100644index 0000000000..4092e339b7--- /dev/null+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/server/web/filter/IcebergMetadataAuthorizationMethodInterceptor.java@@ -0,0 +1,133 @@+/*+ * 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.server.web.filter;++import java.lang.reflect.Parameter;+import java.util.HashMap;+import java.util.Map;+import org.apache.gravitino.Entity;+import org.apache.gravitino.Entity.EntityType;+import org.apache.gravitino.NameIdentifier;+import org.apache.gravitino.iceberg.service.IcebergRESTUtils;+import org.apache.gravitino.iceberg.service.authorization.IcebergRESTServerContext;+import org.apache.gravitino.server.authorization.annotations.AuthorizationMetadata;+import org.apache.gravitino.server.authorization.annotations.IcebergAuthorizationMetadata;+import org.apache.gravitino.utils.NameIdentifierUtil;+import org.apache.iceberg.MetadataTableType;+import org.apache.iceberg.catalog.Namespace;+import org.apache.iceberg.exceptions.NoSuchTableException;+import org.apache.iceberg.rest.RESTUtil;+import org.apache.iceberg.rest.requests.RenameTableRequest;++/**+ * Through dynamic proxy, obtain the annotations on the method and parameter list to perform+ * metadata authorization.+ */+public class IcebergMetadataAuthorizationMethodInterceptor+ extends BaseMetadataAuthorizationMethodInterceptor {+ private final String metalakeName = IcebergRESTServerContext.getInstance().metalakeName();++ @Override+ protected Map<Entity.EntityType, NameIdentifier> extractNameIdentifierFromParameters(+ Parameter[] parameters, Object[] args) {+ Map<Entity.EntityType, NameIdentifier> nameIdentifierMap = new HashMap<>();+ nameIdentifierMap.put(Entity.EntityType.METALAKE, NameIdentifierUtil.ofMetalake(metalakeName));+ // get catalog & namespace from params+ String catalog = null;+ String schema = null;+ Namespace rawNamespace = null;+ for (int i = 0; i < parameters.length; i++) {+ Parameter parameter = parameters[i];+ AuthorizationMetadata authorizeResource =+ parameter.getAnnotation(AuthorizationMetadata.class);+ IcebergAuthorizationMetadata icebergAuthorizeResource =+ parameter.getAnnotation(IcebergAuthorizationMetadata.class);+ if (icebergAuthorizeResource != null) {+ switch (icebergAuthorizeResource.type()) {+ case RENAME_TABLE:+ RenameTableRequest renameTableRequest = (RenameTableRequest) args[i];+ schema = renameTableRequest.source().namespace().level(0);+ nameIdentifierMap.put(+ Entity.EntityType.SCHEMA,+ NameIdentifierUtil.ofSchema(metalakeName, catalog, schema));+ nameIdentifierMap.put(+ Entity.EntityType.TABLE,+ NameIdentifierUtil.ofTable(+ metalakeName, catalog, schema, renameTableRequest.source().name()));+ break;+ case LOAD_TABLE:+ String tableName = String.valueOf(args[i]);+ if (isMetadataTable(tableName, rawNamespace)) {+ throw new NoSuchTableException("Table %s not found", tableName);+ }+ nameIdentifierMap.put(+ Entity.EntityType.TABLE,+ NameIdentifierUtil.ofTable(metalakeName, catalog, schema, tableName));+ break;+ default:+ break;+ }+ }+ if (authorizeResource == null) {+ continue;+ }+ Entity.EntityType type = authorizeResource.type();+ String value = String.valueOf(args[i]);+ switch (type) {+ case CATALOG:+ catalog = IcebergRESTUtils.getCatalogName(value);+ nameIdentifierMap.put(+ Entity.EntityType.CATALOG, NameIdentifierUtil.ofCatalog(metalakeName, catalog));+ break;+ case SCHEMA:+ rawNamespace = RESTUtil.decodeNamespace(value);+ schema = rawNamespace.level(rawNamespace.length() - 1);+ nameIdentifierMap.put(+ Entity.EntityType.SCHEMA, NameIdentifierUtil.ofSchema(metalakeName, catalog, schema));+ break;+ case TABLE:+ nameIdentifierMap.put(+ EntityType.TABLE, NameIdentifierUtil.ofTable(metalakeName, catalog, schema, value));+ break;+ default:+ break;+ }+ }+ return nameIdentifierMap;+ }++ @Override+ protected boolean isExceptionPropagate(Exception e) {+ return e.getClass().getName().startsWith("org.apache.iceberg.exceptions");+ }++ // Check if the table is a metadata table, for metadata table, the namespace is `catalog.db.table`+ private boolean isMetadataTable(String tableName, Namespace namespace) {+ MetadataTableType metadataTableType = MetadataTableType.from(tableName);+ if (metadataTableType == null) {+ return false;+ }++ if (namespace.levels().length > 1) {+ return true;+ }+ return false;+ }+}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/server/web/filter/IcebergRESTAuthInterceptionService.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/server/web/filter/IcebergRESTAuthInterceptionService.javanew file mode 100644index 0000000000..1906d36cb5--- /dev/null+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/server/web/filter/IcebergRESTAuthInterceptionService.java@@ -0,0 +1,48 @@+/*+ * 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.server.web.filter;++import com.google.common.collect.ImmutableList;+import com.google.common.collect.ImmutableSet;+import java.lang.reflect.Method;+import java.util.List;+import org.aopalliance.intercept.MethodInterceptor;+import org.apache.gravitino.iceberg.service.rest.IcebergTableOperations;+import org.apache.gravitino.iceberg.service.rest.IcebergTableRenameOperations;+import org.glassfish.hk2.api.Filter;++/**+ * IcebergRESTAuthInterceptionService defines a method interceptor for REST interfaces to create+ * dynamic proxies. It implements metadata authorization when invoking REST API methods. It needs to+ * be registered in the hk2 bean container when the gravitino server starts.+ */+public class IcebergRESTAuthInterceptionService extends BaseInterceptionService {++ @Override+ public Filter getDescriptorFilter() {+ return new ClassListFilter(+ ImmutableSet.of(+ IcebergTableOperations.class.getName(), IcebergTableRenameOperations.class.getName()));+ }++ @Override+ public List<MethodInterceptor> getMethodInterceptors(Method method) {+ return ImmutableList.of(new IcebergMetadataAuthorizationMethodInterceptor());+ }+}diff --git a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/integration/test/IcebergAuthorizationIT.java b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/integration/test/IcebergAuthorizationIT.javanew file mode 100644index 0000000000..b96f56ef33--- /dev/null+++ b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/integration/test/IcebergAuthorizationIT.java@@ -0,0 +1,304 @@+/*+ * 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.iceberg.integration.test;++import com.google.common.collect.ImmutableList;+import com.google.errorprone.annotations.FormatMethod;+import java.io.IOException;+import java.util.Arrays;+import java.util.HashMap;+import java.util.List;+import java.util.Map;+import java.util.Optional;+import java.util.Set;+import java.util.stream.Collectors;+import java.util.stream.IntStream;+import org.apache.gravitino.Catalog;+import org.apache.gravitino.Configs;+import org.apache.gravitino.MetadataObject;+import org.apache.gravitino.MetadataObjects;+import org.apache.gravitino.NameIdentifier;+import org.apache.gravitino.authorization.Owner;+import org.apache.gravitino.catalog.lakehouse.iceberg.IcebergConstants;+import org.apache.gravitino.client.GravitinoMetalake;+import org.apache.gravitino.exceptions.NoSuchUserException;+import org.apache.gravitino.integration.test.container.ContainerSuite;+import org.apache.gravitino.integration.test.util.BaseIT;+import org.apache.gravitino.integration.test.util.TestDatabaseName;+import org.apache.gravitino.rel.Column;+import org.apache.gravitino.rel.types.Types;+import org.apache.gravitino.server.authorization.jcasbin.JcasbinAuthorizer;+import org.apache.iceberg.CatalogProperties;+import org.apache.spark.SparkConf;+import org.apache.spark.sql.Row;+import org.apache.spark.sql.SparkSession;+import org.junit.jupiter.api.AfterAll;+import org.junit.jupiter.api.Assertions;+import org.junit.jupiter.api.BeforeAll;+import org.slf4j.Logger;+import org.slf4j.LoggerFactory;+import org.testcontainers.shaded.com.google.common.collect.ImmutableMap;++/**+ * This IT starts a Gravitino server with Iceberg REST server in the auxiliary mode, we could create+ * metalake, catalogs in Gravitino server and do the authorization with Iceberg REST server. There+ * are two users: SUPER_USER is the owner of metalake, has all privileges while NORMAL_USER is the+ * user for Spark SQL, doesn't have privileges by default. You could use Spark SQL to try to do the+ * operation and use Gravitino client to grant privilege or check the test result.+ */+public class IcebergAuthorizationIT extends BaseIT {++ private static final Logger LOG = LoggerFactory.getLogger(IcebergAuthorizationIT.class);+ private static final String GRAVITINO_ICEBERG_REST_PREFIX = "gravitino.iceberg-rest.";+ protected static final String METALAKE_NAME = "test_metalake";+ protected static final String GRAVITINO_CATALOG_NAME = "iceberg";+ protected static final String SPARK_CATALOG_NAME = "rest";++ protected static final String SUPER_USER = "super";+ protected static final String NORMAL_USER = "normal";++ protected Catalog catalogClientWithAllPrivilege;+ protected GravitinoMetalake metalakeClientWithAllPrivilege;++ private static ContainerSuite containerSuite = ContainerSuite.getInstance();+ private SparkSession sparkSession;++ @BeforeAll+ @Override+ public void startIntegrationTest() throws Exception {+ containerSuite.startPostgreSQLContainer(TestDatabaseName.PG_ICEBERG_AUTHZ_IT);+ startGravitinoServerWithIcebergREST();+ initMetalakeAndCatalog();+ initSparkEnv();+ }++ @AfterAll+ @Override+ public void stopIntegrationTest() throws IOException, InterruptedException {+ sparkSession.close();+ client.dropMetalake(METALAKE_NAME, true);++ try {+ closer.close();+ } catch (Exception e) {+ LOG.error("Exception in closing CloseableGroup", e);+ }+ super.stopIntegrationTest();+ }++ private void initMetalakeAndCatalog() {+ this.metalakeClientWithAllPrivilege = client.createMetalake(METALAKE_NAME, "", new HashMap<>());+ Optional<Owner> owner =+ metalakeClientWithAllPrivilege.getOwner(+ MetadataObjects.of(Arrays.asList(METALAKE_NAME), MetadataObject.Type.METALAKE));+ Assertions.assertTrue(owner.isPresent());+ Assertions.assertEquals(SUPER_USER, owner.get().name());++ try {+ metalakeClientWithAllPrivilege.getUser(NORMAL_USER);+ } catch (NoSuchUserException e) {+ metalakeClientWithAllPrivilege.addUser(NORMAL_USER);+ }++ catalogClientWithAllPrivilege =+ metalakeClientWithAllPrivilege.createCatalog(+ GRAVITINO_CATALOG_NAME,+ Catalog.Type.RELATIONAL,+ "lakehouse-iceberg",+ "comment",+ ImmutableMap.of(+ IcebergConstants.URI,+ getPGUri(),+ IcebergConstants.CATALOG_BACKEND,+ "jdbc",+ IcebergConstants.GRAVITINO_JDBC_DRIVER,+ "org.postgresql.Driver",+ IcebergConstants.GRAVITINO_JDBC_USER,+ getPGUser(),+ IcebergConstants.GRAVITINO_JDBC_PASSWORD,+ getPGPassword(),+ "gravitino.bypass.jdbc.schema-version",+ "v1",+ IcebergConstants.ICEBERG_JDBC_INITIALIZE,+ "true",+ IcebergConstants.WAREHOUSE,+ "file:///tmp/"));+ }++ private void startGravitinoServerWithIcebergREST() throws Exception {+ ignoreAuxRestService = false;+ // Enable authorization+ customConfigs.putAll(+ ImmutableMap.of(+ "gravitino.authorization.serviceAdmins",+ SUPER_USER,+ "gravitino.authenticators",+ "simple",+ // BaseIT will use SimpleAuthUserName to create Gravitino client+ "SimpleAuthUserName",+ SUPER_USER,+ Configs.ENABLE_AUTHORIZATION.getKey(),+ "true",+ Configs.AUTHORIZATION_IMPL.getKey(),+ JcasbinAuthorizer.class.getCanonicalName(),+ Configs.CACHE_ENABLED.getKey(),+ "true"));+ // add dynamic config provider configs+ customConfigs.putAll(+ ImmutableMap.of(+ GRAVITINO_ICEBERG_REST_PREFIX + IcebergConstants.ICEBERG_REST_CATALOG_CONFIG_PROVIDER,+ IcebergConstants.DYNAMIC_ICEBERG_CATALOG_CONFIG_PROVIDER_NAME,+ GRAVITINO_ICEBERG_REST_PREFIX + IcebergConstants.GRAVITINO_METALAKE,+ METALAKE_NAME,+ GRAVITINO_ICEBERG_REST_PREFIX+ + IcebergConstants.ICEBERG_REST_DEFAULT_DYNAMIC_CATALOG_NAME,+ GRAVITINO_CATALOG_NAME,+ GRAVITINO_ICEBERG_REST_PREFIX + IcebergConstants.GRAVITINO_SIMPLE_USERNAME,+ SUPER_USER));+ super.startIntegrationTest();+ }++ void revokeUserRoles() {+ List<String> roles = metalakeClientWithAllPrivilege.getUser(NORMAL_USER).roles();+ if (roles.size() > 0) {+ metalakeClientWithAllPrivilege.revokeRolesFromUser(roles, NORMAL_USER);+ }+ roles = metalakeClientWithAllPrivilege.getUser(NORMAL_USER).roles();+ Assertions.assertEquals(0, roles.size());+ }++ void resetMetalakeAndCatalogOwner() {+ metalakeClientWithAllPrivilege.setOwner(+ MetadataObjects.of(Arrays.asList(METALAKE_NAME), MetadataObject.Type.METALAKE),+ SUPER_USER,+ Owner.Type.USER);+ MetadataObject catalogObject =+ MetadataObjects.of(Arrays.asList(GRAVITINO_CATALOG_NAME), MetadataObject.Type.CATALOG);+ metalakeClientWithAllPrivilege.setOwner(catalogObject, SUPER_USER, Owner.Type.USER);+ }++ void createTable(String schemaName, String tableName) {+ Column col1 = Column.of("col_1", Types.IntegerType.get(), "col_1_comment");+ catalogClientWithAllPrivilege+ .asTableCatalog()+ .createTable(+ NameIdentifier.of(schemaName, tableName),+ new Column[] {col1},+ "table_comment",+ new HashMap<>());+ boolean exists =+ catalogClientWithAllPrivilege+ .asTableCatalog()+ .tableExists(NameIdentifier.of(schemaName, tableName));+ Assertions.assertTrue(exists);+ }++ private void initSparkEnv() {+ String icebergRESTUri = getIcebergRestServiceUri();+ LOG.info("Iceberg REST uri: {}", icebergRESTUri);+ SparkConf sparkConf =+ new SparkConf()+ .set(+ "spark.sql.extensions",+ "org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions")+ .set("spark.sql.catalog.rest", "org.apache.iceberg.spark.SparkCatalog")+ .set("spark.sql.catalog.rest.type", "rest")+ .set("spark.sql.catalog.rest.uri", icebergRESTUri)+ // disable spark side table cache to check the privilege in each operation+ .set("spark.sql.catalog.rest." + CatalogProperties.CACHE_ENABLED, "false")+ .set("spark.sql.catalog.rest.rest.auth.type", "basic")+ .set("spark.sql.catalog.rest.rest.auth.basic.username", NORMAL_USER)+ .set("spark.sql.catalog.rest.rest.auth.basic.password", "mock")+ // drop Iceberg table purge may hang in spark local mode+ .set("spark.locality.wait.node", "0");++ sparkSession = SparkSession.builder().master("local[1]").config(sparkConf).getOrCreate();+ }++ private String getPGUri() {+ return containerSuite.getPostgreSQLContainer().getJdbcUrl(TestDatabaseName.PG_ICEBERG_AUTHZ_IT);+ }++ private String getPGUser() {+ return containerSuite.getPostgreSQLContainer().getUsername();+ }++ private String getPGPassword() {+ return containerSuite.getPostgreSQLContainer().getPassword();+ }++ protected Map<String, String> getTableInfo(String tableName) {+ return convertToStringMap(sql("desc table extended %s", tableName));+ }++ protected Set<String> listTableNames(String database) {+ return convertToStringSet(sql("SHOW TABLES in %s", database), 1);+ }++ protected List<Object[]> sql2(String query) {+ List<Row> rows = sparkSession.sql(query).collectAsList();+ if (rows.isEmpty()) {+ return ImmutableList.of();+ }+ return rowsToJava(rows);+ }++ @FormatMethod+ protected List<Object[]> sql(String query, Object... args) {+ return sql2(String.format(query, args));+ }++ private static Set<String> convertToStringSet(List<Object[]> objects, int index) {+ return objects.stream().map(row -> String.valueOf(row[index])).collect(Collectors.toSet());+ }++ private List<Object[]> rowsToJava(List<Row> rows) {+ return rows.stream().map(this::toJava).collect(Collectors.toList());+ }++ private Object[] toJava(Row row) {+ return IntStream.range(0, row.size())+ .mapToObj(+ pos -> {+ if (row.isNullAt(pos)) {+ return null;+ }+ Object value = row.get(pos);+ if (value instanceof Row) {+ return toJava((Row) value);+ } else if (value instanceof scala.collection.Seq) {+ return row.getList(pos);+ } else if (value instanceof scala.collection.Map) {+ return row.getJavaMap(pos);+ }+ return value;+ })+ .toArray(Object[]::new);+ }++ private static Map<String, String> convertToStringMap(List<Object[]> objects) {+ return objects.stream()+ .collect(+ Collectors.toMap(+ row -> String.valueOf(row[0]),+ row -> String.valueOf(row[1]),+ (oldValue, newValue) -> oldValue));+ }+}diff --git a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/integration/test/IcebergNamespaceAuthorizationIT.java b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/integration/test/IcebergNamespaceAuthorizationIT.javanew file mode 100644index 0000000000..e8bc0dfbba--- /dev/null+++ b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/integration/test/IcebergNamespaceAuthorizationIT.java@@ -0,0 +1,91 @@+/*+ * 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.iceberg.integration.test;++import com.google.common.collect.ImmutableList;+import java.util.ArrayList;+import java.util.Arrays;+import java.util.HashMap;+import java.util.List;+import java.util.Optional;+import java.util.UUID;+import org.apache.gravitino.MetadataObject;+import org.apache.gravitino.MetadataObjects;+import org.apache.gravitino.authorization.Owner;+import org.apache.gravitino.authorization.Privileges;+import org.apache.gravitino.authorization.SecurableObject;+import org.apache.gravitino.authorization.SecurableObjects;+import org.junit.jupiter.api.Assertions;+import org.junit.jupiter.api.BeforeAll;+import org.junit.jupiter.api.BeforeEach;+import org.junit.jupiter.api.Tag;+import org.junit.jupiter.api.Test;++@Tag("gravitino-docker-test")+public class IcebergNamespaceAuthorizationIT extends IcebergAuthorizationIT {++ @BeforeAll+ public void startIntegrationTest() throws Exception {+ super.startIntegrationTest();+ }++ @BeforeEach+ void revokePrivilege() {+ revokeUserRoles();+ resetMetalakeAndCatalogOwner();+ grantUseCatalogRole(GRAVITINO_CATALOG_NAME);+ sql("USE rest;");+ }++ @Test+ void testCreateSchemaWithOwner() {+ String namespace = "ns_owner";+ sql("CREATE DATABASE %s", namespace);+ Optional<Owner> owner =+ metalakeClientWithAllPrivilege.getOwner(+ MetadataObjects.of(+ Arrays.asList(GRAVITINO_CATALOG_NAME, namespace), MetadataObject.Type.SCHEMA));+ Assertions.assertTrue(owner.isPresent());+ Assertions.assertEquals(NORMAL_USER, owner.get().name());++ // test that the owner has privileges to create a table on the schema+ String tableName = "table_owner";+ sql("USE %s", namespace);+ sql("CREATE TABLE %s(a int)", tableName);+ sql("DESC TABLE %s", tableName);+ owner =+ metalakeClientWithAllPrivilege.getOwner(+ MetadataObjects.of(+ Arrays.asList(GRAVITINO_CATALOG_NAME, namespace, tableName),+ MetadataObject.Type.TABLE));+ Assertions.assertTrue(owner.isPresent());+ Assertions.assertEquals(NORMAL_USER, owner.get().name());+ }++ private void grantUseCatalogRole(String catalogName) {+ String roleName = "useCatalog_" + UUID.randomUUID();+ List<SecurableObject> securableObjects = new ArrayList<>();+ SecurableObject catalogObject =+ SecurableObjects.ofCatalog(catalogName, ImmutableList.of(Privileges.UseCatalog.allow()));+ securableObjects.add(catalogObject);+ metalakeClientWithAllPrivilege.createRole(roleName, new HashMap<>(), securableObjects);+ metalakeClientWithAllPrivilege.grantRolesToUser(ImmutableList.of(roleName), NORMAL_USER);+ }+}diff --git a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/integration/test/IcebergTableAuthorizationIT.java b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/integration/test/IcebergTableAuthorizationIT.javanew file mode 100644index 0000000000..46f99702cc--- /dev/null+++ b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/integration/test/IcebergTableAuthorizationIT.java@@ -0,0 +1,348 @@+/*+ * 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.iceberg.integration.test;++import com.google.common.collect.ImmutableList;+import java.util.ArrayList;+import java.util.Arrays;+import java.util.HashMap;+import java.util.List;+import java.util.Optional;+import java.util.Set;+import java.util.UUID;+import org.apache.gravitino.MetadataObject;+import org.apache.gravitino.MetadataObjects;+import org.apache.gravitino.NameIdentifier;+import org.apache.gravitino.Namespace;+import org.apache.gravitino.authorization.Owner;+import org.apache.gravitino.authorization.Privileges;+import org.apache.gravitino.authorization.SecurableObject;+import org.apache.gravitino.authorization.SecurableObjects;+import org.apache.gravitino.authorization.User;+import org.apache.gravitino.rel.Table;+import org.apache.iceberg.exceptions.ForbiddenException;+import org.apache.spark.sql.AnalysisException;+import org.apache.spark.sql.catalyst.analysis.TableAlreadyExistsException;+import org.junit.jupiter.api.Assertions;+import org.junit.jupiter.api.BeforeAll;+import org.junit.jupiter.api.BeforeEach;+import org.junit.jupiter.api.Tag;+import org.junit.jupiter.api.Test;++@Tag("gravitino-docker-test")+public class IcebergTableAuthorizationIT extends IcebergAuthorizationIT {++ private static final String SCHEMA_NAME = "schema";++ @BeforeAll+ public void startIntegrationTest() throws Exception {+ super.startIntegrationTest();+ catalogClientWithAllPrivilege.asSchemas().createSchema(SCHEMA_NAME, "test", new HashMap<>());+ }++ @BeforeEach+ void revokePrivilege() {+ revokeUserRoles();+ resetMetalakeAndCatalogOwner();+ MetadataObject schemaObject =+ MetadataObjects.of(+ Arrays.asList(GRAVITINO_CATALOG_NAME, SCHEMA_NAME), MetadataObject.Type.SCHEMA);+ metalakeClientWithAllPrivilege.setOwner(schemaObject, SUPER_USER, Owner.Type.USER);+ clearTable();+ // Grant user the privilege to use the catalog and schema+ grantUseSchemaRole(SCHEMA_NAME);+ sql("USE %s;", SPARK_CATALOG_NAME);+ sql("USE %s;", SCHEMA_NAME);+ }++ @Test+ void testCreateTable() {+ String tableName = "test_create";+ boolean exists =+ catalogClientWithAllPrivilege+ .asTableCatalog()+ .tableExists(NameIdentifier.of(SCHEMA_NAME, tableName));+ Assertions.assertFalse(exists);+ Assertions.assertThrowsExactly(+ ForbiddenException.class, () -> sql("CREATE TABLE %s(a int)", tableName));+ exists =+ catalogClientWithAllPrivilege+ .asTableCatalog()+ .tableExists(NameIdentifier.of(SCHEMA_NAME, tableName));+ Assertions.assertFalse(exists);++ String roleName = grantCreateTableRole(SCHEMA_NAME);+ Assertions.assertDoesNotThrow(() -> sql("CREATE TABLE %s(a int)", tableName));+ exists =+ catalogClientWithAllPrivilege+ .asTableCatalog()+ .tableExists(NameIdentifier.of(SCHEMA_NAME, tableName));+ Assertions.assertTrue(exists);++ Optional<Owner> owner =+ metalakeClientWithAllPrivilege.getOwner(+ MetadataObjects.of(+ Arrays.asList(GRAVITINO_CATALOG_NAME, SCHEMA_NAME, tableName),+ MetadataObject.Type.TABLE));+ Assertions.assertTrue(owner.isPresent());+ Assertions.assertEquals(NORMAL_USER, owner.get().name());++ Assertions.assertThrowsExactly(+ TableAlreadyExistsException.class, () -> sql("CREATE TABLE %s(a int)", tableName));++ // test create table with schema owner+ revokeRole(roleName);+ setSchemaOwner(NORMAL_USER);+ String tableName2 = "test_create_2";+ Assertions.assertDoesNotThrow(() -> sql("CREATE TABLE %s(a int)", tableName2));+ exists =+ catalogClientWithAllPrivilege+ .asTableCatalog()+ .tableExists(NameIdentifier.of(SCHEMA_NAME, tableName2));+ Assertions.assertTrue(exists);++ setSchemaOwner(SUPER_USER);+ String tableName3 = "test_create_3";+ Assertions.assertThrowsExactly(+ ForbiddenException.class, () -> sql("CREATE TABLE %s(a int)", tableName3));++ exists =+ catalogClientWithAllPrivilege+ .asTableCatalog()+ .tableExists(NameIdentifier.of(SCHEMA_NAME, tableName3));+ Assertions.assertFalse(exists);+ }++ @Test+ void testLoadTable() {+ String tableName = "test_load";+ createTable(SCHEMA_NAME, tableName);+ Assertions.assertThrowsExactly(ForbiddenException.class, () -> sql("DESC TABLE %s", tableName));++ String roleName = grantSelectTableRole(tableName);+ Assertions.assertDoesNotThrow(() -> sql("DESC TABLE %s", tableName));++ revokeRole(roleName);+ Assertions.assertThrowsExactly(ForbiddenException.class, () -> sql("DESC TABLE %s", tableName));++ setSchemaOwner(NORMAL_USER);+ Assertions.assertDoesNotThrow(() -> sql("DESC TABLE %s", tableName));+ Assertions.assertThrowsExactly(+ AnalysisException.class, () -> sql("DESC TABLE %s_not_exist", tableName));++ setSchemaOwner(SUPER_USER);+ Assertions.assertThrowsExactly(ForbiddenException.class, () -> sql("DESC TABLE %s", tableName));+ }++ @Test+ void testDropTable() {+ String tableName = "test_drop";+ createTable(SCHEMA_NAME, tableName);+ Assertions.assertThrowsExactly(ForbiddenException.class, () -> sql("DROP TABLE %s", tableName));+ boolean exists =+ catalogClientWithAllPrivilege+ .asTableCatalog()+ .tableExists(NameIdentifier.of(SCHEMA_NAME, tableName));+ Assertions.assertTrue(exists);++ setTableOwner(tableName);+ Assertions.assertDoesNotThrow(() -> sql("DROP TABLE %s", tableName));+ exists =+ catalogClientWithAllPrivilege+ .asTableCatalog()+ .tableExists(NameIdentifier.of(SCHEMA_NAME, tableName));+ Assertions.assertFalse(exists);+ }++ @Test+ void testUpdateTable() {+ String tableName = "test_update";+ createTable(SCHEMA_NAME, tableName);+ Assertions.assertThrowsExactly(+ ForbiddenException.class,+ () -> sql("ALTER TABLE %s SET TBLPROPERTIES ('a'='b')", tableName));+ Table table =+ catalogClientWithAllPrivilege+ .asTableCatalog()+ .loadTable(NameIdentifier.of(SCHEMA_NAME, tableName));+ Assertions.assertFalse(table.properties().containsKey("a"));++ setTableOwner(tableName);+ Assertions.assertDoesNotThrow(+ () -> sql("ALTER TABLE %s SET TBLPROPERTIES ('a'='b')", tableName));+ table =+ catalogClientWithAllPrivilege+ .asTableCatalog()+ .loadTable(NameIdentifier.of(SCHEMA_NAME, tableName));+ Assertions.assertTrue(table.properties().containsKey("a"));+ Assertions.assertEquals("b", table.properties().get("a"));+ }++ @Test+ void testListTable() {+ createTable(SCHEMA_NAME, "test_list1");+ createTable(SCHEMA_NAME, "test_list2");++ Set<String> tableNames = listTableNames(SCHEMA_NAME);+ Assertions.assertEquals(0, tableNames.size());++ setTableOwner("test_list1");+ Assertions.assertDoesNotThrow(() -> sql("SHOW TABLES in %s", SCHEMA_NAME));+ tableNames = listTableNames(SCHEMA_NAME);+ Assertions.assertEquals(1, tableNames.size());+ Assertions.assertTrue(tableNames.contains("test_list1"));+ }++ @Test+ void testIcebergMetadataOperation() {+ String tableName = "test_basic_op";+ grantCreateTableRole(SCHEMA_NAME);+ sql("CREATE TABLE %s(a int, b int) PARTITIONED BY (a)", tableName);+ sql("INSERT INTO %s VALUES (1,1),(2,2)", tableName);+ List<Object[]> rows = sql("SELECT * FROM %s", tableName);+ Assertions.assertEquals(2, rows.size());++ rows = sql("SELECT * FROM %s.%s.%s", SPARK_CATALOG_NAME, SCHEMA_NAME, tableName);+ Assertions.assertEquals(2, rows.size());++ rows = sql("SELECT * FROM %s.%s", SCHEMA_NAME, tableName);+ Assertions.assertEquals(2, rows.size());++ rows = sql("SELECT * FROM %s.%s.%s.partitions", SPARK_CATALOG_NAME, SCHEMA_NAME, tableName);+ Assertions.assertEquals(2, rows.size());++ rows = sql("SELECT *,_file FROM %s", tableName);+ Assertions.assertEquals(2, rows.size());+ }++ @Test+ public void testRenameTable() {+ String tableName = "test_rename";+ createTable(SCHEMA_NAME, tableName);+ Assertions.assertThrowsExactly(+ ForbiddenException.class,+ () -> sql("ALTER TABLE %s RENAME TO %s", tableName, tableName + "_renamed"));++ setTableOwner(tableName);+ Assertions.assertDoesNotThrow(+ () -> sql("ALTER TABLE %s RENAME TO %s", tableName, tableName + "_renamed"));+ Table table =+ catalogClientWithAllPrivilege+ .asTableCatalog()+ .loadTable(NameIdentifier.of(SCHEMA_NAME, tableName + "_renamed"));+ Assertions.assertNotNull(table);++ Optional<Owner> owner =+ metalakeClientWithAllPrivilege.getOwner(+ MetadataObjects.of(+ Arrays.asList(GRAVITINO_CATALOG_NAME, SCHEMA_NAME, tableName + "_renamed"),+ MetadataObject.Type.TABLE));+ Assertions.assertTrue(owner.isPresent());+ Assertions.assertEquals(NORMAL_USER, owner.get().name());+ }++ private void grantUseSchemaRole(String schema) {+ String roleName = "useSchema_" + UUID.randomUUID();+ List<SecurableObject> securableObjects = new ArrayList<>();+ SecurableObject catalogObject =+ SecurableObjects.ofCatalog(+ GRAVITINO_CATALOG_NAME, ImmutableList.of(Privileges.UseCatalog.allow()));+ securableObjects.add(catalogObject);+ SecurableObject schemaObject =+ SecurableObjects.ofSchema(+ catalogObject, schema, ImmutableList.of(Privileges.UseSchema.allow()));+ securableObjects.add(schemaObject);+ metalakeClientWithAllPrivilege.createRole(roleName, new HashMap<>(), securableObjects);++ metalakeClientWithAllPrivilege.grantRolesToUser(ImmutableList.of(roleName), NORMAL_USER);+ }++ private String grantCreateTableRole(String schema) {+ String roleName = "createTable_" + UUID.randomUUID();+ List<SecurableObject> securableObjects = new ArrayList<>();+ SecurableObject catalogObject =+ SecurableObjects.ofCatalog(+ GRAVITINO_CATALOG_NAME, ImmutableList.of(Privileges.UseCatalog.allow()));+ securableObjects.add(catalogObject);+ SecurableObject schemaObject =+ SecurableObjects.ofSchema(+ catalogObject,+ schema,+ ImmutableList.of(Privileges.CreateTable.allow(), Privileges.SelectTable.allow()));+ securableObjects.add(schemaObject);+ metalakeClientWithAllPrivilege.createRole(roleName, new HashMap<>(), securableObjects);+ metalakeClientWithAllPrivilege.grantRolesToUser(ImmutableList.of(roleName), NORMAL_USER);+ return roleName;+ }++ private String grantSelectTableRole(String tableName) {+ String roleName = "selectTable_" + UUID.randomUUID();+ List<SecurableObject> securableObjects = new ArrayList<>();+ SecurableObject catalogObject =+ SecurableObjects.ofCatalog(+ GRAVITINO_CATALOG_NAME, ImmutableList.of(Privileges.UseCatalog.allow()));+ securableObjects.add(catalogObject);+ SecurableObject schemaObject =+ SecurableObjects.ofSchema(+ catalogObject, SCHEMA_NAME, ImmutableList.of(Privileges.UseSchema.allow()));+ SecurableObject tableObject =+ SecurableObjects.ofTable(+ schemaObject, tableName, ImmutableList.of(Privileges.SelectTable.allow()));+ securableObjects.add(tableObject);+ metalakeClientWithAllPrivilege.createRole(roleName, new HashMap<>(), securableObjects);+ metalakeClientWithAllPrivilege.grantRolesToUser(ImmutableList.of(roleName), NORMAL_USER);+ return roleName;+ }++ private void revokeRole(String roleName) {+ User user =+ metalakeClientWithAllPrivilege.revokeRolesFromUser(ImmutableList.of(roleName), NORMAL_USER);+ Assertions.assertFalse(user.roles().contains(roleName));+ }++ private void setTableOwner(String tableName) {+ MetadataObject tableMetadataObject =+ MetadataObjects.of(+ Arrays.asList(GRAVITINO_CATALOG_NAME, SCHEMA_NAME, tableName),+ MetadataObject.Type.TABLE);+ metalakeClientWithAllPrivilege.setOwner(tableMetadataObject, NORMAL_USER, Owner.Type.USER);+ }++ private void setSchemaOwner(String userName) {+ MetadataObject schemaMetadataObject =+ MetadataObjects.of(+ Arrays.asList(GRAVITINO_CATALOG_NAME, SCHEMA_NAME), MetadataObject.Type.SCHEMA);+ metalakeClientWithAllPrivilege.setOwner(schemaMetadataObject, userName, Owner.Type.USER);+ }++ private void clearTable() {+ Arrays.stream(+ catalogClientWithAllPrivilege.asTableCatalog().listTables(Namespace.of(SCHEMA_NAME)))+ .forEach(+ table -> {+ catalogClientWithAllPrivilege+ .asTableCatalog()+ .dropTable(NameIdentifier.of(SCHEMA_NAME, table.name()));+ });+ NameIdentifier[] nameIdentifiers =+ catalogClientWithAllPrivilege.asTableCatalog().listTables(Namespace.of(SCHEMA_NAME));+ Assertions.assertEquals(0, nameIdentifiers.length);+ }+}diff --git a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/TestIcebergCatalogWrapperManagerForREST.java b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/TestIcebergCatalogWrapperManagerForREST.javaindex 60c758cc5f..2f51f2c371 100644--- a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/TestIcebergCatalogWrapperManagerForREST.java+++ b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/TestIcebergCatalogWrapperManagerForREST.java@@ -22,6 +22,7 @@ import com.google.common.collect.Maps;import java.util.Map;import org.apache.commons.lang3.StringUtils;import org.apache.gravitino.iceberg.common.ops.IcebergCatalogWrapper;+import org.apache.gravitino.iceberg.service.authorization.IcebergRESTServerContext;import org.apache.gravitino.iceberg.service.provider.IcebergConfigProvider;import org.apache.gravitino.iceberg.service.provider.IcebergConfigProviderFactory;import org.junit.jupiter.api.Assertions;@@ -60,6 +61,7 @@ public class TestIcebergCatalogWrapperManagerForREST {Map<String, String> config = Maps.newHashMap();IcebergConfigProvider configProvider = IcebergConfigProviderFactory.create(config);configProvider.initialize(config);+ IcebergRESTServerContext.create(configProvider, false);IcebergCatalogWrapperManager manager = new IcebergCatalogWrapperManager(config, configProvider);Assertions.assertThrowsExactly(IllegalArgumentException.class, () -> manager.getOps(rawPrefix));diff --git a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/TestIcebergRESTUtils.java b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/TestIcebergRESTUtils.javaindex 050740dbc9..7e4eece172 100644--- a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/TestIcebergRESTUtils.java+++ b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/TestIcebergRESTUtils.java@@ -21,6 +21,8 @@ package org.apache.gravitino.iceberg.service;import org.apache.gravitino.NameIdentifier;import org.apache.gravitino.catalog.lakehouse.iceberg.IcebergConstants;+import org.apache.gravitino.iceberg.service.authorization.IcebergRESTServerContext;+import org.apache.gravitino.iceberg.service.provider.IcebergConfigProvider;import org.apache.iceberg.Schema;import org.apache.iceberg.catalog.TableIdentifier;import org.apache.iceberg.rest.requests.CreateTableRequest;@@ -28,18 +30,31 @@ import org.apache.iceberg.types.Types.IntegerType;import org.apache.iceberg.types.Types.NestedField;import org.apache.iceberg.types.Types.StringType;import org.junit.jupiter.api.Assertions;+import org.junit.jupiter.api.BeforeAll;import org.junit.jupiter.api.Test;+import org.junit.jupiter.api.TestInstance;+import org.mockito.Mockito;@SuppressWarnings("deprecation")+@TestInstance(TestInstance.Lifecycle.PER_CLASS)public class TestIcebergRESTUtils {+ @BeforeAll+ public void init() {+ IcebergConfigProvider icebergConfigProvider = Mockito.mock(IcebergConfigProvider.class);+ Mockito.when(icebergConfigProvider.getMetalakeName()).thenReturn("metalake");+ Mockito.when(icebergConfigProvider.getDefaultCatalogName())+ .thenReturn(IcebergConstants.ICEBERG_REST_DEFAULT_CATALOG);+ IcebergRESTServerContext.create(icebergConfigProvider, false);+ }+@Testvoid testGetGravitinoNameIdentifier() {String metalakeName = "metalake";String catalogName = "catalog";TableIdentifier tableIdentifier = TableIdentifier.of("ns1", "ns2", "table");NameIdentifier nameIdentifier =- IcebergRestUtils.getGravitinoNameIdentifier(metalakeName, catalogName, tableIdentifier);+ IcebergRESTUtils.getGravitinoNameIdentifier(metalakeName, catalogName, tableIdentifier);Assertions.assertEquals(NameIdentifier.of(metalakeName, catalogName, "ns1", "ns2", "table"), nameIdentifier);}@@ -47,9 +62,9 @@ public class TestIcebergRESTUtils {@Testvoid testGetCatalogName() {String prefix = "catalog/";- Assertions.assertEquals("catalog", IcebergRestUtils.getCatalogName(prefix));+ Assertions.assertEquals("catalog", IcebergRESTUtils.getCatalogName(prefix));Assertions.assertEquals(- IcebergConstants.ICEBERG_REST_DEFAULT_CATALOG, IcebergRestUtils.getCatalogName(""));+ IcebergConstants.ICEBERG_REST_DEFAULT_CATALOG, IcebergRESTUtils.getCatalogName(""));}@Test@@ -61,7 +76,7 @@ public class TestIcebergRESTUtils {CreateTableRequest createTableRequest =CreateTableRequest.builder().withName("table").withSchema(tableSchema).build();CreateTableRequest clonedIcebergRESTObject =- IcebergRestUtils.cloneIcebergRESTObject(createTableRequest, CreateTableRequest.class);+ IcebergRESTUtils.cloneIcebergRESTObject(createTableRequest, CreateTableRequest.class);Assertions.assertEquals(createTableRequest.name(), clonedIcebergRESTObject.name());Assertions.assertEquals(createTableRequest.schema().columns().size(),diff --git a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/extension/HelloOperations.java b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/extension/HelloOperations.javaindex bac8b30a09..e5914c93ce 100644--- a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/extension/HelloOperations.java+++ b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/extension/HelloOperations.java@@ -27,7 +27,7 @@ import javax.ws.rs.Produces;import javax.ws.rs.core.Context;import javax.ws.rs.core.MediaType;import javax.ws.rs.core.Response;-import org.apache.gravitino.iceberg.service.IcebergRestUtils;+import org.apache.gravitino.iceberg.service.IcebergRESTUtils;@Path("/hello")@Consumes(MediaType.APPLICATION_JSON)@@ -44,6 +44,6 @@ public class HelloOperations {@GET@Produces(MediaType.APPLICATION_JSON)public Response hello() {- return IcebergRestUtils.ok(new HelloResponse(HELLO_MSG));+ return IcebergRESTUtils.ok(new HelloResponse(HELLO_MSG));}}diff --git a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/IcebergRestTestUtil.java b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/IcebergRestTestUtil.javaindex 0a50a7374e..63a4d4ad49 100644--- a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/IcebergRestTestUtil.java+++ b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/IcebergRestTestUtil.java@@ -37,6 +37,7 @@ import org.apache.gravitino.iceberg.common.IcebergConfig;import org.apache.gravitino.iceberg.service.IcebergCatalogWrapperManager;import org.apache.gravitino.iceberg.service.IcebergExceptionMapper;import org.apache.gravitino.iceberg.service.IcebergObjectMapperProvider;+import org.apache.gravitino.iceberg.service.authorization.IcebergRESTServerContext;import org.apache.gravitino.iceberg.service.dispatcher.IcebergNamespaceEventDispatcher;import org.apache.gravitino.iceberg.service.dispatcher.IcebergNamespaceOperationDispatcher;import org.apache.gravitino.iceberg.service.dispatcher.IcebergNamespaceOperationExecutor;@@ -132,6 +133,8 @@ public class IcebergRestTestUtil {IcebergCatalogWrapperManager icebergCatalogWrapperManager =new IcebergCatalogWrapperManagerForTest(catalogConf, configProvider);+ IcebergRESTServerContext.create(configProvider, false);+EventBus eventBus = new EventBus(eventListenerPlugins);IcebergTableOperationExecutor icebergTableOperationExecutor =diff --git a/integration-test-common/src/test/java/org/apache/gravitino/integration/test/util/BaseIT.java b/integration-test-common/src/test/java/org/apache/gravitino/integration/test/util/BaseIT.javaindex 1ae60a0fec..cbeefc8d6a 100644--- a/integration-test-common/src/test/java/org/apache/gravitino/integration/test/util/BaseIT.java+++ b/integration-test-common/src/test/java/org/apache/gravitino/integration/test/util/BaseIT.java@@ -53,6 +53,7 @@ import org.apache.commons.lang3.StringUtils;import org.apache.gravitino.Config;import org.apache.gravitino.Configs;import org.apache.gravitino.auth.AuthenticatorType;+import org.apache.gravitino.auxiliary.AuxiliaryServiceManager;import org.apache.gravitino.client.GravitinoAdminClient;import org.apache.gravitino.config.ConfigConstants;import org.apache.gravitino.integration.test.MiniGravitino;@@ -297,7 +298,7 @@ public class BaseIT {LOG.info("Running Gravitino Server in {} mode", testMode);- if ("MySQL".equalsIgnoreCase(System.getenv("jdbcBackend"))) {+ if ("MySQL".equalsIgnoreCase(getJDBCBackend())) {// Start MySQL docker instance.String jdbcURL = startAndInitMySQLBackend();customConfigs.put(Configs.ENTITY_STORE_KEY, "relational");@@ -307,7 +308,7 @@ public class BaseIT {Configs.ENTITY_RELATIONAL_JDBC_BACKEND_DRIVER_KEY, "com.mysql.cj.jdbc.Driver");customConfigs.put(Configs.ENTITY_RELATIONAL_JDBC_BACKEND_USER_KEY, "root");customConfigs.put(Configs.ENTITY_RELATIONAL_JDBC_BACKEND_PASSWORD_KEY, "root");- } else if ("PostgreSQL".equalsIgnoreCase(System.getenv("jdbcBackend"))) {+ } else if ("PostgreSQL".equalsIgnoreCase(getJDBCBackend())) {// Start PostgreSQL docker instance.String pgJdbcUrl = startAndInitPGBackend();customConfigs.put(Configs.ENTITY_STORE_KEY, "relational");@@ -329,6 +330,12 @@ public class BaseIT {serverConfig = new ServerConfig();customConfigs.put(ENTITY_RELATIONAL_JDBC_BACKEND_PATH.getKey(), file.getAbsolutePath());+ if (ignoreAuxRestService) {+ customConfigs.put(+ AuxiliaryServiceManager.GRAVITINO_AUX_SERVICE_PREFIX+ + AuxiliaryServiceManager.AUX_SERVICE_NAMES,+ "");+ }if (testMode != null && testMode.equals(ITUtils.EMBEDDED_TEST_MODE)) {MiniGravitinoContext context = new MiniGravitinoContext(customConfigs, ignoreAuxRestService);miniGravitino = new MiniGravitino(context);@@ -583,4 +590,15 @@ public class BaseIT {}return null;}++ protected String getIcebergRestServiceUri() {+ JettyServerConfig jettyServerConfig =+ JettyServerConfig.fromConfig(serverConfig, String.format("gravitino.iceberg-rest."));+ return String.format(+ "http://%s:%d/iceberg/", jettyServerConfig.getHost(), jettyServerConfig.getHttpPort());+ }++ protected String getJDBCBackend() {+ return System.getenv("jdbcBackend");+ }}diff --git a/integration-test-common/src/test/java/org/apache/gravitino/integration/test/util/TestDatabaseName.java b/integration-test-common/src/test/java/org/apache/gravitino/integration/test/util/TestDatabaseName.javaindex 72c466629c..806696c6a2 100644--- a/integration-test-common/src/test/java/org/apache/gravitino/integration/test/util/TestDatabaseName.java+++ b/integration-test-common/src/test/java/org/apache/gravitino/integration/test/util/TestDatabaseName.java@@ -114,4 +114,5 @@ public enum TestDatabaseName {return this.name().toLowerCase();}},+ PG_ICEBERG_AUTHZ_IT,}diff --git a/server-common/src/main/java/org/apache/gravitino/server/web/Utils.java b/server-common/src/main/java/org/apache/gravitino/server/web/Utils.javaindex b11db99c7c..6cf48f6e95 100644--- a/server-common/src/main/java/org/apache/gravitino/server/web/Utils.java+++ b/server-common/src/main/java/org/apache/gravitino/server/web/Utils.java@@ -19,10 +19,13 @@package org.apache.gravitino.server.web;import com.google.common.collect.Maps;+import java.lang.reflect.Parameter;import java.security.PrivilegedExceptionAction;+import java.util.HashMap;import java.util.Map;import java.util.Optional;import javax.servlet.http.HttpServletRequest;+import javax.ws.rs.PathParam;import javax.ws.rs.core.MediaType;import javax.ws.rs.core.Response;import javax.ws.rs.core.Response.Status;@@ -245,4 +248,18 @@ public class Utils {return StringUtils.isBlank(clientVersion) ? null : Version.parseVersionNumber(clientVersion);}++ public static Map<String, Object> extractPathParamsFromParameters(+ Parameter[] parameters, Object[] args) {+ Map<String, Object> pathParams = new HashMap<>();+ for (int i = 0; i < parameters.length; i++) {+ Parameter parameter = parameters[i];+ PathParam pathParam = parameter.getAnnotation(PathParam.class);+ if (pathParam == null) {+ continue;+ }+ pathParams.put("p_" + pathParam.value(), args[i]);+ }+ return pathParams;+ }}diff --git a/server/src/main/java/org/apache/gravitino/server/web/filter/GravitinoInterceptionService.java b/server/src/main/java/org/apache/gravitino/server/web/filter/GravitinoInterceptionService.javaindex a43d4d4236..950fd6e989 100644--- a/server/src/main/java/org/apache/gravitino/server/web/filter/GravitinoInterceptionService.java+++ b/server/src/main/java/org/apache/gravitino/server/web/filter/GravitinoInterceptionService.java@@ -30,7 +30,6 @@ import java.util.Locale;import java.util.Map;import java.util.Optional;import java.util.Set;-import javax.ws.rs.PathParam;import javax.ws.rs.core.Response;import org.aopalliance.intercept.ConstructorInterceptor;import org.aopalliance.intercept.MethodInterceptor;@@ -137,7 +136,7 @@ public class GravitinoInterceptionService implements InterceptionService {String entityType = extractMetadataObjectTypeFromParameters(parameters, args);Map<Entity.EntityType, NameIdentifier> metadataContext =extractNameIdentifierFromParameters(parameters, args);- Map<String, Object> pathParams = extractPathParamsFromParameters(parameters, args);+ Map<String, Object> pathParams = Utils.extractPathParamsFromParameters(parameters, args);AuthorizationExpressionEvaluator authorizationExpressionEvaluator =new AuthorizationExpressionEvaluator(expression);boolean authorizeResult =@@ -313,20 +312,6 @@ public class GravitinoInterceptionService implements InterceptionService {return nameIdentifierMap;}-- private Map<String, Object> extractPathParamsFromParameters(- Parameter[] parameters, Object[] args) {- Map<String, Object> pathParams = new HashMap<>();- for (int i = 0; i < parameters.length; i++) {- Parameter parameter = parameters[i];- PathParam pathParam = parameter.getAnnotation(PathParam.class);- if (pathParam == null) {- continue;- }- pathParams.put("p_" + pathParam.value(), args[i]);- }- return pathParams;- }}private static String extractMetadataObjectTypeFromParameters(diff --git a/server/src/test/java/org/apache/gravitino/server/web/rest/authorization/TestTableAuthorizationExpression.java b/server/src/test/java/org/apache/gravitino/server/web/rest/authorization/TestTableAuthorizationExpression.javaindex 95e6189217..b98fa35d45 100644--- a/server/src/test/java/org/apache/gravitino/server/web/rest/authorization/TestTableAuthorizationExpression.java+++ b/server/src/test/java/org/apache/gravitino/server/web/rest/authorization/TestTableAuthorizationExpression.java@@ -50,6 +50,8 @@ public class TestTableAuthorizationExpression {assertTrue(mockEvaluator.getResult(ImmutableSet.of("SCHEMA::OWNER", "CATALOG::USE_CATALOG")));assertTrue(mockEvaluator.getResult(ImmutableSet.of("SCHEMA::OWNER", "METALAKE::USE_CATALOG")));assertFalse(mockEvaluator.getResult(ImmutableSet.of("SCHEMA::CREATE_TABLE")));+ assertFalse(+ mockEvaluator.getResult(ImmutableSet.of("CATALOG::USE_CATALOG", "SCHEMA::USE_SCHEMA")));assertFalse(mockEvaluator.getResult(ImmutableSet.of("SCHEMA::CREATE_TABLE", "SCHEMA::USE_SCHEMA")));assertTrue(diff --git a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/SparkEnvIT.java b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/SparkEnvIT.javaindex 9c2d2d5110..ede1453f16 100644--- a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/SparkEnvIT.java+++ b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/SparkEnvIT.java@@ -30,7 +30,6 @@ import org.apache.gravitino.Catalog;import org.apache.gravitino.client.GravitinoMetalake;import org.apache.gravitino.integration.test.container.ContainerSuite;import org.apache.gravitino.integration.test.container.HiveContainer;-import org.apache.gravitino.server.web.JettyServerConfig;import org.apache.gravitino.spark.connector.GravitinoSparkConfig;import org.apache.gravitino.spark.connector.iceberg.IcebergPropertiesConstants;import org.apache.gravitino.spark.connector.integration.test.util.SparkUtilIT;@@ -213,12 +212,4 @@ public abstract class SparkEnvIT extends SparkUtilIT {.enableHiveSupport().getOrCreate();}-- private String getIcebergRestServiceUri() {- JettyServerConfig jettyServerConfig =- JettyServerConfig.fromConfig(- serverConfig, String.format("gravitino.%s.", icebergRestServiceName));- return String.format(- "http://%s:%d/iceberg/", jettyServerConfig.getHost(), jettyServerConfig.getHttpPort());- }}