【fix sonar】CommonUtils文件
This commit is contained in:
+9
-6
@@ -30,6 +30,10 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class CommonUtils {
|
public class CommonUtils {
|
||||||
|
|
||||||
|
private CommonUtils(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//中文正则
|
//中文正则
|
||||||
private static Pattern ZHONGWEN_PATTERN = Pattern.compile("[\u4e00-\u9fa5]");
|
private static Pattern ZHONGWEN_PATTERN = Pattern.compile("[\u4e00-\u9fa5]");
|
||||||
|
|
||||||
@@ -188,7 +192,6 @@ public class CommonUtils {
|
|||||||
try {
|
try {
|
||||||
return getDatabaseTypeByDataSource(dataSource);
|
return getDatabaseTypeByDataSource(dataSource);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
//e.printStackTrace();
|
|
||||||
log.warn(e.getMessage(), e);
|
log.warn(e.getMessage(), e);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@@ -202,9 +205,9 @@ public class CommonUtils {
|
|||||||
if (oConvertUtils.isNotEmpty(dbTypeEnum)) {
|
if (oConvertUtils.isNotEmpty(dbTypeEnum)) {
|
||||||
return dbTypeEnum;
|
return dbTypeEnum;
|
||||||
}
|
}
|
||||||
try {
|
DataSource dataSource = SpringContextUtils.getApplicationContext().getBean(DataSource.class);
|
||||||
DataSource dataSource = SpringContextUtils.getApplicationContext().getBean(DataSource.class);
|
try (Connection connection = dataSource.getConnection();) {
|
||||||
dbTypeEnum = JdbcUtils.getDbType(dataSource.getConnection().getMetaData().getURL());
|
dbTypeEnum = JdbcUtils.getDbType(connection.getMetaData().getURL());
|
||||||
return dbTypeEnum;
|
return dbTypeEnum;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.warn(e.getMessage(), e);
|
log.warn(e.getMessage(), e);
|
||||||
@@ -262,10 +265,10 @@ public class CommonUtils {
|
|||||||
* @param RSAPrivateKey 私钥
|
* @param RSAPrivateKey 私钥
|
||||||
* @return String 解密后的字符串
|
* @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);
|
RSA rsa = new RSA(RSAPrivateKey, null);
|
||||||
byte[] decrypt = rsa.decrypt(str, KeyType.PrivateKey);
|
byte[] decrypt = rsa.decrypt(str, KeyType.PrivateKey);
|
||||||
return new String(decrypt);
|
return new String(decrypt);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user