Merge remote-tracking branch 'origin/dev-shangqing' into dev-shangqing
This commit is contained in:
commit
99a7462fdf
@ -7,18 +7,9 @@
|
||||
</command>
|
||||
<data extend="data">
|
||||
|
||||
<dataFlag len="1" cn="数据包标志">
|
||||
<options>
|
||||
<option cn="起始包">
|
||||
<bin>00</bin>
|
||||
</option>
|
||||
<option cn="中间包">
|
||||
<bin>01</bin>
|
||||
</option>
|
||||
<option cn="结束包">
|
||||
<bin>02</bin>
|
||||
</option>
|
||||
</options>
|
||||
<dataFlag len="4" cn="数据包标志">
|
||||
0:起始包
|
||||
其他:传入上一个包返回的数据标志
|
||||
</dataFlag>
|
||||
|
||||
<sqlite3 cn="Sqlite3 查询条件">
|
||||
@ -75,10 +66,7 @@
|
||||
</error>
|
||||
|
||||
<dataFlag len="4" cn="数据包标志">
|
||||
0:起始包
|
||||
1:中间包
|
||||
2:结束包
|
||||
(可能hi因为字节对此,后三字节为垃圾值)
|
||||
已返回证书个数
|
||||
</dataFlag>
|
||||
|
||||
<certAllNum len="4" cn="证书总数">
|
||||
|
||||
5
pom.xml
5
pom.xml
@ -26,6 +26,11 @@
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.houbb</groupId>
|
||||
<artifactId>junitperf</artifactId>
|
||||
<version>1.0.3</version>
|
||||
</dependency>
|
||||
|
||||
<!-- <!– https://mvnrepository.com/artifact/org.apache.commons/commons-pool2 –>-->
|
||||
<!-- <dependency>-->
|
||||
|
||||
@ -1261,7 +1261,7 @@ public class SydApi4j implements SydApi {
|
||||
|
||||
PacketSN sn = PacketSN.gen();
|
||||
packet.put("header", sn.getSn().array());
|
||||
data.put("dataFlag$option", dataFlag);
|
||||
data.put("dataFlag",Util.slenBytes(dataFlag,4));
|
||||
|
||||
String sqlite3 = "1 = 1 ";
|
||||
data.put("sqlite3", sqlite3);
|
||||
@ -1293,13 +1293,17 @@ public class SydApi4j implements SydApi {
|
||||
RetWrap r = new RetWrap();
|
||||
|
||||
PacketSection resDataFlag = (PacketSection) ret.get("dataFlag");
|
||||
r.put("dataFlag", (int) resDataFlag.getBytes()[0]);
|
||||
PacketSection certAllNum = (PacketSection) ret.get("certAllNum");
|
||||
r.put("certAllNum", (int) certAllNum.getBytes()[0]);
|
||||
PacketSection realCertNum = (PacketSection) ret.get("realCertNum");
|
||||
r.put("realCertNum", (int) realCertNum.getBytes()[0]);
|
||||
PacketSection dataAttrFlag = (PacketSection) ret.get("dataAttrFlag");
|
||||
r.put("dataAttrFlag", (int) dataAttrFlag.getBytes()[0]);
|
||||
PacketSection realCertNum = (PacketSection) ret.get("realCertNum");
|
||||
try {
|
||||
r.put("dataFlag",Util.smallLen(resDataFlag.getBytes()) );
|
||||
r.put("certAllNum", Util.smallLen(certAllNum.getBytes()));
|
||||
r.put("dataAttrFlag", Util.smallLen(dataAttrFlag.getBytes()));
|
||||
r.put("realCertNum", Util.smallLen(realCertNum.getBytes()));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
r.put("certLenMax", Integer.parseInt(Util.bytes2HexString(Util.toArray(bb)).substring(60, 62), 16));
|
||||
|
||||
List<String> certs = new ArrayList<String>();
|
||||
@ -1309,11 +1313,13 @@ public class SydApi4j implements SydApi {
|
||||
certs.add(new String(cert, "GBK"));
|
||||
}
|
||||
|
||||
r.put("certDNs", certs.toArray(new String[0]));
|
||||
r.put("certDNlist", certs);
|
||||
// r.put("certDNs",certs.toArray(new String[0]) );
|
||||
|
||||
r.put("certDNs",certs);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
// 测试通过
|
||||
@Override
|
||||
public RetWrap getAllCert(int dataFlag,String sqlite) throws UnsupportedEncodingException {
|
||||
|
||||
67
src/test/java/com/sunyard/sydapi/test/CertTest.java
Normal file
67
src/test/java/com/sunyard/sydapi/test/CertTest.java
Normal file
@ -0,0 +1,67 @@
|
||||
package com.sunyard.sydapi.test;
|
||||
|
||||
import com.github.houbb.junitperf.core.annotation.JunitPerfConfig;
|
||||
import com.github.houbb.junitperf.core.rule.JunitPerfRule;
|
||||
import com.sunyard.RetWrap;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import racal.sunyard.main.SydApi4j;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
import static com.sunyard.sydapi.util.PrintUtil.printRetWrap;
|
||||
|
||||
public class CertTest {
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.setProperty("com.sunyard.sydapi4j.debug", "true");
|
||||
|
||||
SydApi4j api = (SydApi4j) new SydApi4j().connect("192.168.1.129", 8889, null, 1000);
|
||||
try{
|
||||
RetWrap allCert = api.getAllCert(0);
|
||||
printRetWrap(allCert);
|
||||
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
api.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
// 测试参数
|
||||
// private static final int threads = 1;
|
||||
// private static final long duration = 120000;
|
||||
// private static final long warmUp = 30000;
|
||||
//
|
||||
//
|
||||
// @Rule
|
||||
// public JunitPerfRule junitPerfRule = new JunitPerfRule();
|
||||
// SydApi4j api = (SydApi4j) new SydApi4j().connect("192.168.1.129",8889,null,3000);
|
||||
//
|
||||
//
|
||||
// @BeforeClass
|
||||
// public static void init() throws UnsupportedEncodingException {
|
||||
// System.out.println("begin");
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @AfterClass
|
||||
// public static void after() {
|
||||
// System.out.println("all over");
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// @JunitPerfConfig(threads = threads, warmUp = warmUp, duration = duration)
|
||||
// public void getAllCert(){
|
||||
// try {
|
||||
// api.getAllCert(0);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
}
|
||||
114
src/test/java/com/sunyard/sydapi/test/P1P7Test.java
Normal file
114
src/test/java/com/sunyard/sydapi/test/P1P7Test.java
Normal file
@ -0,0 +1,114 @@
|
||||
package com.sunyard.sydapi.test;
|
||||
|
||||
import com.sunyard.proto.Util;
|
||||
import org.junit.runners.MethodSorters;
|
||||
import racal.sunyard.main.SydApi4j;
|
||||
|
||||
import com.github.houbb.junitperf.core.annotation.JunitPerfConfig;
|
||||
import com.github.houbb.junitperf.core.rule.JunitPerfRule;
|
||||
import org.junit.*;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
public class P1P7Test {
|
||||
// 全局配置
|
||||
private static final String dn = "C=CN,O=CFCA OCA1,OU=YCCA,OU=Individual-2,CN=YCCA@黄金交易所@Zhuangj@1";
|
||||
|
||||
// 测试参数
|
||||
private static final int threads = 1;
|
||||
private static final long duration = 120000;
|
||||
private static final long warmUp = 30000;
|
||||
|
||||
// 原始数据
|
||||
private static final byte[] data1k = new byte[ 1024 * 4];
|
||||
|
||||
private static final byte[] data1m = new byte[ 1024 * 1024 ];
|
||||
|
||||
|
||||
// 临时数据
|
||||
private static String pk = null;
|
||||
private static String dm_1k;
|
||||
private static String dm_1m = null;
|
||||
private static byte[] p1sign_1k;
|
||||
private static byte[] p1sign_1m = null;
|
||||
private static String p7dsign_1k;
|
||||
private static String p7dsign_1m = null;
|
||||
private static String p7asign_1k;
|
||||
private static String p7asign_1m = null;
|
||||
|
||||
@Rule
|
||||
public JunitPerfRule junitPerfRule = new JunitPerfRule();
|
||||
SydApi4j api = (SydApi4j) new SydApi4j().connect("192.168.0.200",8889,null,3000);
|
||||
|
||||
|
||||
|
||||
@BeforeClass
|
||||
public static void init() throws UnsupportedEncodingException {
|
||||
System.out.println("begin");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@AfterClass
|
||||
public static void after() {
|
||||
System.out.println("all over");
|
||||
}
|
||||
|
||||
@Test
|
||||
@JunitPerfConfig(threads = threads, warmUp = warmUp, duration = duration)
|
||||
public void p1_sign_1k(){
|
||||
p1sign_1k= api.SYD_NakedSign(data1k, dn);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@JunitPerfConfig(threads = threads, warmUp = warmUp, duration = duration)
|
||||
public void p1_verify_1k(){
|
||||
api.SYD_NakedVerify( data1k, p1sign_1k, dn );
|
||||
}
|
||||
|
||||
@Test
|
||||
@JunitPerfConfig(threads = threads, warmUp = warmUp, duration = duration)
|
||||
public void p7a_sign_1k() throws UnsupportedEncodingException {
|
||||
p7asign_1k = api.attachedSign(data1k, dn);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@JunitPerfConfig(threads = threads, warmUp = warmUp, duration = duration)
|
||||
public void p7a_verify_1k(){
|
||||
api.attachedVerifyAndGetAll( p7asign_1k );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
@JunitPerfConfig(threads = threads, warmUp = warmUp, duration = duration)
|
||||
public void p7d_sign_1k(){
|
||||
p7dsign_1k = api.sm3AndDetachedSign(data1k, pk, dn);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@JunitPerfConfig(threads = threads, warmUp = warmUp, duration = duration)
|
||||
public void p7d_verify_1k(){
|
||||
api.sm3AndDetachedVerify(data1k, pk, p7dsign_1k );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
@JunitPerfConfig(threads = threads, warmUp = warmUp, duration = duration)
|
||||
public void dm_aen_1k() {
|
||||
dm_1k = String.valueOf(api.generateDEByDn(dn, data1k));
|
||||
}
|
||||
|
||||
@Test
|
||||
@JunitPerfConfig(threads = threads, warmUp = warmUp, duration = duration)
|
||||
public void dm_de_1k() {
|
||||
api.decryptDEByDN(dn, Util.hexString2Bytes(dm_1k));
|
||||
}
|
||||
}
|
||||
@ -14,7 +14,7 @@ public class TestPKCS1 {
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
System.setProperty("com.sunyard.sydapi4j.debug","true");
|
||||
// 连接加密机
|
||||
SydApi4j api = (SydApi4j) new SydApi4j().connect("192.168.0.200", 8889, null, 1000);
|
||||
|
||||
@ -22,10 +22,10 @@ public class TestPKCS1 {
|
||||
try {
|
||||
|
||||
// 原始数据模式
|
||||
// case1( api );
|
||||
case1( api );
|
||||
|
||||
// 外部 hash
|
||||
case2( api );
|
||||
// case2( api );
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user