init:项目初始化删除无用依赖

This commit is contained in:
zhangzq
2025-06-24 16:09:54 +08:00
parent 0dcde5740b
commit 303b7a08c9
15 changed files with 412 additions and 968 deletions

View File

@@ -1,105 +1,105 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.nl.common.mnt.util;
import ch.ethz.ssh2.Connection;
import ch.ethz.ssh2.SCPClient;
import com.google.common.collect.Maps;
import java.io.IOException;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* 远程执行linux命令
* @author: ZhangHouYing
* @date: 2019-08-10 10:06
*/
public class ScpClientUtil {
static private Map<String,ScpClientUtil> instance = Maps.newHashMap();
static synchronized public ScpClientUtil getInstance(String ip, int port, String username, String password) {
if (instance.get(ip) == null) {
instance.put(ip, new ScpClientUtil(ip, port, username, password));
}
return instance.get(ip);
}
public ScpClientUtil(String ip, int port, String username, String password) {
this.ip = ip;
this.port = port;
this.username = username;
this.password = password;
}
public void getFile(String remoteFile, String localTargetDirectory) {
Connection conn = new Connection(ip, port);
try {
conn.connect();
boolean isAuthenticated = conn.authenticateWithPassword(username, password);
if (!isAuthenticated) {
System.err.println("authentication failed");
}
SCPClient client = new SCPClient(conn);
client.get(remoteFile, localTargetDirectory);
} catch (IOException ex) {
Logger.getLogger(SCPClient.class.getName()).log(Level.SEVERE, null, ex);
}finally{
conn.close();
}
}
public void putFile(String localFile, String remoteTargetDirectory) {
putFile(localFile, null, remoteTargetDirectory);
}
public void putFile(String localFile, String remoteFileName, String remoteTargetDirectory) {
putFile(localFile, remoteFileName, remoteTargetDirectory,null);
}
public void putFile(String localFile, String remoteFileName, String remoteTargetDirectory, String mode) {
Connection conn = new Connection(ip, port);
try {
conn.connect();
boolean isAuthenticated = conn.authenticateWithPassword(username, password);
if (!isAuthenticated) {
System.err.println("authentication failed");
}
SCPClient client = new SCPClient(conn);
if ((mode == null) || (mode.length() == 0)) {
mode = "0600";
}
if (remoteFileName == null) {
client.put(localFile, remoteTargetDirectory);
} else {
client.put(localFile, remoteFileName, remoteTargetDirectory, mode);
}
} catch (IOException ex) {
Logger.getLogger(ScpClientUtil.class.getName()).log(Level.SEVERE, null, ex);
}finally{
conn.close();
}
}
private String ip;
private int port;
private String username;
private String password;
}
///*
// * Copyright 2019-2020 Zheng Jie
// *
// * Licensed under the Apache License, Version 2.0 (the "License");
// * you may not use this file except in compliance with the License.
// * You may obtain a copy of the License at
// *
// * http://www.apache.org/licenses/LICENSE-2.0
// *
// * Unless required by applicable law or agreed to in writing, software
// * distributed under the License is distributed on an "AS IS" BASIS,
// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// * See the License for the specific language governing permissions and
// * limitations under the License.
// */
//package org.nl.common.mnt.util;
//
//import ch.ethz.ssh2.Connection;
//import ch.ethz.ssh2.SCPClient;
//import com.google.common.collect.Maps;
//
//import java.io.IOException;
//import java.util.Map;
//import java.util.logging.Level;
//import java.util.logging.Logger;
//
///**
// * 远程执行linux命令
// * @author: ZhangHouYing
// * @date: 2019-08-10 10:06
// */
//public class ScpClientUtil {
//
// static private Map<String,ScpClientUtil> instance = Maps.newHashMap();
//
// static synchronized public ScpClientUtil getInstance(String ip, int port, String username, String password) {
// if (instance.get(ip) == null) {
// instance.put(ip, new ScpClientUtil(ip, port, username, password));
// }
// return instance.get(ip);
// }
//
// public ScpClientUtil(String ip, int port, String username, String password) {
// this.ip = ip;
// this.port = port;
// this.username = username;
// this.password = password;
// }
//
// public void getFile(String remoteFile, String localTargetDirectory) {
// Connection conn = new Connection(ip, port);
// try {
// conn.connect();
// boolean isAuthenticated = conn.authenticateWithPassword(username, password);
// if (!isAuthenticated) {
// System.err.println("authentication failed");
// }
// SCPClient client = new SCPClient(conn);
// client.get(remoteFile, localTargetDirectory);
// } catch (IOException ex) {
// Logger.getLogger(SCPClient.class.getName()).log(Level.SEVERE, null, ex);
// }finally{
// conn.close();
// }
// }
//
// public void putFile(String localFile, String remoteTargetDirectory) {
// putFile(localFile, null, remoteTargetDirectory);
// }
//
// public void putFile(String localFile, String remoteFileName, String remoteTargetDirectory) {
// putFile(localFile, remoteFileName, remoteTargetDirectory,null);
// }
//
// public void putFile(String localFile, String remoteFileName, String remoteTargetDirectory, String mode) {
// Connection conn = new Connection(ip, port);
// try {
// conn.connect();
// boolean isAuthenticated = conn.authenticateWithPassword(username, password);
// if (!isAuthenticated) {
// System.err.println("authentication failed");
// }
// SCPClient client = new SCPClient(conn);
// if ((mode == null) || (mode.length() == 0)) {
// mode = "0600";
// }
// if (remoteFileName == null) {
// client.put(localFile, remoteTargetDirectory);
// } else {
// client.put(localFile, remoteFileName, remoteTargetDirectory, mode);
// }
// } catch (IOException ex) {
// Logger.getLogger(ScpClientUtil.class.getName()).log(Level.SEVERE, null, ex);
// }finally{
// conn.close();
// }
// }
//
// private String ip;
// private int port;
// private String username;
// private String password;
//
//
//}

View File

@@ -1,138 +1,138 @@
package org.nl.common.utils;
//package org.nl.common.utils;
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
////
//// Source code recreated from a .class file by IntelliJ IDEA
//// (powered by FernFlower decompiler)
////
//
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;
import javax.crypto.spec.IvParameterSpec;
import java.io.IOException;
import java.security.SecureRandom;
/**
* <p>
* Des加密解密算法工具类
* </p>
*
* @author lyd
* @since 2023-05-03
*/
public class DesUtil {
/**
* 加密算法是des
*/
private static final String ALGORITHM = "DES";
/**
* 转换格式
*/
private static final String TRANSFORMATION = "DES/CBC/PKCS5Padding";
/**
* 加密
*
* @param src 数据源
* @param key 密钥长度必须是8的倍数
* @return 返回加密后的数据
* @throws Exception 出错
*/
public static byte[] encrypt(byte[] src, byte[] key) throws Exception {
// DES算法要求有一个可信任的随机数源
SecureRandom sr = new SecureRandom();
// 从原始密匙数据建立 DESKeySpec对象
DESKeySpec dks = new DESKeySpec(key);
// 建立一个密匙工厂然后用它把DESKeySpec转换成
// 一个SecretKey对象
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(ALGORITHM);
SecretKey securekey = keyFactory.generateSecret(dks);
// Cipher对象实际完成加密操作
Cipher cipher = Cipher.getInstance(TRANSFORMATION);
// 用密匙原始化Cipher对象
cipher.init(Cipher.ENCRYPT_MODE, securekey, new IvParameterSpec(key));
// 现在,获取数据并加密
// 正式执行加密操作
return cipher.doFinal(src);
}
/**
* 解密
*
* @param src 数据源
* @param key 密钥长度必须是8的倍数
* @return 返回解密后的原始数据
* @throws Exception 出错
*/
public static byte[] decrypt(byte[] src, byte[] key) throws Exception {
// DES算法要求有一个可信任的随机数源
SecureRandom sr = new SecureRandom();
// 从原始密匙数据建立一个DESKeySpec对象
DESKeySpec dks = new DESKeySpec(key);
// 建立一个密匙工厂然后用它把DESKeySpec对象转换成
// 一个SecretKey对象
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(ALGORITHM);
SecretKey securekey = keyFactory.generateSecret(dks);
// Cipher对象实际完成解密操作
Cipher cipher = Cipher.getInstance(TRANSFORMATION);
// 用密匙原始化Cipher对象
cipher.init(Cipher.DECRYPT_MODE, securekey, new IvParameterSpec(key));
// 现在,获取数据并解密
// 正式执行解密操作
return cipher.doFinal(src);
}
/**
* Description 根据键值进行加密
*
* @param data
* @param key 加密键byte数组
* @return
* @throws Exception
*/
public static String encrypt(String data, String key) throws Exception {
byte[] bt = encrypt(data.getBytes("UTF-8"), key.getBytes("UTF-8"));
BASE64Encoder encoder = new BASE64Encoder();
return encoder.encode(bt);
//return new String(Base64.encodeBase64(bt), "UTF-8");
}
/**
* Description 根据键值进行解密
*
* @param data
* @param key 加密键byte数组
* @return
* @throws IOException
* @throws Exception
*/
public static String decrypt(String data, String key) throws Exception {
if (data == null)
return null;
BASE64Decoder decoder = new BASE64Decoder();
byte[] buf = decoder.decodeBuffer(data);
byte[] bt = decrypt(buf, key.getBytes("UTF-8"));
return new String(bt, "UTF-8");
}
public static void main(String[] args) throws Exception {
//uL8fXioyU2M=
String key = "11111111";
String pp = encrypt("123456", key);
System.out.println("加密:" + pp);
String mm2 = decrypt(pp, key);
System.out.println("解密:" + mm2);
}
}
//
//import sun.misc.BASE64Decoder;
//import sun.misc.BASE64Encoder;
//
//import javax.crypto.Cipher;
//import javax.crypto.SecretKey;
//import javax.crypto.SecretKeyFactory;
//import javax.crypto.spec.DESKeySpec;
//import javax.crypto.spec.IvParameterSpec;
//import java.io.IOException;
//import java.security.SecureRandom;
//
///**
// * <p>
// * Des加密解密算法工具类
// * </p>
// *
// * @author lyd
// * @since 2023-05-03
// */
//public class DesUtil {
// /**
// * 加密算法是des
// */
// private static final String ALGORITHM = "DES";
// /**
// * 转换格式
// */
// private static final String TRANSFORMATION = "DES/CBC/PKCS5Padding";
//
// /**
// * 加密
// *
// * @param src 数据源
// * @param key 密钥长度必须是8的倍数
// * @return 返回加密后的数据
// * @throws Exception 出错
// */
// public static byte[] encrypt(byte[] src, byte[] key) throws Exception {
// // DES算法要求有一个可信任的随机数源
// SecureRandom sr = new SecureRandom();
// // 从原始密匙数据建立 DESKeySpec对象
// DESKeySpec dks = new DESKeySpec(key);
// // 建立一个密匙工厂然后用它把DESKeySpec转换成
// // 一个SecretKey对象
// SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(ALGORITHM);
// SecretKey securekey = keyFactory.generateSecret(dks);
// // Cipher对象实际完成加密操作
// Cipher cipher = Cipher.getInstance(TRANSFORMATION);
// // 用密匙原始化Cipher对象
// cipher.init(Cipher.ENCRYPT_MODE, securekey, new IvParameterSpec(key));
// // 现在,获取数据并加密
// // 正式执行加密操作
// return cipher.doFinal(src);
// }
//
// /**
// * 解密
// *
// * @param src 数据源
// * @param key 密钥长度必须是8的倍数
// * @return 返回解密后的原始数据
// * @throws Exception 出错
// */
// public static byte[] decrypt(byte[] src, byte[] key) throws Exception {
// // DES算法要求有一个可信任的随机数源
// SecureRandom sr = new SecureRandom();
// // 从原始密匙数据建立一个DESKeySpec对象
// DESKeySpec dks = new DESKeySpec(key);
// // 建立一个密匙工厂然后用它把DESKeySpec对象转换成
// // 一个SecretKey对象
// SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(ALGORITHM);
// SecretKey securekey = keyFactory.generateSecret(dks);
// // Cipher对象实际完成解密操作
// Cipher cipher = Cipher.getInstance(TRANSFORMATION);
// // 用密匙原始化Cipher对象
// cipher.init(Cipher.DECRYPT_MODE, securekey, new IvParameterSpec(key));
// // 现在,获取数据并解密
// // 正式执行解密操作
// return cipher.doFinal(src);
// }
//
// /**
// * Description 根据键值进行加密
// *
// * @param data
// * @param key 加密键byte数组
// * @return
// * @throws Exception
// */
// public static String encrypt(String data, String key) throws Exception {
// byte[] bt = encrypt(data.getBytes("UTF-8"), key.getBytes("UTF-8"));
//
// BASE64Encoder encoder = new BASE64Encoder();
// return encoder.encode(bt);
//
// //return new String(Base64.encodeBase64(bt), "UTF-8");
// }
//
// /**
// * Description 根据键值进行解密
// *
// * @param data
// * @param key 加密键byte数组
// * @return
// * @throws IOException
// * @throws Exception
// */
// public static String decrypt(String data, String key) throws Exception {
// if (data == null)
// return null;
// BASE64Decoder decoder = new BASE64Decoder();
// byte[] buf = decoder.decodeBuffer(data);
//
// byte[] bt = decrypt(buf, key.getBytes("UTF-8"));
// return new String(bt, "UTF-8");
// }
//
//
// public static void main(String[] args) throws Exception {
// //uL8fXioyU2M=
// String key = "11111111";
// String pp = encrypt("123456", key);
// System.out.println("加密:" + pp);
//
// String mm2 = decrypt(pp, key);
// System.out.println("解密:" + mm2);
//
// }
//
//}

View File

@@ -21,8 +21,6 @@ import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import net.dreamlu.mica.ip2region.core.Ip2regionSearcher;
import net.dreamlu.mica.ip2region.core.IpInfo;
import nl.basjes.parse.useragent.UserAgent;
import nl.basjes.parse.useragent.UserAgentAnalyzer;
import org.nl.config.ElAdminProperties;
import org.nl.config.SpringContextHolder;
@@ -50,13 +48,6 @@ public class StringUtils {
private final static Ip2regionSearcher IP_SEARCHER = SpringContextHolder.getBean(Ip2regionSearcher.class);
private static final UserAgentAnalyzer USER_AGENT_ANALYZER = UserAgentAnalyzer
.newBuilder()
.hideMatcherLoadStats()
.withCache(10000)
.withField(UserAgent.AGENT_NAME_VERSION)
.build();
/**
* 驼峰命名法工具
*
@@ -209,10 +200,9 @@ public class StringUtils {
return null;
}
//浏览器信息
public static String getBrowser(HttpServletRequest request) {
UserAgent.ImmutableUserAgent userAgent = USER_AGENT_ANALYZER.parse(request.getHeader("User-Agent"));
return userAgent.get(UserAgent.AGENT_NAME_VERSION).getValue();
return "";
}
/**