Compare commits
3 Commits
dev-V11.03
...
dev-shangq
| Author | SHA1 | Date | |
|---|---|---|---|
| c90bb3ea0f | |||
| c516397ad6 | |||
|
|
e299efe782 |
87
pom.xml
87
pom.xml
@ -4,7 +4,7 @@
|
||||
|
||||
<groupId>com.sunyard</groupId>
|
||||
<artifactId>sydapi4j</artifactId>
|
||||
<version>1.0.2022-SNAPSHOT</version>
|
||||
<version>1.13.20220909-1</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>sydapi4j</name>
|
||||
@ -26,59 +26,11 @@
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.houbb</groupId>
|
||||
<artifactId>junitperf</artifactId>
|
||||
<version>1.0.3</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- <!– https://mvnrepository.com/artifact/org.apache.commons/commons-pool2 –>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.apache.commons</groupId>-->
|
||||
<!-- <artifactId>commons-pool2</artifactId>-->
|
||||
<!-- <version>2.11.1</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.jetbrains.kotlin</groupId>-->
|
||||
<!-- <artifactId>kotlin-test</artifactId>-->
|
||||
<!-- <version>${kotlin.version}</version>-->
|
||||
<!-- <scope>test</scope>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
|
||||
<!-- <!– https://mvnrepository.com/artifact/dom4j/dom4j –>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>dom4j</groupId>-->
|
||||
<!-- <artifactId>dom4j</artifactId>-->
|
||||
<!-- <version>1.6.1</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- <!– https://mvnrepository.com/artifact/com.alibaba/fastjson –>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.alibaba</groupId>-->
|
||||
<!-- <artifactId>fastjson</artifactId>-->
|
||||
<!-- <version>1.2.80</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.jetbrains.kotlin</groupId>-->
|
||||
<!-- <artifactId>kotlin-stdlib-jdk8</artifactId>-->
|
||||
<!-- <version>${kotlin.version}</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
|
||||
<!--<dependency>-->
|
||||
<!--<groupId>com.sunyard</groupId>-->
|
||||
<!--<artifactId>Converter</artifactId>-->
|
||||
<!--<version>[1.0.201807251700, 1.1-SNAPSHOT)</version>-->
|
||||
<!--</dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>com.sunyard</groupId>
|
||||
<artifactId>proto</artifactId>
|
||||
<version>1.1.20221215</version>
|
||||
<version>1.0.20221215</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -87,35 +39,6 @@
|
||||
<version>5.4.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcpkix-jdk15on</artifactId>
|
||||
<version>1.65</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
<version>1.65</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.8.4.M1</version>
|
||||
</dependency>
|
||||
|
||||
<!--<dependency>-->
|
||||
<!--<groupId>club.fullstack</groupId>-->
|
||||
<!--<artifactId>serialize</artifactId>-->
|
||||
<!--<version>[1.0.201806051035, 1.1.SNAPSHOT)</version>-->
|
||||
<!--</dependency>-->
|
||||
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.github.wvengen/proguard-maven-plugin -->
|
||||
<!-- https://mvnrepository.com/artifact/com.github.wvengen/proguard-maven-plugin -->
|
||||
</dependencies>
|
||||
<build>
|
||||
<finalName>sydapi4j</finalName>
|
||||
@ -149,8 +72,8 @@
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<source>6</source>
|
||||
<target>6</target>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
<compilerId>groovy-eclipse-compiler</compilerId>
|
||||
<verbose>true</verbose>
|
||||
<fork>true</fork>
|
||||
@ -243,7 +166,7 @@
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>com.Sample.TestDemo</mainClass>
|
||||
<mainClass>racal.sunyard.main.Version</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
<descriptorRefs>
|
||||
|
||||
@ -728,7 +728,7 @@ public class SydApi4j implements SydApi {
|
||||
data.put("signature", sign);
|
||||
data.put("returnSign$option", 0);
|
||||
ByteBuffer bb = proto.rend(packet);
|
||||
|
||||
|
||||
synchronized(this) {
|
||||
byte[] b = this.syncSend(bb);
|
||||
bb = this.syncRead(b);
|
||||
@ -1049,11 +1049,9 @@ public class SydApi4j implements SydApi {
|
||||
|
||||
}
|
||||
|
||||
// 测试通过
|
||||
@Override
|
||||
public boolean detachedVerify(int dataType, byte[] orgData, String sign) {
|
||||
public boolean detachedVerify(int dataType, byte[] orgData, String sign, Boolean checkCert) {
|
||||
Proto8006 proto = new Proto8006();
|
||||
// 填充数据
|
||||
// 填充数据
|
||||
HashMap<String, Object> packet = new HashMap<String, Object>();
|
||||
PacketSN sn = PacketSN.gen();
|
||||
|
||||
@ -1071,7 +1069,7 @@ public class SydApi4j implements SydApi {
|
||||
|
||||
|
||||
data.put("signData", sign.getBytes());
|
||||
data.put("flag$option", 0);
|
||||
data.put("flag$option", checkCert ? 1 : 0);
|
||||
// 渲染发送
|
||||
ByteBuffer bb = proto.rend(packet);
|
||||
|
||||
@ -1102,6 +1100,12 @@ public class SydApi4j implements SydApi {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 测试通过
|
||||
@Override
|
||||
public boolean detachedVerify(int dataType, byte[] orgData, String sign) {
|
||||
return detachedVerify(dataType, orgData, sign, false);
|
||||
}
|
||||
|
||||
public boolean detachedVerifyAll(int rFlag,byte[] orgData, String sign){
|
||||
try {
|
||||
boolean sm2Cert = CertUtil.isSignedBySM2Cert(sign);
|
||||
@ -1676,7 +1680,7 @@ public class SydApi4j implements SydApi {
|
||||
|
||||
return m_certs;
|
||||
}
|
||||
|
||||
|
||||
// 测试通过
|
||||
@Override
|
||||
public RetWrap getAllCert(int dataFlag,String sqlite) throws UnsupportedEncodingException {
|
||||
@ -12120,7 +12124,7 @@ public class SydApi4j implements SydApi {
|
||||
byte[] pk = (byte[]) ret.get("pk");
|
||||
byte[] hash = this.SM3Hash(Util.bytes2HexString(pk), orgData);
|
||||
String sign2 = (String) ret.get("sign");
|
||||
boolean pass = this.detachedVerify(0, hash, sign2);
|
||||
boolean pass = this.detachedVerify(0, hash, sign2, true);
|
||||
if (pass) {
|
||||
ret.put("oData", orgData);
|
||||
String certInfo = (String) ret.get("cert");
|
||||
@ -12409,9 +12413,9 @@ public class SydApi4j implements SydApi {
|
||||
@Override
|
||||
public byte[] attachedVerifyRD(byte[] sign) {
|
||||
RetWrap retWrap = attachedVerifyAndGetAll(sign);
|
||||
if (retWrap == null)
|
||||
if (retWrap == null) {
|
||||
return null;
|
||||
|
||||
}
|
||||
return (byte[]) retWrap.get("oData");
|
||||
}
|
||||
|
||||
@ -12422,23 +12426,29 @@ public class SydApi4j implements SydApi {
|
||||
* @param sign 已签名数据
|
||||
* @return 返回CERT_INFO结构的证书数据
|
||||
*/
|
||||
@Override
|
||||
public X509 attachedVerifyAndGetX509(String sign) {
|
||||
return attachedVerifyAndGetX509( sign.getBytes() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public X509 attachedVerifyAndGetX509(byte[] sign) {
|
||||
RetWrap retWrap = attachedVerifyAndGetAll( sign);
|
||||
if (retWrap == null)
|
||||
|
||||
if (retWrap == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (X509) retWrap.get("x509");
|
||||
}
|
||||
|
||||
|
||||
public RetWrap attachedVerifyAndGetAll(String sign) {
|
||||
return attachedVerifyAndGetAll( sign.getBytes() );
|
||||
}
|
||||
|
||||
// 大数据兼容处理
|
||||
@Override
|
||||
public RetWrap attachedVerifyAndGetAll(byte[] sign) {
|
||||
if( sign.length > 4096 ) {
|
||||
|
||||
@ -12483,7 +12493,10 @@ public class SydApi4j implements SydApi {
|
||||
PacketSection error = (PacketSection) ret.get("error");
|
||||
byte[] be = error.getBytes();
|
||||
if ((0 != (be[0] ^ be[1]))) {
|
||||
return null;
|
||||
SydApiException e = new SydApiException(error.getInfo(), error.autoInt());
|
||||
// println("验签失败=" + e.toString());
|
||||
// return null;
|
||||
throw e;
|
||||
}
|
||||
|
||||
PacketSection info = (PacketSection) ret.get("info");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user