支持 mysql_clear_password 明文密码模式, 在一些开发、测试环境可能遇上。 (#4628)

Co-authored-by: zhongfu <zhongfu@tesla.com>
This commit is contained in:
fuzhong-jiye
2023-03-16 18:39:11 +08:00
committed by GitHub
parent b52c5d149b
commit 9edbe7e827

View File

@@ -224,13 +224,15 @@ public class MysqlConnector {
boolean isSha2Password = false;
byte[] encryptedPassword = null;
if (pluginName != null && "mysql_native_password".equals(pluginName)) {
if ("mysql_clear_password".equals(pluginName)) {
encryptedPassword = getPassword().getBytes();
} else if ("mysql_native_password".equals(pluginName)) {
try {
encryptedPassword = MySQLPasswordEncrypter.scramble411(getPassword().getBytes(), authData);
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException("can't encrypt password that will be sent to MySQL server.", e);
}
} else if (pluginName != null && "caching_sha2_password".equals(pluginName)) {
} else if ("caching_sha2_password".equals(pluginName)) {
isSha2Password = true;
try {
encryptedPassword = MySQLPasswordEncrypter.scrambleCachingSha2(getPassword().getBytes(), authData);