| 
					
				 | 
			
			
				@@ -1,18 +1,12 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-package org.dromara.cryptapi.filter; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+package org.dromara.common.encrypt.filter; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import cn.hutool.core.codec.Base64; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.hutool.core.io.IoUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import jakarta.servlet.ReadListener; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import jakarta.servlet.ServletInputStream; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import jakarta.servlet.http.HttpServletRequest; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import jakarta.servlet.http.HttpServletRequestWrapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.dromara.common.core.constant.Constants; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.dromara.common.core.exception.base.BaseException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.dromara.common.core.utils.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.dromara.cryptapi.core.AesEncryptor; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.dromara.cryptapi.core.EncryptContext; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.dromara.cryptapi.core.RsaEncryptor; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.dromara.cryptapi.enums.EncodeType; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.dromara.common.encrypt.utils.EncryptUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.http.MediaType; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.io.BufferedReader; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -30,21 +24,18 @@ public class DecryptRequestBodyWrapper extends HttpServletRequestWrapper { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private final byte[] body; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public DecryptRequestBodyWrapper(HttpServletRequest request, RsaEncryptor rsaEncryptor, String headerFlag) throws IOException { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public DecryptRequestBodyWrapper(HttpServletRequest request, String publicKey, String privateKey, String headerFlag) throws IOException { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         super(request); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        String requestRsa = request.getHeader(headerFlag); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (StringUtils.isEmpty(requestRsa)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            throw new BaseException("加密AES的动态密码不能为空"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        String decryptAes = new String(Base64.decode(rsaEncryptor.decrypt(requestRsa))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 获取 AES 密码 采用 RSA 加密 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String headerRsa = request.getHeader(headerFlag); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String decryptAes = EncryptUtils.decryptByRsa(headerRsa, privateKey); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 解密 AES 密码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String aesPassword = EncryptUtils.decryptByBase64(decryptAes); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         request.setCharacterEncoding(Constants.UTF8); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         byte[] readBytes = IoUtil.readBytes(request.getInputStream(), false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        String requestBody = StringUtils.toEncodedString(readBytes, StandardCharsets.UTF_8); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        EncryptContext encryptContext = new EncryptContext(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        encryptContext.setPassword(decryptAes); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        encryptContext.setEncode(EncodeType.BASE64); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        AesEncryptor aesEncryptor = new AesEncryptor(encryptContext); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        String decryptBody = aesEncryptor.decrypt(requestBody); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String requestBody = new String(readBytes, StandardCharsets.UTF_8); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 解密 body 采用 AES 加密 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String decryptBody = EncryptUtils.decryptByAes(requestBody, aesPassword); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         body = decryptBody.getBytes(StandardCharsets.UTF_8); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 |