Appearance
接口通用说明
API 调用时序图
详细流程解析
说明:进件成功需媒体提供用户签订三方协议证明,存证后我方(智瑀)返回进件结果。(如有特殊情况不能及时返回三方存证请联系商务人员)
接口描述
接口的入参都是通过post请求
请求环境
测试环境域名:https://tapi.zhiyusmart.com.cn
生产环境域名:https://api.zhiyusmart.com.cn
关于 appid
联系运营人员获取
关于加密
为了提高效率,建议直接使用下面的demo加密逻辑
我方会提供公钥(联系运营人员)
java
public class demo {
public static void main(String[] args) throws NoSuchAlgorithmException {
//生成一个随机aeskey
String aesKey = MediaEncryptUtils.generateAESKey();
//使用aeskey加密请求参数 并且base64
String secketDate = MediaEncryptUtils.encryptData(requestBody.toJSONString(), aesKey);
//使用aeskey 机密公钥,并且base64
String secPublic = MediaEncryptUtils.encryptKey(publicKey, aesKey);
JSONObject resultJson = new JSONObject();
resultJson.put("aesKey", secPublic);
resultJson.put("bizData", secketDate);
}
}
public class MediaEncryptUtils{
/**
* 随机生成一个aesKey
*
* @return SecretKey
* @throws Exception
*/
public static String generateAESKey() throws Exception {
KeyGenerator keyGenerator = KeyGenerator.getInstance("AES");
keyGenerator.init(128);
return Base64.getEncoder().encodeToString(keyGenerator.generateKey().getEncoded());
}
/**
* 使用AES密钥加密传输数据
*
* @param jsonData json数据
* @param aesKey 临时密钥
* @return String
* @throws Exception
*/
public static String encryptData(String jsonData, String aesKey) throws Exception {
SecretKeySpec key = new SecretKeySpec(Base64.getDecoder().decode(aesKey), "AES");
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, key);
byte[] encryptedJson = cipher.doFinal(jsonData.getBytes(StandardCharsets.UTF_8));
return Base64.getEncoder().encodeToString(encryptedJson);
}
/**
* 使用RSA公钥加密随机AES密钥
*
* @param publicRSAKey RSA公钥
* @return String
* @throws Exception
*/
public static String encryptKey(String publicRSAKey, String aesKey) throws Exception {
byte[] publicKeyData = Base64.getDecoder().decode(publicRSAKey);
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
PublicKey publicKey = keyFactory.generatePublic(new X509EncodedKeySpec(publicKeyData));
Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
cipher.init(Cipher.ENCRYPT_MODE, publicKey);
byte[] encryptedKey = cipher.doFinal(Base64.getDecoder().decode(aesKey));
return Base64.getEncoder().encodeToString(encryptedKey);
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
请求方式
POST
请求参数
Header
| 参数名 | 参数值 | 必填 | 描述 |
|---|---|---|---|
| Content-Type | application/json | Y | body传递json格式参数 |
Param
| 参数名 | 类型 | 必选 | 描述 |
|---|---|---|---|
| appid | String | Y | 联系运营人员 |
Body
注意,各接口中的省份城市信息需与附录 city.json 信息一致。
| 参数名 | 类型 | 必选 | 描述 |
|---|---|---|---|
| aesKey | String | Y | 密文:RSA加密后的AESkey base64 |
| bizData | String | Y | 密文:AES加密后的业务数据 base64 |
请求示例
json
appid=10000
{
"aesKey": "",
"bizData": ""
}1
2
3
4
5
2
3
4
5
返回参数
| 参数名 | 类型 | 必选 | 描述 |
|---|---|---|---|
| code | Integer | Y | 200成功,不等于200都是失败 |
| msg | String | N | 失败原因 |
| data | object | N | 返回值 |
| requestId | String | Y | 请求ID用于排查问题 |
返回示例
json
{
"code": 0,
"msg": "",
"data": object,
"requestId": ""
}1
2
3
4
5
6
2
3
4
5
6