From df05fc5ccd9302ccca1e92c2c8ca24c272a658e4 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期三, 13 十一月 2024 16:41:56 +0800 Subject: [PATCH] 1 --- se-auth/src/main/java/com/se/auth/controller/HealthController.java | 7 - se-modules/se-system/src/main/java/com/se/system/controller/HealthController.java | 7 - se-modules/se-system/src/main/java/com/se/system/service/impl/IsimUserService.java | 6 - se-modules/se-system/src/main/resources/logback.xml | 2 se-common/se-common-core/src/main/java/com/se/common/core/utils/AesUtils.java | 71 ----------------- se-modules/se-system/src/main/java/com/se/system/service/impl/SyncUserService.java | 7 - se-common/se-common-core/src/main/java/com/se/common/core/utils/RsaUtils.java | 81 ------------------- docker-compose/docker-compose.yml | 2 se-gateway/src/main/java/com/se/gateway/handler/HealthController.java | 7 - 9 files changed, 7 insertions(+), 183 deletions(-) diff --git a/docker-compose/docker-compose.yml b/docker-compose/docker-compose.yml index 041a6f9..4eff45d 100644 --- a/docker-compose/docker-compose.yml +++ b/docker-compose/docker-compose.yml @@ -38,7 +38,7 @@ # - 7848:7848 - 8848:8848 - 9848:9848 -# - 9849:9849 +# - 9849:9849 depends_on: - se-mysql networks: diff --git a/se-auth/src/main/java/com/se/auth/controller/HealthController.java b/se-auth/src/main/java/com/se/auth/controller/HealthController.java index dc39dc1..d032018 100644 --- a/se-auth/src/main/java/com/se/auth/controller/HealthController.java +++ b/se-auth/src/main/java/com/se/auth/controller/HealthController.java @@ -5,13 +5,8 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -/** - * 鍋ュ悍鎺у埗鍣� - * - * @author WWW - * @date 2024-08-24 - */ @RestController +@SuppressWarnings("ALL") public class HealthController extends BaseController { @GetMapping("/health") public long test() { diff --git a/se-common/se-common-core/src/main/java/com/se/common/core/utils/AesUtils.java b/se-common/se-common-core/src/main/java/com/se/common/core/utils/AesUtils.java index bf450f6..57a1291 100644 --- a/se-common/se-common-core/src/main/java/com/se/common/core/utils/AesUtils.java +++ b/se-common/se-common-core/src/main/java/com/se/common/core/utils/AesUtils.java @@ -4,77 +4,30 @@ import javax.crypto.spec.SecretKeySpec; import java.util.Base64; -/** - * AES鍔犲瘑宸ュ叿 - * - * @author WWW - * @date 2024-08-25 - */ @SuppressWarnings("ALL") public class AesUtils { - /** - * 瀵嗛挜闀垮害蹇呴』鏄�16 - */ private static final String DEFAULT_KEY = "A#s_zZ3seRve_k.y"; private static final String KEY_ALGORITHM = "AES"; - /** - * 绠楁硶 - */ private static final String ALGORITHMSTR = "AES/ECB/PKCS5Padding"; - /** - * aes瑙e瘑 - * - * @param encrypt 鍐呭 - * @return - * @throws Exception - */ public static String decrypt(String encrypt) throws Exception { return decrypt(encrypt, DEFAULT_KEY); } - /** - * aes鍔犲瘑 - * - * @param content 鍐呭 - * @return - * @throws Exception - */ public static String encrypt(String content) throws Exception { return encrypt(content, DEFAULT_KEY); } - /** - * base 64 encode - * - * @param bytes 寰呯紪鐮佺殑byte[] - * @return 缂栫爜鍚庣殑base64 code - */ private static String base64Encode(byte[] bytes) { return Base64.getEncoder().encodeToString(bytes); } - /** - * base 64 decode - * - * @param base64Code 寰呰В鐮佺殑base64 code - * @return 瑙g爜鍚庣殑byte[] - * @throws Exception - */ private static byte[] base64Decode(String base64Code) { return StringUtils.isEmpty(base64Code) ? null : Base64.getDecoder().decode(base64Code); } - /** - * AES鍔犲瘑 - * - * @param content 寰呭姞瀵嗙殑鍐呭 - * @param encryptKey 鍔犲瘑瀵嗛挜 - * @return 鍔犲瘑鍚庣殑byte[] - * @throws Exception - */ private static byte[] aesEncryptToBytes(String content, String encryptKey) throws Exception { // KeyGenerator kGen = KeyGenerator.getInstance(KEY_ALGORITHM) // kGen.init(128) @@ -85,38 +38,14 @@ return cipher.doFinal(content.getBytes("utf-8")); } - /** - * AES鍔犲瘑涓篵ase 64 code - * - * @param content 寰呭姞瀵嗙殑鍐呭 - * @param encryptKey 鍔犲瘑瀵嗛挜 - * @return 鍔犲瘑鍚庣殑base 64 code - * @throws Exception - */ public static String encrypt(String content, String encryptKey) throws Exception { return base64Encode(aesEncryptToBytes(content, encryptKey)); } - /** - * 灏哹ase 64 code AES瑙e瘑 - * - * @param encryptStr 寰呰В瀵嗙殑base 64 code - * @param decryptKey 瑙e瘑瀵嗛挜 - * @return 瑙e瘑鍚庣殑string - * @throws Exception - */ public static String decrypt(String encryptStr, String decryptKey) throws Exception { return StringUtils.isEmpty(encryptStr) ? null : aesDecryptByBytes(base64Decode(encryptStr), decryptKey); } - /** - * AES瑙e瘑 - * - * @param encryptBytes 寰呰В瀵嗙殑byte[] - * @param decryptKey 瑙e瘑瀵嗛挜 - * @return 瑙e瘑鍚庣殑String - * @throws Exception - */ private static String aesDecryptByBytes(byte[] encryptBytes, String decryptKey) throws Exception { // KeyGenerator kGen = KeyGenerator.getInstance(KEY_ALGORITHM) // kGen.init(128) diff --git a/se-common/se-common-core/src/main/java/com/se/common/core/utils/RsaUtils.java b/se-common/se-common-core/src/main/java/com/se/common/core/utils/RsaUtils.java index 27010cf..49ee43e 100644 --- a/se-common/se-common-core/src/main/java/com/se/common/core/utils/RsaUtils.java +++ b/se-common/se-common-core/src/main/java/com/se/common/core/utils/RsaUtils.java @@ -16,53 +16,24 @@ import java.util.HashMap; import java.util.Map; -/** - * RSA宸ュ叿绫� - * - * @author WWW - * @date 2024-08-25 - */ +@SuppressWarnings("ALL") public class RsaUtils { - /** - * 绉侀挜 - */ private static String privateKey; - /** - * 鍏挜 - */ private static String publicKey; - /** - * 瀵嗛挜绠楁硶 - */ private static final String KEY_ALGORITHM = "RSA"; - /** - * RSA瀵嗛挜闀垮害锛�1024 鎴� 2048 - */ private static final int DEFAULT_RSA_KEY_SIZE = 1024; - /** - * 鏃ュ織 - */ private static final Logger log = LoggerFactory.getLogger(RsaUtils.class); - /** - * 鐢熸垚鍏閽� - */ public static void generate() { Map<String, String> result = generateRsaKey(DEFAULT_RSA_KEY_SIZE); System.out.println("鍏挜涓猴細" + result.get("publicKey")); System.out.println("绉侀挜涓猴細" + result.get("privateKey")); } - /** - * 鑾峰彇RSA鍔犲瘑绉侀挜 - * - * @return - * @throws IOException - */ public static String getPrivateKey() throws IOException { if (privateKey == null) { InputStream inPrivate = new ClassPathResource("config" + File.separator + "rsa_private_key.txt").getInputStream(); @@ -73,12 +44,6 @@ return privateKey; } - /** - * 鑾峰彇RSA鍔犲瘑鍏挜 - * - * @return - * @throws IOException - */ public static String getPublicKey() throws IOException { if (publicKey == null) { InputStream inPrivate = new ClassPathResource("config" + File.separator + "rsa_public_key.txt").getInputStream(); @@ -89,13 +54,6 @@ return publicKey; } - /** - * 璇诲彇鏂囨湰鏂囦欢 - * - * @param fileName 鏂囦欢璺緞 - * @return - * @throws IOException - */ public static String readFile(String fileName) throws IOException { File file = new File(fileName); BufferedReader br = new BufferedReader(new FileReader(file)); @@ -111,13 +69,6 @@ return result.toString(); } - /** - * 鎶奿nputStream杞垚String - * - * @param is - * @return - * @throws IOException - */ private static String inputStream2String(InputStream is) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); @@ -132,28 +83,18 @@ return str; } - /** - * 鐢熸垚RSA鐨勫叕绉侀挜 - * - * @param keySize 1025 鎴� 2048 - * @return - */ public static Map<String, String> generateRsaKey(int keySize) { Map<String, String> result = new HashMap<>(2); try { KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance(KEY_ALGORITHM); - // 鍒濆鍖栧瘑閽ュ鐢熸垚鍣紝瀵嗛挜澶у皬涓�1024 2048浣� keyPairGen.initialize(keySize, new SecureRandom()); - // 鐢熸垚涓�涓瘑閽ュ锛屼繚瀛樺湪keyPair涓� KeyPair keyPair = keyPairGen.generateKeyPair(); - // 寰楀埌鍏挜瀛楃涓� String pub = new String(Base64.encodeBase64(keyPair.getPublic().getEncoded())); result.put("publicKey", pub); - // 寰楀埌绉侀挜瀛楃涓� String pri = new String(Base64.encodeBase64(keyPair.getPrivate().getEncoded())); result.put("privateKey", pri); } catch (Exception ex) { @@ -163,22 +104,13 @@ return result; } - /** - * RSA绉侀挜瑙e瘑 - * - * @param str 鍔犲瘑鐨勫瓧绗︿覆 - * @return 瑙e瘑瀛楃涓� - * @throws Exception 鍔犲瘑杩囩▼涓殑寮傚父淇℃伅 - */ public static String decrypt(String str) throws Exception { - // 64浣嶈В鐮佸姞瀵嗗悗鐨勫瓧绗︿覆 byte[] inputByte = Base64.decodeBase64(str.getBytes(StandardCharsets.UTF_8)); - // Base64缂栫爜鐨勭閽� byte[] decoded = Base64.decodeBase64(getPrivateKey()); RSAPrivateKey priKey = (RSAPrivateKey) KeyFactory.getInstance("RSA").generatePrivate(new PKCS8EncodedKeySpec(decoded)); - // RSA瑙e瘑锛歊SA/ECB/NoPadding + // RSA/ECB/NoPadding Cipher cipher = Cipher.getInstance("RSA"); cipher.init(Cipher.DECRYPT_MODE, priKey); @@ -187,20 +119,11 @@ return outStr; } - /** - * RSA鍏挜鍔犲瘑 - * - * @param str 闇�瑕佸姞瀵嗙殑瀛楃涓� - * @return 瀵嗘枃 - * @throws Exception 鍔犲瘑杩囩▼涓殑寮傚父淇℃伅 - */ public static String encrypt(String str) throws Exception { - // Base64缂栫爜鐨勫叕閽� byte[] decoded = Base64.decodeBase64(getPublicKey()); RSAPublicKey pubKey = (RSAPublicKey) KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(decoded)); - // RSA鍔犲瘑锛歊SA/ECB/NoPadding Cipher cipher = Cipher.getInstance("RSA"); cipher.init(Cipher.ENCRYPT_MODE, pubKey); diff --git a/se-gateway/src/main/java/com/se/gateway/handler/HealthController.java b/se-gateway/src/main/java/com/se/gateway/handler/HealthController.java index 74a663f..f29afb5 100644 --- a/se-gateway/src/main/java/com/se/gateway/handler/HealthController.java +++ b/se-gateway/src/main/java/com/se/gateway/handler/HealthController.java @@ -5,13 +5,8 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -/** - * 鍋ュ悍鎺у埗鍣� - * - * @author WWW - * @date 2024-08-24 - */ @RestController +@SuppressWarnings("ALL") @RequestMapping("/gateway") public class HealthController extends BaseController { @GetMapping("/health") diff --git a/se-modules/se-system/src/main/java/com/se/system/controller/HealthController.java b/se-modules/se-system/src/main/java/com/se/system/controller/HealthController.java index 2a2b41b..d22e460 100644 --- a/se-modules/se-system/src/main/java/com/se/system/controller/HealthController.java +++ b/se-modules/se-system/src/main/java/com/se/system/controller/HealthController.java @@ -4,13 +4,8 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; -/** - * 鍋ュ悍鎺у埗鍣� - * - * @author WWW - * @date 2024-08-24 - */ @RestController +@SuppressWarnings("ALL") public class HealthController extends BaseController { @GetMapping("/health") public long test() { diff --git a/se-modules/se-system/src/main/java/com/se/system/service/impl/IsimUserService.java b/se-modules/se-system/src/main/java/com/se/system/service/impl/IsimUserService.java index b38cd56..d908f46 100644 --- a/se-modules/se-system/src/main/java/com/se/system/service/impl/IsimUserService.java +++ b/se-modules/se-system/src/main/java/com/se/system/service/impl/IsimUserService.java @@ -6,12 +6,6 @@ import java.util.List; -/** - * ISIM鐢ㄦ埛鏈嶅姟 - * - * @author WWW - * @date 2024-08-30 - */ @Slf4j @Service @SuppressWarnings("ALL") diff --git a/se-modules/se-system/src/main/java/com/se/system/service/impl/SyncUserService.java b/se-modules/se-system/src/main/java/com/se/system/service/impl/SyncUserService.java index e76767c..7d88aba 100644 --- a/se-modules/se-system/src/main/java/com/se/system/service/impl/SyncUserService.java +++ b/se-modules/se-system/src/main/java/com/se/system/service/impl/SyncUserService.java @@ -11,12 +11,6 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -/** - * 鐢ㄦ埛鍚屾鏈嶅姟 - * - * @author WWW - * @date 2024-08-30 - */ @Slf4j @Service @SuppressWarnings("ALL") @@ -25,7 +19,6 @@ IsimUserService isimUserService; public void insertUser(SysUser user) { - // supplyAsync-甯﹁繑鍥炲�硷紝runAsync-鏃犺繑鍥炲�� CompletableFuture.runAsync(() -> { isimUserService.insertUser(user); }); diff --git a/se-modules/se-system/src/main/resources/logback.xml b/se-modules/se-system/src/main/resources/logback.xml index a60457c..5138555 100644 --- a/se-modules/se-system/src/main/resources/logback.xml +++ b/se-modules/se-system/src/main/resources/logback.xml @@ -58,7 +58,7 @@ </appender> <!-- 绯荤粺妯″潡鏃ュ織绾у埆鎺у埗:info,debug --> - <logger name="com.se" level="info" /> + <logger name="com.se" level="debug" /> <!-- Spring鏃ュ織绾у埆鎺у埗 --> <logger name="org.springframework" level="warn" /> -- Gitblit v1.9.3