This commit is contained in:
parent
4a77e8e9cb
commit
5f925b1ffe
|
@ -51,6 +51,19 @@
|
||||||
<artifactId>mysql-connector-j</artifactId>
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- tcctyn Common DataSource -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.tcctyn</groupId>
|
||||||
|
<artifactId>tcctyn-common-datasource</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- tcctyn Common DataScope -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.tcctyn</groupId>
|
||||||
|
<artifactId>tcctyn-common-datascope</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<!-- tcctyn Common Log -->
|
<!-- tcctyn Common Log -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tcctyn</groupId>
|
<groupId>com.tcctyn</groupId>
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
package com.tcctyn.iot.common.config;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Jason
|
|
||||||
* @date 2025年05月22日 15:13:27
|
|
||||||
*/
|
|
||||||
public class test {
|
|
||||||
}
|
|
|
@ -4,8 +4,14 @@ import com.alibaba.fastjson.JSON;
|
||||||
import com.hikvision.artemis.sdk.ArtemisHttpUtil;
|
import com.hikvision.artemis.sdk.ArtemisHttpUtil;
|
||||||
import com.hikvision.artemis.sdk.config.ArtemisConfig;
|
import com.hikvision.artemis.sdk.config.ArtemisConfig;
|
||||||
|
|
||||||
|
import javax.crypto.Mac;
|
||||||
|
import javax.crypto.spec.SecretKeySpec;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.Base64;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Jason
|
* @author Jason
|
||||||
|
@ -29,7 +35,8 @@ public class TestApi {
|
||||||
ArtemisConfig config = new ArtemisConfig();
|
ArtemisConfig config = new ArtemisConfig();
|
||||||
config.setHost("116.53.205.228:14443"); // 代理API网关nginx服务器ip端口
|
config.setHost("116.53.205.228:14443"); // 代理API网关nginx服务器ip端口
|
||||||
config.setAppKey("21887937"); // 秘钥appkey
|
config.setAppKey("21887937"); // 秘钥appkey
|
||||||
config.setAppSecret("lofnD6DbnBllHmk5YOyx");// 秘钥appSecret
|
config.setAppSecret("hwOzOEqxuPDz5frAnEXb");// 秘钥appSecret
|
||||||
|
|
||||||
final String getCamsApi = ARTEMIS_PATH + "/api/resource/v1/org/orgList";
|
final String getCamsApi = ARTEMIS_PATH + "/api/resource/v1/org/orgList";
|
||||||
Map<String, String> paramMap = new HashMap<String, String>();// post请求Form表单参数
|
Map<String, String> paramMap = new HashMap<String, String>();// post请求Form表单参数
|
||||||
paramMap.put("pageNo", "1");
|
paramMap.put("pageNo", "1");
|
||||||
|
@ -40,7 +47,42 @@ public class TestApi {
|
||||||
put("https://", getCamsApi);
|
put("https://", getCamsApi);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, "application/json");
|
Map<String, String> headers = new HashMap<>();
|
||||||
|
headers.put("Content-Type", "application/json");
|
||||||
|
return ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, "application/json",headers);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String calculateSignature(String appKey,String appSecret, String method, String path,
|
||||||
|
String query, String body, String timestamp) {
|
||||||
|
try {
|
||||||
|
// 1. 构建待签名字符串
|
||||||
|
String content = method + "\n" +
|
||||||
|
"application/json\n" + // Accept
|
||||||
|
"application/json\n" + // Content-Type
|
||||||
|
"\n" + // Date (可为空)
|
||||||
|
"x-ca-key:" + appKey + "\n" +
|
||||||
|
"x-ca-nonce:" + UUID.randomUUID().toString() + "\n" +
|
||||||
|
"x-ca-timestamp:" + timestamp + "\n" +
|
||||||
|
path;
|
||||||
|
|
||||||
|
if (query != null && !query.isEmpty()) {
|
||||||
|
content += "?" + query;
|
||||||
|
}
|
||||||
|
|
||||||
|
content += "\n" + body;
|
||||||
|
|
||||||
|
// 2. 计算HMAC-SHA256签名
|
||||||
|
Mac sha256_HMAC = Mac.getInstance("HmacSHA256");
|
||||||
|
SecretKeySpec secret_key = new SecretKeySpec(appSecret.getBytes(StandardCharsets.UTF_8), "HmacSHA256");
|
||||||
|
sha256_HMAC.init(secret_key);
|
||||||
|
byte[] hash = sha256_HMAC.doFinal(content.getBytes(StandardCharsets.UTF_8));
|
||||||
|
|
||||||
|
return Base64.getEncoder().encodeToString(hash);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("计算签名失败", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
package com.tcctyn.iot.uav;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Jason
|
|
||||||
* @date 2025年05月22日 15:13:16
|
|
||||||
*/
|
|
||||||
public class test {
|
|
||||||
}
|
|
Loading…
Reference in New Issue