更新文档目录结构

This commit is contained in:
citln-dev
2019-08-16 10:39:59 +08:00
parent c8883c311a
commit 3568dc7319
7 changed files with 893 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
# IDIS-SDK changes
* * *
**Changes in 2.0.0**
适用IDIS版本:企业版本V1.3.1-0
[add] 通道管理接口
[add] 标识基本管理操作接口
[add] 消息数据格式及消息字节转换方式
[add] 支持国家标识解析体系认证查询
[add] 支持分布式身份认证
2019-08-15
+129
View File
@@ -0,0 +1,129 @@
## IDIS-SDK开发指南
#### 基本概念介绍:
IDIS:智能分布式标识系统
IDIS-SDK:IDIS系统开发包
管理操作:创建标识、删除标识、添加标识值、修改标识值、移除标识值。
非管理操作:主要是查询操作。
通道:IDIS-SDK与IDIS系统之间的连接。
#### IDIS-SDK与IDIS版本对应关系说明
> |IDIS-SDK版本|IDIS版本 |
> | :-------- | :--------|
>|2.0.0 |企业版1.3.1 |
#### 快速使用
1. jar包获取:下载开源项目IDIS-SDK,导出jar包,并从该项目中获取依赖jar包,log4j-1.2.17.jar、gson-2.3.1.jar、commons-codec-1.12.jar、commons-logging-1.2.jar。
2. 环境要求:jdk1.8或以上。
3. 开发示例:
建立java项目,导入IDIS-SDK的jar包以及其依赖的jar包,根据我们提供的联系方式(参见[README.md](./README.md))获取到IDIS服务信息以及登录信息以后,通过以下三个步骤可以快速进行开发:
1). 创建通道管理实例IChannelManageService
2). 创建与IDIS连接的通道实例IIDManageServiceChannel,此处需要提供IDIS服务的IP地址和端口号,采用“TCP”传输协议
3). 通道实例IIDManageServiceChannel创建成功,即可以进行查询操作,若要进行标识管理操作,需要首先执行登录操作,登录成功以后可以进行各项管理操作
如图:
![Alt text](./res/pic1.jpg)
Demo如下:
```java
package test1;
import cn.ac.caict.iiiiot.idisc.core.BaseResponse;
import cn.ac.caict.iiiiot.idisc.core.ErrorResponse;
import cn.ac.caict.iiiiot.idisc.core.IdentifierException;
import cn.ac.caict.iiiiot.idisc.data.IdentifierValue;
import cn.ac.caict.iiiiot.idisc.data.MsgSettings;
import cn.ac.caict.iiiiot.idisc.service.IChannelManageService;
import cn.ac.caict.iiiiot.idisc.service.IIDManageServiceChannel;
import cn.ac.caict.iiiiot.idisc.service.impl.ChannelManageServiceImpl;
public class TestManageConnection {
public static final int CHANNEL_CLOSED = 0;
public static final int CHANNEL_LOGIN = 1;
public static final int CHANNEL_LOGOUT = 2;
public static void main(String[] args) {
//创建通道管理实例
IChannelManageService idfService = new ChannelManageServiceImpl();
try {
//根据IDIS系统提供的ip和端口,创建与IDIS的连接通道对象
IIDManageServiceChannel channel = idfService.generateChannel("192.168.150.13", 1304, "TCP");
//若要对标识进行管理操作,则需要首先登录
if (channel != null && idfService.getIDManageServiceChannelState(channel) == CHANNEL_LOGOUT) {
//登录
BaseResponse loginResp = testLogin(channel);
if(loginResp != null && loginResp.responseCode == 1){
System.out.println("登录成功!");
//创建标识
BaseResponse createResp = testCreate(channel);
if(createResp != null && createResp.responseCode == 1){
System.out.println("标识创建成功!");
} else if(createResp != null && createResp instanceof ErrorResponse){
System.out.println(((ErrorResponse)createResp).toString());
}
//添加标识值
//BaseResponse addResp = testAdd(channel);
//修改标识值
//BaseResponse editResp = testEdit(channel);
//移除标识值
//BaseResponse rmResp = testRemove(channel);
//删除标识
//BaseResponse delResp = testDelete(channel);
//if(delResp != null && delResp.responseCode == 1)
// System.out.println("删除成功!");
}
}
//通道未登录也可以执行查询操作
BaseResponse resp = testLookup(channel);
System.out.println(resp);
} catch (IdentifierException e) {
e.printStackTrace();
}
}
private static BaseResponse testLogin(IIDManageServiceChannel channel) throws IdentifierException{
return channel.login("88.1000.1/ADMIN", 301, "C:\\keys\\rsa_pri.pem", null,1);
}
private static BaseResponse testDelete(IIDManageServiceChannel channel) throws IdentifierException{
return channel.deleteIdentifier("88.1000.2/mm", new MsgSettings());
}
private static BaseResponse testCreate(IIDManageServiceChannel channel) throws IdentifierException{
IdentifierValue[] values = new IdentifierValue[5];
values[0] = new IdentifierValue(1, "URL", "www.aaa.com");
values[1] = new IdentifierValue(2, "email", "www.163.com");
values[2] = new IdentifierValue(3, "url", "www.ccc.com");
values[3] = new IdentifierValue(4, "email", "www.ddd.com");
values[4] = new IdentifierValue(5, "email", "www.fff.com");
return channel.createIdentifier("88.1000.2/mm", values, new MsgSettings());
}
private static BaseResponse testAdd(IIDManageServiceChannel channel) throws IdentifierException{
IdentifierValue[] values = new IdentifierValue[2];
values[0] = new IdentifierValue(6, "URL", "www.666.com");
values[1] = new IdentifierValue(7, "email", "www.777.com");
return channel.addIdentifierValues("88.1000.2/mm", values, new MsgSettings());
}
private static BaseResponse testEdit(IIDManageServiceChannel channel) throws IdentifierException{
IdentifierValue[] values = new IdentifierValue[2];
values[0] = new IdentifierValue(6, "email", "www.666e.com");
values[1] = new IdentifierValue(7, "url", "www.777e.com");
return channel.modifyIdentifierValues("88.1000.2/mm", values, new MsgSettings());
}
private static BaseResponse testRemove(IIDManageServiceChannel channel) throws IdentifierException{
IdentifierValue[] values = new IdentifierValue[2];
values[0] = new IdentifierValue(6, "email", "www.666e.com");
values[1] = new IdentifierValue(7, "url", "www.777e.com");
int[] arr = {6,7};
return channel.removeIdentifierValues("88.1000.2/mm", arr, null);
}
private static BaseResponse testLookup(IIDManageServiceChannel channel) throws IdentifierException{
String identifier = "88.1000.2/mm";
int[] arr = null;
String[] types = null;
return channel.lookupIdentifier(identifier, arr, types, null);
}
}
```
+201
View File
@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2019 Institute of Industrial Internet & Internet of Things
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
+545
View File
@@ -0,0 +1,545 @@
## apidoc
一\. 通道管理IChannelManageService
---
**1\. generateChannel**
###### 接口功能
> 创建与IDIS服务的连接通道实例(线程安全),需要捕获异常(异常码描述参照附表2)
###### 输入参数
>|参数|必选|类型|说明|
>| :-------- | :--------| :--------| :--------|
>|ip |true |String|目标IDIS服务的IP地址 |
>|port |true |int |目标IDIS服务端口|
>|protocol |true |String |数据传输采用的协议,TCP/UDP|
###### 返回值
> |类型|说明 |
> | :-------- | :--------|
>|IIDManageServiceChannel |返回通道实例,若创建失败则返回异常信息(异常码描述参照附表2) |
###### 接口示例
``` java
//创建通道管理实例
IChannelManageService chnnlService = new ChannelManageServiceImpl();
//创建与IDIS系统连接的通道
try {
IIDManageServiceChannel channel = chnnlService .generateChannel("192.168.150.13", 1304, "TCP");
if (channel != null && chnnlService .getIDManageServiceChannelState(channel) == 2){
System.out.println("连接通道创建成功!");
} else {
System.out.println("连接通道创建失败!");
}
} catch (IdentifierException e) {
e.printStackTrace();
}
```
**2\. generateChannelByConfig**
###### 接口功能
> 创建连接通道实例(线程安全),需要捕获异常(异常码描述参照附表2)。该方法通过配置文件中配置的信息来创建连接通道,config.json配置文件在工程的src/目录下,由工程创建者添加,格式如下:
> {
> "ip":"127.0.0.1",
> "port":"1999",
> "query":true,
> "admin":true,
> "protocol":"TCP"
> }
###### 输入参数
无。
###### 返回值
> |类型|说明 |
> | :-------- | :--------|
>|IIDManageServiceChannel |返回已创建的连接通道实例,若创建失败则返回异常信息,需要捕获异常并处理(异常码描述参照附表2) |
###### 接口示例
``` java
//创建通道管理实例
IChannelManageService chnnlService = new ChannelManageServiceImpl();
//创建与IDIS系统连接的通道
try {
IIDManageServiceChannel channel = chnnlService .generateChannelByConfig();
if (channel != null){
System.out.println("连接通道创建成功!");
} else {
System.out.println("连接通道创建失败!");
}
} catch (IdentifierException e) {
e.printStackTrace();
}
```
**3\. closeChannel**
###### 接口功能
> 关闭连接通道,需要捕获异常(异常码描述参照附表2)
###### 输入参数
> |参数|必选|类型|说明|
> | :-------- | :--------| :--------| :--------|
>|channel |true |IIDManageServiceChannel|目标通道对象 |
###### 返回值
无
###### 接口示例
``` java
//创建通道管理实例
IChannelManageService chnnlService = new ChannelManageServiceImpl();
try {
IIDManageServiceChannel channel = chnnlService .generateChannel("192.168.150.13", 1304, "TCP");
if (channel != null) {
//关闭连接通道
chnnlService .closeChannel(channel);
} else {
System.out.println("连接通道创建失败!");
}
} catch (IdentifierException e) {
e.printStackTrace();
}
```
**4\. getIDManageServiceChannelState**
###### 接口功能
> 获取连接通道状态
###### 输入参数
> |参数|必选|类型|说明|
> | :-------- | :--------| :--------| :--------|
>|channel |true |IIDManageServiceChannel|目标通道对象 |
###### 返回值
> |类型 |说明 |
> | :-------- | :--------|
>|int |0代表关闭状态 1代表登录状态 2代表已连接但未登录状态 |
###### 接口示例
``` java
//创建通道管理实例
IChannelManageService chnnlService = new ChannelManageServiceImpl();
try {
IIDManageServiceChannel channel = chnnlService .generateChannel("192.168.150.13", 1304, "TCP");
if (channel != null) {
//获取连接通道状态
int state = chnnlService .getIDManageServiceChannelState(channel);
if(state == 0){
System.out.println("当前连接通道已关闭");
} else if (state == 1){
System.out.println("当前连接通道已登录");
} else if(state == 2){
System.out.println("当前连接通道未登录");
}
}
} catch (IdentifierException e) {
e.printStackTrace();
}
```
**5\. getIDManageServiceChannelCount**
###### 接口功能
> 获取当前连接通道个数
###### 输入参数
无
###### 返回值
> |类型 |说明 |
> | :-------- | :--------|
>|int |当前连接通道个数 |
###### 接口示例
``` java
//创建通道管理实例
IChannelManageService chnnlService = new ChannelManageServiceImpl();
try {
IIDManageServiceChannel channel = chnnlService .generateChannel("192.168.150.13", 1304, "TCP");
if( channel != null) {
int count = chnnlService .getIDManageServiceChannelCount();
System.out.println("当前的连接数为:" + count);
}
} catch (IdentifierException e) {
e.printStackTrace();
}
```
**6\. getChannelUserIdentifier**
###### 接口功能
> 获取目标通道登录用户标识名称,若未登录则返回null
###### 输入参数
> |参数|必选|类型|说明|
> | :-------- | :--------| :--------| :--------|
> |channel |true |IIDManageServiceChannel |目标通道对象 |
###### 返回值
> |类型|说明 |
> | :-------- | :--------|
> |String |登录用户标识名称 |
###### 接口示例
``` java
//创建通道管理实例
IChannelManageService chnnlService = new ChannelManageServiceImpl();
try {
//根据IDIS系统提供的ip和端口,创建与IDIS的连接通道对象
IIDManageServiceChannel channel = chnnlService.generateChannel("192.168.150.13", 1304, "TCP");
if (channel != null) {
BaseResponse loginResp = channel.login("88.1000.1/ADMIN", 301, "c:\\keys\\rsa_pri.pem", null,1);
if(loginResp != null && loginResp.responseCode == 1){
System.out.println("登录成功!");
String userId = chnnlService.getChannelUserIdentifier(channel);
System.out.println(userId);
}
}
} catch (IdentifierException e) {
e.printStackTrace();
}
```
二\. 标识管理IIDManageServiceChannel
---
标识管理操作是基于请求响应模型实现数据通信的。
在进行数据通信过程中,消息设置是通过MsgSetting结构来实现的,说明如下:
>|字段|类型|默认值|描述|
>| :-------- | :--------| :--------| :--------|
>|truestyQuery |boolean |false |查询时是否进行可信解析 |
>|certify |boolean |false |是否需要认证 |
在进行数据通信过程中,标识值数据是通过IdentifierValue结构来设置的,说明如下:
>|字段|类型|默认值|描述|
>| :-------- | :--------| :--------| :--------|
>|index |int |-1 |标识值的索引 |
>|type |byte[] |new byte[0] |标识值类型 |
>|data |byte[] |new byte[0] |标识值数据 |
>|bAdminRead |boolean |true |管理员可读 |
>|bAdminWrite |boolean |true |管理员可写 |
>|bPublicRead |boolean |true |公共可读 |
>|bPublicWrite |boolean |false |公共可写 |
>|ttl |int |86400 |存活时间,单位秒 |
>|ttlType |byte |0 |默认采用相对时间模式 |
>|timestamp |int |当前时间 |时间戳 ,从1970年起始计算至当前时间的秒数 |
>|references |ValueReference[] |null |标识值引用的标识值数组, ValueReference结构指的是包含byte[]类型的标识和标识值的某索引,该索引即是引用的标识值的索引。 |
**1\. login**
###### 接口功能
> 与IDIS服务的连接通道建立后,若进行标识管理操作,须首先登录。该操作需要捕获异常(异常码描述参照附表2)。
###### 输入参数
> |参数|必选|类型|说明|
>| :-------- | :--------| :--------| :--------|
>|identifier |true |String|管理员标识 |
>|index |true |int |公钥对应标识值的索引 |
>|privakeyFilePath |true |String |私钥文件路径,支持pem文件格式私钥 |
>|password |false |String |如果私钥有密码,将密码赋值给password,如果私钥没有密码则password为null |
>|rdType |true |int |生成摘要hash算法,MD5算法:rdType=1,SH1算法:rdType=2,SH256算法:rdType=3 |
###### 返回值
> |类型|说明 |
>| :-------- | :--------|
>|BaseResponse |返回码为1登录成功,返回码不为1则登录失败(其他返回码参照附表1) |
###### 接口示例
``` java
//创建通道管理实例
IChannelManageService chnnlService = new ChannelManageServiceImpl();
try {
//根据IDIS系统提供的ip和端口,创建与IDIS的连接通道对象
IIDManageServiceChannel channel = chnnlService.generateChannel("192.168.150.13", 1304, "TCP");
if (channel != null) {
BaseResponse loginResp = channel.login("88.1000.1/ADMIN", 301, "c:\\keys\\rsa_pri.pem", null,1);
if(loginResp != null && loginResp.responseCode == 1){
System.out.println("登录成功!");
} else if(loginResp != null && loginResp instanceof ErrorResponse){
System.out.println((ErrorResponse) loginResp).toString();
}
}
} catch (IdentifierException e) {
e.printStackTrace();
}
```
**2\. lookupIdentifier**
###### 接口功能
> 该查询操作可以通道创建后不登录的情况下执行,在通道登录情况下也可执行。当然如果连接通道断开是无法查询的。该接口的功能是查询指定标识下的标识值信息,可以查询指定标识下的全部标识值,也可以进行条件查询,即按索引、类型进行查询。需要捕获异常(异常码描述参照附表2)。
> 在执行查询标识时,将MsgSetting的truestyQuery字段设置为true时,查询结果是经过国家标识解析体系认证的,是具有权威可信性的。
###### 输入参数
> |参数|必选|类型|说明|
>| :-------- | :--------| :--------| :--------|
>|identifier |true |String|标识名称 |
>|indexes |false |int[]|待查询标识值的索引数组 |
>|types |false |String[]|待查询标识值的数据类型数组 |
>|settings |false |MsgSettings |消息设置 |
###### 返回值
> |类型|说明 |
>| :-------- | :--------|
>|BaseResponse |返回码为1查询成功,返回码不为1查询结果异常(其他返回码参照附表1)。当消息设置中将truestyQuery字段置为true即进行可信解析时,返回值BaseResponse的trustedResult字段代表可信解析结果,有三种取值:0代表返回的结果不确定是否可信,1代表返回的结果可信,2代表返回的结果不可信 |
###### 接口示例
``` java
//创建通道管理实例
IChannelManageService chnnlService = new ChannelManageServiceImpl();
try {
//根据IDIS系统提供的ip和端口,创建与IDIS的连接通道对象
IIDManageServiceChannel channel = chnnlService.generateChannel("192.168.150.13", 1304, "TCP");
//若要对标识进行管理操作,则需要首先登录
if (channel != null) {
//通道未登录也可以执行查询操作
String identifier = "88.1000.2/mm";
int[] arr = null;
String[] types = null;
BaseResponse resp = channel.lookupIdentifier(identifier, arr, types, null);
System.out.println(resp);
}
} catch (IdentifierException e) {
e.printStackTrace();
}
```
**3\. createIdentifier**
###### 接口功能
> 创建标识,可以仅创建标识不带有标识值,也可以在创建带有标识值的标识。该接口需要捕获异常(异常码描述参照附表2)。
###### 输入参数
> |参数|必选|类型|说明|
>| :-------- | :--------| :--------| :--------|
>|identifier |true |String|待创建标识名称 |
>|values |false |IdentifierValue[] |创建标识可以添加标识值,若不添加标识值则该值为null |
>|settings |false |MsgSettings |消息设置 |
###### 返回值
> |类型|说明 |
>| :-------- | :--------|
>|BaseResponse |返回码为1创建标识成功,返回码不为1则创建标识失败(其他返回码参照附表1) |
###### 接口示例
``` java
//创建通道管理实例
IChannelManageService chnnlService = new ChannelManageServiceImpl();
try {
//根据IDIS系统提供的ip和端口,创建与IDIS的连接通道对象
IIDManageServiceChannel channel = chnnlService.generateChannel("192.168.150.13", 1304, "TCP");
//若要对标识进行管理操作,则需要首先登录
if (channel != null && chnnlService.getIDManageServiceChannelState(channel) == 2) {
BaseResponse loginResp = channel.login("88.1000.1/ADMIN", 301, "c:\\keys\\rsa_pri.pem", null,1);
if(loginResp != null && loginResp.responseCode == 1){
//创建标识
BaseResponse createResp = testCreate(channel);
if(createResp != null && createResp.responseCode == 1){
System.out.println("标识创建成功!");
} else if(createResp != null && createResp instanceof ErrorResponse){
System.out.println(((ErrorResponse)createResp).toString());
}
}
}
} catch (IdentifierException e) {
e.printStackTrace();
}
```
**4\. deleteIdentifier**
###### 接口功能
> 删除指定标识的全部数据,包括标识及其所有标识值。该接口需要捕获异常(异常码描述参照附表2)。
###### 输入参数
> |参数|必选|类型|说明|
>| :-------- | :--------| :--------| :--------|
>|identifier |true |String|待删除标识名称 |
###### 返回值
> |类型|说明 |
>| :-------- | :--------|
>|BaseResponse |返回码为1删除成功,返回码不为1则删除失败 (其他返回码参照附表1) |
###### 接口示例
``` java
//创建通道管理实例
IChannelManageService chnnlService = new ChannelManageServiceImpl();
try {
//根据IDIS系统提供的ip和端口,创建与IDIS的连接通道对象
IIDManageServiceChannel channel = chnnlService.generateChannel("192.168.150.13", 1304, "TCP");
//若要对标识进行管理操作,则需要首先登录
if (channel != null && chnnlService.getIDManageServiceChannelState(channel) == CHANNEL_LOGOUT) {
BaseResponse loginResp = channel.login("88.1000.1/ADMIN", 301, "c:\\keys\\rsa_pri.pem", null,1);
if(loginResp != null && loginResp.responseCode == 1){
System.out.println("登录成功!");
//删除标识
BaseResponse deleteResp = channel.deleteIdentifier("88.1000.2/mm", new MsgSettings());
if(deleteResp != null && deleteResp.responseCode == 1){
System.out.println("标识删除成功!");
} else if(deleteResp != null && deleteResp instanceof ErrorResponse){
System.out.println(((ErrorResponse)deleteResp).toString());
}
}
}
} catch (IdentifierException e) {
e.printStackTrace();
}
```
**5\. addIdentifierValues**
###### 接口功能
> 向目标标识添加若干标识值。该接口需要捕获异常(异常码描述参照附表2)。
###### 输入参数
> |参数|必选|类型|说明|
>| :-------- | :--------| :--------| :--------|
>|identifier |true |String| 目标标识 |
>|values |true |IdentifierValue[] | 待添加的标识值数组 |
>|settings |false |MsgSettings |消息设置 |
###### 返回值
> |类型|说明 |
>| :-------- | :--------|
>|BaseResponse |返回码为1添加标识值成功,返回码不为1则添加标识值失败 (其他返回码参照附表1)|
###### 接口示例
``` java
//创建通道管理实例
IChannelManageService chnnlService = new ChannelManageServiceImpl();
try {
//根据IDIS系统提供的ip和端口,创建与IDIS的连接通道对象
IIDManageServiceChannel channel = chnnlService.generateChannel("192.168.150.13", 1304, "TCP");
//若要对标识进行管理操作,则需要首先登录
if (channel != null && chnnlService.getIDManageServiceChannelState(channel) == CHANNEL_LOGOUT) {
BaseResponse loginResp = channel.login("88.1000.1/ADMIN", 301, "c:\\keys\\rsa_pri.pem", null,1);
if(loginResp != null && loginResp.responseCode == 1){
IdentifierValue[] values = new IdentifierValue[2];
values[0] = new IdentifierValue(6, "URL", "www.666.com");
values[1] = new IdentifierValue(7, "email", "www.777.com");
BaseResponse addResp = channel.addIdentifierValues("88.1000.2/mm", values, new MsgSettings());
if(addResp != null && addResp.responseCode == 1){
System.out.println("标识值添加成功!");
} else if(addResp != null && addResp instanceof ErrorResponse){
System.out.println(((ErrorResponse)addResp).toString());
}
}
}
} catch (IdentifierException e) {
e.printStackTrace();
}
```
**6\. modifyIdentifierValues**
###### 接口功能
> 修改目标标识下的若干标识值。该接口需要捕获异常(异常码描述参照附表2)。
###### 输入参数
> |参数|必选|类型|说明|
>| :-------- | :--------| :--------| :--------|
>|identifier |true |String| 目标标识 |
>|values |true |IdentifierValue[] | 待编辑的标识值数组 |
>|settings |false |MsgSettings |消息设置 |
###### 返回值
> |类型|说明 |
>| :-------- | :--------|
>|BaseResponse |返回码为1修改标识值成功,返回码不为1则修改标识值失败(其他返回码参照附表1) |
###### 接口示例
``` java
//创建通道管理实例
IChannelManageService chnnlService = new ChannelManageServiceImpl();
try {
//根据IDIS系统提供的ip和端口,创建与IDIS的连接通道对象
IIDManageServiceChannel channel = chnnlService.generateChannel("192.168.150.13", 1304, "TCP");
if (channel != null && chnnlService.getIDManageServiceChannelState(channel) == CHANNEL_LOGOUT) {
BaseResponse loginResp = channel.login("88.1000.1/ADMIN", 301, "c:\\keys\\rsa_pri.pem", null,1);
if(loginResp != null && loginResp.responseCode == 1){
IdentifierValue[] values = new IdentifierValue[2];
values[0] = new IdentifierValue(6, "email", "www.666e.com");
values[1] = new IdentifierValue(7, "url", "www.777e.com");
BaseResponse modifyResp = channel.modifyIdentifierValues("88.1000.2/mm", values, new MsgSettings());
if(modifyResp != null && modifyResp.responseCode == 1){
System.out.println("编辑标识值成功!");
} else if(modifyResp != null && modifyResp instanceof ErrorResponse){
System.out.println(((ErrorResponse)modifyResp).toString());
}
}
}
} catch (IdentifierException e) {
e.printStackTrace();
}
```
**7\. removeIdentifierValues**
###### 接口功能
> 移除目标标识下指定索引对应的标识值
###### 输入参数
> |参数|必选|类型|说明|
>| :-------- | :--------| :--------| :--------|
>|identifier |true |String|目标标识 |
>|indexes |true |int[] |待移除标识值索引 |
>|settings |false |MsgSettings |消息设置 |
###### 返回值
> |类型|说明 |
>| :-------- | :--------|
>|BaseResponse |返回码为1移除标识值成功,返回码不为1则移除标识值失败 (其他返回码参照附表1) |
###### 接口示例
``` java
//创建通道管理实例
IChannelManageService chnnlService = new ChannelManageServiceImpl();
try {
//根据IDIS系统提供的ip和端口,创建与IDIS的连接通道对象
IIDManageServiceChannel channel = chnnlService.generateChannel("192.168.150.13", 1304, "TCP");
if (channel != null && chnnlService.getIDManageServiceChannelState(channel) == 2) {
BaseResponse loginResp = channel.login("88.1000.1/ADMIN", 301, "c:\\keys\\rsa_pri.pem", null,1);
if(loginResp != null && loginResp.responseCode == 1){
int[] arr = {6,7};
BaseResponse removeResp = channel.removeIdentifierValues("88.1000.2/mm", arr, new MsgSettings());
if(removeResp != null && removeResp.responseCode == 1){
System.out.println("移除标识值成功!");
} else if(removeResp != null && removeResp instanceof ErrorResponse){
System.out.println(((ErrorResponse)removeResp).toString());
}
}
}
} catch (IdentifierException e) {
e.printStackTrace();
}
```
**8\. isLogin**
###### 接口功能
> 判断当前通道是否已登录
###### 输入参数
无
###### 返回值
> |类型|说明 |
>| :-------- | :--------|
>|boolean |若已登录则返回true,若未登录则返回false |
###### 接口示例
``` java
//创建通道管理实例
IChannelManageService chnnlService = new ChannelManageServiceImpl();
try {
//根据IDIS系统提供的ip和端口,创建与IDIS的连接通道对象
IIDManageServiceChannel channel = chnnlService.generateChannel("192.168.150.13", 1304, "TCP");
if(channel != null){
boolean bLogin = channel.isLogin();
}
} catch (IdentifierException e) {
e.printStackTrace();
}
```
附表1
---
###### 响应码
> |响应码 |标识符|提示消息|
>| :-------- | :--------| :--------|
>|0 |RC_RESERVED |RC_RESERVED |
>|1 |RC_SUCCESS |SUCCESS |
>|2 |RC_ERROR |ERROR |
>|3 |RC_SERVER_BUSY |SERVER TOO BUSY |
>|4 |RC_PROTOCOL_ERROR |PROTOCOL ERROR |
>|100 |RC_IDENTIFIER_NOT_FOUND |IDENTIFIER NOT FOUND |
>|101 |RC_ IDENTIFIER _ALREADY_EXIST |IDENTIFIER ALREADY EXISTS |
>|102 |RC_INVALID_ IDENTIFIER |INVALID IDENTIFIER |
>|200 |RC_VALUE_NOT_FOUND |VALUES NOT FOUND |
>|201 |RC_VALUE_ALREADY_EXIST |VALUE ALREADY EXISTS |
>|202 |RC_VALUE_INVALID |INVALID VALUE |
>|302 |RC_SERVICE_REFERRAL |SERVICE REFERRAL |
>|303 |RC_PREFIX_REFERRAL |PREFIX REFERRAL |
>|400 |RC_INVALID_ADMIN |INVALID ADMIN |
>|401 |RC_INSUFFICIENT_PERMISSIONS |INSUFFICIENT PERMISSIONS |
>|402 |RC_AUTHENTICATION_NEEDED |AUTHENTICATION NEEDED |
>|403 |RC_AUTHENTICATION_FAILED |AUTHENTICATION FAILED |
>|404 |RC_INVALID_CREDENTIAL |INVALID CREDENTIAL |
>|405 |RC_AUTHEN_TIMEOUT |AUTHENTICATION TIMEOUT |
>|407 |RC_RELOGIN |CLIENT REPEAT LOGIN |
>|408 |RC_LOGIN_FIRST |PLEASE LOGIN FIRST |
附表2
---
###### 异常码
> |异常码 |标识符|提示消息|
>| :-------- | :--------| :--------|
>|-1 |EXCEPTIONCODE_UNSUPPORTENCODING |SDK_INNER_UNSUPPORTENCODING_EXCEPTION |
>|-2 |EXCEPTIONCODE_DISCONN_FAILED |DISCONNECT_FAILED |
>|-4 |EXCEPTIONCODE_LONGCONNSOCKET_CREATE_FAILED |LONGCONNSOCKET_CREATE_FAILED |
>|-5 |EXCEPTIONCODE_ILLEGAL_IP |ILLEGAL_IP |
>|-6 |EXCEPTIONCODE_ILLEGAL_PORT |ILLEGAL_PORT |
>|-7 |INVALID_PARM |INVALID_PARAMETER |
>|-8 |IDENTIFIER_ENGINE_ERROR |IDENTIFIER_ENGINE_ERROR |
>|0 |EXCEPTIONCODE_INVALID_VALUE |INVALID_VALUE |
>|1 |EXCEPTIONCODE_INTERNAL_ERROR |INTERNAL_ERROR |
>|2 |EXCEPTIONCODE_FOUND_NO_SERVICE |ISERVICE_NOT_FOUND |
>|3 |EXCEPTIONCODE_NO_ACCEPTABLE_IDISCOMMUNICATIONITEMS |NO_ACCEPTABLE_INTERFACES |
>|4 |EXCEPTIONCODE_UNKNOWN_PROTOCOL |UNKNOWN_PROTOCOL |
>|5 |EXCEPTIONCODE_IDENTIFIER_ALREADY_EXISTS |IDENTIFIER_ALREADY_EXISTS |
>|6 |EXCEPTIONCODE_MESSAGE_FORMAT_ERROR |MESSAGE_FORMAT_ERROR |
>|7 |EXCEPTIONCODE_CANNOT_CONNECT_TO_IDIS_SERVER |CANNOT_CONNECT_TO_SERVER |
>|8 |EXCEPTIONCODE_UNABLE_TO_AUTHENTICATE |UNABLE_TO_AUTHENTICATE |
>|9 |EXCEPTIONCODE_IDENTIFIER_DOES_NOT_EXIST |IDENTIFIER_DOES_NOT_EXIST|
>|10 |EXCEPTIONCODE_SECURITY_ALERT |SECURITY_ALERT |
>|13 |EXCEPTIONCODE_MISSING_OR_INVALID_SIGNAtrue |MISSING_OR_INVALID_SIGNAtrue |
>|14 |EXCEPTIONCODE_MISSING_CRYPTO_PROVIDER |MISSING_CRYPTO_PROVIDER |
>|15 |EXCEPTIONCODE_IDIS_SERVER_ERROR |SERVER_ERROR |
>|16 |EXCEPTIONCODE_UNKNOWN_ALGORITHM_ID |UNKNOWN_ALGORITHM_ID |
>|17 |EXCEPTIONCODE_GOT_EXPIRED_MESSAGE |GOT_EXPIRED_MESSAGE |
>|26 |EXCEPTIONCODE_ENCRYPTION_ERROR |ENCRYPTION_ERROR |
>|29 |EXCEPTIONCODE_SERVICE_REFERRAL_ERROR |SERVICE_REFERRAL_ERROR |
版权声明:工业互联网与物联网研究所
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 833 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 165 KiB