完善异常信息捕获、证书列表获取

This commit is contained in:
yihzhou
2022-11-28 10:17:52 +08:00
parent 99a7462fdf
commit 0f28395ce9
5 changed files with 130 additions and 186 deletions
@@ -107,6 +107,12 @@ public class SydApiException extends RuntimeException{
transMsg();
}
public SydApiException(int retCode, Exception e) {
super("SydApiException(" + "code = "+String.format("%04x", retCode) + ")" , e);
this.retCode = retCode;
transMsg();
}
public SydApiException(String msg, int retCode){
super("SydApiException(" + String.format(" %04X", retCode) + ":" + ( null == msg ? transMsg(retCode) : msg ) + ")" );
+17 -13
View File
@@ -1310,7 +1310,7 @@ public class SydApi4j implements SydApi {
while (bb.limit() - bb.position() >= 128) {
byte[] cert = new byte[128];
bb.get(cert);
certs.add(new String(cert, "GBK"));
certs.add(new String(cert, "GBK").trim());
}
// r.put("certDNs",certs.toArray(new String[0]) );
@@ -1333,10 +1333,9 @@ 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);
data.put("sqlite3", sqlite);
// 渲染发送
ByteBuffer bb = proto.rend(packet);
@@ -1365,24 +1364,29 @@ 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>();
while (bb.limit() - bb.position() >= 128) {
byte[] cert = new byte[128];
bb.get(cert);
certs.add(new String(cert, "GBK"));
certs.add(new String(cert, "GBK").trim());
}
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;
}
@@ -1760,7 +1764,7 @@ public class SydApi4j implements SydApi {
}
socket.setSoTimeout(timeout);
} catch (Exception e) {
socket = reConnect(new SydApiException(-2));
socket = reConnect(new SydApiException(-2, e));
}