jerryshao commented on code in PR #5682: URL: https://github.com/apache/gravitino/pull/5682#discussion_r1896605013
########## core/src/main/java/org/apache/gravitino/connector/BaseCatalog.java: ########## @@ -78,6 +97,8 @@ public abstract class BaseCatalog<T extends BaseCatalog> private volatile Map<String, String> properties; + private volatile CatalogCredentialManager catalogCredentialManager; Review Comment: I still think we should use a different name, the name of `CatalogCredentialManager` is too close to `CredentialManager`, and easily gets misled. ########## core/src/main/java/org/apache/gravitino/connector/credential/CredentialPrivilege.java: ########## @@ -0,0 +1,25 @@ +/* + * 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.connector.credential; + +public enum CredentialPrivilege { + READ, + WRITE, +} Review Comment: Please add javadoc for class, and also add `@DeveloperApi` tag to all the classes in this package. ########## core/src/main/java/org/apache/gravitino/connector/credential/SupportsPathBasedCredentials.java: ########## @@ -0,0 +1,129 @@ +/* + * 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.connector.credential; + +import com.google.common.base.Preconditions; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; +import org.apache.gravitino.NameIdentifier; +import org.apache.gravitino.Namespace; +import org.apache.gravitino.credential.CredentialUtils; +import org.apache.gravitino.utils.PrincipalUtils; + +/** + * Generates {@link PathBasedCredentialContext}, the catalog operation should implement this + * interface to generate the path based credentials. + */ +public interface SupportsPathBasedCredentials { + /** + * The object contains necessary information to generate {@link PathBasedCredentialContext}. + * + * <p>The objects like {@link org.apache.gravitino.file.Fileset}, ${@link + * org.apache.gravitino.rel.Table} Should generate this object to void load multipal times to get + * paths and properties. + */ + class PathBasedCredentialContextInfo { + private List<String> paths; + private Map<String, String> properties; + + /** + * {@link PathBasedCredentialContextInfo} constructor. + * + * @param paths The paths of the object, used to generate {@link + * PathBasedCredentialContextInfo}. + * @param properties The properties of the object, used to get credential provider + * configurations. + */ + public PathBasedCredentialContextInfo(List<String> paths, Map<String, String> properties) { + this.paths = paths; + this.properties = properties; + } + } + + /** + * The schema properties. + * + * <p>Used to get credential provider configuration from schema if necessary. + * + * @param schemaIdentifier The schema identifier. + * @return The schema properties. + */ + Map<String, String> schemaProperties(NameIdentifier schemaIdentifier); Review Comment: Why do we need schema properties? ########## core/src/main/java/org/apache/gravitino/connector/credential/SupportsCredentialOperations.java: ########## @@ -0,0 +1,40 @@ +/* + * 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.connector.credential; + +import java.util.List; +import org.apache.gravitino.NameIdentifier; +import org.apache.gravitino.credential.Credential; + +/** + * This interface defines how to get credentials, the catalog operation must implement this + * interface to support credential vending. + */ +public interface SupportsCredentialOperations { Review Comment: Why do we need two `SupportsXXX` interfaces, one for `BaseCatalog`, one for `CatalogOperations`? It's hard to understand, also confuses the users. ########## core/src/main/java/org/apache/gravitino/connector/credential/CatalogCredentialManager.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.connector.credential; + +import com.google.common.base.Preconditions; +import java.io.Closeable; +import java.io.IOException; +import java.util.Map; +import org.apache.gravitino.catalog.CatalogManager; +import org.apache.gravitino.credential.Credential; +import org.apache.gravitino.credential.CredentialProvider; +import org.apache.gravitino.credential.CredentialUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** Manages credentials in one catalog. */ +public class CatalogCredentialManager implements Closeable { Review Comment: It's not proper to expose this class to the catalog implementors, catalog implementors don't need know the details of this class. If you want to expose something to let users to leverage, it is better to expose interface, not implementation. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
