World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#8101] Improvement(authz): Remove AuthorizationMetadataPrivileges (#8104)
yangyang zhongc67a81ba9efb
diff --git a/server-common/src/main/java/org/apache/gravitino/server/authorization/annotations/AuthorizationMetadataPrivileges.java b/server-common/src/main/java/org/apache/gravitino/server/authorization/annotations/AuthorizationMetadataPrivileges.javadeleted file mode 100644index 1e2703ccb7..0000000000--- a/server-common/src/main/java/org/apache/gravitino/server/authorization/annotations/AuthorizationMetadataPrivileges.java+++ /dev/null@@ -1,49 +0,0 @@-/*- * 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;-import org.apache.gravitino.MetadataObject;-import org.apache.gravitino.authorization.Privilege;--/**- * Defines the annotation for authorizing access to an API. Use the resourceType and privileges- * fields to define the required privileges and resource type for the API.- */-@Target({ElementType.METHOD})-@Retention(RetentionPolicy.RUNTIME)-public @interface AuthorizationMetadataPrivileges {- /**- * The list of privileges required to access the API.- *- * @return the list of privileges required to access the API.- */- Privilege.Name[] privileges();-- /**- * The resource type of the API.- *- * @return the resource type of the API.- */- MetadataObject.Type metadataType();-}diff --git a/server-common/src/test/java/org/apache/gravitino/server/authorization/annotations/TestAnnotations.java b/server-common/src/test/java/org/apache/gravitino/server/authorization/annotations/TestAnnotations.javaindex c089119e42..c3fee237f4 100644--- a/server-common/src/test/java/org/apache/gravitino/server/authorization/annotations/TestAnnotations.java+++ b/server-common/src/test/java/org/apache/gravitino/server/authorization/annotations/TestAnnotations.java@@ -23,7 +23,6 @@ import java.lang.reflect.Method;import java.lang.reflect.Parameter;import org.apache.gravitino.Entity;import org.apache.gravitino.MetadataObject;-import org.apache.gravitino.authorization.Privilege;import org.junit.jupiter.api.Assertions;import org.junit.jupiter.api.Test;@@ -48,10 +47,6 @@ public class TestAnnotations {// 1. ResourceAuthorizeApi// 2. AuthorizationExpressionstatic class TestAuthorizeAnnotationClass {- @AuthorizationMetadataPrivileges(- privileges = {Privilege.Name.CREATE_CATALOG, Privilege.Name.USE_CATALOG},- metadataType = MetadataObject.Type.CATALOG)- public void testAuthedMethodUseResourceType() {}@AuthorizationExpression(expression = "CATALOG::CREATE_TABLE || TABLE::CREATE_TABLE",@@ -59,24 +54,6 @@ public class TestAnnotations {public void testAuthedMethodUseExpression() {}}- @Test- void testAuthorizeApiWithResourceType() throws NoSuchMethodException {- Class<TestAuthorizeAnnotationClass> testClass = TestAuthorizeAnnotationClass.class;- Method method = testClass.getMethod("testAuthedMethodUseResourceType");-- boolean hasAnnotation = method.isAnnotationPresent(AuthorizationMetadataPrivileges.class);- Assertions.assertTrue(hasAnnotation);-- AuthorizationMetadataPrivileges annotation =- method.getAnnotation(AuthorizationMetadataPrivileges.class);- Assertions.assertNotNull(annotation);-- Assertions.assertArrayEquals(- new Privilege.Name[] {Privilege.Name.CREATE_CATALOG, Privilege.Name.USE_CATALOG},- annotation.privileges());- Assertions.assertEquals(MetadataObject.Type.CATALOG, annotation.metadataType());- }-@Testvoid testAuthorizeApiWithExpression() throws NoSuchMethodException {Class<TestAuthorizeAnnotationClass> testClass = TestAuthorizeAnnotationClass.class;