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("/layer/**", "anon");
map.put("/ueditor/**", "anon");
map.put("/favicon.png", "anon");
// map.put("/admin/login", "authc");

View File

@ -61,17 +61,17 @@ public class Base64Utils {
byte[] data = new byte[0];
File file = new File(filePath);
if (file.exists()) {
FileInputStream in = new FileInputStream(file);
ByteArrayOutputStream out = new ByteArrayOutputStream(2048);
byte[] cache = new byte[CACHE_SIZE];
int nRead = 0;
while ((nRead = in.read(cache)) != -1) {
out.write(cache, 0, nRead);
out.flush();
try( FileInputStream in = new FileInputStream(file);
ByteArrayOutputStream out = new ByteArrayOutputStream(2048)) {
byte[] cache = new byte[CACHE_SIZE];
int nRead = 0;
while ((nRead = in.read(cache)) != -1) {
out.write(cache, 0, nRead);
out.flush();
}
data = out.toByteArray();
}
out.close();
in.close();
data = out.toByteArray();
}
return data;
}
@ -83,21 +83,20 @@ public class Base64Utils {
* @param filePath
*/
public static void byteArrayToFile(byte[] bytes, String filePath) throws Exception {
InputStream in = new ByteArrayInputStream(bytes);
File destFile = new File(filePath);
if (!destFile.getParentFile().exists()) {
destFile.getParentFile().mkdirs();
}
destFile.createNewFile();
OutputStream out = new FileOutputStream(destFile);
byte[] cache = new byte[CACHE_SIZE];
int nRead = 0;
while ((nRead = in.read(cache)) != -1) {
out.write(cache, 0, nRead);
out.flush();
try(InputStream in = new ByteArrayInputStream(bytes);
OutputStream out = new FileOutputStream(destFile)){
byte[] cache = new byte[CACHE_SIZE];
int nRead = 0;
while ((nRead = in.read(cache)) != -1) {
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.digest.DigestUtils;
import sun.misc.BASE64Encoder;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
@ -51,22 +52,6 @@ public class DESCrypto {
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{
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{
// 生成一个可信任的随机数源