sonar问题处理

master
pengqiang 2021-12-06 14:49:29 +08:00
parent a2ef87106d
commit 2de6f42a16
3 changed files with 20 additions and 40 deletions

View File

@ -136,7 +136,6 @@ public class ShiroConfig {
map.put("/jqPaginator/**", "anon"); map.put("/jqPaginator/**", "anon");
map.put("/layer/**", "anon"); map.put("/layer/**", "anon");
map.put("/ueditor/**", "anon"); map.put("/ueditor/**", "anon");
map.put("/favicon.png", "anon");
// map.put("/admin/login", "authc"); // map.put("/admin/login", "authc");

View File

@ -61,17 +61,17 @@ public class Base64Utils {
byte[] data = new byte[0]; byte[] data = new byte[0];
File file = new File(filePath); File file = new File(filePath);
if (file.exists()) { if (file.exists()) {
FileInputStream in = new FileInputStream(file); try( FileInputStream in = new FileInputStream(file);
ByteArrayOutputStream out = new ByteArrayOutputStream(2048); ByteArrayOutputStream out = new ByteArrayOutputStream(2048)) {
byte[] cache = new byte[CACHE_SIZE];
int nRead = 0; byte[] cache = new byte[CACHE_SIZE];
while ((nRead = in.read(cache)) != -1) { int nRead = 0;
out.write(cache, 0, nRead); while ((nRead = in.read(cache)) != -1) {
out.flush(); out.write(cache, 0, nRead);
out.flush();
}
data = out.toByteArray();
} }
out.close();
in.close();
data = out.toByteArray();
} }
return data; return data;
} }
@ -83,21 +83,20 @@ public class Base64Utils {
* @param filePath * @param filePath
*/ */
public static void byteArrayToFile(byte[] bytes, String filePath) throws Exception { public static void byteArrayToFile(byte[] bytes, String filePath) throws Exception {
InputStream in = new ByteArrayInputStream(bytes);
File destFile = new File(filePath); File destFile = new File(filePath);
if (!destFile.getParentFile().exists()) { if (!destFile.getParentFile().exists()) {
destFile.getParentFile().mkdirs(); destFile.getParentFile().mkdirs();
} }
destFile.createNewFile(); destFile.createNewFile();
OutputStream out = new FileOutputStream(destFile); try(InputStream in = new ByteArrayInputStream(bytes);
byte[] cache = new byte[CACHE_SIZE]; OutputStream out = new FileOutputStream(destFile)){
int nRead = 0; byte[] cache = new byte[CACHE_SIZE];
while ((nRead = in.read(cache)) != -1) { int nRead = 0;
out.write(cache, 0, nRead); while ((nRead = in.read(cache)) != -1) {
out.flush(); out.write(cache, 0, nRead);
out.flush();
}
} }
out.close();
in.close();
} }
} }

View File

@ -2,7 +2,8 @@ package cn.palmte.work.utils;
import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.codec.digest.DigestUtils;
import sun.misc.BASE64Encoder;
import javax.crypto.Cipher; import javax.crypto.Cipher;
import javax.crypto.SecretKey; import javax.crypto.SecretKey;
@ -51,22 +52,6 @@ public class DESCrypto {
return digest; return digest;
} }
// public static void main(String[] args) throws Exception{
// String key = "VBZ0NR";
// String value = "dzgadmin0.123456789.!@#$%^&*()";
//
// byte[] bytes = value.getBytes(encoding);
// String newKey = string2MD5(key).substring(0, 8).toUpperCase();
// String a = toHexString(encrypt(bytes, newKey)).toUpperCase();
// System.out.println("加密后的数据为:" + a);
//
// String b = java.net.URLDecoder.decode(decrypt(a, newKey), encoding);
// System.out.println("解密后的数据:" + b);
//
// String res = encryptPassword(value, key);
//
// System.out.println("res:" + res);
// }
public static String encryptPassword(String password, String key) throws Exception{ public static String encryptPassword(String password, String key) throws Exception{
byte[] bytes = password.getBytes(encoding); byte[] bytes = password.getBytes(encoding);
@ -114,9 +99,6 @@ public class DESCrypto {
} }
public static String encryptZSK(String data) throws Exception{
return new BASE64Encoder().encode(encryptZSK(data.getBytes(), "zhangshangweike0".getBytes()));
}
private static byte[] encryptZSK(byte[] data, byte[] key) throws Exception{ private static byte[] encryptZSK(byte[] data, byte[] key) throws Exception{
// 生成一个可信任的随机数源 // 生成一个可信任的随机数源