yuqi1129 commented on code in PR #10081:
URL: https://github.com/apache/gravitino/pull/10081#discussion_r3093436505


##########
api/src/main/java/org/apache/gravitino/credential/JdbcCredential.java:
##########
@@ -0,0 +1,110 @@
+/*
+ *  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 com.google.common.collect.ImmutableMap;
+import java.util.Map;
+import org.apache.commons.lang3.StringUtils;
+
+/** JDBC credential for accessing JDBC backend services. */
+public class JdbcCredential implements Credential {
+
+  /** JDBC credential type. */
+  public static final String JDBC_CREDENTIAL_TYPE = "jdbc";
+  /** The JDBC user name. */
+  public static final String GRAVITINO_JDBC_USER = "jdbc-user";
+  /** The JDBC password. */
+  public static final String GRAVITINO_JDBC_PASSWORD = "jdbc-password";
+
+  private String jdbcUser;
+  private String jdbcPassword;
+
+  /**
+   * Constructs an instance of {@link JdbcCredential} with the JDBC user and 
password.
+   *
+   * @param jdbcUser The JDBC user name.
+   * @param jdbcPassword The JDBC password.
+   */
+  public JdbcCredential(String jdbcUser, String jdbcPassword) {
+    validate(jdbcUser, jdbcPassword, 0);
+    this.jdbcUser = jdbcUser;
+    this.jdbcPassword = jdbcPassword;
+  }
+
+  /**
+   * This is the constructor that is used by credential factory to create an 
instance of credential
+   * according to the credential information.
+   */
+  public JdbcCredential() {}
+
+  @Override
+  public String credentialType() {
+    return JDBC_CREDENTIAL_TYPE;
+  }
+
+  @Override
+  public long expireTimeInMs() {
+    return 0;
+  }
+
+  @Override

Review Comment:
   `credentialInfo()` returns the password in plain text. This map may end up 
serialized in REST responses or logs. Consider whether there is a need for 
redaction/masking in the credential info map, similar to how other sensitive 
properties are handled in the codebase. At minimum, the `toString()` method 
(inherited from Object) should be overridden to avoid accidental password 
leakage in logs.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to