Professional Documents
Culture Documents
OpenAPI安全认证库 (Java)开发指南V1.1.7
OpenAPI安全认证库 (Java)开发指南V1.1.7
OpenAPI安全认证库 (Java)开发指南V1.1.7
Prepared by Li Chao39
1 Introduction
1.1 Preface
Thank you very much for using our company's products, we will do our best to provide you with the best service. this manual
May contain technical inaccuracies or typographical errors. The contents of this manual will be updated regularly without
Further notice, the updated content will be added in the new version of this manual. We may improve or update this book at any time
When you read this development guide, you should also have the files listed in Table 1.2-1. file functions such as
Develop reference sample code, such as getting a list of organizations and getting
ArtemisPostTest.java
Two POST request interface calls to get the list of regions.
OpenAPI Security Authentication Library (Java) Development Guide A development guide for using the OpenAPI Secure Authentication Library (Java), i.e.
It encapsulates the dependent JAR files for the security authentication and signature work. Development requires
artemis-http-client-x.x.x.jar
to be introduced into the project.
readme.txt A brief description of the results, which must be read before development.
Unzip the OpenAPI security authentication library (java) product, its directory structure is as follows:
ÿÿdemo
ÿ
ÿÿArtemisPostTest.java
ÿÿdoc
ÿ
ÿÿOpenAPI Security Authentication Library (Java) Development Guide Vx.xxpdf
ÿÿartemis-http-client-x.x.x.jar
ÿÿreadme.txt
Machine Translated by Google
The OpenAPI security authentication library encapsulates the POST and GET methods of HTTP/HTTPS, providing
Java calls the unified entry of OpenAPI HTTP interface. OpenAPI security authentication library blocked
OpenAPI HTTP interface signature details, reducing the complexity of Java docking OpenAPI, the user
Just introduce OpenAPI Security Authentication Library ( Java ÿ You can easily and quickly implement OpenAPI HTTP connection
mouth call.
ÿ V1.1.7
ÿ V1.1.6
Support file upload type interface calls; upgrade third-party libraries to solve security vulnerabilities.
ÿ V1.1.5
ÿ V1.1.4
ÿ V1.1.3
ÿ V1.1.2
Modify the static list in the request and throw ConcurrentModificationException during concurrent access
unusual question.
ÿ V1.1.1
The code compilation version is changed to 1.6, which supports the use of jdk1.6 for development.
ÿ V1.1.0
Machine Translated by Google
The OpenAPI security authentication library (Java) code is open source, which can be imported through the public network maven dependency.
ÿ V1.0.0
Solve the problem that the image downloaded from the https address does not ignore the authentication.
2 Interface description
<dependency>
<groupId>com.hikvision.ga</groupId>
<artifactId>artemis-http-client</artifactId>
<version>1.1.6</version>
</dependency>
All encapsulated Post and Get methods are in the ArtemisHttpUtil class. Please refer to 2.1.2 Initialization Parameters
Explain the assignment of parameters, and then directly call OpenAPI through the static method provided by the ArtemisHttpUtil class
HTTP interface, method signature, please refer to 2.2 Method Definition section.
Before calling the interface, please contact Hikvision technical support to obtain information about the caller's access to the platform, including
The platform IP, port, and the caller correspond to the partner's partner Key and partner's Secret.
Platform initialization parameters are set by setting the static properties of the ArtemisConfig class. ArtemisConfig
ArtemisConfig {
public String;
Machine Translated by Google
When the interface is called using the https protocol, the IP is the platform (nginx) IP, Port
When using the http protocol to call the interface, the IP is the IP of the artemis service , and the Port
appKey String true assigns the partner's partner Key parameter to the caller
appSecret String true Assign the partner's partner Secret parameter to the caller
artemisConfig.setAppSecret("AAAAAAAAAAAAA");//Partner Secret
The caller selects the appropriate method in the method definition in 2.2 according to the interface request parameters and Method type to be called.
method.
The path parameter of all methods is a HashMap collection that only stores one set of data, that is, the path parameter
Value: interface path, the format is the context of the API gateway backend service + the request of the OpenAPI interface
Find path.
The protocol of the http request refers to the protocol of the OpenAPI interface (HTTP/HTTPS);
Machine Translated by Google
The request path of the OpenAPI interface is the request path provided by the interface configured in the API gateway.
};
query refers to the parameters in the request address, that is, the query parameters in the request url.
For "aa=CC&bb=DD", when the method call encapsulates the query parameter, the key-value pair of Key=Value needs to be
Stored in Map.
Example code for setting the query parameter "aa=CC&bb=DD" in the request address:
querys.put(“aa”, “CC”);
querys.put(“bb”, “DD”);
The DEFAULT_TIMEOUT static property can be used to set the timeout time of the method call in milliseconds
seconds. Before the interface is called, the timeout period of the interface call can be set through this property, for example:
The host parameter is set to 10.0.0.1:443, and the appKey parameter of artemisConfig is set to the partner's
AK, set the appSecret parameter of artemisConfig to the SK of the partner used.
“AAAAAAAAAAAAAA”);
This section introduces the meaning of static methods and parameters provided in the ArtemisHttpUtil class, and provides sample code
g t
path The path requested by Map true, the format is as described in 2.1.3.1 path parameter description.
querys Map false The query parameter of the request url, the format refers to the description of 2.1.3.2 query parameter.
accept String false specifies the data type that the client can receive. When this parameter is empty, it is set by default.
contentType String false The media type of the request entity body, this parameter is set to the default value when empty
application/textÿ
Machine Translated by Google
2.1.1.3 Example
put(“https://”, getSecurityApi);
};
querys.put(“start”, “0”);
querys.put(“size”, “20”);
System.out.println(result);
Map<String, String> querys, String accept, String contentType, Map<String, String> header);
artemisConfi Object true Request host, partner ak/sk package class, format refer to 2.1.3.4
path The path requested by Map true, the format is as described in 2.1.3.1 path parameter description.
querys Map false The query parameter of the request url, the format refers to the description of 2.1.3.2 query parameter.
accept String false specifies the data type that the client can receive, the default setting when this parameter is empty
contentType String false The media type of the request entity body, this parameter is set to the default value when empty
application/textÿ
header The header parameter of the Map false request needs to be in key-value pair format.
2.2.2.3 Example
artemisConfig.setAppSecret("AAAAAAAAAAAA");//Partner Secret
put(“https://”, getSecurityApi);
};
Map<String, String> head = new HashMap<String, String>(2) { //get the header parameter of the request
put(“headget”, “sky-test”);
};
querys.put(“start”, “0”);
querys.put(“size”, “20”);
System.out.println(result);
}
Machine Translated by Google
Encapsulates a post form type request without header parameters, and the request parameters include query parameters and form forms
parameter.
Map<String, String> paramMap, Map<String, String> querys, String accept, String contentType);
artemisConfi Object true Request host, partner ak/sk package class, format refer to 2.1.3.4
path The path requested by Map true, the format is as described in 2.1.3.1 path parameter description.
paramMap Map false form The parameter of the form request, which needs to be set in key-value pair format.
querys Map false The query parameter of the request url, the format refers to the description of 2.1.3.2 query parameter.
accept String false specifies the data type that the client can receive, the default setting when this parameter is empty
contentType String false The media type of the request entity body, this parameter is set to the default value when empty
application/textÿ
2.2.3.2 Example
artemisConfig.setAppSecret("AAAAAAAAAAAA");//Partner Secretfinal
put(“https://”, getSecurityApi);
};
querys.put(“start”, “0”);
querys.put(“size”, “20”);
null,null);
System.out.println(result);
A post form type request encapsulated with header parameters, the request parameters include query parameters and form forms
parameter.
Map<String, String> paramMap, Map<String, String> querys, String accept, String contentType,
artemisConfi Object true Request host, partner ak/sk package class, format refer to 2.1.3.4
path The path requested by Map true, the format is as described in 2.1.3.1 path parameter description.
paramMap Map false form The parameter of the form request, which needs to be set in key-value pair format.
querys Map false The query parameter of the request url, the format refers to the description of 2.1.3.2 query parameter.
accept String false specifies the data type that the client can receive, the default setting when this parameter is empty
Machine Translated by Google
contentType String false The media type of the request entity body, this parameter is set to the default value when empty
application/textÿ
header The header parameter of the Map false request needs to be in key-value pair format.
2.2.4.3 Example
artemisConfig.setAppSecret("AAAAAAAAAAAA");//Partner Secret
put(“https://”, getSecurityApi);
};
Map<String, String> head = new HashMap<String, String>(2) { //header parameter of post request
put(“headpost”, “sky-test”);
};
querys.put(“start”, “0”);
querys.put(“size”, “20”);
null,null,head);
System.out.println(result);
Encapsulates a post type request without header parameters, and the request body is a json string.
Machine Translated by Google
artemisConfi Object true Request host, partner ak/sk package class, format refer to 2.1.3.4
path The path requested by Map true, the format is as described in 2.1.3.1 path parameter description.
body String false A request parameter in JSON format, which needs to be converted to a string.
querys Map false The query parameter of the request url, the format refers to the description of 2.1.3.2 query parameter.
accept String false specifies the data type that the client can receive, the default setting when this parameter is empty
contentType String false The media type of the request entity body, this parameter is set to the default value when empty
2.2.5.3 Example
artemisConfig.setAppSecret("AAAAAAAAAAAAA");//Partner Secret
put(“https://”, getSecurityApi);
};
Machine Translated by Google
jsonBody.put(“deviceCodes”,”-1”);
jsonBody.put(“sex”,-1);
jsonBody.put("beginDate",,"2017-09-01 12:00:00");
jsonBody.put(“endDate”,”2017-09-12 12:00:00”);
null,”application/json”);
System.out.println(result);
A post type request encapsulated with header parameters, the request body is a json string.
artemisConfi Object true Request host, partner ak/sk package class, format refer to 2.1.3.4
path The path requested by Map true, the format is as described in 2.1.3.1 path parameter description.
body Map false Request parameters in JSON format, which need to be converted to strings.
querys Map false The query parameter of the request url, the format refers to the description of 2.1.3.2 query parameter.
accept String false specifies the data type that the client can receive, the default setting when this parameter is empty
contentType String false The media type of the request entity body, this parameter is set to the default value when empty
Machine Translated by Google
header The header parameter of the Map false request needs to be in key-value pair format.
2.2.6.3 Example
artemisConfig.setAppSecret("AAAAAAAAAAAA");//Partner Secret
put(“https://”, getSecurityApi);
};
Map<String, String> head = new HashMap<String, String>(2) { //header parameter of post request
put(“headpost”, “sky-test”);
};
jsonBody.put(“deviceCodes”,”-1”);
jsonBody.put(“sex”,-1);
jsonBody.put("beginDate",,"2017-09-01 12:00:00");
jsonBody.put(“endDate”,”2017-09-12 12:00:00”);
null,”application/json”,head);
System.out.println(result);
2.2.7 doPostStringImgArtem
The package uses POST to download the image interface request, and the request body is a json string.
Machine Translated by Google
Map<String, String> querys, String accept, String contentType, Map<String, String> header);
artemisConfi Object true Request host, partner ak/sk package class, format refer to 2.1.3.4
path The path requested by Map true, the format is as described in 2.1.3.1 path parameter description.
body String false A request parameter in JSON format, which needs to be converted to a string.
querys Map false The query parameter of the request url, the format refers to the description of 2.1.3.2 query parameter.
accept String false specifies the data type that the client can receive, the default setting when this parameter is empty
contentType String false The media type of the request entity body, this parameter is set to the default value when empty
header The header parameter of the Map false request needs to be in key-value pair format.
2.2.7.3 Example
artemisConfig.setAppSecret("AAAAAAAAAAAA");//Partner Secret
put(“https://”,VehicleDataApi);
}
Machine Translated by Google
};
jsonBody.put(“svrIndexCode”, “30a80833-9ced-46c0-bf53-441a6121856e”);
jsonBody.put(“picUri”, “/pic?6ddz4a-=s72eb2*=ids1*=idp3*=ef8bi12i73=”);
System.out.println(“body: “+body);
path,body,null,null,”application/json”,null);
2.2.7 doPostFileFormArtemis
Encapsulates a request using the POST file upload interface. The request is in the form format. This request is only applicable to
Interface with file upload type, please use doPostFormArtemis for other form requests.
Map<String, String> querys, String accept, String contentType, Map<String, String> header);
artemisConfi Object true Request host, partner ak/sk package class, format refer to 2.1.3.4
path The path requested by Map true, the format is as described in 2.1.3.1 path parameter description.
paramMap Map false form The parameter of the form request, which needs to be set in key-value pair format.
querys Map false The query parameter of the request url, the format refers to the description of 2.1.3.2 query parameter.
accept String false specifies the data type that the client can receive, the default setting when this parameter is empty
contentType String false The media type of the request entity body, this parameter is set to the default value when empty
Machine Translated by Google
application/textÿ
2.2.7.3 Example
artemisConfig.setAppSecret("AAAAAAAAAAAAA");//Partner Secret
put(“https://”,VehicleDataApi);
};
jsonBody.put(“svrIndexCode”, “30a80833-9ced-46c0-bf53-441a6121856e”);
jsonBody.put(“picUri”, “/pic?6ddz4a-=s72eb2*=ids1*=idp3*=ef8bi12i73=”);
System.out.println(“body: “+body);
path,body,null,null,”application/json”,null);
When requesting to get the picture interface, and the interface returns in 302 mode, you need to call
doStringImgArtemis interface, this interface will return HttpResponse, users can get
Get the Location of the request header. For specific code, please refer to: ArtemisPostTest.java(artemis
sdk-demo\src\main\java\ga)
Machine Translated by Google
4 Revision History
Serial number change time version change person approver change description
1 2019-09-24 V1.1.2 Zhang Xiaofang 14 Zhang Sen 5 Create a new document to provide basic interface instructions
2 2020-01-13 V1.1.3 Zhang Xiaofang 14 Zhang Sen 5 Modification and update instructions
4 2022-05-11 V1.1.5 Huang Jingru Chen Zhe 8 Modification and update instructions
5 2022-06-10 V1.1.6 Li Chao39 Chen Zhe8 Added file upload interface calling API, repaired
6 2022-07-27 V1.1.7 Li Chao39 Chen Zhe8 Fixed a large number of CLOSE_WAIT connections
answer questions