package com.hikvision.artemis.sdk.util;

import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils; public class SignUtil
{
public static String sign(String secret, String method, String path, Map<String, String> headers, Map<String, String> querys, Map<String, String> bodys, List<String> signHeaderPrefixList)
{
try
{
Mac hmacSha256 = Mac.getInstance("HmacSHA256");
byte[] keyBytes = secret.getBytes("UTF-8");
hmacSha256.init(new SecretKeySpec(keyBytes, 0, keyBytes.length, "HmacSHA256")); return new String(Base64.encodeBase64(hmacSha256
.doFinal(buildStringToSign(method, path, headers, querys, bodys, signHeaderPrefixList)
.getBytes("UTF-8"))), "UTF-8");
}
catch (Exception e)
{
throw new RuntimeException(e);
}
} private static String buildStringToSign(String method, String path, Map<String, String> headers, Map<String, String> querys, Map<String, String> bodys, List<String> signHeaderPrefixList)
{
StringBuilder sb = new StringBuilder(); sb.append(method.toUpperCase()).append("\n");
if (null != headers)
{
if (null != headers.get("Accept"))
{
sb.append((String)headers.get("Accept"));
sb.append("\n");
}
if (null != headers.get("Content-MD5"))
{
sb.append((String)headers.get("Content-MD5"));
sb.append("\n");
}
if (null != headers.get("Content-Type"))
{
sb.append((String)headers.get("Content-Type"));
sb.append("\n");
}
if (null != headers.get("Date"))
{
sb.append((String)headers.get("Date"));
sb.append("\n");
}
}
sb.append(buildHeaders(headers, signHeaderPrefixList));
sb.append(buildResource(path, querys, bodys));
return sb.toString();
} private static String buildResource(String path, Map<String, String> querys, Map<String, String> bodys)
{
StringBuilder sb = new StringBuilder();
if (!StringUtils.isBlank(path)) {
sb.append(path);
}
Map<String, String> sortMap = new TreeMap();
if (null != querys) {
for (Map.Entry<String, String> query : querys.entrySet()) {
if (!StringUtils.isBlank((CharSequence)query.getKey())) {
sortMap.put(query.getKey(), query.getValue());
}
}
}
if (null != bodys) {
for (??? = bodys.entrySet().iterator(); ???.hasNext();)
{
body = (Map.Entry)???.next();
if (!StringUtils.isBlank((CharSequence)body.getKey())) {
sortMap.put(body.getKey(), body.getValue());
}
}
}
Map.Entry<String, String> body;
StringBuilder sbParam = new StringBuilder();
for (Map.Entry<String, String> item : sortMap.entrySet()) {
if (!StringUtils.isBlank((CharSequence)item.getKey()))
{
if (0 < sbParam.length()) {
sbParam.append("&");
}
sbParam.append((String)item.getKey());
if (!StringUtils.isBlank((CharSequence)item.getValue())) {
sbParam.append("=").append((String)item.getValue());
}
}
}
if (0 < sbParam.length())
{
sb.append("?");
sb.append(sbParam);
}
return sb.toString();
} private static String buildHeaders(Map<String, String> headers, List<String> signHeaderPrefixList)
{
StringBuilder sb = new StringBuilder();
if (null != signHeaderPrefixList)
{
signHeaderPrefixList.remove("x-ca-signature");
signHeaderPrefixList.remove("Accept");
signHeaderPrefixList.remove("Content-MD5");
signHeaderPrefixList.remove("Content-Type");
signHeaderPrefixList.remove("Date");
Collections.sort(signHeaderPrefixList);
}
if (null != headers)
{
Map<String, String> sortMap = new TreeMap();
sortMap.putAll(headers);
StringBuilder signHeadersStringBuilder = new StringBuilder();
for (Map.Entry<String, String> header : sortMap.entrySet()) {
if (isHeaderToSign((String)header.getKey(), signHeaderPrefixList))
{
sb.append((String)header.getKey());
sb.append(":");
if (!StringUtils.isBlank((CharSequence)header.getValue())) {
sb.append((String)header.getValue());
}
sb.append("\n");
if (0 < signHeadersStringBuilder.length()) {
signHeadersStringBuilder.append(",");
}
signHeadersStringBuilder.append((String)header.getKey());
}
}
headers.put("x-ca-signature-headers", signHeadersStringBuilder.toString());
}
return sb.toString();
} private static boolean isHeaderToSign(String headerName, List<String> signHeaderPrefixList)
{
if (StringUtils.isBlank(headerName)) {
return false;
}
if (headerName.startsWith("x-ca-")) {
return true;
}
if (null != signHeaderPrefixList) {
for (String signHeaderPrefix : signHeaderPrefixList) {
if (headerName.equalsIgnoreCase(signHeaderPrefix)) {
return true;
}
}
}
return false;
}
}
package com.hikvision.artemis.sdk.util;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair; public class HttpUtils
{
public static HttpResponse doGet(String host, String path, String method, Map<String, String> headers, Map<String, String> querys)
throws Exception
{
HttpClient httpClient = wrapClient(host); HttpGet request = new HttpGet(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader((String)e.getKey(), (String)e.getValue());
}
return httpClient.execute(request);
} public static HttpResponse doPost(String host, String path, String method, Map<String, String> headers, Map<String, String> querys, Map<String, String> bodys)
throws Exception
{
HttpClient httpClient = wrapClient(host); HttpPost request = new HttpPost(buildUrl(host, path, querys));
for (Iterator localIterator = headers.entrySet().iterator(); localIterator.hasNext();)
{
e = (Map.Entry)localIterator.next();
request.addHeader((String)e.getKey(), (String)e.getValue());
}
Map.Entry<String, String> e;
if (bodys != null)
{
Object nameValuePairList = new ArrayList();
for (String key : bodys.keySet()) {
((List)nameValuePairList).add(new BasicNameValuePair(key, (String)bodys.get(key)));
}
UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity((List)nameValuePairList, "utf-8");
formEntity.setContentType("application/x-www-form-urlencoded; charset=UTF-8");
request.setEntity(formEntity);
}
return httpClient.execute(request);
} public static HttpResponse doPost(String host, String path, String method, Map<String, String> headers, Map<String, String> querys, String body)
throws Exception
{
HttpClient httpClient = wrapClient(host); HttpPost request = new HttpPost(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader((String)e.getKey(), (String)e.getValue());
}
if (StringUtils.isNotBlank(body)) {
request.setEntity(new StringEntity(body, "utf-8"));
}
return httpClient.execute(request);
} public static HttpResponse doPost(String host, String path, String method, Map<String, String> headers, Map<String, String> querys, byte[] body)
throws Exception
{
HttpClient httpClient = wrapClient(host); HttpPost request = new HttpPost(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader((String)e.getKey(), (String)e.getValue());
}
if (body != null) {
request.setEntity(new ByteArrayEntity(body));
}
return httpClient.execute(request);
} public static HttpResponse doPut(String host, String path, String method, Map<String, String> headers, Map<String, String> querys, String body)
throws Exception
{
HttpClient httpClient = wrapClient(host); HttpPut request = new HttpPut(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader((String)e.getKey(), (String)e.getValue());
}
if (StringUtils.isNotBlank(body)) {
request.setEntity(new StringEntity(body, "utf-8"));
}
return httpClient.execute(request);
} public static HttpResponse doPut(String host, String path, String method, Map<String, String> headers, Map<String, String> querys, byte[] body)
throws Exception
{
HttpClient httpClient = wrapClient(host); HttpPut request = new HttpPut(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader((String)e.getKey(), (String)e.getValue());
}
if (body != null) {
request.setEntity(new ByteArrayEntity(body));
}
return httpClient.execute(request);
} public static HttpResponse doDelete(String host, String path, String method, Map<String, String> headers, Map<String, String> querys)
throws Exception
{
HttpClient httpClient = wrapClient(host); HttpDelete request = new HttpDelete(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader((String)e.getKey(), (String)e.getValue());
}
return httpClient.execute(request);
} private static String buildUrl(String host, String path, Map<String, String> querys)
throws UnsupportedEncodingException
{
StringBuilder sbUrl = new StringBuilder();
sbUrl.append(host);
if (!StringUtils.isBlank(path)) {
sbUrl.append(path);
}
if (null != querys)
{
StringBuilder sbQuery = new StringBuilder();
for (Map.Entry<String, String> query : querys.entrySet())
{
if (0 < sbQuery.length()) {
sbQuery.append("&");
}
if ((StringUtils.isBlank((CharSequence)query.getKey())) && (!StringUtils.isBlank((CharSequence)query.getValue()))) {
sbQuery.append((String)query.getValue());
}
if (!StringUtils.isBlank((CharSequence)query.getKey()))
{
sbQuery.append((String)query.getKey());
if (!StringUtils.isBlank((CharSequence)query.getValue()))
{
sbQuery.append("=");
sbQuery.append(URLEncoder.encode((String)query.getValue(), "utf-8"));
}
}
}
if (0 < sbQuery.length()) {
sbUrl.append("?").append(sbQuery);
}
}
return sbUrl.toString();
} private static HttpClient wrapClient(String host)
{
HttpClient httpClient = new DefaultHttpClient();
if (host.startsWith("https://")) {
sslClient(httpClient);
}
return httpClient;
} private static void sslClient(HttpClient httpClient)
{
try
{
SSLContext ctx = SSLContext.getInstance("TLS");
X509TrustManager tm = new X509TrustManager()
{
public X509Certificate[] getAcceptedIssuers()
{
return null;
} public void checkClientTrusted(X509Certificate[] xcs, String str) {} public void checkServerTrusted(X509Certificate[] xcs, String str) {}
};
ctx.init(null, new TrustManager[] { tm }, null);
SSLSocketFactory ssf = new SSLSocketFactory(ctx);
ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
ClientConnectionManager ccm = httpClient.getConnectionManager();
SchemeRegistry registry = ccm.getSchemeRegistry();
registry.register(new Scheme("https", 443, ssf));
}
catch (KeyManagementException ex)
{
throw new RuntimeException(ex);
}
catch (NoSuchAlgorithmException ex)
{
throw new RuntimeException(ex);
}
}
}

doget

package com.hikvision.artemis.sdk;

import com.hikvision.artemis.sdk.config.ArtemisConfig;
import com.hikvision.artemis.sdk.enums.Method;
import com.hikvision.artemis.sdk.util.MessageDigestUtil;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; public class ArtemisHttpUtil
{
private static final Logger logger = LoggerFactory.getLogger(ArtemisHttpUtil.class);
private static final List<String> CUSTOM_HEADERS_TO_SIGN_PREFIX = new ArrayList();
private static final String SUCC_PRE = "2"; public static String doGetArtemis(Map<String, String> path, Map<String, String> querys, String accept, String contentType)
{
String httpSchema = (String)path.keySet().toArray()[0];
if ((httpSchema == null) || (StringUtils.isEmpty(httpSchema))) {
throw new RuntimeException("http��https��������httpSchema: " + httpSchema);
}
String responseStr = null;
try
{
Map<String, String> headers = new HashMap();
if (StringUtils.isNotBlank(accept)) {
headers.put("Accept", accept);
} else {
headers.put("Accept", "*/*");
}
if (StringUtils.isNotBlank(contentType)) {
headers.put("Content-Type", contentType);
} else {
headers.put("Content-Type", "application/text;charset=UTF-8");
}
CUSTOM_HEADERS_TO_SIGN_PREFIX.clear(); Request request = new Request(Method.GET, httpSchema + ArtemisConfig.host, (String)path.get(httpSchema), ArtemisConfig.appKey, ArtemisConfig.appSecret, 2000);
request.setHeaders(headers);
request.setSignHeaderPrefixList(CUSTOM_HEADERS_TO_SIGN_PREFIX); request.setQuerys(querys); Response response = Client.execute(request); responseStr = getResponseResult(response);
}
catch (Exception e)
{
logger.error("the Artemis GET Request is failed[doGetArtemis]", e);
}
return responseStr;
} public static String doPostFormArtemis(Map<String, String> path, Map<String, String> paramMap, Map<String, String> querys, String accept, String contentType)
{
String httpSchema = (String)path.keySet().toArray()[0];
if ((httpSchema == null) || (StringUtils.isEmpty(httpSchema))) {
throw new RuntimeException("http��https��������httpSchema: " + httpSchema);
}
String responseStr = null;
try
{
Map<String, String> headers = new HashMap();
if (StringUtils.isNotBlank(accept)) {
headers.put("Accept", accept);
} else {
headers.put("Accept", "*/*");
}
if (StringUtils.isNotBlank(contentType)) {
headers.put("Content-Type", contentType);
} else {
headers.put("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
}
CUSTOM_HEADERS_TO_SIGN_PREFIX.clear(); Request request = new Request(Method.POST_FORM, httpSchema + ArtemisConfig.host, (String)path.get(httpSchema), ArtemisConfig.appKey, ArtemisConfig.appSecret, 2000);
request.setHeaders(headers);
request.setSignHeaderPrefixList(CUSTOM_HEADERS_TO_SIGN_PREFIX); request.setQuerys(querys); request.setBodys(paramMap); Response response = Client.execute(request); responseStr = getResponseResult(response);
}
catch (Exception e)
{
logger.error("the Artemis PostForm Request is failed[doPostFormArtemis]", e);
}
return responseStr;
} public static String doPostStringArtemis(Map<String, String> path, String body, Map<String, String> querys, String accept, String contentType)
{
String httpSchema = (String)path.keySet().toArray()[0];
if ((httpSchema == null) || (StringUtils.isEmpty(httpSchema))) {
throw new RuntimeException("http��https��������httpSchema: " + httpSchema);
}
String responseStr = null;
try
{
Map<String, String> headers = new HashMap();
if (StringUtils.isNotBlank(accept)) {
headers.put("Accept", accept);
} else {
headers.put("Accept", "*/*");
}
if (StringUtils.isNotBlank(contentType)) {
headers.put("Content-Type", contentType);
} else {
headers.put("Content-Type", "application/text;charset=UTF-8");
}
CUSTOM_HEADERS_TO_SIGN_PREFIX.clear(); Request request = new Request(Method.POST_STRING, httpSchema + ArtemisConfig.host, (String)path.get(httpSchema), ArtemisConfig.appKey, ArtemisConfig.appSecret, 2000);
request.setHeaders(headers);
request.setSignHeaderPrefixList(CUSTOM_HEADERS_TO_SIGN_PREFIX); request.setQuerys(querys); request.setStringBody(body); Response response = Client.execute(request); responseStr = getResponseResult(response);
}
catch (Exception e)
{
logger.error("the Artemis PostString Request is failed[doPostStringArtemis]", e);
}
return responseStr;
} public static String doPostBytesArtemis(Map<String, String> path, byte[] bytesBody, Map<String, String> querys, String accept, String contentType)
{
String httpSchema = (String)path.keySet().toArray()[0];
if ((httpSchema == null) || (StringUtils.isEmpty(httpSchema))) {
throw new RuntimeException("http��https��������httpSchema: " + httpSchema);
}
String responseStr = null;
try
{
Map<String, String> headers = new HashMap();
if (StringUtils.isNotBlank(accept)) {
headers.put("Accept", accept);
} else {
headers.put("Accept", "*/*");
}
if (bytesBody != null) {
headers.put("Content-MD5", MessageDigestUtil.base64AndMD5(bytesBody));
}
if (StringUtils.isNotBlank(contentType)) {
headers.put("Content-Type", contentType);
} else {
headers.put("Content-Type", "application/text;charset=UTF-8");
}
CUSTOM_HEADERS_TO_SIGN_PREFIX.clear(); Request request = new Request(Method.POST_BYTES, httpSchema + ArtemisConfig.host, (String)path.get(httpSchema), ArtemisConfig.appKey, ArtemisConfig.appSecret, 2000);
request.setHeaders(headers);
request.setSignHeaderPrefixList(CUSTOM_HEADERS_TO_SIGN_PREFIX); request.setQuerys(querys);
request.setBytesBody(bytesBody); Response response = Client.execute(request); responseStr = getResponseResult(response);
}
catch (Exception e)
{
logger.error("the Artemis PostBytes Request is failed[doPostBytesArtemis]", e);
}
return responseStr;
} public static String doPutStringArtemis(Map<String, String> path, String body, String accept, String contentType)
{
String httpSchema = (String)path.keySet().toArray()[0];
if ((httpSchema == null) || (StringUtils.isEmpty(httpSchema))) {
throw new RuntimeException("http��https��������httpSchema: " + httpSchema);
}
String responseStr = null;
try
{
Map<String, String> headers = new HashMap();
if (StringUtils.isNotBlank(accept)) {
headers.put("Accept", accept);
} else {
headers.put("Accept", "*/*");
}
if (StringUtils.isNotBlank(body)) {
headers.put("Content-MD5", MessageDigestUtil.base64AndMD5(body));
}
if (StringUtils.isNotBlank(contentType)) {
headers.put("Content-Type", contentType);
} else {
headers.put("Content-Type", "application/text;charset=UTF-8");
}
CUSTOM_HEADERS_TO_SIGN_PREFIX.clear(); Request request = new Request(Method.PUT_STRING, httpSchema + ArtemisConfig.host, (String)path.get(httpSchema), ArtemisConfig.appKey, ArtemisConfig.appSecret, 2000);
request.setHeaders(headers);
request.setSignHeaderPrefixList(CUSTOM_HEADERS_TO_SIGN_PREFIX);
request.setStringBody(body); Response response = Client.execute(request); responseStr = getResponseResult(response);
}
catch (Exception e)
{
logger.error("the Artemis PutString Request is failed[doPutStringArtemis]", e);
}
return responseStr;
} public static String doPutBytesArtemis(Map<String, String> path, byte[] bytesBody, String accept, String contentType)
{
String httpSchema = (String)path.keySet().toArray()[0];
if ((httpSchema == null) || (StringUtils.isEmpty(httpSchema))) {
throw new RuntimeException("http��https��������httpSchema: " + httpSchema);
}
String responseStr = null;
try
{
Map<String, String> headers = new HashMap();
if (StringUtils.isNotBlank(accept)) {
headers.put("Accept", accept);
} else {
headers.put("Accept", "*/*");
}
if (bytesBody != null) {
headers.put("Content-MD5", MessageDigestUtil.base64AndMD5(bytesBody));
}
if (StringUtils.isNotBlank(contentType)) {
headers.put("Content-Type", contentType);
} else {
headers.put("Content-Type", "application/text;charset=UTF-8");
}
CUSTOM_HEADERS_TO_SIGN_PREFIX.clear(); Request request = new Request(Method.PUT_BYTES, httpSchema + ArtemisConfig.host, (String)path.get(httpSchema), ArtemisConfig.appKey, ArtemisConfig.appSecret, 2000);
request.setHeaders(headers);
request.setSignHeaderPrefixList(CUSTOM_HEADERS_TO_SIGN_PREFIX);
request.setBytesBody(bytesBody); Response response = Client.execute(request); responseStr = getResponseResult(response);
}
catch (Exception e)
{
logger.error("the Artemis PutBytes Request is failed[doPutBytesArtemis]", e);
}
return responseStr;
} public static String doDeleteArtemis(Map<String, String> path, Map<String, String> querys, String accept, String contentType)
{
String httpSchema = (String)path.keySet().toArray()[0];
if ((httpSchema == null) || (StringUtils.isEmpty(httpSchema))) {
throw new RuntimeException("http��https��������httpSchema: " + httpSchema);
}
String responseStr = null;
try
{
Map<String, String> headers = new HashMap();
if (StringUtils.isNotBlank(accept)) {
headers.put("Accept", accept);
} else {
headers.put("Accept", "*/*");
}
if (StringUtils.isNotBlank(contentType)) {
headers.put("Content-Type", contentType);
}
Request request = new Request(Method.DELETE, httpSchema + ArtemisConfig.host, (String)path.get(httpSchema), ArtemisConfig.appKey, ArtemisConfig.appSecret, 2000);
request.setHeaders(headers);
request.setSignHeaderPrefixList(CUSTOM_HEADERS_TO_SIGN_PREFIX);
request.setQuerys(querys); Response response = Client.execute(request); responseStr = getResponseResult(response);
}
catch (Exception e)
{
logger.error("the Artemis DELETE Request is failed[doDeleteArtemis]", e);
}
return responseStr;
} private static String getResponseResult(Response response)
{
String responseStr = null; int statusCode = response.getStatusCode();
if (String.valueOf(statusCode).startsWith("2"))
{
responseStr = response.getBody();
logger.info("the Artemis Request is Success,statusCode:" + statusCode + " SuccessMsg:" + response.getBody());
}
else
{
String msg = response.getErrorMessage();
responseStr = response.getBody();
logger.error("the Artemis Request is Failed,statusCode:" + statusCode + " errorMsg:" + msg);
}
return responseStr;
}
}
package com.hikvision.ga;

import java.util.HashMap;
import java.util.Map; import com.hikvision.artemis.sdk.ArtemisHttpUtil;
import com.hikvision.artemis.sdk.config.ArtemisConfig; /**
* ��Class��������, ����������������������, ��������������������������������������.
* ������������������:
* [1] ����������������������
* https://open8200.hikvision.com/artemis-portal/document?version=4&docId=306&apiBlock=1
* [2] ����appKey������������
* https://open8200.hikvision.com/artemis-portal/document?version=4&docId=284&apiBlock=2
* @author zhangtuo
*
*/
public class ArtemisTest { /**
* ������������appKey��appSecret����static������������������.
* [1 host]
* ����������������open8200����,������������������,������������������,host��������.������open8200.hikvision.com
* ����������������������������,host������������������ip,����1.0 ��������������9999.����2.0 ��������������443.����:10.33.25.22:9999 ����10.33.25.22:443
* [2 appKey��appSecret]
* ��������������appKey��appSecret����.
*
* ps. ����������open8200��������������������,��������������,��������������,������������.
*
*/
static {
ArtemisConfig.host ="open8200.hikvision.com"; //artemis����������ip����
ArtemisConfig.appKey ="22425132"; //����appkey
ArtemisConfig.appSecret ="mcsioUGkT5GRMZTvjwAC";//����appSecret
}
/**
* ����������������������
* TODO ������������������/artemis
*/
private static final String ARTEMIS_PATH = "/artemis"; /**
* [1] ������������������������������
* @return
*/
public static String callApiGetCameraInfos() {
/**
* https://open8200.hikvision.com/artemis-portal/document?version=4&docId=306&apiBlock=1
* ����API��������������,��������GET������Rest����, ������������������queryString, ����������������������:
* http://ip:port/path?a=1&b=2
* ArtemisHttpUtil������������doGetArtemis��������, ����������������������������������.
* ����������https, ��������������path����hashmap����,��put����key-value, querys������������.
* start��������, size��������.
*/
String getCamsApi = ARTEMIS_PATH + "/api/common/v1/remoteCameraInfoRestService/findCameraInfoPage";
Map<String,String> querys = new HashMap<String,String>();//get��������������
querys.put("start", "0");
querys.put("size", "20");
Map<String, String> path = new HashMap<String, String>(2){
{
put("https://", getCamsApi);
}
};
String result = ArtemisHttpUtil.doGetArtemis(path, querys,null,null);
return result;
} /**
* [2] ����appKey������������
* @return
*/
public static String callApiGetSecurity() {
/**
* https://open8200.hikvision.com/artemis-portal/document?version=4&docId=284&apiBlock=2
* ����API��������������,��������GET������Rest����,
* ����������������Parameter Path,����queryString����������.
* ��������: /api/artemis/v1/agreementService/securityParam/appKey/{appKey}
* {appKey}��Parameter Path
* ����, doGetArtemis����������������null
*
* TODO ��������������appKey����������static��������������appKey
*/
String getSecurityApi = ARTEMIS_PATH + "/api/artemis/v1/agreementService/securityParam/appKey/22425132";
Map<String, String> path = new HashMap<String, String>(2){
{
put("https://", getSecurityApi);
}
};
String result = ArtemisHttpUtil.doGetArtemis(path, null,null,null);
return result;
} public static void main(String[] args) {
/**
* ������������������
*/
String camsResult = callApiGetCameraInfos(); /**
* ����appKey������������
*/
String securityResult = callApiGetSecurity();
System.out.println(camsResult);
System.out.println(securityResult);
}
}

海康sdk的更多相关文章

  1. 海康SDK编程指南(C#二次开发版本)

    海康SDK编程指南 目前使用的海康SDK包括IPC_SDK(硬件设备),Plat_SDK(平台),其中两套SDK都需单独调用海康播放库PlayCtrl.dll来解码视频流,返回视频信息和角度信息.本文 ...

  2. 海康SDK编程指南

    转至心澄欲遣 目前使用的海康SDK包括IPC_SDK(硬件设备),Plat_SDK(平台),其中两套SDK都需单独调用海康播放库PlayCtrl.dll来解码视频流,返回视频信息和角度信息.本文仅对视 ...

  3. 使用golang对海康sdk进行业务开发

    目录 准备工作 开发环境信息 改写HCNetSDK.h头文件 开发过程 基本数据类型转换 业务开发 参考 项目最近需要改造升级:操作海康摄像头(包括登录,拍照,录像)等基本功能.经过一段时间研究后,发 ...

  4. 海康SDK JAVA版本调用步骤及问题介绍

    一.前言 本文为海康SDK JAVA版本Demo的介绍,采用Eclipse运行,以及一些问题记录. 海康SDK版本:SDK_Win32 Eclipse版本:Mars2.0 JDK版本:1.8.0_15 ...

  5. 封装海康SDK出现无法加载 DLL“..\bin\HCNetSDK.dll”: 找不到指定的模块

    今天在封装海康设备的时候出现了这么一个问题,在初始化的时候提升无法加载 DLL“..\bin\HCNetSDK.dll”: 找不到指定的模块. 在网上查找了几个方法,并不是很靠谱,于是从源头找找,是什 ...

  6. C#制作ActiveX控件中调用海康SDK的问题

    事情是这样的,有一台海康威视的摄像头,客户需要一个ActiveX控件嵌入到网页中,通过点击按钮开始录制和结束录制来进行视频的录制和保存,关于海康摄像头的二次开发在此就不多说了,可以参考SDK中的说明. ...

  7. golang调用海康sdk

    git地址:https://gitee.com/mimo431/hcnet-sdk_golang 网络不太流畅,先传gitee上 参考链接: https://www.cnblogs.com/dust9 ...

  8. 使用c#封装海康SDK出现无法加载 DLL“..\bin\HCNetSDK.dll”: 找不到指定的模块

    最近在研究网络摄像头的二次开发,测试了一款海康威视的网络摄像头,程序调试的时候,出现如题的报错. 调试随机自带的demo时,程序运行正常,但当把该程序引入到我自己的程序中时,就开始报错.根据开发软件包 ...

  9. 海康相机SDK二次开发只有视频无声音问题

    海康SDK相信做企业开发的的同仁,在项目中经常会用到,毕竟使用范围这么广. 本次就开发遇到的奇葩问题来说明一下我们的解决方案. 场景 虽然海康有4200客户端,但是对于高度定制化的项目,肯定不能再使用 ...

随机推荐

  1. html常用属性border-radius、linear-gradient怎么使用

    html常用属性border-radius.linear-gradient怎么使用 一.总结 一句话总结: 1.border-radius: 8px 8px 8px 8px !important; 2 ...

  2. 使用CentOS7卸载自带jdk安装自己的JDK1.8

    不管在什么地方,什么时候,学习是快速提升自己的能力的一种体现!!!!!!!!!!! 关于JDK1.8 与之前的版本相比有哪些变化和新特性我也不在这详细的说明了,毕竟一度娘啥都有了,既然不多说那就直接开 ...

  3. 【b604】2K进制数

    Time Limit: 1 second Memory Limit: 50 MB [问题描述] 设r是个2K进制数,并满足以下条件: (1)r至少是个2位的2K进制数. (2)作为2K进制数,除最后一 ...

  4. C 删除字符串1字符串2

    #include<stdio.h> #include<string.h> void main() { char s1[1000],s2[100],b[100]; int i,j ...

  5. 衡量镜头解像能力性能的指标-MTF曲线

    MTF(Modulation Transfer Function,模量传递函数),是目前分析镜头解像能力的方法,可以用来评判镜头还原物体对比度的能力.说到MTF,不得不先提一下衡量镜头性能的两在重要指 ...

  6. Method and apparatus for establishing IEEE 1588 clock synchronization across a network element comprising first and second cooperating smart interface converters wrapping the network element

    Apparatus for making legacy network elements transparent to IEEE 1588 Precision Time Protocol operat ...

  7. TCP 报文段结构

      源端口.目标端口:计算机上的进程要和其他进程通信是要通过计算机端口的,而一个计算机端口某个时刻只能被一个进程占用,所以通过指定源端口和目标端口,就可以知道是哪两个进程需要通信.源端口.目标端口是用 ...

  8. 简明Python3教程 7.运算符和表达式

    简介 你写的大多数逻辑行都包含表达式.表达式的一个简单例子是2 + 3.一个表达式可分为操作符和操作数两部分. 操作符的功能是执行一项任务:操作符可由一个符号或关键字代表,如+ .操作符需要数据以供执 ...

  9. arcserver开发小结(三)

    一.关于网络数据集的制作 由于要做实现网络分析的功能,而手中却没有网络数据集,关于网络数据集的制作,网上也有不少的资料.我参考的是ESRI为我们提供的帮助文档(Network_Analyst_Tuto ...

  10. CSRF 专题

    一.CSRF是什么? CSRF(Cross-site request forgery),中文名称:跨站请求伪造.      也被称为:one click attack/session riding(一 ...