【fix sonar】CommonUtils文件

This commit is contained in:
梁琦涛
2023-03-03 16:28:21 +08:00
parent 711f6453bf
commit b342d29bf9
@@ -30,6 +30,10 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
public class CommonUtils {
private CommonUtils(){
}
//中文正则
private static Pattern ZHONGWEN_PATTERN = Pattern.compile("[\u4e00-\u9fa5]");
@@ -188,7 +192,6 @@ public class CommonUtils {
try {
return getDatabaseTypeByDataSource(dataSource);
} catch (SQLException e) {
//e.printStackTrace();
log.warn(e.getMessage(), e);
return "";
}
@@ -202,9 +205,9 @@ public class CommonUtils {
if (oConvertUtils.isNotEmpty(dbTypeEnum)) {
return dbTypeEnum;
}
try {
DataSource dataSource = SpringContextUtils.getApplicationContext().getBean(DataSource.class);
dbTypeEnum = JdbcUtils.getDbType(dataSource.getConnection().getMetaData().getURL());
DataSource dataSource = SpringContextUtils.getApplicationContext().getBean(DataSource.class);
try (Connection connection = dataSource.getConnection();) {
dbTypeEnum = JdbcUtils.getDbType(connection.getMetaData().getURL());
return dbTypeEnum;
} catch (SQLException e) {
log.warn(e.getMessage(), e);
@@ -262,10 +265,10 @@ public class CommonUtils {
* @param RSAPrivateKey 私钥
* @return String 解密后的字符串
*/
public static String decryptBtRsaPriKey(String str,String RSAPrivateKey) throws Exception {
public static String decryptBtRsaPriKey(String str,String RSAPrivateKey){
RSA rsa = new RSA(RSAPrivateKey, null);
byte[] decrypt = rsa.decrypt(str, KeyType.PrivateKey);
return new String(decrypt);
}
}
}