feat:通知请求参数解密返回参数T支持String类型
parent
4615b3fccd
commit
849aa32f4f
|
|
@ -101,7 +101,8 @@ public interface ApiClient {
|
||||||
String bodyCiphertext = requestJson.get("body").getAsString();
|
String bodyCiphertext = requestJson.get("body").getAsString();
|
||||||
// 对称解密后body 明文
|
// 对称解密后body 明文
|
||||||
String bodyPlain = getProfile().getPrivacy().getSecretCipher().decrypt(Strings.toBytes(secretKeyPlain), Strings.toBytes(bodyCiphertext));
|
String bodyPlain = getProfile().getPrivacy().getSecretCipher().decrypt(Strings.toBytes(secretKeyPlain), Strings.toBytes(bodyCiphertext));
|
||||||
return Json.fromJson(bodyPlain, requestClass);
|
// T支持返回String
|
||||||
|
return requestClass == String.class ? requestClass.cast(bodyPlain) : Json.fromJson(bodyPlain, requestClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,9 @@ public class NotifyHandler {
|
||||||
/**
|
/**
|
||||||
* 通知请求参数解密
|
* 通知请求参数解密
|
||||||
*
|
*
|
||||||
* @param requestJsonStr 请求参数JSON字符串
|
* @param requestJsonStr 请求参数完整的JSON字符串(包含header及body)
|
||||||
* @param requestClass 请求参数Class
|
* @param requestClass 请求参数类的Class对象
|
||||||
* @return 请求参数
|
* @return 请求参数Object
|
||||||
* @author H.T
|
* @author H.T
|
||||||
* @since 2026/5/19
|
* @since 2026/5/19
|
||||||
*/
|
*/
|
||||||
|
|
@ -33,7 +33,7 @@ public class NotifyHandler {
|
||||||
* 通知应答参数加密
|
* 通知应答参数加密
|
||||||
*
|
*
|
||||||
* @param responseObject 应答参数Object
|
* @param responseObject 应答参数Object
|
||||||
* @return 应答完整JSON
|
* @return 应答完整的JSON字符串(包含header及body)
|
||||||
* @author H.T
|
* @author H.T
|
||||||
* @since 2026/5/19
|
* @since 2026/5/19
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ class NotifyHandlerTest {
|
||||||
|
|
||||||
System.err.println(jsonObject);
|
System.err.println(jsonObject);
|
||||||
System.out.println(notifyHandler.decryptRequest(jsonObject.toString(), OfflineRechargeRefundRequest.class));
|
System.out.println(notifyHandler.decryptRequest(jsonObject.toString(), OfflineRechargeRefundRequest.class));
|
||||||
|
System.out.println(notifyHandler.decryptRequest(jsonObject.toString(), String.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue