mirror of
				https://gitee.com/binary/weixin-java-tools.git
				synced 2025-10-31 18:46:10 +08:00 
			
		
		
		
	♻️ 过时语义不清晰的 decrypt 方法
This commit is contained in:
		| @ -259,7 +259,9 @@ public class WxCryptUtil { | |||||||
|    * @param nonce        随机串,对应URL参数的nonce |    * @param nonce        随机串,对应URL参数的nonce | ||||||
|    * @param encryptedXml 包含 Encrypt 密文的 xml,对应POST请求的数据 |    * @param encryptedXml 包含 Encrypt 密文的 xml,对应POST请求的数据 | ||||||
|    * @return 解密后的原文 |    * @return 解密后的原文 | ||||||
|  |    * @deprecated 由于语义不清晰,置为过时方法,请查看替代方法 {@link #decryptXml} | ||||||
|    */ |    */ | ||||||
|  |   @Deprecated | ||||||
|   public String decrypt(String msgSignature, String timeStamp, String nonce, String encryptedXml) { |   public String decrypt(String msgSignature, String timeStamp, String nonce, String encryptedXml) { | ||||||
|     return decryptXml(msgSignature, timeStamp, nonce, encryptedXml); |     return decryptXml(msgSignature, timeStamp, nonce, encryptedXml); | ||||||
|   } |   } | ||||||
|  | |||||||
| @ -96,7 +96,7 @@ public class WxCryptUtilTest { | |||||||
|  |  | ||||||
|       String encrypt = nodelist1.item(0).getTextContent(); |       String encrypt = nodelist1.item(0).getTextContent(); | ||||||
|       String fromXML = String.format(this.xmlFormat, encrypt); |       String fromXML = String.format(this.xmlFormat, encrypt); | ||||||
|       pc.decrypt("12345", this.timestamp, this.nonce, fromXML); // 这里签名错误 |       pc.decryptXml("12345", this.timestamp, this.nonce, fromXML); // 这里签名错误 | ||||||
|     } catch (RuntimeException e) { |     } catch (RuntimeException e) { | ||||||
|       assertEquals(e.getMessage(), "加密消息签名校验失败"); |       assertEquals(e.getMessage(), "加密消息签名校验失败"); | ||||||
|       return; |       return; | ||||||
|  | |||||||
| @ -463,7 +463,7 @@ public class WxCpXmlMessage implements Serializable { | |||||||
|   public static WxCpXmlMessage fromEncryptedXml(String encryptedXml, WxCpConfigStorage wxCpConfigStorage, |   public static WxCpXmlMessage fromEncryptedXml(String encryptedXml, WxCpConfigStorage wxCpConfigStorage, | ||||||
|                                                 String timestamp, String nonce, String msgSignature) { |                                                 String timestamp, String nonce, String msgSignature) { | ||||||
|     WxCpCryptUtil cryptUtil = new WxCpCryptUtil(wxCpConfigStorage); |     WxCpCryptUtil cryptUtil = new WxCpCryptUtil(wxCpConfigStorage); | ||||||
|     String plainText = cryptUtil.decrypt(msgSignature, timestamp, nonce, encryptedXml); |     String plainText = cryptUtil.decryptXml(msgSignature, timestamp, nonce, encryptedXml); | ||||||
|     log.debug("解密后的原始xml消息内容:{}", plainText); |     log.debug("解密后的原始xml消息内容:{}", plainText); | ||||||
|     return fromXml(plainText); |     return fromXml(plainText); | ||||||
|   } |   } | ||||||
|  | |||||||
| @ -165,7 +165,7 @@ public class WxMaMessage implements Serializable { | |||||||
|   public static WxMaMessage fromEncryptedXml(String encryptedXml, |   public static WxMaMessage fromEncryptedXml(String encryptedXml, | ||||||
|                                              WxMaConfig wxMaConfig, String timestamp, String nonce, |                                              WxMaConfig wxMaConfig, String timestamp, String nonce, | ||||||
|                                              String msgSignature) { |                                              String msgSignature) { | ||||||
|     String plainText = new WxMaCryptUtils(wxMaConfig).decrypt(msgSignature, timestamp, nonce, encryptedXml); |     String plainText = new WxMaCryptUtils(wxMaConfig).decryptXml(msgSignature, timestamp, nonce, encryptedXml); | ||||||
|     return fromXml(plainText); |     return fromXml(plainText); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  | |||||||
| @ -827,7 +827,7 @@ public class WxMpXmlMessage implements Serializable { | |||||||
|   public static WxMpXmlMessage fromEncryptedXml(String encryptedXml, WxMpConfigStorage wxMpConfigStorage, |   public static WxMpXmlMessage fromEncryptedXml(String encryptedXml, WxMpConfigStorage wxMpConfigStorage, | ||||||
|                                                 String timestamp, String nonce, String msgSignature) { |                                                 String timestamp, String nonce, String msgSignature) { | ||||||
|     WxMpCryptUtil cryptUtil = new WxMpCryptUtil(wxMpConfigStorage); |     WxMpCryptUtil cryptUtil = new WxMpCryptUtil(wxMpConfigStorage); | ||||||
|     String plainText = cryptUtil.decrypt(msgSignature, timestamp, nonce, encryptedXml); |     String plainText = cryptUtil.decryptXml(msgSignature, timestamp, nonce, encryptedXml); | ||||||
|     log.debug("解密后的原始xml消息内容:{}", plainText); |     log.debug("解密后的原始xml消息内容:{}", plainText); | ||||||
|     return fromXml(plainText); |     return fromXml(plainText); | ||||||
|   } |   } | ||||||
|  | |||||||
| @ -147,7 +147,7 @@ public class WxOpenXmlMessage implements Serializable { | |||||||
|   public static WxOpenXmlMessage fromEncryptedXml(String encryptedXml, WxOpenConfigStorage wxOpenConfigStorage, |   public static WxOpenXmlMessage fromEncryptedXml(String encryptedXml, WxOpenConfigStorage wxOpenConfigStorage, | ||||||
|                                                   String timestamp, String nonce, String msgSignature) { |                                                   String timestamp, String nonce, String msgSignature) { | ||||||
|     WxOpenCryptUtil cryptUtil = new WxOpenCryptUtil(wxOpenConfigStorage); |     WxOpenCryptUtil cryptUtil = new WxOpenCryptUtil(wxOpenConfigStorage); | ||||||
|     String plainText = cryptUtil.decrypt(msgSignature, timestamp, nonce, encryptedXml); |     String plainText = cryptUtil.decryptXml(msgSignature, timestamp, nonce, encryptedXml); | ||||||
|     log.debug("解密后的原始xml消息内容:{}", plainText); |     log.debug("解密后的原始xml消息内容:{}", plainText); | ||||||
|     return fromXml(plainText); |     return fromXml(plainText); | ||||||
|   } |   } | ||||||
| @ -155,7 +155,7 @@ public class WxOpenXmlMessage implements Serializable { | |||||||
|   public static WxMpXmlMessage fromEncryptedMpXml(String encryptedXml, WxOpenConfigStorage wxOpenConfigStorage, |   public static WxMpXmlMessage fromEncryptedMpXml(String encryptedXml, WxOpenConfigStorage wxOpenConfigStorage, | ||||||
|                                                   String timestamp, String nonce, String msgSignature) { |                                                   String timestamp, String nonce, String msgSignature) { | ||||||
|     WxOpenCryptUtil cryptUtil = new WxOpenCryptUtil(wxOpenConfigStorage); |     WxOpenCryptUtil cryptUtil = new WxOpenCryptUtil(wxOpenConfigStorage); | ||||||
|     String plainText = cryptUtil.decrypt(msgSignature, timestamp, nonce, encryptedXml); |     String plainText = cryptUtil.decryptXml(msgSignature, timestamp, nonce, encryptedXml); | ||||||
|     return WxMpXmlMessage.fromXml(plainText); |     return WxMpXmlMessage.fromXml(plainText); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Scruel Tao
					Scruel Tao