转至元数据结尾
转至元数据起始

正在查看旧版本。 查看 当前版本.

与当前比较 查看页面历史

版本 1 当前 »

描述

系统中配置完接收方的url和secret后,订单添加/编辑/取消操作将会推送信息给接收方

路径

请求头样例



接收方解密方式


使用AES方式加密。提供接收方解密代码参考如下:

import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.nio.charset.StandardCharsets;
import java.util.Base64;

public class AesDecryptor {

private static final String ALGORITHM = "AES/CBC/PKCS5Padding";
private static final String CHARSET = "UTF-8";

/**
* AES 解密方法
*
* @param cipherText 已加密的 Base64 字符串
* @param secretKey 加密使用的密钥(需与发送方一致)
* @return 原始明文字符串
*/
public static String decrypt(String cipherText, String secretKey) throws Exception {
byte[] encryptedData = Base64.getDecoder().decode(cipherText);

Cipher cipher = Cipher.getInstance(ALGORITHM);
byte[] keyBytes = padKey(secretKey).getBytes(CHARSET);
byte[] ivBytes = new byte[16]; // 使用与加密时相同的 IV(此处为前16字节)
System.arraycopy(keyBytes, 0, ivBytes, 0, 16);

SecretKeySpec keySpec = new SecretKeySpec(keyBytes, "AES");
IvParameterSpec ivSpec = new IvParameterSpec(ivBytes);

cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec);
byte[] decrypted = cipher.doFinal(encryptedData);

return new String(decrypted, StandardCharsets.UTF_8);
}

/**
* 补全密钥至 32 字节(256位)
*/
private static String padKey(String key) {
StringBuilder paddedKey = new StringBuilder(key);
while (paddedKey.length() < 32) {
paddedKey.append("0");
}
return paddedKey.substring(0, 32);
}

// 测试用例
public static void main(String[] args) throws Exception {
String secret = "my-secret-key"; // 可能小于32字节
String original = "{\"orderNo\":\"123456\",\"modifyDate\":\"2023-10-10T12:00:00Z\"}";

// 发送方加密
String encrypted = AesUtils.encrypt(original, secret);
System.out.println("Encrypted: " + encrypted);

// 接收方解密
String decrypted = decrypt(encrypted, secret);
System.out.println("Decrypted: " + decrypted);
}
}


字段

推送字段

Description_CNFieldType

系统订单号orderNoVARCHAR
操作描述operationVARCHAR
操作时间operationTimeVARCHAR
操作人operatorVARCHAR

推送数据试例:

{
"orderNo": "123456",
"operation": "create",
"operationTime": "2023-09-25T12:00:00Z",
"operator": "admin"
}


  • 无标签