jerryshao commented on code in PR #4995: URL: https://github.com/apache/gravitino/pull/4995#discussion_r1798941527
########## core/src/main/java/org/apache/gravitino/credential/Context.java: ########## @@ -0,0 +1,30 @@ +/* + * 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.credential; + +/** Contains context information to get credential from credential provider. */ +public interface Context { Review Comment: Please rename to `CredentialContext`, `CatalogCredentialContext`, something like this. ########## common/src/main/java/org/apache/gravitino/credential/Credential.java: ########## @@ -0,0 +1,63 @@ +/* + * 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.credential; + +import com.google.common.collect.ImmutableMap; +import java.util.Map; + +/** Interface representing a credential with type, expiration time, and additional information. */ +public interface Credential { + + /** + * Returns the type of the credential. It should same with the credential type of the credential + * provider. + * + * @return the credential type as a String. + */ + String credentialType(); + + /** + * Returns the expiration time of the credential in milliseconds since the epoch, 0 means not + * expire. + * + * @return the expiration time as a long. + */ + long expireTimeMs(); Review Comment: "expireTimeInMs" ########## common/src/main/java/org/apache/gravitino/credential/Credential.java: ########## @@ -0,0 +1,62 @@ +/* + * 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.credential; + +import com.google.common.collect.ImmutableMap; +import java.util.Map; + +/** Interface representing a credential with type, expiration time, and additional information. */ +public interface Credential { Review Comment: Can you please give me an example about how to use it in client side? ########## core/src/main/java/org/apache/gravitino/credential/LocationContext.java: ########## @@ -0,0 +1,57 @@ +/* + * 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.credential; + +import com.google.common.base.Preconditions; +import java.util.Set; +import javax.validation.constraints.NotNull; + +/** + * LocationContext is generated when user requesting resources associated with storage location like + * table, fileset, etc. + */ +public class LocationContext implements Context { Review Comment: I think we can rename this class name to `PathBasedCredentialContext`, and change from "locations" to "paths". ########## core/src/main/java/org/apache/gravitino/credential/LocationContext.java: ########## @@ -0,0 +1,57 @@ +/* + * 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.credential; + +import com.google.common.base.Preconditions; +import java.util.Set; +import javax.validation.constraints.NotNull; + +/** + * LocationContext is generated when user requesting resources associated with storage location like + * table, fileset, etc. + */ +public class LocationContext implements Context { + + @NotNull private final Set<String> writeLocations; + @NotNull private final Set<String> readLocations; + @NotNull private final String userName; + + public LocationContext(String userName, Set<String> writeLocations, Set<String> readLocations) { + Preconditions.checkNotNull(userName, "User name should not be null"); + Preconditions.checkNotNull(writeLocations, "Write locations should not be null"); + Preconditions.checkNotNull(readLocations, "Read locations should not be null"); + this.userName = userName; + this.writeLocations = writeLocations; + this.readLocations = readLocations; + } + + @Override + public String getUserName() { + return userName; + } + + public Set<String> getWriteLocations() { Review Comment: "writePaths" -- 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]
