From 286867923dcfb0d9c5e18a554414ba84ff59801e Mon Sep 17 00:00:00 2001 From: zhoubin <2023106681@qq.com> Date: Tue, 7 Dec 2021 14:33:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=93=B6=E8=81=94=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=90=8D=E5=8F=8A=E6=8E=A5=E5=8F=A3=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E7=BD=91=E8=81=94=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DProto/6C.xml | 4 + DProto/6D.xml | 4 + .../sunyard/inf/customize/SydUnionPayApi.java | 4 +- .../java/racal/sunyard/main/SydApi4j.java | 84 +- .../java/racal/sunyard/main/dto/DTO4D41.java | 1015 ---------- .../java/racal/sunyard/main/dto/DTO4D43.java | 1015 ---------- .../java/racal/sunyard/main/dto/DTO60.java | 735 -------- .../java/racal/sunyard/main/dto/DTO61.java | 771 -------- .../java/racal/sunyard/main/dto/DTO62.java | 999 ---------- .../java/racal/sunyard/main/dto/DTO63.java | 999 ---------- .../java/racal/sunyard/main/dto/DTO64.java | 1049 ----------- .../java/racal/sunyard/main/dto/DTO65.java | 1011 ---------- .../java/racal/sunyard/main/dto/DTO66.java | 906 --------- .../java/racal/sunyard/main/dto/DTO67.java | 868 --------- .../java/racal/sunyard/main/dto/DTO68.java | 1276 ------------- .../java/racal/sunyard/main/dto/DTO69.java | 1319 ------------- .../java/racal/sunyard/main/dto/DTO6A.java | 1128 ------------ .../java/racal/sunyard/main/dto/DTO6B.java | 1061 ----------- .../java/racal/sunyard/main/dto/DTO6C.java | 982 ---------- .../java/racal/sunyard/main/dto/DTO6D.java | 1025 ----------- .../java/racal/sunyard/main/dto/DTO6E.java | 825 --------- .../java/racal/sunyard/main/dto/DTO71.java | 762 -------- .../java/racal/sunyard/main/dto/DTO72.java | 944 ---------- .../java/racal/sunyard/main/dto/DTO73.java | 980 ---------- .../java/racal/sunyard/main/dto/DTO74.java | 1190 ------------ .../java/racal/sunyard/main/dto/DTO75.java | 1089 ----------- .../java/racal/sunyard/main/dto/DTO76.java | 1017 ---------- .../java/racal/sunyard/main/dto/DTO77.java | 865 --------- .../java/racal/sunyard/main/dto/DTO78.java | 1056 ----------- .../java/racal/sunyard/main/dto/DTO79.java | 901 --------- .../java/racal/sunyard/main/dto/DTO7A.java | 865 --------- .../java/racal/sunyard/main/dto/DTO7B.java | 1092 ----------- .../java/racal/sunyard/main/dto/DTO7C.java | 1098 ----------- .../java/racal/sunyard/main/dto/DTO7D.java | 954 ---------- .../java/racal/sunyard/main/dto/DTO7E.java | 818 -------- .../java/racal/sunyard/main/dto/DTO80.java | 879 --------- .../java/racal/sunyard/main/dto/DTO8003.java | 864 --------- .../java/racal/sunyard/main/dto/DTO8004.java | 994 ---------- .../java/racal/sunyard/main/dto/DTO8005.java | 767 -------- .../java/racal/sunyard/main/dto/DTO8006.java | 877 --------- .../java/racal/sunyard/main/dto/DTO8012.java | 884 --------- .../java/racal/sunyard/main/dto/DTO8016.java | 680 ------- .../java/racal/sunyard/main/dto/DTO8017.java | 754 -------- .../java/racal/sunyard/main/dto/DTO8018.java | 695 ------- .../java/racal/sunyard/main/dto/DTO8019.java | 769 -------- .../java/racal/sunyard/main/dto/DTO8024.java | 767 -------- .../java/racal/sunyard/main/dto/DTO8025.java | 877 --------- .../java/racal/sunyard/main/dto/DTO8026.java | 807 -------- .../java/racal/sunyard/main/dto/DTO81.java | 872 --------- .../java/racal/sunyard/main/dto/DTO82.java | 914 --------- .../java/racal/sunyard/main/dto/DTO83.java | 1033 ----------- .../java/racal/sunyard/main/dto/DTO93.java | 832 --------- .../java/racal/sunyard/main/dto/DTO94.java | 868 --------- .../java/racal/sunyard/main/dto/DTO95.java | 942 ---------- .../java/racal/sunyard/main/dto/DTO96.java | 796 -------- .../java/racal/sunyard/main/dto/DTOA0.java | 1071 ----------- .../java/racal/sunyard/main/dto/DTOA2.java | 879 --------- .../java/racal/sunyard/main/dto/DTOA4.java | 944 ---------- .../java/racal/sunyard/main/dto/DTOA6.java | 951 ---------- .../java/racal/sunyard/main/dto/DTOA8.java | 944 ---------- .../java/racal/sunyard/main/dto/DTOAA.java | 873 --------- .../java/racal/sunyard/main/dto/DTOAB.java | 947 ---------- .../java/racal/sunyard/main/dto/DTOAE.java | 959 ---------- .../java/racal/sunyard/main/dto/DTOAG.java | 1009 ---------- .../java/racal/sunyard/main/dto/DTOB0.java | 815 -------- .../java/racal/sunyard/main/dto/DTOBA.java | 796 -------- .../java/racal/sunyard/main/dto/DTOBY.java | 973 ---------- .../java/racal/sunyard/main/dto/DTOCA.java | 1259 ------------- .../java/racal/sunyard/main/dto/DTOCB.java | 1418 -------------- .../java/racal/sunyard/main/dto/DTOCC.java | 1252 ------------- .../java/racal/sunyard/main/dto/DTODE.java | 855 --------- .../java/racal/sunyard/main/dto/DTOE0.java | 1640 ----------------- .../java/racal/sunyard/main/dto/DTOE1.java | 1640 ----------------- .../java/racal/sunyard/main/dto/DTOE2.java | 1019 ---------- .../java/racal/sunyard/main/dto/DTOE4.java | 952 ---------- .../java/racal/sunyard/main/dto/DTOFA.java | 1016 ---------- .../java/racal/sunyard/main/dto/DTOFC.java | 1002 ---------- .../java/racal/sunyard/main/dto/DTOFE.java | 1009 ---------- .../java/racal/sunyard/main/dto/DTOFI.java | 1249 ------------- .../java/racal/sunyard/main/dto/DTOFK.java | 1148 ------------ .../java/racal/sunyard/main/dto/DTOFM.java | 1148 ------------ .../java/racal/sunyard/main/dto/DTOGC.java | 1016 ---------- .../java/racal/sunyard/main/dto/DTOGY.java | 1023 ---------- .../java/racal/sunyard/main/dto/DTOHA.java | 1040 ----------- .../java/racal/sunyard/main/dto/DTOHC.java | 1038 ----------- .../java/racal/sunyard/main/dto/DTOHI.java | 708 ------- .../java/racal/sunyard/main/dto/DTOHV.java | 780 -------- .../java/racal/sunyard/main/dto/DTOIA.java | 1031 ----------- .../java/racal/sunyard/main/dto/DTOJA.java | 839 --------- .../java/racal/sunyard/main/dto/DTOJC.java | 1070 ----------- .../java/racal/sunyard/main/dto/DTOJE.java | 1070 ----------- .../java/racal/sunyard/main/dto/DTOJG.java | 1070 ----------- .../java/racal/sunyard/main/dto/DTOLB.java | 923 ---------- .../java/racal/sunyard/main/dto/DTOLF.java | 801 -------- .../java/racal/sunyard/main/dto/DTOLG.java | 945 ---------- .../java/racal/sunyard/main/dto/DTOMA.java | 976 ---------- .../java/racal/sunyard/main/dto/DTOMAXF.java | 858 --------- .../java/racal/sunyard/main/dto/DTOMC.java | 976 ---------- .../java/racal/sunyard/main/dto/DTOMF.java | 1009 ---------- .../java/racal/sunyard/main/dto/DTOMG.java | 1009 ---------- .../java/racal/sunyard/main/dto/DTOMS.java | 1174 ------------ .../java/racal/sunyard/main/dto/DTOMU.java | 939 ---------- .../java/racal/sunyard/main/dto/DTONE.java | 915 --------- .../java/racal/sunyard/main/dto/DTONG.java | 803 -------- .../java/racal/sunyard/main/dto/DTOOC.java | 930 ---------- .../java/racal/sunyard/main/dto/DTOPA.java | 692 ------- .../java/racal/sunyard/main/dto/DTOPE.java | 953 ---------- .../java/racal/sunyard/main/dto/DTOQ1.java | 1180 ------------ .../java/racal/sunyard/main/dto/DTOQ2.java | 1180 ------------ .../java/racal/sunyard/main/dto/DTOQN.java | 691 ------- .../java/racal/sunyard/main/dto/DTOQQ.java | 718 -------- .../java/racal/sunyard/main/dto/DTOQX.java | 718 -------- .../java/racal/sunyard/main/dto/DTOTC.java | 771 -------- .../java/racal/sunyard/main/dto/DTOY0.java | 1275 ------------- .../java/racal/sunyard/main/dto/DTOY8.java | 693 ------- .../java/racal/sunyard/main/dto/DTOYA.java | 1013 ---------- .../sunyard/sydapi/test/TestAllMethods.java | 10 +- 117 files changed, 97 insertions(+), 108090 deletions(-) delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO4D41.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO4D43.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO60.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO61.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO62.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO63.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO64.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO65.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO66.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO67.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO68.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO69.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO6A.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO6B.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO6C.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO6D.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO6E.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO71.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO72.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO73.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO74.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO75.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO76.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO77.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO78.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO79.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO7A.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO7B.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO7C.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO7D.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO7E.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO80.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO8003.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO8004.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO8005.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO8006.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO8012.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO8016.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO8017.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO8018.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO8019.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO8024.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO8025.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO8026.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO81.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO82.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO83.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO93.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO94.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO95.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTO96.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOA0.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOA2.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOA4.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOA6.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOA8.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOAA.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOAB.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOAE.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOAG.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOB0.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOBA.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOBY.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOCA.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOCB.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOCC.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTODE.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOE0.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOE1.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOE2.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOE4.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOFA.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOFC.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOFE.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOFI.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOFK.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOFM.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOGC.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOGY.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOHA.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOHC.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOHI.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOHV.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOIA.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOJA.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOJC.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOJE.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOJG.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOLB.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOLF.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOLG.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOMA.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOMAXF.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOMC.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOMF.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOMG.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOMS.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOMU.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTONE.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTONG.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOOC.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOPA.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOPE.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOQ1.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOQ2.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOQN.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOQQ.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOQX.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOTC.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOY0.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOY8.java delete mode 100644 src/main/java/racal/sunyard/main/dto/DTOYA.java diff --git a/DProto/6C.xml b/DProto/6C.xml index 6bd757e..3b3af7b 100644 --- a/DProto/6C.xml +++ b/DProto/6C.xml @@ -32,6 +32,10 @@ 可选项,只针对“证书模式”为 1时有。 + + 可以没有,如果有一定是 ‘P’,表示后续值是 SM3HASH + + 数据长度 diff --git a/DProto/6D.xml b/DProto/6D.xml index b61b4eb..bd42b56 100644 --- a/DProto/6D.xml +++ b/DProto/6D.xml @@ -39,6 +39,10 @@ 可选项,只针对“证书模式”为2 时有。 + + 可以没有,如果有一定是 ‘P’,表示后续值是 SM3HASH + + 数据长度 diff --git a/src/main/java/com/sunyard/inf/customize/SydUnionPayApi.java b/src/main/java/com/sunyard/inf/customize/SydUnionPayApi.java index 00ea8f7..2f372a8 100644 --- a/src/main/java/com/sunyard/inf/customize/SydUnionPayApi.java +++ b/src/main/java/com/sunyard/inf/customize/SydUnionPayApi.java @@ -12,7 +12,7 @@ public interface SydUnionPayApi { * @param pOrgData 输入。 待签名的原始数据。 * @return 签名数据(BASE64 编码)。 */ - String netSign(String pCertSerial, String userId, byte[] pOrgData); + String unPSign(String pCertSerial, String userId, byte[] pOrgData); /** @@ -24,5 +24,5 @@ public interface SydUnionPayApi { * @param pSignData 输入。 签名数据(BASE64 编码)。 * @return true 表示验证正确;false 表示失败; */ - boolean netVerify(String pCertSerial, String userId, byte[] pOrgData, String pSignData); + boolean unPVerify(String pCertSerial, String userId, byte[] pOrgData, String pSignData); } diff --git a/src/main/java/racal/sunyard/main/SydApi4j.java b/src/main/java/racal/sunyard/main/SydApi4j.java index b0a0056..f6af4c9 100644 --- a/src/main/java/racal/sunyard/main/SydApi4j.java +++ b/src/main/java/racal/sunyard/main/SydApi4j.java @@ -2242,7 +2242,7 @@ public class SydApi4j implements SydApi { * @return 签名数据(BASE64 编码)。 */ @Override - public String netSign(String pCertSerial, String userId, byte[] pOrgData) { + public String unPSign(String pCertSerial, String userId, byte[] pOrgData) { // 针对传化需求定制 // 获取协议 @@ -2296,7 +2296,7 @@ public class SydApi4j implements SydApi { * @return true 表示验证正确;false 表示失败; */ @Override - public boolean netVerify(String pCertSerial, String userId, byte[] pOrgData, String pSignData) { + public boolean unPVerify(String pCertSerial, String userId, byte[] pOrgData, String pSignData) { // 获取协议 Proto6D proto=new Proto6D(); @@ -2346,7 +2346,46 @@ public class SydApi4j implements SydApi { */ @Override public String netSign(String pCertSerial, byte[] pOrgData) { - return netSign(pCertSerial, null, pOrgData); + // 针对传化需求定制 + // 获取协议 + //ProtocolRender render = pset.getProtocolReqRender("6C"); + Proto6C proto = new Proto6C(); + + // 先进行 HASH + pOrgData = SM3HashSNaId( pCertSerial, null, pOrgData ); + + // 填充数据 + PacketSN sn = PacketSN.gen(); + HashMap packet = new HashMap(); + packet.put("header", sn.getSn().array()); + HashMap data = new HashMap(); + data.put("certificateModel$option", 0); + data.put("certificateSn", pCertSerial); + data.put("inData", pOrgData); + packet.put("data", data); + + // 渲染发送 + ByteBuffer bb = proto.rend(packet); + synchronized (this) { + // 响应解析 + bb = syncRead(syncSend(bb)); + } + + //ProtocolParser parser = pset.getProtocolResParse(); + Packet p = proto.parse(bb); + Map ret = p.toMap(); + if ( + !Arrays.equals(sn.getSn().array(), ((PacketSection) ret.get("header")).getBytes()) + ) { + throw new SydApiException("包序号不匹配", -4); + } + ret = (Map) ret.get("data"); + PacketSection error = (PacketSection) ret.get("error"); + if (!"00".equals(error.getString())) { + throw new SydApiException(error.getInfo(), error.autoInt()); + } + + return ((PacketSection) ret.get("sign")).getString(); } /** @@ -2359,7 +2398,44 @@ public class SydApi4j implements SydApi { */ @Override public boolean netVerify(String pCertSerial, byte[] pOrgData, String pSignData) { - return netVerify(pCertSerial, null, pOrgData, pSignData); + // 获取协议 + //ProtocolRender render = pset.getProtocolReqRender("6D"); + Proto6D proto=new Proto6D(); + + pOrgData = SM3HashSNaId( pCertSerial, null, pOrgData ); + + // 填充数据 + PacketSN sn = PacketSN.gen(); + HashMap packet = new HashMap(); + packet.put("header", sn.getSn().array()); + HashMap data = new HashMap(); + data.put("certificateModel$option", 0); + data.put("certificateSn", pCertSerial); + data.put("inData", pOrgData); + data.put("sign", pSignData); + packet.put("data", data); + + // 渲染发送 + ByteBuffer bb = proto.rend(packet); + synchronized (this) { + // 响应解析 + bb = syncRead( syncSend(bb) ); + } + //ProtocolParser parser = pset.getProtocolResParse(); + Packet p = proto.parse(bb); + Map ret = p.toMap(); + if ( + !Arrays.equals(sn.getSn().array(), ((PacketSection) ret.get("header")).getBytes()) + ) { + throw new SydApiException("包序号不匹配", -4); + } + ret = (Map) ret.get("data"); + PacketSection error = (PacketSection) ret.get("error"); + if (!"00".equals(error.getString())) { + throw new SydApiException(error.getInfo(), error.autoInt()); + } + + return true; } diff --git a/src/main/java/racal/sunyard/main/dto/DTO4D41.java b/src/main/java/racal/sunyard/main/dto/DTO4D41.java deleted file mode 100644 index 230aa5a..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO4D41.java +++ /dev/null @@ -1,1015 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO4D41 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] tag = null; - private byte[] alg = null; - private byte[] type = null; - private byte[] full = null; - private byte[] macLen = null; - private byte[] key = null; - private byte[] mACData = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getTagAsBin( ) { - - return this.tag; - } - - - public String getTagAsStr( ) { - - if( null == this.tag) return null; - return Arrays.toString(this.tag); - } - - - public String getTagAsHex( ) { - - if( null == this.tag) return null; - return Util.bytes2HexString(tag); - } - - - public Data setTag( byte[] bytes ) { - - this.tag = bytes; - return this; - } - - - public byte[] getAlgAsBin( ) { - - return this.alg; - } - - - public String getAlgAsStr( ) { - - if( null == this.alg) return null; - return Arrays.toString(this.alg); - } - - - public String getAlgAsHex( ) { - - if( null == this.alg) return null; - return Util.bytes2HexString(alg); - } - - - public Data setAlg( byte[] bytes ) { - - this.alg = bytes; - return this; - } -public enum AlgOptions { - - OPV3DES(Util.hexString2Bytes("31")), - OPVSM4(Util.hexString2Bytes("32")); - private byte[] bin; - AlgOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getAlgCn( ) { - - if( null == alg) { return null; } - if( "31".equals(Util.bytes2HexString(this.alg))) { - return "3DES"; - } - if( "32".equals(Util.bytes2HexString(this.alg))) { - return "SM4"; - } - return null; - } - - - public Integer getAlgOptionIndex( ) { - - if( null == alg) { return null; } - if( "31".equals(Util.bytes2HexString(this.alg))) { - return 0; - } - if( "32".equals(Util.bytes2HexString(this.alg))) { - return 1; - } - return null; - } - - - public byte[] getTypeAsBin( ) { - - return this.type; - } - - - public String getTypeAsStr( ) { - - if( null == this.type) return null; - return Arrays.toString(this.type); - } - - - public String getTypeAsHex( ) { - - if( null == this.type) return null; - return Util.bytes2HexString(type); - } - - - public Data setType( byte[] bytes ) { - - this.type = bytes; - return this; - } -public enum TypeOptions { - - OPVZAK13DES认证密钥(Util.hexString2Bytes("30")), - OPVZAK2SM4认证密钥(Util.hexString2Bytes("31")); - private byte[] bin; - TypeOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getTypeCn( ) { - - if( null == type) { return null; } - if( "30".equals(Util.bytes2HexString(this.type))) { - return "ZAK1(3DES 认证密钥) "; - } - if( "31".equals(Util.bytes2HexString(this.type))) { - return "ZAK2(SM4 认证密钥) "; - } - return null; - } - - - public Integer getTypeOptionIndex( ) { - - if( null == type) { return null; } - if( "30".equals(Util.bytes2HexString(this.type))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.type))) { - return 1; - } - return null; - } - - - public byte[] getFullAsBin( ) { - - return this.full; - } - - - public String getFullAsStr( ) { - - if( null == this.full) return null; - return Arrays.toString(this.full); - } - - - public String getFullAsHex( ) { - - if( null == this.full) return null; - return Util.bytes2HexString(full); - } - - - public Data setFull( byte[] bytes ) { - - this.full = bytes; - return this; - } - - - public byte[] getMacLenAsBin( ) { - - return this.macLen; - } - - - public String getMacLenAsStr( ) { - - if( null == this.macLen) return null; - return Arrays.toString(this.macLen); - } - - - public String getMacLenAsHex( ) { - - if( null == this.macLen) return null; - return Util.bytes2HexString(macLen); - } - - - public Data setMacLen( byte[] bytes ) { - - this.macLen = bytes; - return this; - } - - - public byte[] getKeyAsBin( ) { - - return this.key; - } - - - public String getKeyAsStr( ) { - - if( null == this.key) return null; - return Arrays.toString(this.key); - } - - - public String getKeyAsHex( ) { - - if( null == this.key) return null; - return Util.bytes2HexString(key); - } - - - public Data setKey( byte[] bytes ) { - - this.key = bytes; - return this; - } - - - public byte[] getMACDataAsBin( ) { - - return this.mACData; - } - - - public String getMACDataAsStr( ) { - - if( null == this.mACData) return null; - return Arrays.toString(this.mACData); - } - - - public String getMACDataAsHex( ) { - - if( null == this.mACData) return null; - return Util.bytes2HexString(mACData); - } - - - public Data setMACData( byte[] bytes ) { - - this.mACData = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - soup.put("tag", Util.hexString2Bytes("50")); - if( null != tag ){ - soup.put("tag", this.tag); - } - - if( null != alg ){ - soup.put("alg", this.alg); - soup.put("alg$option", getAlgOptionIndex()); - } - - if( null != type ){ - soup.put("type", this.type); - soup.put("type$option", getTypeOptionIndex()); - } - - if( null != full ){ - soup.put("full", this.full); - } - - if( null != macLen ){ - soup.put("macLen", this.macLen); - } - - if( null != key ){ - soup.put("key", this.key); - } - - if( null != mACData ){ - soup.put("MACData", this.mACData); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - this.tag = Util.hexString2Bytes("50"); - if( soup.containsKey("tag") ){ - this.tag = ((PacketSection) soup.get("tag")).getBytes(); - } - - if( soup.containsKey("alg") ){ - this.alg = ((PacketSection) soup.get("alg")).getBytes(); - } - - if( soup.containsKey("type") ){ - this.type = ((PacketSection) soup.get("type")).getBytes(); - } - - if( soup.containsKey("full") ){ - this.full = ((PacketSection) soup.get("full")).getBytes(); - } - - if( soup.containsKey("macLen") ){ - this.macLen = ((PacketSection) soup.get("macLen")).getBytes(); - } - - if( soup.containsKey("key") ){ - this.key = ((PacketSection) soup.get("key")).getBytes(); - } - - if( soup.containsKey("MACData") ){ - this.mACData = ((PacketSection) soup.get("MACData")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4D41")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4D41"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] mAC = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPVMAC校验错(Util.hexString2Bytes("3031")), - OPVTAK奇偶校验错(Util.hexString2Bytes("3130")), - OPV用户存储区没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误报告给管理员(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV无效的用户存储索引(Util.hexString2Bytes("3231")), - OPV密钥方案错误(Util.hexString2Bytes("3236")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3031".equals(Util.bytes2HexString(this.error))) { - return "MAC校验错"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "TAK奇偶校验错"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK错误;报告给管理员"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效的用户存储索引"; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return "密钥方案错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3031".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 8; - } - return null; - } - - - public byte[] getMACAsBin( ) { - - return this.mAC; - } - - - public String getMACAsStr( ) { - - if( null == this.mAC) return null; - return Arrays.toString(this.mAC); - } - - - public String getMACAsHex( ) { - - if( null == this.mAC) return null; - return Util.bytes2HexString(mAC); - } - - - public Data setMAC( byte[] bytes ) { - - this.mAC = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != mAC ){ - soup.put("MAC", this.mAC); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("MAC") ){ - this.mAC = ((PacketSection) soup.get("MAC")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4D42")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4D42"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO4D43.java b/src/main/java/racal/sunyard/main/dto/DTO4D43.java deleted file mode 100644 index 916c8e2..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO4D43.java +++ /dev/null @@ -1,1015 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO4D43 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] tag = null; - private byte[] alg = null; - private byte[] type = null; - private byte[] full = null; - private byte[] macLen = null; - private byte[] key = null; - private byte[] mAC = null; - private byte[] mACData = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getTagAsBin( ) { - - return this.tag; - } - - - public String getTagAsStr( ) { - - if( null == this.tag) return null; - return Arrays.toString(this.tag); - } - - - public String getTagAsHex( ) { - - if( null == this.tag) return null; - return Util.bytes2HexString(tag); - } - - - public Data setTag( byte[] bytes ) { - - this.tag = bytes; - return this; - } - - - public byte[] getAlgAsBin( ) { - - return this.alg; - } - - - public String getAlgAsStr( ) { - - if( null == this.alg) return null; - return Arrays.toString(this.alg); - } - - - public String getAlgAsHex( ) { - - if( null == this.alg) return null; - return Util.bytes2HexString(alg); - } - - - public Data setAlg( byte[] bytes ) { - - this.alg = bytes; - return this; - } -public enum AlgOptions { - - OPV3DES(Util.hexString2Bytes("31")), - OPVSM4(Util.hexString2Bytes("32")); - private byte[] bin; - AlgOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getAlgCn( ) { - - if( null == alg) { return null; } - if( "31".equals(Util.bytes2HexString(this.alg))) { - return "3DES"; - } - if( "32".equals(Util.bytes2HexString(this.alg))) { - return "SM4"; - } - return null; - } - - - public Integer getAlgOptionIndex( ) { - - if( null == alg) { return null; } - if( "31".equals(Util.bytes2HexString(this.alg))) { - return 0; - } - if( "32".equals(Util.bytes2HexString(this.alg))) { - return 1; - } - return null; - } - - - public byte[] getTypeAsBin( ) { - - return this.type; - } - - - public String getTypeAsStr( ) { - - if( null == this.type) return null; - return Arrays.toString(this.type); - } - - - public String getTypeAsHex( ) { - - if( null == this.type) return null; - return Util.bytes2HexString(type); - } - - - public Data setType( byte[] bytes ) { - - this.type = bytes; - return this; - } -public enum TypeOptions { - - OPVZAK13DES认证密钥(Util.hexString2Bytes("30")), - OPVZAK2SM4认证密钥(Util.hexString2Bytes("31")); - private byte[] bin; - TypeOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getTypeCn( ) { - - if( null == type) { return null; } - if( "30".equals(Util.bytes2HexString(this.type))) { - return "ZAK1(3DES 认证密钥) "; - } - if( "31".equals(Util.bytes2HexString(this.type))) { - return "ZAK2(SM4 认证密钥) "; - } - return null; - } - - - public Integer getTypeOptionIndex( ) { - - if( null == type) { return null; } - if( "30".equals(Util.bytes2HexString(this.type))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.type))) { - return 1; - } - return null; - } - - - public byte[] getFullAsBin( ) { - - return this.full; - } - - - public String getFullAsStr( ) { - - if( null == this.full) return null; - return Arrays.toString(this.full); - } - - - public String getFullAsHex( ) { - - if( null == this.full) return null; - return Util.bytes2HexString(full); - } - - - public Data setFull( byte[] bytes ) { - - this.full = bytes; - return this; - } - - - public byte[] getMacLenAsBin( ) { - - return this.macLen; - } - - - public String getMacLenAsStr( ) { - - if( null == this.macLen) return null; - return Arrays.toString(this.macLen); - } - - - public String getMacLenAsHex( ) { - - if( null == this.macLen) return null; - return Util.bytes2HexString(macLen); - } - - - public Data setMacLen( byte[] bytes ) { - - this.macLen = bytes; - return this; - } - - - public byte[] getKeyAsBin( ) { - - return this.key; - } - - - public String getKeyAsStr( ) { - - if( null == this.key) return null; - return Arrays.toString(this.key); - } - - - public String getKeyAsHex( ) { - - if( null == this.key) return null; - return Util.bytes2HexString(key); - } - - - public Data setKey( byte[] bytes ) { - - this.key = bytes; - return this; - } - - - public byte[] getMACAsBin( ) { - - return this.mAC; - } - - - public String getMACAsStr( ) { - - if( null == this.mAC) return null; - return Arrays.toString(this.mAC); - } - - - public String getMACAsHex( ) { - - if( null == this.mAC) return null; - return Util.bytes2HexString(mAC); - } - - - public Data setMAC( byte[] bytes ) { - - this.mAC = bytes; - return this; - } - - - public byte[] getMACDataAsBin( ) { - - return this.mACData; - } - - - public String getMACDataAsStr( ) { - - if( null == this.mACData) return null; - return Arrays.toString(this.mACData); - } - - - public String getMACDataAsHex( ) { - - if( null == this.mACData) return null; - return Util.bytes2HexString(mACData); - } - - - public Data setMACData( byte[] bytes ) { - - this.mACData = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - soup.put("tag", Util.hexString2Bytes("50")); - if( null != tag ){ - soup.put("tag", this.tag); - } - - if( null != alg ){ - soup.put("alg", this.alg); - soup.put("alg$option", getAlgOptionIndex()); - } - - if( null != type ){ - soup.put("type", this.type); - soup.put("type$option", getTypeOptionIndex()); - } - - if( null != full ){ - soup.put("full", this.full); - } - - if( null != macLen ){ - soup.put("macLen", this.macLen); - } - - if( null != key ){ - soup.put("key", this.key); - } - - if( null != mAC ){ - soup.put("MAC", this.mAC); - } - - if( null != mACData ){ - soup.put("MACData", this.mACData); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - this.tag = Util.hexString2Bytes("50"); - if( soup.containsKey("tag") ){ - this.tag = ((PacketSection) soup.get("tag")).getBytes(); - } - - if( soup.containsKey("alg") ){ - this.alg = ((PacketSection) soup.get("alg")).getBytes(); - } - - if( soup.containsKey("type") ){ - this.type = ((PacketSection) soup.get("type")).getBytes(); - } - - if( soup.containsKey("full") ){ - this.full = ((PacketSection) soup.get("full")).getBytes(); - } - - if( soup.containsKey("macLen") ){ - this.macLen = ((PacketSection) soup.get("macLen")).getBytes(); - } - - if( soup.containsKey("key") ){ - this.key = ((PacketSection) soup.get("key")).getBytes(); - } - - if( soup.containsKey("MAC") ){ - this.mAC = ((PacketSection) soup.get("MAC")).getBytes(); - } - - if( soup.containsKey("MACData") ){ - this.mACData = ((PacketSection) soup.get("MACData")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4D43")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4D43"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPVMAC校验错(Util.hexString2Bytes("3031")), - OPVTAK奇偶校验错(Util.hexString2Bytes("3130")), - OPV用户存储区没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误报告给管理员(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV无效的用户存储索引(Util.hexString2Bytes("3231")), - OPV密钥方案错误(Util.hexString2Bytes("3236")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3031".equals(Util.bytes2HexString(this.error))) { - return "MAC校验错"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "TAK奇偶校验错"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK错误;报告给管理员"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效的用户存储索引"; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return "密钥方案错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3031".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 8; - } - return null; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4D44")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4D44"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO60.java b/src/main/java/racal/sunyard/main/dto/DTO60.java deleted file mode 100644 index d6d4327..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO60.java +++ /dev/null @@ -1,735 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO60 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3630")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3630"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] dK = null; - private byte[] keyCheck = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV无效的成份号(Util.hexString2Bytes("3033")), - OPV成份奇偶校验错(Util.hexString2Bytes("3130")), - OPV用户存储区没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV不在授权状态(Util.hexString2Bytes("3137")), - OPV无效的用户存储索引(Util.hexString2Bytes("3231")), - OPV无效的密钥方案(Util.hexString2Bytes("3236")), - OPV传输保护秘钥校验值和和实际不一致(Util.hexString2Bytes("3537")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3033".equals(Util.bytes2HexString(this.error))) { - return "无效的成份号"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "成份奇偶校验错"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3137".equals(Util.bytes2HexString(this.error))) { - return "不在授权状态"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效的用户存储索引"; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return "无效的密钥方案"; - } - if( "3537".equals(Util.bytes2HexString(this.error))) { - return "传输保护秘钥校验值和和实际不一致"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3033".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3137".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3537".equals(Util.bytes2HexString(this.error))) { - return 9; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 10; - } - return null; - } - - - public byte[] getDKAsBin( ) { - - return this.dK; - } - - - public String getDKAsStr( ) { - - if( null == this.dK) return null; - return Arrays.toString(this.dK); - } - - - public String getDKAsHex( ) { - - if( null == this.dK) return null; - return Util.bytes2HexString(dK); - } - - - public Data setDK( byte[] bytes ) { - - this.dK = bytes; - return this; - } - - - public byte[] getKeyCheckAsBin( ) { - - return this.keyCheck; - } - - - public String getKeyCheckAsStr( ) { - - if( null == this.keyCheck) return null; - return Arrays.toString(this.keyCheck); - } - - - public String getKeyCheckAsHex( ) { - - if( null == this.keyCheck) return null; - return Util.bytes2HexString(keyCheck); - } - - - public Data setKeyCheck( byte[] bytes ) { - - this.keyCheck = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != dK ){ - soup.put("DK", this.dK); - } - - if( null != keyCheck ){ - soup.put("keyCheck", this.keyCheck); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("DK") ){ - this.dK = ((PacketSection) soup.get("DK")).getBytes(); - } - - if( soup.containsKey("keyCheck") ){ - this.keyCheck = ((PacketSection) soup.get("keyCheck")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3631")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3631"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO61.java b/src/main/java/racal/sunyard/main/dto/DTO61.java deleted file mode 100644 index 1d16cbe..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO61.java +++ /dev/null @@ -1,771 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO61 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] roleInfo = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getRoleInfoAsBin( ) { - - return this.roleInfo; - } - - - public String getRoleInfoAsStr( ) { - - if( null == this.roleInfo) return null; - return Arrays.toString(this.roleInfo); - } - - - public String getRoleInfoAsHex( ) { - - if( null == this.roleInfo) return null; - return Util.bytes2HexString(roleInfo); - } - - - public Data setRoleInfo( byte[] bytes ) { - - this.roleInfo = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != roleInfo ){ - soup.put("roleInfo", this.roleInfo); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("roleInfo") ){ - this.roleInfo = ((PacketSection) soup.get("roleInfo")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3631")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3631"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] roleType = null; - private byte[] roleId = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV验证失败(Util.hexString2Bytes("3032")), - OPV无效的成份号(Util.hexString2Bytes("3033")), - OPV成份奇偶校验错(Util.hexString2Bytes("3130")), - OPV用户存储区没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误报告给管理员(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV不在授权状态(Util.hexString2Bytes("3137")), - OPV无效的用户存储索引(Util.hexString2Bytes("3231")), - OPV无效的密钥方案(Util.hexString2Bytes("3236")), - OPV数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3032".equals(Util.bytes2HexString(this.error))) { - return "验证失败"; - } - if( "3033".equals(Util.bytes2HexString(this.error))) { - return "无效的成份号"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "成份奇偶校验错"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK错误;报告给管理员"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3137".equals(Util.bytes2HexString(this.error))) { - return "不在授权状态"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效的用户存储索引"; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return "无效的密钥方案"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3032".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3033".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3137".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return 9; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 10; - } - return null; - } - - - public byte[] getRoleTypeAsBin( ) { - - return this.roleType; - } - - - public String getRoleTypeAsStr( ) { - - if( null == this.roleType) return null; - return Arrays.toString(this.roleType); - } - - - public String getRoleTypeAsHex( ) { - - if( null == this.roleType) return null; - return Util.bytes2HexString(roleType); - } - - - public Data setRoleType( byte[] bytes ) { - - this.roleType = bytes; - return this; - } - - - public byte[] getRoleIdAsBin( ) { - - return this.roleId; - } - - - public String getRoleIdAsStr( ) { - - if( null == this.roleId) return null; - return Arrays.toString(this.roleId); - } - - - public String getRoleIdAsHex( ) { - - if( null == this.roleId) return null; - return Util.bytes2HexString(roleId); - } - - - public Data setRoleId( byte[] bytes ) { - - this.roleId = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != roleType ){ - soup.put("roleType", this.roleType); - } - - if( null != roleId ){ - soup.put("roleId", this.roleId); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("roleType") ){ - this.roleType = ((PacketSection) soup.get("roleType")).getBytes(); - } - - if( soup.containsKey("roleId") ){ - this.roleId = ((PacketSection) soup.get("roleId")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3632")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3632"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO62.java b/src/main/java/racal/sunyard/main/dto/DTO62.java deleted file mode 100644 index 4b405b1..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO62.java +++ /dev/null @@ -1,999 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO62 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] keyType = null; - private byte[] key = null; - private byte[] algorithmKey = null; - private byte[] alg = null; - private byte[] outputFormat = null; - private byte[] dataLength = null; - private byte[] infoData = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getKeyTypeAsBin( ) { - - return this.keyType; - } - - - public String getKeyTypeAsStr( ) { - - if( null == this.keyType) return null; - return Arrays.toString(this.keyType); - } - - - public String getKeyTypeAsHex( ) { - - if( null == this.keyType) return null; - return Util.bytes2HexString(keyType); - } - - - public Data setKeyType( byte[] bytes ) { - - this.keyType = bytes; - return this; - } - - - public byte[] getKeyAsBin( ) { - - return this.key; - } - - - public String getKeyAsStr( ) { - - if( null == this.key) return null; - return Arrays.toString(this.key); - } - - - public String getKeyAsHex( ) { - - if( null == this.key) return null; - return Util.bytes2HexString(key); - } - - - public Data setKey( byte[] bytes ) { - - this.key = bytes; - return this; - } - - - public byte[] getAlgorithmKeyAsBin( ) { - - return this.algorithmKey; - } - - - public String getAlgorithmKeyAsStr( ) { - - if( null == this.algorithmKey) return null; - return Arrays.toString(this.algorithmKey); - } - - - public String getAlgorithmKeyAsHex( ) { - - if( null == this.algorithmKey) return null; - return Util.bytes2HexString(algorithmKey); - } - - - public Data setAlgorithmKey( byte[] bytes ) { - - this.algorithmKey = bytes; - return this; - } - - - public byte[] getAlgAsBin( ) { - - return this.alg; - } - - - public String getAlgAsStr( ) { - - if( null == this.alg) return null; - return Arrays.toString(this.alg); - } - - - public String getAlgAsHex( ) { - - if( null == this.alg) return null; - return Util.bytes2HexString(alg); - } - - - public Data setAlg( byte[] bytes ) { - - this.alg = bytes; - return this; - } -public enum AlgOptions { - - OPVIDEA(Util.hexString2Bytes("30")), - OPVSM1(Util.hexString2Bytes("31")); - private byte[] bin; - AlgOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getAlgCn( ) { - - if( null == alg) { return null; } - if( "30".equals(Util.bytes2HexString(this.alg))) { - return "IDEA"; - } - if( "31".equals(Util.bytes2HexString(this.alg))) { - return "SM1"; - } - return null; - } - - - public Integer getAlgOptionIndex( ) { - - if( null == alg) { return null; } - if( "30".equals(Util.bytes2HexString(this.alg))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.alg))) { - return 1; - } - return null; - } - - - public byte[] getOutputFormatAsBin( ) { - - return this.outputFormat; - } - - - public String getOutputFormatAsStr( ) { - - if( null == this.outputFormat) return null; - return Arrays.toString(this.outputFormat); - } - - - public String getOutputFormatAsHex( ) { - - if( null == this.outputFormat) return null; - return Util.bytes2HexString(outputFormat); - } - - - public Data setOutputFormat( byte[] bytes ) { - - this.outputFormat = bytes; - return this; - } -public enum OutputFormatOptions { - - OPV软MD5后前8与后8异或后加密密押取前4位并转为8字节的HEX格式(Util.hexString2Bytes("30")), - OPV软MD5后取前8字节加密输出8节的BIN格式(Util.hexString2Bytes("31")); - private byte[] bin; - OutputFormatOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getOutputFormatCn( ) { - - if( null == outputFormat) { return null; } - if( "30".equals(Util.bytes2HexString(this.outputFormat))) { - return "软MD5后前8与后8异或后加密,密押取前4位并转为8字节的HEX格式"; - } - if( "31".equals(Util.bytes2HexString(this.outputFormat))) { - return "软MD5后取前8字节加密,输出8节的BIN格式"; - } - return null; - } - - - public Integer getOutputFormatOptionIndex( ) { - - if( null == outputFormat) { return null; } - if( "30".equals(Util.bytes2HexString(this.outputFormat))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.outputFormat))) { - return 1; - } - return null; - } - - - public byte[] getDataLengthAsBin( ) { - - return this.dataLength; - } - - - public String getDataLengthAsStr( ) { - - if( null == this.dataLength) return null; - return Arrays.toString(this.dataLength); - } - - - public String getDataLengthAsHex( ) { - - if( null == this.dataLength) return null; - return Util.bytes2HexString(dataLength); - } - - - public Data setDataLength( byte[] bytes ) { - - this.dataLength = bytes; - return this; - } - - - public byte[] getInfoDataAsBin( ) { - - return this.infoData; - } - - - public String getInfoDataAsStr( ) { - - if( null == this.infoData) return null; - return Arrays.toString(this.infoData); - } - - - public String getInfoDataAsHex( ) { - - if( null == this.infoData) return null; - return Util.bytes2HexString(infoData); - } - - - public Data setInfoData( byte[] bytes ) { - - this.infoData = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != keyType ){ - soup.put("keyType", this.keyType); - } - - if( null != key ){ - soup.put("key", this.key); - } - - if( null != algorithmKey ){ - soup.put("AlgorithmKey", this.algorithmKey); - } - - if( null != alg ){ - soup.put("alg", this.alg); - soup.put("alg$option", getAlgOptionIndex()); - } - - if( null != outputFormat ){ - soup.put("outputFormat", this.outputFormat); - soup.put("outputFormat$option", getOutputFormatOptionIndex()); - } - - if( null != dataLength ){ - soup.put("dataLength", this.dataLength); - } - - if( null != infoData ){ - soup.put("infoData", this.infoData); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("keyType") ){ - this.keyType = ((PacketSection) soup.get("keyType")).getBytes(); - } - - if( soup.containsKey("key") ){ - this.key = ((PacketSection) soup.get("key")).getBytes(); - } - - if( soup.containsKey("AlgorithmKey") ){ - this.algorithmKey = ((PacketSection) soup.get("AlgorithmKey")).getBytes(); - } - - if( soup.containsKey("alg") ){ - this.alg = ((PacketSection) soup.get("alg")).getBytes(); - } - - if( soup.containsKey("outputFormat") ){ - this.outputFormat = ((PacketSection) soup.get("outputFormat")).getBytes(); - } - - if( soup.containsKey("dataLength") ){ - this.dataLength = ((PacketSection) soup.get("dataLength")).getBytes(); - } - - if( soup.containsKey("infoData") ){ - this.infoData = ((PacketSection) soup.get("infoData")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3632")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3632"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] mAC = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV用户存储区没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV无效的用户存储索引(Util.hexString2Bytes("3231")), - OPV密钥方案错误(Util.hexString2Bytes("3236")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效的用户存储索引"; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return "密钥方案错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 6; - } - return null; - } - - - public byte[] getMACAsBin( ) { - - return this.mAC; - } - - - public String getMACAsStr( ) { - - if( null == this.mAC) return null; - return Arrays.toString(this.mAC); - } - - - public String getMACAsHex( ) { - - if( null == this.mAC) return null; - return Util.bytes2HexString(mAC); - } - - - public Data setMAC( byte[] bytes ) { - - this.mAC = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != mAC ){ - soup.put("MAC", this.mAC); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("MAC") ){ - this.mAC = ((PacketSection) soup.get("MAC")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3633")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3633"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO63.java b/src/main/java/racal/sunyard/main/dto/DTO63.java deleted file mode 100644 index 5548a12..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO63.java +++ /dev/null @@ -1,999 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO63 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] keyType = null; - private byte[] key = null; - private byte[] algorithmKey = null; - private byte[] alg = null; - private byte[] outputFormat = null; - private byte[] secret = null; - private byte[] dataLength = null; - private byte[] infoData = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getKeyTypeAsBin( ) { - - return this.keyType; - } - - - public String getKeyTypeAsStr( ) { - - if( null == this.keyType) return null; - return Arrays.toString(this.keyType); - } - - - public String getKeyTypeAsHex( ) { - - if( null == this.keyType) return null; - return Util.bytes2HexString(keyType); - } - - - public Data setKeyType( byte[] bytes ) { - - this.keyType = bytes; - return this; - } - - - public byte[] getKeyAsBin( ) { - - return this.key; - } - - - public String getKeyAsStr( ) { - - if( null == this.key) return null; - return Arrays.toString(this.key); - } - - - public String getKeyAsHex( ) { - - if( null == this.key) return null; - return Util.bytes2HexString(key); - } - - - public Data setKey( byte[] bytes ) { - - this.key = bytes; - return this; - } - - - public byte[] getAlgorithmKeyAsBin( ) { - - return this.algorithmKey; - } - - - public String getAlgorithmKeyAsStr( ) { - - if( null == this.algorithmKey) return null; - return Arrays.toString(this.algorithmKey); - } - - - public String getAlgorithmKeyAsHex( ) { - - if( null == this.algorithmKey) return null; - return Util.bytes2HexString(algorithmKey); - } - - - public Data setAlgorithmKey( byte[] bytes ) { - - this.algorithmKey = bytes; - return this; - } - - - public byte[] getAlgAsBin( ) { - - return this.alg; - } - - - public String getAlgAsStr( ) { - - if( null == this.alg) return null; - return Arrays.toString(this.alg); - } - - - public String getAlgAsHex( ) { - - if( null == this.alg) return null; - return Util.bytes2HexString(alg); - } - - - public Data setAlg( byte[] bytes ) { - - this.alg = bytes; - return this; - } -public enum AlgOptions { - - OPVIDEA(Util.hexString2Bytes("30")), - OPVSM1(Util.hexString2Bytes("31")); - private byte[] bin; - AlgOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getAlgCn( ) { - - if( null == alg) { return null; } - if( "30".equals(Util.bytes2HexString(this.alg))) { - return "IDEA"; - } - if( "31".equals(Util.bytes2HexString(this.alg))) { - return "SM1"; - } - return null; - } - - - public Integer getAlgOptionIndex( ) { - - if( null == alg) { return null; } - if( "30".equals(Util.bytes2HexString(this.alg))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.alg))) { - return 1; - } - return null; - } - - - public byte[] getOutputFormatAsBin( ) { - - return this.outputFormat; - } - - - public String getOutputFormatAsStr( ) { - - if( null == this.outputFormat) return null; - return Arrays.toString(this.outputFormat); - } - - - public String getOutputFormatAsHex( ) { - - if( null == this.outputFormat) return null; - return Util.bytes2HexString(outputFormat); - } - - - public Data setOutputFormat( byte[] bytes ) { - - this.outputFormat = bytes; - return this; - } -public enum OutputFormatOptions { - - OPV软MD5后前8与后8异或后加密密押取前4位并转为8字节的HEX格式(Util.hexString2Bytes("30")), - OPV软MD5后取前8字节加密输出8节的BIN格式(Util.hexString2Bytes("31")); - private byte[] bin; - OutputFormatOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getOutputFormatCn( ) { - - if( null == outputFormat) { return null; } - if( "30".equals(Util.bytes2HexString(this.outputFormat))) { - return "软MD5后前8与后8异或后加密,密押取前4位并转为8字节的HEX格式"; - } - if( "31".equals(Util.bytes2HexString(this.outputFormat))) { - return "软MD5后取前8字节加密,输出8节的BIN格式"; - } - return null; - } - - - public Integer getOutputFormatOptionIndex( ) { - - if( null == outputFormat) { return null; } - if( "30".equals(Util.bytes2HexString(this.outputFormat))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.outputFormat))) { - return 1; - } - return null; - } - - - public byte[] getSecretAsBin( ) { - - return this.secret; - } - - - public String getSecretAsStr( ) { - - if( null == this.secret) return null; - return Arrays.toString(this.secret); - } - - - public String getSecretAsHex( ) { - - if( null == this.secret) return null; - return Util.bytes2HexString(secret); - } - - - public Data setSecret( byte[] bytes ) { - - this.secret = bytes; - return this; - } - - - public byte[] getDataLengthAsBin( ) { - - return this.dataLength; - } - - - public String getDataLengthAsStr( ) { - - if( null == this.dataLength) return null; - return Arrays.toString(this.dataLength); - } - - - public String getDataLengthAsHex( ) { - - if( null == this.dataLength) return null; - return Util.bytes2HexString(dataLength); - } - - - public Data setDataLength( byte[] bytes ) { - - this.dataLength = bytes; - return this; - } - - - public byte[] getInfoDataAsBin( ) { - - return this.infoData; - } - - - public String getInfoDataAsStr( ) { - - if( null == this.infoData) return null; - return Arrays.toString(this.infoData); - } - - - public String getInfoDataAsHex( ) { - - if( null == this.infoData) return null; - return Util.bytes2HexString(infoData); - } - - - public Data setInfoData( byte[] bytes ) { - - this.infoData = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != keyType ){ - soup.put("keyType", this.keyType); - } - - if( null != key ){ - soup.put("key", this.key); - } - - if( null != algorithmKey ){ - soup.put("AlgorithmKey", this.algorithmKey); - } - - if( null != alg ){ - soup.put("alg", this.alg); - soup.put("alg$option", getAlgOptionIndex()); - } - - if( null != outputFormat ){ - soup.put("outputFormat", this.outputFormat); - soup.put("outputFormat$option", getOutputFormatOptionIndex()); - } - - if( null != secret ){ - soup.put("secret", this.secret); - } - - if( null != dataLength ){ - soup.put("dataLength", this.dataLength); - } - - if( null != infoData ){ - soup.put("infoData", this.infoData); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("keyType") ){ - this.keyType = ((PacketSection) soup.get("keyType")).getBytes(); - } - - if( soup.containsKey("key") ){ - this.key = ((PacketSection) soup.get("key")).getBytes(); - } - - if( soup.containsKey("AlgorithmKey") ){ - this.algorithmKey = ((PacketSection) soup.get("AlgorithmKey")).getBytes(); - } - - if( soup.containsKey("alg") ){ - this.alg = ((PacketSection) soup.get("alg")).getBytes(); - } - - if( soup.containsKey("outputFormat") ){ - this.outputFormat = ((PacketSection) soup.get("outputFormat")).getBytes(); - } - - if( soup.containsKey("secret") ){ - this.secret = ((PacketSection) soup.get("secret")).getBytes(); - } - - if( soup.containsKey("dataLength") ){ - this.dataLength = ((PacketSection) soup.get("dataLength")).getBytes(); - } - - if( soup.containsKey("infoData") ){ - this.infoData = ((PacketSection) soup.get("infoData")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3633")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3633"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV用户存储区没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV无效的用户存储索引(Util.hexString2Bytes("3231")), - OPV密钥方案错误(Util.hexString2Bytes("3236")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效的用户存储索引"; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return "密钥方案错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 6; - } - return null; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3634")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3634"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO64.java b/src/main/java/racal/sunyard/main/dto/DTO64.java deleted file mode 100644 index 22b2ddb..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO64.java +++ /dev/null @@ -1,1049 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO64 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] keyType = null; - private byte[] key = null; - private byte[] log = null; - private byte[] algorithmKey = null; - private byte[] alg = null; - private byte[] dataLength = null; - private byte[] infoData = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getKeyTypeAsBin( ) { - - return this.keyType; - } - - - public String getKeyTypeAsStr( ) { - - if( null == this.keyType) return null; - return Arrays.toString(this.keyType); - } - - - public String getKeyTypeAsHex( ) { - - if( null == this.keyType) return null; - return Util.bytes2HexString(keyType); - } - - - public Data setKeyType( byte[] bytes ) { - - this.keyType = bytes; - return this; - } - - - public byte[] getKeyAsBin( ) { - - return this.key; - } - - - public String getKeyAsStr( ) { - - if( null == this.key) return null; - return Arrays.toString(this.key); - } - - - public String getKeyAsHex( ) { - - if( null == this.key) return null; - return Util.bytes2HexString(key); - } - - - public Data setKey( byte[] bytes ) { - - this.key = bytes; - return this; - } - - - public byte[] getLogAsBin( ) { - - return this.log; - } - - - public String getLogAsStr( ) { - - if( null == this.log) return null; - return Arrays.toString(this.log); - } - - - public String getLogAsHex( ) { - - if( null == this.log) return null; - return Util.bytes2HexString(log); - } - - - public Data setLog( byte[] bytes ) { - - this.log = bytes; - return this; - } -public enum LogOptions { - - OPV加密(Util.hexString2Bytes("30")), - OPV解密(Util.hexString2Bytes("31")); - private byte[] bin; - LogOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getLogCn( ) { - - if( null == log) { return null; } - if( "30".equals(Util.bytes2HexString(this.log))) { - return "加密"; - } - if( "31".equals(Util.bytes2HexString(this.log))) { - return "解密"; - } - return null; - } - - - public Integer getLogOptionIndex( ) { - - if( null == log) { return null; } - if( "30".equals(Util.bytes2HexString(this.log))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.log))) { - return 1; - } - return null; - } - - - public byte[] getAlgorithmKeyAsBin( ) { - - return this.algorithmKey; - } - - - public String getAlgorithmKeyAsStr( ) { - - if( null == this.algorithmKey) return null; - return Arrays.toString(this.algorithmKey); - } - - - public String getAlgorithmKeyAsHex( ) { - - if( null == this.algorithmKey) return null; - return Util.bytes2HexString(algorithmKey); - } - - - public Data setAlgorithmKey( byte[] bytes ) { - - this.algorithmKey = bytes; - return this; - } - - - public byte[] getAlgAsBin( ) { - - return this.alg; - } - - - public String getAlgAsStr( ) { - - if( null == this.alg) return null; - return Arrays.toString(this.alg); - } - - - public String getAlgAsHex( ) { - - if( null == this.alg) return null; - return Util.bytes2HexString(alg); - } - - - public Data setAlg( byte[] bytes ) { - - this.alg = bytes; - return this; - } -public enum AlgOptions { - - OPVIDEA(Util.hexString2Bytes("30")), - OPVSM1(Util.hexString2Bytes("31")), - OPV3DES(Util.hexString2Bytes("32")), - OPVSM4(Util.hexString2Bytes("33")); - private byte[] bin; - AlgOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getAlgCn( ) { - - if( null == alg) { return null; } - if( "30".equals(Util.bytes2HexString(this.alg))) { - return "IDEA"; - } - if( "31".equals(Util.bytes2HexString(this.alg))) { - return "SM1"; - } - if( "32".equals(Util.bytes2HexString(this.alg))) { - return "3DES"; - } - if( "33".equals(Util.bytes2HexString(this.alg))) { - return "SM4"; - } - return null; - } - - - public Integer getAlgOptionIndex( ) { - - if( null == alg) { return null; } - if( "30".equals(Util.bytes2HexString(this.alg))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.alg))) { - return 1; - } - if( "32".equals(Util.bytes2HexString(this.alg))) { - return 2; - } - if( "33".equals(Util.bytes2HexString(this.alg))) { - return 3; - } - return null; - } - - - public byte[] getDataLengthAsBin( ) { - - return this.dataLength; - } - - - public String getDataLengthAsStr( ) { - - if( null == this.dataLength) return null; - return Arrays.toString(this.dataLength); - } - - - public String getDataLengthAsHex( ) { - - if( null == this.dataLength) return null; - return Util.bytes2HexString(dataLength); - } - - - public Data setDataLength( byte[] bytes ) { - - this.dataLength = bytes; - return this; - } - - - public byte[] getInfoDataAsBin( ) { - - return this.infoData; - } - - - public String getInfoDataAsStr( ) { - - if( null == this.infoData) return null; - return Arrays.toString(this.infoData); - } - - - public String getInfoDataAsHex( ) { - - if( null == this.infoData) return null; - return Util.bytes2HexString(infoData); - } - - - public Data setInfoData( byte[] bytes ) { - - this.infoData = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != keyType ){ - soup.put("keyType", this.keyType); - } - - if( null != key ){ - soup.put("key", this.key); - } - - if( null != log ){ - soup.put("log", this.log); - soup.put("log$option", getLogOptionIndex()); - } - - if( null != algorithmKey ){ - soup.put("AlgorithmKey", this.algorithmKey); - } - - if( null != alg ){ - soup.put("alg", this.alg); - soup.put("alg$option", getAlgOptionIndex()); - } - - if( null != dataLength ){ - soup.put("dataLength", this.dataLength); - } - - if( null != infoData ){ - soup.put("infoData", this.infoData); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("keyType") ){ - this.keyType = ((PacketSection) soup.get("keyType")).getBytes(); - } - - if( soup.containsKey("key") ){ - this.key = ((PacketSection) soup.get("key")).getBytes(); - } - - if( soup.containsKey("log") ){ - this.log = ((PacketSection) soup.get("log")).getBytes(); - } - - if( soup.containsKey("AlgorithmKey") ){ - this.algorithmKey = ((PacketSection) soup.get("AlgorithmKey")).getBytes(); - } - - if( soup.containsKey("alg") ){ - this.alg = ((PacketSection) soup.get("alg")).getBytes(); - } - - if( soup.containsKey("dataLength") ){ - this.dataLength = ((PacketSection) soup.get("dataLength")).getBytes(); - } - - if( soup.containsKey("infoData") ){ - this.infoData = ((PacketSection) soup.get("infoData")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3634")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3634"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] infoLen = null; - private byte[] info = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV用户存储区没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV无效的用户存储索引(Util.hexString2Bytes("3231")), - OPV密钥方案错误(Util.hexString2Bytes("3236")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效的用户存储索引"; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return "密钥方案错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 6; - } - return null; - } - - - public byte[] getInfoLenAsBin( ) { - - return this.infoLen; - } - - - public String getInfoLenAsStr( ) { - - if( null == this.infoLen) return null; - return Arrays.toString(this.infoLen); - } - - - public String getInfoLenAsHex( ) { - - if( null == this.infoLen) return null; - return Util.bytes2HexString(infoLen); - } - - - public Data setInfoLen( byte[] bytes ) { - - this.infoLen = bytes; - return this; - } - - - public byte[] getInfoAsBin( ) { - - return this.info; - } - - - public String getInfoAsStr( ) { - - if( null == this.info) return null; - return Arrays.toString(this.info); - } - - - public String getInfoAsHex( ) { - - if( null == this.info) return null; - return Util.bytes2HexString(info); - } - - - public Data setInfo( byte[] bytes ) { - - this.info = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != infoLen ){ - soup.put("infoLen", this.infoLen); - } - - if( null != info ){ - soup.put("info", this.info); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("infoLen") ){ - this.infoLen = ((PacketSection) soup.get("infoLen")).getBytes(); - } - - if( soup.containsKey("info") ){ - this.info = ((PacketSection) soup.get("info")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3635")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3635"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO65.java b/src/main/java/racal/sunyard/main/dto/DTO65.java deleted file mode 100644 index 8d6cbf0..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO65.java +++ /dev/null @@ -1,1011 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO65 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] keyType = null; - private byte[] srcKey = null; - private byte[] aimKey = null; - private byte[] algorithmKey = null; - private byte[] alg = null; - private byte[] dataLength = null; - private byte[] infoData = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getKeyTypeAsBin( ) { - - return this.keyType; - } - - - public String getKeyTypeAsStr( ) { - - if( null == this.keyType) return null; - return Arrays.toString(this.keyType); - } - - - public String getKeyTypeAsHex( ) { - - if( null == this.keyType) return null; - return Util.bytes2HexString(keyType); - } - - - public Data setKeyType( byte[] bytes ) { - - this.keyType = bytes; - return this; - } - - - public byte[] getSrcKeyAsBin( ) { - - return this.srcKey; - } - - - public String getSrcKeyAsStr( ) { - - if( null == this.srcKey) return null; - return Arrays.toString(this.srcKey); - } - - - public String getSrcKeyAsHex( ) { - - if( null == this.srcKey) return null; - return Util.bytes2HexString(srcKey); - } - - - public Data setSrcKey( byte[] bytes ) { - - this.srcKey = bytes; - return this; - } - - - public byte[] getAimKeyAsBin( ) { - - return this.aimKey; - } - - - public String getAimKeyAsStr( ) { - - if( null == this.aimKey) return null; - return Arrays.toString(this.aimKey); - } - - - public String getAimKeyAsHex( ) { - - if( null == this.aimKey) return null; - return Util.bytes2HexString(aimKey); - } - - - public Data setAimKey( byte[] bytes ) { - - this.aimKey = bytes; - return this; - } - - - public byte[] getAlgorithmKeyAsBin( ) { - - return this.algorithmKey; - } - - - public String getAlgorithmKeyAsStr( ) { - - if( null == this.algorithmKey) return null; - return Arrays.toString(this.algorithmKey); - } - - - public String getAlgorithmKeyAsHex( ) { - - if( null == this.algorithmKey) return null; - return Util.bytes2HexString(algorithmKey); - } - - - public Data setAlgorithmKey( byte[] bytes ) { - - this.algorithmKey = bytes; - return this; - } - - - public byte[] getAlgAsBin( ) { - - return this.alg; - } - - - public String getAlgAsStr( ) { - - if( null == this.alg) return null; - return Arrays.toString(this.alg); - } - - - public String getAlgAsHex( ) { - - if( null == this.alg) return null; - return Util.bytes2HexString(alg); - } - - - public Data setAlg( byte[] bytes ) { - - this.alg = bytes; - return this; - } -public enum AlgOptions { - - OPVIDEA(Util.hexString2Bytes("30")), - OPVSM1(Util.hexString2Bytes("31")), - OPV3DES(Util.hexString2Bytes("32")), - OPVSM4(Util.hexString2Bytes("33")); - private byte[] bin; - AlgOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getAlgCn( ) { - - if( null == alg) { return null; } - if( "30".equals(Util.bytes2HexString(this.alg))) { - return "IDEA"; - } - if( "31".equals(Util.bytes2HexString(this.alg))) { - return "SM1"; - } - if( "32".equals(Util.bytes2HexString(this.alg))) { - return "3DES"; - } - if( "33".equals(Util.bytes2HexString(this.alg))) { - return "SM4"; - } - return null; - } - - - public Integer getAlgOptionIndex( ) { - - if( null == alg) { return null; } - if( "30".equals(Util.bytes2HexString(this.alg))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.alg))) { - return 1; - } - if( "32".equals(Util.bytes2HexString(this.alg))) { - return 2; - } - if( "33".equals(Util.bytes2HexString(this.alg))) { - return 3; - } - return null; - } - - - public byte[] getDataLengthAsBin( ) { - - return this.dataLength; - } - - - public String getDataLengthAsStr( ) { - - if( null == this.dataLength) return null; - return Arrays.toString(this.dataLength); - } - - - public String getDataLengthAsHex( ) { - - if( null == this.dataLength) return null; - return Util.bytes2HexString(dataLength); - } - - - public Data setDataLength( byte[] bytes ) { - - this.dataLength = bytes; - return this; - } - - - public byte[] getInfoDataAsBin( ) { - - return this.infoData; - } - - - public String getInfoDataAsStr( ) { - - if( null == this.infoData) return null; - return Arrays.toString(this.infoData); - } - - - public String getInfoDataAsHex( ) { - - if( null == this.infoData) return null; - return Util.bytes2HexString(infoData); - } - - - public Data setInfoData( byte[] bytes ) { - - this.infoData = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != keyType ){ - soup.put("keyType", this.keyType); - } - - if( null != srcKey ){ - soup.put("srcKey", this.srcKey); - } - - if( null != aimKey ){ - soup.put("aimKey", this.aimKey); - } - - if( null != algorithmKey ){ - soup.put("AlgorithmKey", this.algorithmKey); - } - - if( null != alg ){ - soup.put("alg", this.alg); - soup.put("alg$option", getAlgOptionIndex()); - } - - if( null != dataLength ){ - soup.put("dataLength", this.dataLength); - } - - if( null != infoData ){ - soup.put("infoData", this.infoData); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("keyType") ){ - this.keyType = ((PacketSection) soup.get("keyType")).getBytes(); - } - - if( soup.containsKey("srcKey") ){ - this.srcKey = ((PacketSection) soup.get("srcKey")).getBytes(); - } - - if( soup.containsKey("aimKey") ){ - this.aimKey = ((PacketSection) soup.get("aimKey")).getBytes(); - } - - if( soup.containsKey("AlgorithmKey") ){ - this.algorithmKey = ((PacketSection) soup.get("AlgorithmKey")).getBytes(); - } - - if( soup.containsKey("alg") ){ - this.alg = ((PacketSection) soup.get("alg")).getBytes(); - } - - if( soup.containsKey("dataLength") ){ - this.dataLength = ((PacketSection) soup.get("dataLength")).getBytes(); - } - - if( soup.containsKey("infoData") ){ - this.infoData = ((PacketSection) soup.get("infoData")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3635")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3635"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] infoLen = null; - private byte[] info = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV用户存储区没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV无效的用户存储索引(Util.hexString2Bytes("3231")), - OPV密钥方案错误(Util.hexString2Bytes("3236")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效的用户存储索引"; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return "密钥方案错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 6; - } - return null; - } - - - public byte[] getInfoLenAsBin( ) { - - return this.infoLen; - } - - - public String getInfoLenAsStr( ) { - - if( null == this.infoLen) return null; - return Arrays.toString(this.infoLen); - } - - - public String getInfoLenAsHex( ) { - - if( null == this.infoLen) return null; - return Util.bytes2HexString(infoLen); - } - - - public Data setInfoLen( byte[] bytes ) { - - this.infoLen = bytes; - return this; - } - - - public byte[] getInfoAsBin( ) { - - return this.info; - } - - - public String getInfoAsStr( ) { - - if( null == this.info) return null; - return Arrays.toString(this.info); - } - - - public String getInfoAsHex( ) { - - if( null == this.info) return null; - return Util.bytes2HexString(info); - } - - - public Data setInfo( byte[] bytes ) { - - this.info = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != infoLen ){ - soup.put("infoLen", this.infoLen); - } - - if( null != info ){ - soup.put("info", this.info); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("infoLen") ){ - this.infoLen = ((PacketSection) soup.get("infoLen")).getBytes(); - } - - if( soup.containsKey("info") ){ - this.info = ((PacketSection) soup.get("info")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3636")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3636"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO66.java b/src/main/java/racal/sunyard/main/dto/DTO66.java deleted file mode 100644 index 36ef232..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO66.java +++ /dev/null @@ -1,906 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO66 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] key = null; - private byte[] log = null; - private byte[] algorithmKey = null; - private byte[] alg = null; - private byte[] pin = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getKeyAsBin( ) { - - return this.key; - } - - - public String getKeyAsStr( ) { - - if( null == this.key) return null; - return Arrays.toString(this.key); - } - - - public String getKeyAsHex( ) { - - if( null == this.key) return null; - return Util.bytes2HexString(key); - } - - - public Data setKey( byte[] bytes ) { - - this.key = bytes; - return this; - } - - - public byte[] getLogAsBin( ) { - - return this.log; - } - - - public String getLogAsStr( ) { - - if( null == this.log) return null; - return Arrays.toString(this.log); - } - - - public String getLogAsHex( ) { - - if( null == this.log) return null; - return Util.bytes2HexString(log); - } - - - public Data setLog( byte[] bytes ) { - - this.log = bytes; - return this; - } -public enum LogOptions { - - OPV加密(Util.hexString2Bytes("30")), - OPV解密(Util.hexString2Bytes("31")); - private byte[] bin; - LogOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getLogCn( ) { - - if( null == log) { return null; } - if( "30".equals(Util.bytes2HexString(this.log))) { - return "加密"; - } - if( "31".equals(Util.bytes2HexString(this.log))) { - return "解密"; - } - return null; - } - - - public Integer getLogOptionIndex( ) { - - if( null == log) { return null; } - if( "30".equals(Util.bytes2HexString(this.log))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.log))) { - return 1; - } - return null; - } - - - public byte[] getAlgorithmKeyAsBin( ) { - - return this.algorithmKey; - } - - - public String getAlgorithmKeyAsStr( ) { - - if( null == this.algorithmKey) return null; - return Arrays.toString(this.algorithmKey); - } - - - public String getAlgorithmKeyAsHex( ) { - - if( null == this.algorithmKey) return null; - return Util.bytes2HexString(algorithmKey); - } - - - public Data setAlgorithmKey( byte[] bytes ) { - - this.algorithmKey = bytes; - return this; - } - - - public byte[] getAlgAsBin( ) { - - return this.alg; - } - - - public String getAlgAsStr( ) { - - if( null == this.alg) return null; - return Arrays.toString(this.alg); - } - - - public String getAlgAsHex( ) { - - if( null == this.alg) return null; - return Util.bytes2HexString(alg); - } - - - public Data setAlg( byte[] bytes ) { - - this.alg = bytes; - return this; - } -public enum AlgOptions { - - OPV3DES(Util.hexString2Bytes("30")), - OPVSM4(Util.hexString2Bytes("31")); - private byte[] bin; - AlgOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getAlgCn( ) { - - if( null == alg) { return null; } - if( "30".equals(Util.bytes2HexString(this.alg))) { - return "3DES"; - } - if( "31".equals(Util.bytes2HexString(this.alg))) { - return "SM4"; - } - return null; - } - - - public Integer getAlgOptionIndex( ) { - - if( null == alg) { return null; } - if( "30".equals(Util.bytes2HexString(this.alg))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.alg))) { - return 1; - } - return null; - } - - - public byte[] getPinAsBin( ) { - - return this.pin; - } - - - public String getPinAsStr( ) { - - if( null == this.pin) return null; - return Arrays.toString(this.pin); - } - - - public String getPinAsHex( ) { - - if( null == this.pin) return null; - return Util.bytes2HexString(pin); - } - - - public Data setPin( byte[] bytes ) { - - this.pin = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != key ){ - soup.put("key", this.key); - } - - if( null != log ){ - soup.put("log", this.log); - soup.put("log$option", getLogOptionIndex()); - } - - if( null != algorithmKey ){ - soup.put("AlgorithmKey", this.algorithmKey); - } - - if( null != alg ){ - soup.put("alg", this.alg); - soup.put("alg$option", getAlgOptionIndex()); - } - - if( null != pin ){ - soup.put("pin", this.pin); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("key") ){ - this.key = ((PacketSection) soup.get("key")).getBytes(); - } - - if( soup.containsKey("log") ){ - this.log = ((PacketSection) soup.get("log")).getBytes(); - } - - if( soup.containsKey("AlgorithmKey") ){ - this.algorithmKey = ((PacketSection) soup.get("AlgorithmKey")).getBytes(); - } - - if( soup.containsKey("alg") ){ - this.alg = ((PacketSection) soup.get("alg")).getBytes(); - } - - if( soup.containsKey("pin") ){ - this.pin = ((PacketSection) soup.get("pin")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3636")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3636"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] info = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV不在授权状态(Util.hexString2Bytes("3137")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3137".equals(Util.bytes2HexString(this.error))) { - return "不在授权状态"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3137".equals(Util.bytes2HexString(this.error))) { - return 3; - } - return null; - } - - - public byte[] getInfoAsBin( ) { - - return this.info; - } - - - public String getInfoAsStr( ) { - - if( null == this.info) return null; - return Arrays.toString(this.info); - } - - - public String getInfoAsHex( ) { - - if( null == this.info) return null; - return Util.bytes2HexString(info); - } - - - public Data setInfo( byte[] bytes ) { - - this.info = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != info ){ - soup.put("info", this.info); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("info") ){ - this.info = ((PacketSection) soup.get("info")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3637")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3637"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO67.java b/src/main/java/racal/sunyard/main/dto/DTO67.java deleted file mode 100644 index 81fe856..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO67.java +++ /dev/null @@ -1,868 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO67 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] srcKey = null; - private byte[] aimKey = null; - private byte[] algorithmKey = null; - private byte[] alg = null; - private byte[] pin = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getSrcKeyAsBin( ) { - - return this.srcKey; - } - - - public String getSrcKeyAsStr( ) { - - if( null == this.srcKey) return null; - return Arrays.toString(this.srcKey); - } - - - public String getSrcKeyAsHex( ) { - - if( null == this.srcKey) return null; - return Util.bytes2HexString(srcKey); - } - - - public Data setSrcKey( byte[] bytes ) { - - this.srcKey = bytes; - return this; - } - - - public byte[] getAimKeyAsBin( ) { - - return this.aimKey; - } - - - public String getAimKeyAsStr( ) { - - if( null == this.aimKey) return null; - return Arrays.toString(this.aimKey); - } - - - public String getAimKeyAsHex( ) { - - if( null == this.aimKey) return null; - return Util.bytes2HexString(aimKey); - } - - - public Data setAimKey( byte[] bytes ) { - - this.aimKey = bytes; - return this; - } - - - public byte[] getAlgorithmKeyAsBin( ) { - - return this.algorithmKey; - } - - - public String getAlgorithmKeyAsStr( ) { - - if( null == this.algorithmKey) return null; - return Arrays.toString(this.algorithmKey); - } - - - public String getAlgorithmKeyAsHex( ) { - - if( null == this.algorithmKey) return null; - return Util.bytes2HexString(algorithmKey); - } - - - public Data setAlgorithmKey( byte[] bytes ) { - - this.algorithmKey = bytes; - return this; - } - - - public byte[] getAlgAsBin( ) { - - return this.alg; - } - - - public String getAlgAsStr( ) { - - if( null == this.alg) return null; - return Arrays.toString(this.alg); - } - - - public String getAlgAsHex( ) { - - if( null == this.alg) return null; - return Util.bytes2HexString(alg); - } - - - public Data setAlg( byte[] bytes ) { - - this.alg = bytes; - return this; - } -public enum AlgOptions { - - OPV3DES(Util.hexString2Bytes("30")), - OPVSM4(Util.hexString2Bytes("31")); - private byte[] bin; - AlgOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getAlgCn( ) { - - if( null == alg) { return null; } - if( "30".equals(Util.bytes2HexString(this.alg))) { - return "3DES"; - } - if( "31".equals(Util.bytes2HexString(this.alg))) { - return "SM4"; - } - return null; - } - - - public Integer getAlgOptionIndex( ) { - - if( null == alg) { return null; } - if( "30".equals(Util.bytes2HexString(this.alg))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.alg))) { - return 1; - } - return null; - } - - - public byte[] getPinAsBin( ) { - - return this.pin; - } - - - public String getPinAsStr( ) { - - if( null == this.pin) return null; - return Arrays.toString(this.pin); - } - - - public String getPinAsHex( ) { - - if( null == this.pin) return null; - return Util.bytes2HexString(pin); - } - - - public Data setPin( byte[] bytes ) { - - this.pin = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != srcKey ){ - soup.put("srcKey", this.srcKey); - } - - if( null != aimKey ){ - soup.put("aimKey", this.aimKey); - } - - if( null != algorithmKey ){ - soup.put("AlgorithmKey", this.algorithmKey); - } - - if( null != alg ){ - soup.put("alg", this.alg); - soup.put("alg$option", getAlgOptionIndex()); - } - - if( null != pin ){ - soup.put("pin", this.pin); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("srcKey") ){ - this.srcKey = ((PacketSection) soup.get("srcKey")).getBytes(); - } - - if( soup.containsKey("aimKey") ){ - this.aimKey = ((PacketSection) soup.get("aimKey")).getBytes(); - } - - if( soup.containsKey("AlgorithmKey") ){ - this.algorithmKey = ((PacketSection) soup.get("AlgorithmKey")).getBytes(); - } - - if( soup.containsKey("alg") ){ - this.alg = ((PacketSection) soup.get("alg")).getBytes(); - } - - if( soup.containsKey("pin") ){ - this.pin = ((PacketSection) soup.get("pin")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3637")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3637"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] info = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV不在授权状态(Util.hexString2Bytes("3137")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3137".equals(Util.bytes2HexString(this.error))) { - return "不在授权状态"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3137".equals(Util.bytes2HexString(this.error))) { - return 3; - } - return null; - } - - - public byte[] getInfoAsBin( ) { - - return this.info; - } - - - public String getInfoAsStr( ) { - - if( null == this.info) return null; - return Arrays.toString(this.info); - } - - - public String getInfoAsHex( ) { - - if( null == this.info) return null; - return Util.bytes2HexString(info); - } - - - public Data setInfo( byte[] bytes ) { - - this.info = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != info ){ - soup.put("info", this.info); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("info") ){ - this.info = ((PacketSection) soup.get("info")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3638")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3638"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO68.java b/src/main/java/racal/sunyard/main/dto/DTO68.java deleted file mode 100644 index 755ac25..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO68.java +++ /dev/null @@ -1,1276 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO68 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] dEK = null; - private byte[] infoDataLen = null; - private byte[] infoData = null; - private byte[] alg = null; - private byte[] fillKey = null; - private byte[] publicKeyLen = null; - private byte[] publicKey = null; - private byte[] algorithmKey1 = null; - private byte[] encryAlgorithm1 = null; - private byte[] algorithmKey2 = null; - private byte[] encryAlgorithm2 = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getDEKAsBin( ) { - - return this.dEK; - } - - - public String getDEKAsStr( ) { - - if( null == this.dEK) return null; - return Arrays.toString(this.dEK); - } - - - public String getDEKAsHex( ) { - - if( null == this.dEK) return null; - return Util.bytes2HexString(dEK); - } - - - public Data setDEK( byte[] bytes ) { - - this.dEK = bytes; - return this; - } - - - public byte[] getInfoDataLenAsBin( ) { - - return this.infoDataLen; - } - - - public String getInfoDataLenAsStr( ) { - - if( null == this.infoDataLen) return null; - return Arrays.toString(this.infoDataLen); - } - - - public String getInfoDataLenAsHex( ) { - - if( null == this.infoDataLen) return null; - return Util.bytes2HexString(infoDataLen); - } - - - public Data setInfoDataLen( byte[] bytes ) { - - this.infoDataLen = bytes; - return this; - } - - - public byte[] getInfoDataAsBin( ) { - - return this.infoData; - } - - - public String getInfoDataAsStr( ) { - - if( null == this.infoData) return null; - return Arrays.toString(this.infoData); - } - - - public String getInfoDataAsHex( ) { - - if( null == this.infoData) return null; - return Util.bytes2HexString(infoData); - } - - - public Data setInfoData( byte[] bytes ) { - - this.infoData = bytes; - return this; - } - - - public byte[] getAlgAsBin( ) { - - return this.alg; - } - - - public String getAlgAsStr( ) { - - if( null == this.alg) return null; - return Arrays.toString(this.alg); - } - - - public String getAlgAsHex( ) { - - if( null == this.alg) return null; - return Util.bytes2HexString(alg); - } - - - public Data setAlg( byte[] bytes ) { - - this.alg = bytes; - return this; - } -public enum AlgOptions { - - OPVRSA(Util.hexString2Bytes("30")), - OPVSM2(Util.hexString2Bytes("31")); - private byte[] bin; - AlgOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getAlgCn( ) { - - if( null == alg) { return null; } - if( "30".equals(Util.bytes2HexString(this.alg))) { - return "RSA"; - } - if( "31".equals(Util.bytes2HexString(this.alg))) { - return "SM2"; - } - return null; - } - - - public Integer getAlgOptionIndex( ) { - - if( null == alg) { return null; } - if( "30".equals(Util.bytes2HexString(this.alg))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.alg))) { - return 1; - } - return null; - } - - - public byte[] getFillKeyAsBin( ) { - - return this.fillKey; - } - - - public String getFillKeyAsStr( ) { - - if( null == this.fillKey) return null; - return Arrays.toString(this.fillKey); - } - - - public String getFillKeyAsHex( ) { - - if( null == this.fillKey) return null; - return Util.bytes2HexString(fillKey); - } - - - public Data setFillKey( byte[] bytes ) { - - this.fillKey = bytes; - return this; - } -public enum FillKeyOptions { - - OPV数据长度必须等于密钥长度DER对应的数据长度(Util.hexString2Bytes("30")), - OPVPKCS1v15填充方式(Util.hexString2Bytes("31")); - private byte[] bin; - FillKeyOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getFillKeyCn( ) { - - if( null == fillKey) { return null; } - if( "30".equals(Util.bytes2HexString(this.fillKey))) { - return "数据长度必须等于密钥长度(DER对应的数据长度)"; - } - if( "31".equals(Util.bytes2HexString(this.fillKey))) { - return "PKCS#1 v1.5 填充方式"; - } - return null; - } - - - public Integer getFillKeyOptionIndex( ) { - - if( null == fillKey) { return null; } - if( "30".equals(Util.bytes2HexString(this.fillKey))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.fillKey))) { - return 1; - } - return null; - } - - - public byte[] getPublicKeyLenAsBin( ) { - - return this.publicKeyLen; - } - - - public String getPublicKeyLenAsStr( ) { - - if( null == this.publicKeyLen) return null; - return Arrays.toString(this.publicKeyLen); - } - - - public String getPublicKeyLenAsHex( ) { - - if( null == this.publicKeyLen) return null; - return Util.bytes2HexString(publicKeyLen); - } - - - public Data setPublicKeyLen( byte[] bytes ) { - - this.publicKeyLen = bytes; - return this; - } - - - public byte[] getPublicKeyAsBin( ) { - - return this.publicKey; - } - - - public String getPublicKeyAsStr( ) { - - if( null == this.publicKey) return null; - return Arrays.toString(this.publicKey); - } - - - public String getPublicKeyAsHex( ) { - - if( null == this.publicKey) return null; - return Util.bytes2HexString(publicKey); - } - - - public Data setPublicKey( byte[] bytes ) { - - this.publicKey = bytes; - return this; - } - - - public byte[] getAlgorithmKey1AsBin( ) { - - return this.algorithmKey1; - } - - - public String getAlgorithmKey1AsStr( ) { - - if( null == this.algorithmKey1) return null; - return Arrays.toString(this.algorithmKey1); - } - - - public String getAlgorithmKey1AsHex( ) { - - if( null == this.algorithmKey1) return null; - return Util.bytes2HexString(algorithmKey1); - } - - - public Data setAlgorithmKey1( byte[] bytes ) { - - this.algorithmKey1 = bytes; - return this; - } - - - public byte[] getEncryAlgorithm1AsBin( ) { - - return this.encryAlgorithm1; - } - - - public String getEncryAlgorithm1AsStr( ) { - - if( null == this.encryAlgorithm1) return null; - return Arrays.toString(this.encryAlgorithm1); - } - - - public String getEncryAlgorithm1AsHex( ) { - - if( null == this.encryAlgorithm1) return null; - return Util.bytes2HexString(encryAlgorithm1); - } - - - public Data setEncryAlgorithm1( byte[] bytes ) { - - this.encryAlgorithm1 = bytes; - return this; - } -public enum EncryAlgorithm1Options { - - OPV3DES(Util.hexString2Bytes("30")), - OPVSM4(Util.hexString2Bytes("31")); - private byte[] bin; - EncryAlgorithm1Options(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getEncryAlgorithm1Cn( ) { - - if( null == encryAlgorithm1) { return null; } - if( "30".equals(Util.bytes2HexString(this.encryAlgorithm1))) { - return "3DES"; - } - if( "31".equals(Util.bytes2HexString(this.encryAlgorithm1))) { - return "SM4"; - } - return null; - } - - - public Integer getEncryAlgorithm1OptionIndex( ) { - - if( null == encryAlgorithm1) { return null; } - if( "30".equals(Util.bytes2HexString(this.encryAlgorithm1))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.encryAlgorithm1))) { - return 1; - } - return null; - } - - - public byte[] getAlgorithmKey2AsBin( ) { - - return this.algorithmKey2; - } - - - public String getAlgorithmKey2AsStr( ) { - - if( null == this.algorithmKey2) return null; - return Arrays.toString(this.algorithmKey2); - } - - - public String getAlgorithmKey2AsHex( ) { - - if( null == this.algorithmKey2) return null; - return Util.bytes2HexString(algorithmKey2); - } - - - public Data setAlgorithmKey2( byte[] bytes ) { - - this.algorithmKey2 = bytes; - return this; - } - - - public byte[] getEncryAlgorithm2AsBin( ) { - - return this.encryAlgorithm2; - } - - - public String getEncryAlgorithm2AsStr( ) { - - if( null == this.encryAlgorithm2) return null; - return Arrays.toString(this.encryAlgorithm2); - } - - - public String getEncryAlgorithm2AsHex( ) { - - if( null == this.encryAlgorithm2) return null; - return Util.bytes2HexString(encryAlgorithm2); - } - - - public Data setEncryAlgorithm2( byte[] bytes ) { - - this.encryAlgorithm2 = bytes; - return this; - } -public enum EncryAlgorithm2Options { - - OPVECB(Util.hexString2Bytes("30")), - OPVCBC(Util.hexString2Bytes("31")); - private byte[] bin; - EncryAlgorithm2Options(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getEncryAlgorithm2Cn( ) { - - if( null == encryAlgorithm2) { return null; } - if( "30".equals(Util.bytes2HexString(this.encryAlgorithm2))) { - return "ECB"; - } - if( "31".equals(Util.bytes2HexString(this.encryAlgorithm2))) { - return "CBC"; - } - return null; - } - - - public Integer getEncryAlgorithm2OptionIndex( ) { - - if( null == encryAlgorithm2) { return null; } - if( "30".equals(Util.bytes2HexString(this.encryAlgorithm2))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.encryAlgorithm2))) { - return 1; - } - return null; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != dEK ){ - soup.put("DEK", this.dEK); - } - - if( null != infoDataLen ){ - soup.put("infoDataLen", this.infoDataLen); - } - - if( null != infoData ){ - soup.put("infoData", this.infoData); - } - - if( null != alg ){ - soup.put("alg", this.alg); - soup.put("alg$option", getAlgOptionIndex()); - } - - if( null != fillKey ){ - soup.put("fillKey", this.fillKey); - soup.put("fillKey$option", getFillKeyOptionIndex()); - } - - if( null != publicKeyLen ){ - soup.put("publicKeyLen", this.publicKeyLen); - } - - if( null != publicKey ){ - soup.put("publicKey", this.publicKey); - } - - if( null != algorithmKey1 ){ - soup.put("AlgorithmKey1", this.algorithmKey1); - } - - if( null != encryAlgorithm1 ){ - soup.put("EncryAlgorithm1", this.encryAlgorithm1); - soup.put("EncryAlgorithm1$option", getEncryAlgorithm1OptionIndex()); - } - - if( null != algorithmKey2 ){ - soup.put("AlgorithmKey2", this.algorithmKey2); - } - - if( null != encryAlgorithm2 ){ - soup.put("EncryAlgorithm2", this.encryAlgorithm2); - soup.put("EncryAlgorithm2$option", getEncryAlgorithm2OptionIndex()); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("DEK") ){ - this.dEK = ((PacketSection) soup.get("DEK")).getBytes(); - } - - if( soup.containsKey("infoDataLen") ){ - this.infoDataLen = ((PacketSection) soup.get("infoDataLen")).getBytes(); - } - - if( soup.containsKey("infoData") ){ - this.infoData = ((PacketSection) soup.get("infoData")).getBytes(); - } - - if( soup.containsKey("alg") ){ - this.alg = ((PacketSection) soup.get("alg")).getBytes(); - } - - if( soup.containsKey("fillKey") ){ - this.fillKey = ((PacketSection) soup.get("fillKey")).getBytes(); - } - - if( soup.containsKey("publicKeyLen") ){ - this.publicKeyLen = ((PacketSection) soup.get("publicKeyLen")).getBytes(); - } - - if( soup.containsKey("publicKey") ){ - this.publicKey = ((PacketSection) soup.get("publicKey")).getBytes(); - } - - if( soup.containsKey("AlgorithmKey1") ){ - this.algorithmKey1 = ((PacketSection) soup.get("AlgorithmKey1")).getBytes(); - } - - if( soup.containsKey("EncryAlgorithm1") ){ - this.encryAlgorithm1 = ((PacketSection) soup.get("EncryAlgorithm1")).getBytes(); - } - - if( soup.containsKey("AlgorithmKey2") ){ - this.algorithmKey2 = ((PacketSection) soup.get("AlgorithmKey2")).getBytes(); - } - - if( soup.containsKey("EncryAlgorithm2") ){ - this.encryAlgorithm2 = ((PacketSection) soup.get("EncryAlgorithm2")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3638")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3638"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] keyLen = null; - private byte[] key = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV公钥不符合编码规则(Util.hexString2Bytes("3034")), - OPV无效的加密标识(Util.hexString2Bytes("3036")), - OPV无效的附加模式标识(Util.hexString2Bytes("3037")), - OPV密钥奇偶校验错误(Util.hexString2Bytes("3130")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVDSP错误(Util.hexString2Bytes("3437")), - OPV密钥块长度错误(Util.hexString2Bytes("3736")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return "公钥不符合编码规则"; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return "无效的加密标识"; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return "无效的附加模式标识"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "密钥奇偶校验错误"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return "DSP 错误"; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return "密钥块长度错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 9; - } - return null; - } - - - public byte[] getKeyLenAsBin( ) { - - return this.keyLen; - } - - - public String getKeyLenAsStr( ) { - - if( null == this.keyLen) return null; - return Arrays.toString(this.keyLen); - } - - - public String getKeyLenAsHex( ) { - - if( null == this.keyLen) return null; - return Util.bytes2HexString(keyLen); - } - - - public Data setKeyLen( byte[] bytes ) { - - this.keyLen = bytes; - return this; - } - - - public byte[] getKeyAsBin( ) { - - return this.key; - } - - - public String getKeyAsStr( ) { - - if( null == this.key) return null; - return Arrays.toString(this.key); - } - - - public String getKeyAsHex( ) { - - if( null == this.key) return null; - return Util.bytes2HexString(key); - } - - - public Data setKey( byte[] bytes ) { - - this.key = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != keyLen ){ - soup.put("keyLen", this.keyLen); - } - - if( null != key ){ - soup.put("key", this.key); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("keyLen") ){ - this.keyLen = ((PacketSection) soup.get("keyLen")).getBytes(); - } - - if( soup.containsKey("key") ){ - this.key = ((PacketSection) soup.get("key")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3639")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3639"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO69.java b/src/main/java/racal/sunyard/main/dto/DTO69.java deleted file mode 100644 index 1f9a889..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO69.java +++ /dev/null @@ -1,1319 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO69 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] alg = null; - private byte[] fillKey = null; - private byte[] privateKeyTag = null; - private byte[] privateKeyLength = null; - private byte[] privateKey = null; - private byte[] dataLength = null; - private byte[] infoData = null; - private byte[] dEK = null; - private byte[] algorithmKey1 = null; - private byte[] encryAlgorithm1 = null; - private byte[] algorithmKey2 = null; - private byte[] encryAlgorithm2 = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getAlgAsBin( ) { - - return this.alg; - } - - - public String getAlgAsStr( ) { - - if( null == this.alg) return null; - return Arrays.toString(this.alg); - } - - - public String getAlgAsHex( ) { - - if( null == this.alg) return null; - return Util.bytes2HexString(alg); - } - - - public Data setAlg( byte[] bytes ) { - - this.alg = bytes; - return this; - } -public enum AlgOptions { - - OPVRSA(Util.hexString2Bytes("30")), - OPVSM2(Util.hexString2Bytes("31")); - private byte[] bin; - AlgOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getAlgCn( ) { - - if( null == alg) { return null; } - if( "30".equals(Util.bytes2HexString(this.alg))) { - return "RSA"; - } - if( "31".equals(Util.bytes2HexString(this.alg))) { - return "SM2"; - } - return null; - } - - - public Integer getAlgOptionIndex( ) { - - if( null == alg) { return null; } - if( "30".equals(Util.bytes2HexString(this.alg))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.alg))) { - return 1; - } - return null; - } - - - public byte[] getFillKeyAsBin( ) { - - return this.fillKey; - } - - - public String getFillKeyAsStr( ) { - - if( null == this.fillKey) return null; - return Arrays.toString(this.fillKey); - } - - - public String getFillKeyAsHex( ) { - - if( null == this.fillKey) return null; - return Util.bytes2HexString(fillKey); - } - - - public Data setFillKey( byte[] bytes ) { - - this.fillKey = bytes; - return this; - } -public enum FillKeyOptions { - - OPV数据长度必须等于密钥长度DER对应的数据长度(Util.hexString2Bytes("30")), - OPVPKCS1v15填充方式(Util.hexString2Bytes("31")); - private byte[] bin; - FillKeyOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getFillKeyCn( ) { - - if( null == fillKey) { return null; } - if( "30".equals(Util.bytes2HexString(this.fillKey))) { - return "数据长度必须等于密钥长度(DER对应的数据长度)"; - } - if( "31".equals(Util.bytes2HexString(this.fillKey))) { - return "PKCS#1 v1.5 填充方式"; - } - return null; - } - - - public Integer getFillKeyOptionIndex( ) { - - if( null == fillKey) { return null; } - if( "30".equals(Util.bytes2HexString(this.fillKey))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.fillKey))) { - return 1; - } - return null; - } - - - public byte[] getPrivateKeyTagAsBin( ) { - - return this.privateKeyTag; - } - - - public String getPrivateKeyTagAsStr( ) { - - if( null == this.privateKeyTag) return null; - return Arrays.toString(this.privateKeyTag); - } - - - public String getPrivateKeyTagAsHex( ) { - - if( null == this.privateKeyTag) return null; - return Util.bytes2HexString(privateKeyTag); - } - - - public Data setPrivateKeyTag( byte[] bytes ) { - - this.privateKeyTag = bytes; - return this; - } - - - public byte[] getPrivateKeyLengthAsBin( ) { - - return this.privateKeyLength; - } - - - public String getPrivateKeyLengthAsStr( ) { - - if( null == this.privateKeyLength) return null; - return Arrays.toString(this.privateKeyLength); - } - - - public String getPrivateKeyLengthAsHex( ) { - - if( null == this.privateKeyLength) return null; - return Util.bytes2HexString(privateKeyLength); - } - - - public Data setPrivateKeyLength( byte[] bytes ) { - - this.privateKeyLength = bytes; - return this; - } - - - public byte[] getPrivateKeyAsBin( ) { - - return this.privateKey; - } - - - public String getPrivateKeyAsStr( ) { - - if( null == this.privateKey) return null; - return Arrays.toString(this.privateKey); - } - - - public String getPrivateKeyAsHex( ) { - - if( null == this.privateKey) return null; - return Util.bytes2HexString(privateKey); - } - - - public Data setPrivateKey( byte[] bytes ) { - - this.privateKey = bytes; - return this; - } - - - public byte[] getDataLengthAsBin( ) { - - return this.dataLength; - } - - - public String getDataLengthAsStr( ) { - - if( null == this.dataLength) return null; - return Arrays.toString(this.dataLength); - } - - - public String getDataLengthAsHex( ) { - - if( null == this.dataLength) return null; - return Util.bytes2HexString(dataLength); - } - - - public Data setDataLength( byte[] bytes ) { - - this.dataLength = bytes; - return this; - } - - - public byte[] getInfoDataAsBin( ) { - - return this.infoData; - } - - - public String getInfoDataAsStr( ) { - - if( null == this.infoData) return null; - return Arrays.toString(this.infoData); - } - - - public String getInfoDataAsHex( ) { - - if( null == this.infoData) return null; - return Util.bytes2HexString(infoData); - } - - - public Data setInfoData( byte[] bytes ) { - - this.infoData = bytes; - return this; - } - - - public byte[] getDEKAsBin( ) { - - return this.dEK; - } - - - public String getDEKAsStr( ) { - - if( null == this.dEK) return null; - return Arrays.toString(this.dEK); - } - - - public String getDEKAsHex( ) { - - if( null == this.dEK) return null; - return Util.bytes2HexString(dEK); - } - - - public Data setDEK( byte[] bytes ) { - - this.dEK = bytes; - return this; - } - - - public byte[] getAlgorithmKey1AsBin( ) { - - return this.algorithmKey1; - } - - - public String getAlgorithmKey1AsStr( ) { - - if( null == this.algorithmKey1) return null; - return Arrays.toString(this.algorithmKey1); - } - - - public String getAlgorithmKey1AsHex( ) { - - if( null == this.algorithmKey1) return null; - return Util.bytes2HexString(algorithmKey1); - } - - - public Data setAlgorithmKey1( byte[] bytes ) { - - this.algorithmKey1 = bytes; - return this; - } - - - public byte[] getEncryAlgorithm1AsBin( ) { - - return this.encryAlgorithm1; - } - - - public String getEncryAlgorithm1AsStr( ) { - - if( null == this.encryAlgorithm1) return null; - return Arrays.toString(this.encryAlgorithm1); - } - - - public String getEncryAlgorithm1AsHex( ) { - - if( null == this.encryAlgorithm1) return null; - return Util.bytes2HexString(encryAlgorithm1); - } - - - public Data setEncryAlgorithm1( byte[] bytes ) { - - this.encryAlgorithm1 = bytes; - return this; - } -public enum EncryAlgorithm1Options { - - OPV3DES(Util.hexString2Bytes("30")), - OPVSM4(Util.hexString2Bytes("31")); - private byte[] bin; - EncryAlgorithm1Options(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getEncryAlgorithm1Cn( ) { - - if( null == encryAlgorithm1) { return null; } - if( "30".equals(Util.bytes2HexString(this.encryAlgorithm1))) { - return "3DES"; - } - if( "31".equals(Util.bytes2HexString(this.encryAlgorithm1))) { - return "SM4"; - } - return null; - } - - - public Integer getEncryAlgorithm1OptionIndex( ) { - - if( null == encryAlgorithm1) { return null; } - if( "30".equals(Util.bytes2HexString(this.encryAlgorithm1))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.encryAlgorithm1))) { - return 1; - } - return null; - } - - - public byte[] getAlgorithmKey2AsBin( ) { - - return this.algorithmKey2; - } - - - public String getAlgorithmKey2AsStr( ) { - - if( null == this.algorithmKey2) return null; - return Arrays.toString(this.algorithmKey2); - } - - - public String getAlgorithmKey2AsHex( ) { - - if( null == this.algorithmKey2) return null; - return Util.bytes2HexString(algorithmKey2); - } - - - public Data setAlgorithmKey2( byte[] bytes ) { - - this.algorithmKey2 = bytes; - return this; - } - - - public byte[] getEncryAlgorithm2AsBin( ) { - - return this.encryAlgorithm2; - } - - - public String getEncryAlgorithm2AsStr( ) { - - if( null == this.encryAlgorithm2) return null; - return Arrays.toString(this.encryAlgorithm2); - } - - - public String getEncryAlgorithm2AsHex( ) { - - if( null == this.encryAlgorithm2) return null; - return Util.bytes2HexString(encryAlgorithm2); - } - - - public Data setEncryAlgorithm2( byte[] bytes ) { - - this.encryAlgorithm2 = bytes; - return this; - } -public enum EncryAlgorithm2Options { - - OPVECB(Util.hexString2Bytes("30")), - OPVCBC(Util.hexString2Bytes("31")); - private byte[] bin; - EncryAlgorithm2Options(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getEncryAlgorithm2Cn( ) { - - if( null == encryAlgorithm2) { return null; } - if( "30".equals(Util.bytes2HexString(this.encryAlgorithm2))) { - return "ECB"; - } - if( "31".equals(Util.bytes2HexString(this.encryAlgorithm2))) { - return "CBC"; - } - return null; - } - - - public Integer getEncryAlgorithm2OptionIndex( ) { - - if( null == encryAlgorithm2) { return null; } - if( "30".equals(Util.bytes2HexString(this.encryAlgorithm2))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.encryAlgorithm2))) { - return 1; - } - return null; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != alg ){ - soup.put("alg", this.alg); - soup.put("alg$option", getAlgOptionIndex()); - } - - if( null != fillKey ){ - soup.put("fillKey", this.fillKey); - soup.put("fillKey$option", getFillKeyOptionIndex()); - } - - if( null != privateKeyTag ){ - soup.put("privateKeyTag", this.privateKeyTag); - } - - if( null != privateKeyLength ){ - soup.put("privateKeyLength", this.privateKeyLength); - } - - if( null != privateKey ){ - soup.put("privateKey", this.privateKey); - } - - if( null != dataLength ){ - soup.put("dataLength", this.dataLength); - } - - if( null != infoData ){ - soup.put("infoData", this.infoData); - } - - if( null != dEK ){ - soup.put("DEK", this.dEK); - } - - if( null != algorithmKey1 ){ - soup.put("AlgorithmKey1", this.algorithmKey1); - } - - if( null != encryAlgorithm1 ){ - soup.put("EncryAlgorithm1", this.encryAlgorithm1); - soup.put("EncryAlgorithm1$option", getEncryAlgorithm1OptionIndex()); - } - - if( null != algorithmKey2 ){ - soup.put("AlgorithmKey2", this.algorithmKey2); - } - - if( null != encryAlgorithm2 ){ - soup.put("EncryAlgorithm2", this.encryAlgorithm2); - soup.put("EncryAlgorithm2$option", getEncryAlgorithm2OptionIndex()); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("alg") ){ - this.alg = ((PacketSection) soup.get("alg")).getBytes(); - } - - if( soup.containsKey("fillKey") ){ - this.fillKey = ((PacketSection) soup.get("fillKey")).getBytes(); - } - - if( soup.containsKey("privateKeyTag") ){ - this.privateKeyTag = ((PacketSection) soup.get("privateKeyTag")).getBytes(); - } - - if( soup.containsKey("privateKeyLength") ){ - this.privateKeyLength = ((PacketSection) soup.get("privateKeyLength")).getBytes(); - } - - if( soup.containsKey("privateKey") ){ - this.privateKey = ((PacketSection) soup.get("privateKey")).getBytes(); - } - - if( soup.containsKey("dataLength") ){ - this.dataLength = ((PacketSection) soup.get("dataLength")).getBytes(); - } - - if( soup.containsKey("infoData") ){ - this.infoData = ((PacketSection) soup.get("infoData")).getBytes(); - } - - if( soup.containsKey("DEK") ){ - this.dEK = ((PacketSection) soup.get("DEK")).getBytes(); - } - - if( soup.containsKey("AlgorithmKey1") ){ - this.algorithmKey1 = ((PacketSection) soup.get("AlgorithmKey1")).getBytes(); - } - - if( soup.containsKey("EncryAlgorithm1") ){ - this.encryAlgorithm1 = ((PacketSection) soup.get("EncryAlgorithm1")).getBytes(); - } - - if( soup.containsKey("AlgorithmKey2") ){ - this.algorithmKey2 = ((PacketSection) soup.get("AlgorithmKey2")).getBytes(); - } - - if( soup.containsKey("EncryAlgorithm2") ){ - this.encryAlgorithm2 = ((PacketSection) soup.get("EncryAlgorithm2")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3639")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3639"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] keyLen = null; - private byte[] key = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV公钥不符合编码规则(Util.hexString2Bytes("3034")), - OPV无效的对称密钥类型(Util.hexString2Bytes("3035")), - OPV无效的加密标识(Util.hexString2Bytes("3036")), - OPV无效的附加模式标识(Util.hexString2Bytes("3037")), - OPV密钥奇偶校验错误(Util.hexString2Bytes("3130")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVDSP错误(Util.hexString2Bytes("3437")), - OPV密钥块长度错误(Util.hexString2Bytes("3736")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return "公钥不符合编码规则"; - } - if( "3035".equals(Util.bytes2HexString(this.error))) { - return "无效的对称密钥类型"; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return "无效的加密标识"; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return "无效的附加模式标识"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "密钥奇偶校验错误"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return "DSP 错误"; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return "密钥块长度错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3035".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return 9; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 10; - } - return null; - } - - - public byte[] getKeyLenAsBin( ) { - - return this.keyLen; - } - - - public String getKeyLenAsStr( ) { - - if( null == this.keyLen) return null; - return Arrays.toString(this.keyLen); - } - - - public String getKeyLenAsHex( ) { - - if( null == this.keyLen) return null; - return Util.bytes2HexString(keyLen); - } - - - public Data setKeyLen( byte[] bytes ) { - - this.keyLen = bytes; - return this; - } - - - public byte[] getKeyAsBin( ) { - - return this.key; - } - - - public String getKeyAsStr( ) { - - if( null == this.key) return null; - return Arrays.toString(this.key); - } - - - public String getKeyAsHex( ) { - - if( null == this.key) return null; - return Util.bytes2HexString(key); - } - - - public Data setKey( byte[] bytes ) { - - this.key = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != keyLen ){ - soup.put("keyLen", this.keyLen); - } - - if( null != key ){ - soup.put("key", this.key); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("keyLen") ){ - this.keyLen = ((PacketSection) soup.get("keyLen")).getBytes(); - } - - if( soup.containsKey("key") ){ - this.key = ((PacketSection) soup.get("key")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3641")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3641"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO6A.java b/src/main/java/racal/sunyard/main/dto/DTO6A.java deleted file mode 100644 index ee952e9..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO6A.java +++ /dev/null @@ -1,1128 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO6A { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] alg = null; - private byte[] certificateModel = null; - private byte[] certificateLen = null; - private byte[] certificateSn = null; - private byte[] certificateDn = null; - private byte[] keyType = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getAlgAsBin( ) { - - return this.alg; - } - - - public String getAlgAsStr( ) { - - if( null == this.alg) return null; - return Arrays.toString(this.alg); - } - - - public String getAlgAsHex( ) { - - if( null == this.alg) return null; - return Util.bytes2HexString(alg); - } - - - public Data setAlg( byte[] bytes ) { - - this.alg = bytes; - return this; - } -public enum AlgOptions { - - OPVRSA2048AES256ECB(Util.hexString2Bytes("30")), - OPVSM2SM4ECB(Util.hexString2Bytes("31")); - private byte[] bin; - AlgOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getAlgCn( ) { - - if( null == alg) { return null; } - if( "30".equals(Util.bytes2HexString(this.alg))) { - return "RSA2048_AES256_ECB"; - } - if( "31".equals(Util.bytes2HexString(this.alg))) { - return "SM2_SM4_ECB"; - } - return null; - } - - - public Integer getAlgOptionIndex( ) { - - if( null == alg) { return null; } - if( "30".equals(Util.bytes2HexString(this.alg))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.alg))) { - return 1; - } - return null; - } - - - public byte[] getCertificateModelAsBin( ) { - - return this.certificateModel; - } - - - public String getCertificateModelAsStr( ) { - - if( null == this.certificateModel) return null; - return Arrays.toString(this.certificateModel); - } - - - public String getCertificateModelAsHex( ) { - - if( null == this.certificateModel) return null; - return Util.bytes2HexString(certificateModel); - } - - - public Data setCertificateModel( byte[] bytes ) { - - this.certificateModel = bytes; - return this; - } -public enum CertificateModelOptions { - - OPV证书序号(Util.hexString2Bytes("30")), - OPV证书DN(Util.hexString2Bytes("31")); - private byte[] bin; - CertificateModelOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getCertificateModelCn( ) { - - if( null == certificateModel) { return null; } - if( "30".equals(Util.bytes2HexString(this.certificateModel))) { - return "证书序号"; - } - if( "31".equals(Util.bytes2HexString(this.certificateModel))) { - return "证书 DN"; - } - return null; - } - - - public Integer getCertificateModelOptionIndex( ) { - - if( null == certificateModel) { return null; } - if( "30".equals(Util.bytes2HexString(this.certificateModel))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.certificateModel))) { - return 1; - } - return null; - } - - - public byte[] getCertificateLenAsBin( ) { - - return this.certificateLen; - } - - - public String getCertificateLenAsStr( ) { - - if( null == this.certificateLen) return null; - return Arrays.toString(this.certificateLen); - } - - - public String getCertificateLenAsHex( ) { - - if( null == this.certificateLen) return null; - return Util.bytes2HexString(certificateLen); - } - - - public Data setCertificateLen( byte[] bytes ) { - - this.certificateLen = bytes; - return this; - } - - - public byte[] getCertificateSnAsBin( ) { - - return this.certificateSn; - } - - - public String getCertificateSnAsStr( ) { - - if( null == this.certificateSn) return null; - return Arrays.toString(this.certificateSn); - } - - - public String getCertificateSnAsHex( ) { - - if( null == this.certificateSn) return null; - return Util.bytes2HexString(certificateSn); - } - - - public Data setCertificateSn( byte[] bytes ) { - - this.certificateSn = bytes; - return this; - } - - - public byte[] getCertificateDnAsBin( ) { - - return this.certificateDn; - } - - - public String getCertificateDnAsStr( ) { - - if( null == this.certificateDn) return null; - return Arrays.toString(this.certificateDn); - } - - - public String getCertificateDnAsHex( ) { - - if( null == this.certificateDn) return null; - return Util.bytes2HexString(certificateDn); - } - - - public Data setCertificateDn( byte[] bytes ) { - - this.certificateDn = bytes; - return this; - } - - - public byte[] getKeyTypeAsBin( ) { - - return this.keyType; - } - - - public String getKeyTypeAsStr( ) { - - if( null == this.keyType) return null; - return Arrays.toString(this.keyType); - } - - - public String getKeyTypeAsHex( ) { - - if( null == this.keyType) return null; - return Util.bytes2HexString(keyType); - } - - - public Data setKeyType( byte[] bytes ) { - - this.keyType = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != alg ){ - soup.put("alg", this.alg); - soup.put("alg$option", getAlgOptionIndex()); - } - - if( null != certificateModel ){ - soup.put("certificateModel", this.certificateModel); - soup.put("certificateModel$option", getCertificateModelOptionIndex()); - } - - if( null != certificateLen ){ - soup.put("certificateLen", this.certificateLen); - } - - if( null != certificateSn ){ - soup.put("certificateSn", this.certificateSn); - } - - if( null != certificateDn ){ - soup.put("certificateDn", this.certificateDn); - } - - if( null != keyType ){ - soup.put("keyType", this.keyType); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("alg") ){ - this.alg = ((PacketSection) soup.get("alg")).getBytes(); - } - - if( soup.containsKey("certificateModel") ){ - this.certificateModel = ((PacketSection) soup.get("certificateModel")).getBytes(); - } - - if( soup.containsKey("certificateLen") ){ - this.certificateLen = ((PacketSection) soup.get("certificateLen")).getBytes(); - } - - if( soup.containsKey("certificateSn") ){ - this.certificateSn = ((PacketSection) soup.get("certificateSn")).getBytes(); - } - - if( soup.containsKey("certificateDn") ){ - this.certificateDn = ((PacketSection) soup.get("certificateDn")).getBytes(); - } - - if( soup.containsKey("keyType") ){ - this.keyType = ((PacketSection) soup.get("keyType")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3641")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3641"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] keyLen = null; - private byte[] key = null; - private byte[] lmkHead = null; - private byte[] lmk = null; - private byte[] keyCheck = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV公钥不符合编码规则(Util.hexString2Bytes("3034")), - OPV无效的加密标识(Util.hexString2Bytes("3036")), - OPV无效的附加模式标识(Util.hexString2Bytes("3037")), - OPV密钥奇偶校验错误(Util.hexString2Bytes("3130")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVDSP错误(Util.hexString2Bytes("3437")), - OPV密钥块长度错误(Util.hexString2Bytes("3736")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return "公钥不符合编码规则"; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return "无效的加密标识"; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return "无效的附加模式标识"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "密钥奇偶校验错误"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return "DSP 错误"; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return "密钥块长度错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 9; - } - return null; - } - - - public byte[] getKeyLenAsBin( ) { - - return this.keyLen; - } - - - public String getKeyLenAsStr( ) { - - if( null == this.keyLen) return null; - return Arrays.toString(this.keyLen); - } - - - public String getKeyLenAsHex( ) { - - if( null == this.keyLen) return null; - return Util.bytes2HexString(keyLen); - } - - - public Data setKeyLen( byte[] bytes ) { - - this.keyLen = bytes; - return this; - } - - - public byte[] getKeyAsBin( ) { - - return this.key; - } - - - public String getKeyAsStr( ) { - - if( null == this.key) return null; - return Arrays.toString(this.key); - } - - - public String getKeyAsHex( ) { - - if( null == this.key) return null; - return Util.bytes2HexString(key); - } - - - public Data setKey( byte[] bytes ) { - - this.key = bytes; - return this; - } - - - public byte[] getLmkHeadAsBin( ) { - - return this.lmkHead; - } - - - public String getLmkHeadAsStr( ) { - - if( null == this.lmkHead) return null; - return Arrays.toString(this.lmkHead); - } - - - public String getLmkHeadAsHex( ) { - - if( null == this.lmkHead) return null; - return Util.bytes2HexString(lmkHead); - } - - - public Data setLmkHead( byte[] bytes ) { - - this.lmkHead = bytes; - return this; - } - - - public byte[] getLmkAsBin( ) { - - return this.lmk; - } - - - public String getLmkAsStr( ) { - - if( null == this.lmk) return null; - return Arrays.toString(this.lmk); - } - - - public String getLmkAsHex( ) { - - if( null == this.lmk) return null; - return Util.bytes2HexString(lmk); - } - - - public Data setLmk( byte[] bytes ) { - - this.lmk = bytes; - return this; - } - - - public byte[] getKeyCheckAsBin( ) { - - return this.keyCheck; - } - - - public String getKeyCheckAsStr( ) { - - if( null == this.keyCheck) return null; - return Arrays.toString(this.keyCheck); - } - - - public String getKeyCheckAsHex( ) { - - if( null == this.keyCheck) return null; - return Util.bytes2HexString(keyCheck); - } - - - public Data setKeyCheck( byte[] bytes ) { - - this.keyCheck = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != keyLen ){ - soup.put("keyLen", this.keyLen); - } - - if( null != key ){ - soup.put("key", this.key); - } - - if( null != lmkHead ){ - soup.put("lmkHead", this.lmkHead); - } - - if( null != lmk ){ - soup.put("lmk", this.lmk); - } - - if( null != keyCheck ){ - soup.put("keyCheck", this.keyCheck); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("keyLen") ){ - this.keyLen = ((PacketSection) soup.get("keyLen")).getBytes(); - } - - if( soup.containsKey("key") ){ - this.key = ((PacketSection) soup.get("key")).getBytes(); - } - - if( soup.containsKey("lmkHead") ){ - this.lmkHead = ((PacketSection) soup.get("lmkHead")).getBytes(); - } - - if( soup.containsKey("lmk") ){ - this.lmk = ((PacketSection) soup.get("lmk")).getBytes(); - } - - if( soup.containsKey("keyCheck") ){ - this.keyCheck = ((PacketSection) soup.get("keyCheck")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3642")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3642"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO6B.java b/src/main/java/racal/sunyard/main/dto/DTO6B.java deleted file mode 100644 index 7508b21..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO6B.java +++ /dev/null @@ -1,1061 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO6B { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] certificateModel = null; - private byte[] certificateLen = null; - private byte[] certificateSn = null; - private byte[] certificateDn = null; - private byte[] keyLen = null; - private byte[] key = null; - private byte[] keyType = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getCertificateModelAsBin( ) { - - return this.certificateModel; - } - - - public String getCertificateModelAsStr( ) { - - if( null == this.certificateModel) return null; - return Arrays.toString(this.certificateModel); - } - - - public String getCertificateModelAsHex( ) { - - if( null == this.certificateModel) return null; - return Util.bytes2HexString(certificateModel); - } - - - public Data setCertificateModel( byte[] bytes ) { - - this.certificateModel = bytes; - return this; - } -public enum CertificateModelOptions { - - OPV证书序号(Util.hexString2Bytes("30")), - OPV证书DN(Util.hexString2Bytes("31")); - private byte[] bin; - CertificateModelOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getCertificateModelCn( ) { - - if( null == certificateModel) { return null; } - if( "30".equals(Util.bytes2HexString(this.certificateModel))) { - return "证书序号"; - } - if( "31".equals(Util.bytes2HexString(this.certificateModel))) { - return "证书 DN"; - } - return null; - } - - - public Integer getCertificateModelOptionIndex( ) { - - if( null == certificateModel) { return null; } - if( "30".equals(Util.bytes2HexString(this.certificateModel))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.certificateModel))) { - return 1; - } - return null; - } - - - public byte[] getCertificateLenAsBin( ) { - - return this.certificateLen; - } - - - public String getCertificateLenAsStr( ) { - - if( null == this.certificateLen) return null; - return Arrays.toString(this.certificateLen); - } - - - public String getCertificateLenAsHex( ) { - - if( null == this.certificateLen) return null; - return Util.bytes2HexString(certificateLen); - } - - - public Data setCertificateLen( byte[] bytes ) { - - this.certificateLen = bytes; - return this; - } - - - public byte[] getCertificateSnAsBin( ) { - - return this.certificateSn; - } - - - public String getCertificateSnAsStr( ) { - - if( null == this.certificateSn) return null; - return Arrays.toString(this.certificateSn); - } - - - public String getCertificateSnAsHex( ) { - - if( null == this.certificateSn) return null; - return Util.bytes2HexString(certificateSn); - } - - - public Data setCertificateSn( byte[] bytes ) { - - this.certificateSn = bytes; - return this; - } - - - public byte[] getCertificateDnAsBin( ) { - - return this.certificateDn; - } - - - public String getCertificateDnAsStr( ) { - - if( null == this.certificateDn) return null; - return Arrays.toString(this.certificateDn); - } - - - public String getCertificateDnAsHex( ) { - - if( null == this.certificateDn) return null; - return Util.bytes2HexString(certificateDn); - } - - - public Data setCertificateDn( byte[] bytes ) { - - this.certificateDn = bytes; - return this; - } - - - public byte[] getKeyLenAsBin( ) { - - return this.keyLen; - } - - - public String getKeyLenAsStr( ) { - - if( null == this.keyLen) return null; - return Arrays.toString(this.keyLen); - } - - - public String getKeyLenAsHex( ) { - - if( null == this.keyLen) return null; - return Util.bytes2HexString(keyLen); - } - - - public Data setKeyLen( byte[] bytes ) { - - this.keyLen = bytes; - return this; - } - - - public byte[] getKeyAsBin( ) { - - return this.key; - } - - - public String getKeyAsStr( ) { - - if( null == this.key) return null; - return Arrays.toString(this.key); - } - - - public String getKeyAsHex( ) { - - if( null == this.key) return null; - return Util.bytes2HexString(key); - } - - - public Data setKey( byte[] bytes ) { - - this.key = bytes; - return this; - } - - - public byte[] getKeyTypeAsBin( ) { - - return this.keyType; - } - - - public String getKeyTypeAsStr( ) { - - if( null == this.keyType) return null; - return Arrays.toString(this.keyType); - } - - - public String getKeyTypeAsHex( ) { - - if( null == this.keyType) return null; - return Util.bytes2HexString(keyType); - } - - - public Data setKeyType( byte[] bytes ) { - - this.keyType = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != certificateModel ){ - soup.put("certificateModel", this.certificateModel); - soup.put("certificateModel$option", getCertificateModelOptionIndex()); - } - - if( null != certificateLen ){ - soup.put("certificateLen", this.certificateLen); - } - - if( null != certificateSn ){ - soup.put("certificateSn", this.certificateSn); - } - - if( null != certificateDn ){ - soup.put("certificateDn", this.certificateDn); - } - - if( null != keyLen ){ - soup.put("keyLen", this.keyLen); - } - - if( null != key ){ - soup.put("key", this.key); - } - - if( null != keyType ){ - soup.put("keyType", this.keyType); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("certificateModel") ){ - this.certificateModel = ((PacketSection) soup.get("certificateModel")).getBytes(); - } - - if( soup.containsKey("certificateLen") ){ - this.certificateLen = ((PacketSection) soup.get("certificateLen")).getBytes(); - } - - if( soup.containsKey("certificateSn") ){ - this.certificateSn = ((PacketSection) soup.get("certificateSn")).getBytes(); - } - - if( soup.containsKey("certificateDn") ){ - this.certificateDn = ((PacketSection) soup.get("certificateDn")).getBytes(); - } - - if( soup.containsKey("keyLen") ){ - this.keyLen = ((PacketSection) soup.get("keyLen")).getBytes(); - } - - if( soup.containsKey("key") ){ - this.key = ((PacketSection) soup.get("key")).getBytes(); - } - - if( soup.containsKey("keyType") ){ - this.keyType = ((PacketSection) soup.get("keyType")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3642")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3642"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] lmkHead = null; - private byte[] lmk = null; - private byte[] keyCheck = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV公钥不符合编码规则(Util.hexString2Bytes("3034")), - OPV无效的加密标识(Util.hexString2Bytes("3036")), - OPV无效的附加模式标识(Util.hexString2Bytes("3037")), - OPV密钥奇偶校验错误(Util.hexString2Bytes("3130")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV输入的数据格式错误(Util.hexString2Bytes("3231")), - OPVDSP错误(Util.hexString2Bytes("3437")), - OPV密钥块长度错误(Util.hexString2Bytes("3736")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return "公钥不符合编码规则"; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return "无效的加密标识"; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return "无效的附加模式标识"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "密钥奇偶校验错误"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "输入的数据格式错误"; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return "DSP 错误"; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return "密钥块长度错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return 9; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 10; - } - return null; - } - - - public byte[] getLmkHeadAsBin( ) { - - return this.lmkHead; - } - - - public String getLmkHeadAsStr( ) { - - if( null == this.lmkHead) return null; - return Arrays.toString(this.lmkHead); - } - - - public String getLmkHeadAsHex( ) { - - if( null == this.lmkHead) return null; - return Util.bytes2HexString(lmkHead); - } - - - public Data setLmkHead( byte[] bytes ) { - - this.lmkHead = bytes; - return this; - } - - - public byte[] getLmkAsBin( ) { - - return this.lmk; - } - - - public String getLmkAsStr( ) { - - if( null == this.lmk) return null; - return Arrays.toString(this.lmk); - } - - - public String getLmkAsHex( ) { - - if( null == this.lmk) return null; - return Util.bytes2HexString(lmk); - } - - - public Data setLmk( byte[] bytes ) { - - this.lmk = bytes; - return this; - } - - - public byte[] getKeyCheckAsBin( ) { - - return this.keyCheck; - } - - - public String getKeyCheckAsStr( ) { - - if( null == this.keyCheck) return null; - return Arrays.toString(this.keyCheck); - } - - - public String getKeyCheckAsHex( ) { - - if( null == this.keyCheck) return null; - return Util.bytes2HexString(keyCheck); - } - - - public Data setKeyCheck( byte[] bytes ) { - - this.keyCheck = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != lmkHead ){ - soup.put("lmkHead", this.lmkHead); - } - - if( null != lmk ){ - soup.put("lmk", this.lmk); - } - - if( null != keyCheck ){ - soup.put("keyCheck", this.keyCheck); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("lmkHead") ){ - this.lmkHead = ((PacketSection) soup.get("lmkHead")).getBytes(); - } - - if( soup.containsKey("lmk") ){ - this.lmk = ((PacketSection) soup.get("lmk")).getBytes(); - } - - if( soup.containsKey("keyCheck") ){ - this.keyCheck = ((PacketSection) soup.get("keyCheck")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3643")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3643"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO6C.java b/src/main/java/racal/sunyard/main/dto/DTO6C.java deleted file mode 100644 index 793355b..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO6C.java +++ /dev/null @@ -1,982 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO6C { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] certificateModel = null; - private byte[] certificateLen = null; - private byte[] certificateSn = null; - private byte[] certificateDn = null; - private byte[] dataLen = null; - private byte[] inData = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getCertificateModelAsBin( ) { - - return this.certificateModel; - } - - - public String getCertificateModelAsStr( ) { - - if( null == this.certificateModel) return null; - return Arrays.toString(this.certificateModel); - } - - - public String getCertificateModelAsHex( ) { - - if( null == this.certificateModel) return null; - return Util.bytes2HexString(certificateModel); - } - - - public Data setCertificateModel( byte[] bytes ) { - - this.certificateModel = bytes; - return this; - } -public enum CertificateModelOptions { - - OPV证书序号(Util.hexString2Bytes("30")), - OPV证书DN(Util.hexString2Bytes("31")); - private byte[] bin; - CertificateModelOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getCertificateModelCn( ) { - - if( null == certificateModel) { return null; } - if( "30".equals(Util.bytes2HexString(this.certificateModel))) { - return "证书序号"; - } - if( "31".equals(Util.bytes2HexString(this.certificateModel))) { - return "证书 DN"; - } - return null; - } - - - public Integer getCertificateModelOptionIndex( ) { - - if( null == certificateModel) { return null; } - if( "30".equals(Util.bytes2HexString(this.certificateModel))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.certificateModel))) { - return 1; - } - return null; - } - - - public byte[] getCertificateLenAsBin( ) { - - return this.certificateLen; - } - - - public String getCertificateLenAsStr( ) { - - if( null == this.certificateLen) return null; - return Arrays.toString(this.certificateLen); - } - - - public String getCertificateLenAsHex( ) { - - if( null == this.certificateLen) return null; - return Util.bytes2HexString(certificateLen); - } - - - public Data setCertificateLen( byte[] bytes ) { - - this.certificateLen = bytes; - return this; - } - - - public byte[] getCertificateSnAsBin( ) { - - return this.certificateSn; - } - - - public String getCertificateSnAsStr( ) { - - if( null == this.certificateSn) return null; - return Arrays.toString(this.certificateSn); - } - - - public String getCertificateSnAsHex( ) { - - if( null == this.certificateSn) return null; - return Util.bytes2HexString(certificateSn); - } - - - public Data setCertificateSn( byte[] bytes ) { - - this.certificateSn = bytes; - return this; - } - - - public byte[] getCertificateDnAsBin( ) { - - return this.certificateDn; - } - - - public String getCertificateDnAsStr( ) { - - if( null == this.certificateDn) return null; - return Arrays.toString(this.certificateDn); - } - - - public String getCertificateDnAsHex( ) { - - if( null == this.certificateDn) return null; - return Util.bytes2HexString(certificateDn); - } - - - public Data setCertificateDn( byte[] bytes ) { - - this.certificateDn = bytes; - return this; - } - - - public byte[] getDataLenAsBin( ) { - - return this.dataLen; - } - - - public String getDataLenAsStr( ) { - - if( null == this.dataLen) return null; - return Arrays.toString(this.dataLen); - } - - - public String getDataLenAsHex( ) { - - if( null == this.dataLen) return null; - return Util.bytes2HexString(dataLen); - } - - - public Data setDataLen( byte[] bytes ) { - - this.dataLen = bytes; - return this; - } - - - public byte[] getInDataAsBin( ) { - - return this.inData; - } - - - public String getInDataAsStr( ) { - - if( null == this.inData) return null; - return Arrays.toString(this.inData); - } - - - public String getInDataAsHex( ) { - - if( null == this.inData) return null; - return Util.bytes2HexString(inData); - } - - - public Data setInData( byte[] bytes ) { - - this.inData = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != certificateModel ){ - soup.put("certificateModel", this.certificateModel); - soup.put("certificateModel$option", getCertificateModelOptionIndex()); - } - - if( null != certificateLen ){ - soup.put("certificateLen", this.certificateLen); - } - - if( null != certificateSn ){ - soup.put("certificateSn", this.certificateSn); - } - - if( null != certificateDn ){ - soup.put("certificateDn", this.certificateDn); - } - - if( null != dataLen ){ - soup.put("dataLen", this.dataLen); - } - - if( null != inData ){ - soup.put("inData", this.inData); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("certificateModel") ){ - this.certificateModel = ((PacketSection) soup.get("certificateModel")).getBytes(); - } - - if( soup.containsKey("certificateLen") ){ - this.certificateLen = ((PacketSection) soup.get("certificateLen")).getBytes(); - } - - if( soup.containsKey("certificateSn") ){ - this.certificateSn = ((PacketSection) soup.get("certificateSn")).getBytes(); - } - - if( soup.containsKey("certificateDn") ){ - this.certificateDn = ((PacketSection) soup.get("certificateDn")).getBytes(); - } - - if( soup.containsKey("dataLen") ){ - this.dataLen = ((PacketSection) soup.get("dataLen")).getBytes(); - } - - if( soup.containsKey("inData") ){ - this.inData = ((PacketSection) soup.get("inData")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3643")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3643"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] signLen = null; - private byte[] sign = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV公钥不符合编码规则(Util.hexString2Bytes("3034")), - OPV无效的加密标识(Util.hexString2Bytes("3036")), - OPV无效的附加模式标识(Util.hexString2Bytes("3037")), - OPV密钥奇偶校验错误(Util.hexString2Bytes("3130")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVDSP错误(Util.hexString2Bytes("3437")), - OPV密钥块长度错误(Util.hexString2Bytes("3736")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return "公钥不符合编码规则"; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return "无效的加密标识"; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return "无效的附加模式标识"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "密钥奇偶校验错误"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return "DSP 错误"; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return "密钥块长度错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 9; - } - return null; - } - - - public byte[] getSignLenAsBin( ) { - - return this.signLen; - } - - - public String getSignLenAsStr( ) { - - if( null == this.signLen) return null; - return Arrays.toString(this.signLen); - } - - - public String getSignLenAsHex( ) { - - if( null == this.signLen) return null; - return Util.bytes2HexString(signLen); - } - - - public Data setSignLen( byte[] bytes ) { - - this.signLen = bytes; - return this; - } - - - public byte[] getSignAsBin( ) { - - return this.sign; - } - - - public String getSignAsStr( ) { - - if( null == this.sign) return null; - return Arrays.toString(this.sign); - } - - - public String getSignAsHex( ) { - - if( null == this.sign) return null; - return Util.bytes2HexString(sign); - } - - - public Data setSign( byte[] bytes ) { - - this.sign = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != signLen ){ - soup.put("signLen", this.signLen); - } - - if( null != sign ){ - soup.put("sign", this.sign); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("signLen") ){ - this.signLen = ((PacketSection) soup.get("signLen")).getBytes(); - } - - if( soup.containsKey("sign") ){ - this.sign = ((PacketSection) soup.get("sign")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3644")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3644"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO6D.java b/src/main/java/racal/sunyard/main/dto/DTO6D.java deleted file mode 100644 index 6cdd379..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO6D.java +++ /dev/null @@ -1,1025 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO6D { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] certificateModel = null; - private byte[] certificateLen = null; - private byte[] certificateSn = null; - private byte[] certificateDn = null; - private byte[] organizationNum = null; - private byte[] dataLen = null; - private byte[] inData = null; - private byte[] signLen = null; - private byte[] sign = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getCertificateModelAsBin( ) { - - return this.certificateModel; - } - - - public String getCertificateModelAsStr( ) { - - if( null == this.certificateModel) return null; - return Arrays.toString(this.certificateModel); - } - - - public String getCertificateModelAsHex( ) { - - if( null == this.certificateModel) return null; - return Util.bytes2HexString(certificateModel); - } - - - public Data setCertificateModel( byte[] bytes ) { - - this.certificateModel = bytes; - return this; - } -public enum CertificateModelOptions { - - OPV证书序号(Util.hexString2Bytes("30")), - OPV证书DN(Util.hexString2Bytes("31")), - OPV机构号(Util.hexString2Bytes("32")); - private byte[] bin; - CertificateModelOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getCertificateModelCn( ) { - - if( null == certificateModel) { return null; } - if( "30".equals(Util.bytes2HexString(this.certificateModel))) { - return "证书序号"; - } - if( "31".equals(Util.bytes2HexString(this.certificateModel))) { - return "证书 DN"; - } - if( "32".equals(Util.bytes2HexString(this.certificateModel))) { - return "机构号"; - } - return null; - } - - - public Integer getCertificateModelOptionIndex( ) { - - if( null == certificateModel) { return null; } - if( "30".equals(Util.bytes2HexString(this.certificateModel))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.certificateModel))) { - return 1; - } - if( "32".equals(Util.bytes2HexString(this.certificateModel))) { - return 2; - } - return null; - } - - - public byte[] getCertificateLenAsBin( ) { - - return this.certificateLen; - } - - - public String getCertificateLenAsStr( ) { - - if( null == this.certificateLen) return null; - return Arrays.toString(this.certificateLen); - } - - - public String getCertificateLenAsHex( ) { - - if( null == this.certificateLen) return null; - return Util.bytes2HexString(certificateLen); - } - - - public Data setCertificateLen( byte[] bytes ) { - - this.certificateLen = bytes; - return this; - } - - - public byte[] getCertificateSnAsBin( ) { - - return this.certificateSn; - } - - - public String getCertificateSnAsStr( ) { - - if( null == this.certificateSn) return null; - return Arrays.toString(this.certificateSn); - } - - - public String getCertificateSnAsHex( ) { - - if( null == this.certificateSn) return null; - return Util.bytes2HexString(certificateSn); - } - - - public Data setCertificateSn( byte[] bytes ) { - - this.certificateSn = bytes; - return this; - } - - - public byte[] getCertificateDnAsBin( ) { - - return this.certificateDn; - } - - - public String getCertificateDnAsStr( ) { - - if( null == this.certificateDn) return null; - return Arrays.toString(this.certificateDn); - } - - - public String getCertificateDnAsHex( ) { - - if( null == this.certificateDn) return null; - return Util.bytes2HexString(certificateDn); - } - - - public Data setCertificateDn( byte[] bytes ) { - - this.certificateDn = bytes; - return this; - } - - - public byte[] getOrganizationNumAsBin( ) { - - return this.organizationNum; - } - - - public String getOrganizationNumAsStr( ) { - - if( null == this.organizationNum) return null; - return Arrays.toString(this.organizationNum); - } - - - public String getOrganizationNumAsHex( ) { - - if( null == this.organizationNum) return null; - return Util.bytes2HexString(organizationNum); - } - - - public Data setOrganizationNum( byte[] bytes ) { - - this.organizationNum = bytes; - return this; - } - - - public byte[] getDataLenAsBin( ) { - - return this.dataLen; - } - - - public String getDataLenAsStr( ) { - - if( null == this.dataLen) return null; - return Arrays.toString(this.dataLen); - } - - - public String getDataLenAsHex( ) { - - if( null == this.dataLen) return null; - return Util.bytes2HexString(dataLen); - } - - - public Data setDataLen( byte[] bytes ) { - - this.dataLen = bytes; - return this; - } - - - public byte[] getInDataAsBin( ) { - - return this.inData; - } - - - public String getInDataAsStr( ) { - - if( null == this.inData) return null; - return Arrays.toString(this.inData); - } - - - public String getInDataAsHex( ) { - - if( null == this.inData) return null; - return Util.bytes2HexString(inData); - } - - - public Data setInData( byte[] bytes ) { - - this.inData = bytes; - return this; - } - - - public byte[] getSignLenAsBin( ) { - - return this.signLen; - } - - - public String getSignLenAsStr( ) { - - if( null == this.signLen) return null; - return Arrays.toString(this.signLen); - } - - - public String getSignLenAsHex( ) { - - if( null == this.signLen) return null; - return Util.bytes2HexString(signLen); - } - - - public Data setSignLen( byte[] bytes ) { - - this.signLen = bytes; - return this; - } - - - public byte[] getSignAsBin( ) { - - return this.sign; - } - - - public String getSignAsStr( ) { - - if( null == this.sign) return null; - return Arrays.toString(this.sign); - } - - - public String getSignAsHex( ) { - - if( null == this.sign) return null; - return Util.bytes2HexString(sign); - } - - - public Data setSign( byte[] bytes ) { - - this.sign = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != certificateModel ){ - soup.put("certificateModel", this.certificateModel); - soup.put("certificateModel$option", getCertificateModelOptionIndex()); - } - - if( null != certificateLen ){ - soup.put("certificateLen", this.certificateLen); - } - - if( null != certificateSn ){ - soup.put("certificateSn", this.certificateSn); - } - - if( null != certificateDn ){ - soup.put("certificateDn", this.certificateDn); - } - - if( null != organizationNum ){ - soup.put("organizationNum", this.organizationNum); - } - - if( null != dataLen ){ - soup.put("dataLen", this.dataLen); - } - - if( null != inData ){ - soup.put("inData", this.inData); - } - - if( null != signLen ){ - soup.put("signLen", this.signLen); - } - - if( null != sign ){ - soup.put("sign", this.sign); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("certificateModel") ){ - this.certificateModel = ((PacketSection) soup.get("certificateModel")).getBytes(); - } - - if( soup.containsKey("certificateLen") ){ - this.certificateLen = ((PacketSection) soup.get("certificateLen")).getBytes(); - } - - if( soup.containsKey("certificateSn") ){ - this.certificateSn = ((PacketSection) soup.get("certificateSn")).getBytes(); - } - - if( soup.containsKey("certificateDn") ){ - this.certificateDn = ((PacketSection) soup.get("certificateDn")).getBytes(); - } - - if( soup.containsKey("organizationNum") ){ - this.organizationNum = ((PacketSection) soup.get("organizationNum")).getBytes(); - } - - if( soup.containsKey("dataLen") ){ - this.dataLen = ((PacketSection) soup.get("dataLen")).getBytes(); - } - - if( soup.containsKey("inData") ){ - this.inData = ((PacketSection) soup.get("inData")).getBytes(); - } - - if( soup.containsKey("signLen") ){ - this.signLen = ((PacketSection) soup.get("signLen")).getBytes(); - } - - if( soup.containsKey("sign") ){ - this.sign = ((PacketSection) soup.get("sign")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3644")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3644"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV公钥不符合编码规则(Util.hexString2Bytes("3034")), - OPV无效的加密标识(Util.hexString2Bytes("3036")), - OPV无效的附加模式标识(Util.hexString2Bytes("3037")), - OPV密钥奇偶校验错误(Util.hexString2Bytes("3130")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVDSP错误(Util.hexString2Bytes("3437")), - OPV密钥块长度错误(Util.hexString2Bytes("3736")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return "公钥不符合编码规则"; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return "无效的加密标识"; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return "无效的附加模式标识"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "密钥奇偶校验错误"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return "DSP 错误"; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return "密钥块长度错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 9; - } - return null; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3645")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3645"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO6E.java b/src/main/java/racal/sunyard/main/dto/DTO6E.java deleted file mode 100644 index 8ad0160..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO6E.java +++ /dev/null @@ -1,825 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO6E { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] certificateModel = null; - private byte[] dnLen = null; - private byte[] certificateDn = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getCertificateModelAsBin( ) { - - return this.certificateModel; - } - - - public String getCertificateModelAsStr( ) { - - if( null == this.certificateModel) return null; - return Arrays.toString(this.certificateModel); - } - - - public String getCertificateModelAsHex( ) { - - if( null == this.certificateModel) return null; - return Util.bytes2HexString(certificateModel); - } - - - public Data setCertificateModel( byte[] bytes ) { - - this.certificateModel = bytes; - return this; - } -public enum CertificateModelOptions { - - OPV签名证书(Util.hexString2Bytes("30")), - OPV加密证书(Util.hexString2Bytes("31")); - private byte[] bin; - CertificateModelOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getCertificateModelCn( ) { - - if( null == certificateModel) { return null; } - if( "30".equals(Util.bytes2HexString(this.certificateModel))) { - return "签名证书"; - } - if( "31".equals(Util.bytes2HexString(this.certificateModel))) { - return "加密证书"; - } - return null; - } - - - public Integer getCertificateModelOptionIndex( ) { - - if( null == certificateModel) { return null; } - if( "30".equals(Util.bytes2HexString(this.certificateModel))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.certificateModel))) { - return 1; - } - return null; - } - - - public byte[] getDnLenAsBin( ) { - - return this.dnLen; - } - - - public String getDnLenAsStr( ) { - - if( null == this.dnLen) return null; - return Arrays.toString(this.dnLen); - } - - - public String getDnLenAsHex( ) { - - if( null == this.dnLen) return null; - return Util.bytes2HexString(dnLen); - } - - - public Data setDnLen( byte[] bytes ) { - - this.dnLen = bytes; - return this; - } - - - public byte[] getCertificateDnAsBin( ) { - - return this.certificateDn; - } - - - public String getCertificateDnAsStr( ) { - - if( null == this.certificateDn) return null; - return Arrays.toString(this.certificateDn); - } - - - public String getCertificateDnAsHex( ) { - - if( null == this.certificateDn) return null; - return Util.bytes2HexString(certificateDn); - } - - - public Data setCertificateDn( byte[] bytes ) { - - this.certificateDn = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != certificateModel ){ - soup.put("certificateModel", this.certificateModel); - soup.put("certificateModel$option", getCertificateModelOptionIndex()); - } - - if( null != dnLen ){ - soup.put("dnLen", this.dnLen); - } - - if( null != certificateDn ){ - soup.put("certificateDn", this.certificateDn); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("certificateModel") ){ - this.certificateModel = ((PacketSection) soup.get("certificateModel")).getBytes(); - } - - if( soup.containsKey("dnLen") ){ - this.dnLen = ((PacketSection) soup.get("dnLen")).getBytes(); - } - - if( soup.containsKey("certificateDn") ){ - this.certificateDn = ((PacketSection) soup.get("certificateDn")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3645")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3645"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] snLen = null; - private byte[] sn = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV无效的DN(Util.hexString2Bytes("3231")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效的DN"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 2; - } - return null; - } - - - public byte[] getSnLenAsBin( ) { - - return this.snLen; - } - - - public String getSnLenAsStr( ) { - - if( null == this.snLen) return null; - return Arrays.toString(this.snLen); - } - - - public String getSnLenAsHex( ) { - - if( null == this.snLen) return null; - return Util.bytes2HexString(snLen); - } - - - public Data setSnLen( byte[] bytes ) { - - this.snLen = bytes; - return this; - } - - - public byte[] getSnAsBin( ) { - - return this.sn; - } - - - public String getSnAsStr( ) { - - if( null == this.sn) return null; - return Arrays.toString(this.sn); - } - - - public String getSnAsHex( ) { - - if( null == this.sn) return null; - return Util.bytes2HexString(sn); - } - - - public Data setSn( byte[] bytes ) { - - this.sn = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != snLen ){ - soup.put("snLen", this.snLen); - } - - if( null != sn ){ - soup.put("sn", this.sn); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("snLen") ){ - this.snLen = ((PacketSection) soup.get("snLen")).getBytes(); - } - - if( soup.containsKey("sn") ){ - this.sn = ((PacketSection) soup.get("sn")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3646")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3646"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO71.java b/src/main/java/racal/sunyard/main/dto/DTO71.java deleted file mode 100644 index 23d45e1..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO71.java +++ /dev/null @@ -1,762 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO71 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] publicKeyLength = null; - private byte[] publicKey = null; - private byte[] key = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getPublicKeyLengthAsBin( ) { - - return this.publicKeyLength; - } - - - public String getPublicKeyLengthAsStr( ) { - - if( null == this.publicKeyLength) return null; - return Arrays.toString(this.publicKeyLength); - } - - - public String getPublicKeyLengthAsHex( ) { - - if( null == this.publicKeyLength) return null; - return Util.bytes2HexString(publicKeyLength); - } - - - public Data setPublicKeyLength( byte[] bytes ) { - - this.publicKeyLength = bytes; - return this; - } - - - public byte[] getPublicKeyAsBin( ) { - - return this.publicKey; - } - - - public String getPublicKeyAsStr( ) { - - if( null == this.publicKey) return null; - return Arrays.toString(this.publicKey); - } - - - public String getPublicKeyAsHex( ) { - - if( null == this.publicKey) return null; - return Util.bytes2HexString(publicKey); - } - - - public Data setPublicKey( byte[] bytes ) { - - this.publicKey = bytes; - return this; - } - - - public byte[] getKeyAsBin( ) { - - return this.key; - } - - - public String getKeyAsStr( ) { - - if( null == this.key) return null; - return Arrays.toString(this.key); - } - - - public String getKeyAsHex( ) { - - if( null == this.key) return null; - return Util.bytes2HexString(key); - } - - - public Data setKey( byte[] bytes ) { - - this.key = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != publicKeyLength ){ - soup.put("publicKeyLength", this.publicKeyLength); - } - - if( null != publicKey ){ - soup.put("publicKey", this.publicKey); - } - - if( null != key ){ - soup.put("key", this.key); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("publicKeyLength") ){ - this.publicKeyLength = ((PacketSection) soup.get("publicKeyLength")).getBytes(); - } - - if( soup.containsKey("publicKey") ){ - this.publicKey = ((PacketSection) soup.get("publicKey")).getBytes(); - } - - if( soup.containsKey("key") ){ - this.key = ((PacketSection) soup.get("key")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3731")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3731"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] keyLength = null; - private byte[] key = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV公钥不符合编码规则(Util.hexString2Bytes("3034")), - OPV无效的签名标识(Util.hexString2Bytes("3036")), - OPV无效的附加标识(Util.hexString2Bytes("3037")), - OPV密钥奇偶校验错误(Util.hexString2Bytes("3130")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVDSP错误(Util.hexString2Bytes("3437")), - OPV密钥块长度错误(Util.hexString2Bytes("3736")), - OPV信息长度错(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return "公钥不符合编码规则"; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return "无效的签名标识"; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return "无效的附加标识"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "密钥奇偶校验错误"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return "DSP 错误"; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return "密钥块长度错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "信息长度错"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 9; - } - return null; - } - - - public byte[] getKeyLengthAsBin( ) { - - return this.keyLength; - } - - - public String getKeyLengthAsStr( ) { - - if( null == this.keyLength) return null; - return Arrays.toString(this.keyLength); - } - - - public String getKeyLengthAsHex( ) { - - if( null == this.keyLength) return null; - return Util.bytes2HexString(keyLength); - } - - - public Data setKeyLength( byte[] bytes ) { - - this.keyLength = bytes; - return this; - } - - - public byte[] getKeyAsBin( ) { - - return this.key; - } - - - public String getKeyAsStr( ) { - - if( null == this.key) return null; - return Arrays.toString(this.key); - } - - - public String getKeyAsHex( ) { - - if( null == this.key) return null; - return Util.bytes2HexString(key); - } - - - public Data setKey( byte[] bytes ) { - - this.key = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != keyLength ){ - soup.put("keyLength", this.keyLength); - } - - if( null != key ){ - soup.put("key", this.key); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("keyLength") ){ - this.keyLength = ((PacketSection) soup.get("keyLength")).getBytes(); - } - - if( soup.containsKey("key") ){ - this.key = ((PacketSection) soup.get("key")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3732")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3732"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO72.java b/src/main/java/racal/sunyard/main/dto/DTO72.java deleted file mode 100644 index 2acd4d2..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO72.java +++ /dev/null @@ -1,944 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO72 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] publicKeyLength = null; - private byte[] publicKey = null; - private byte[] lmk = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getPublicKeyLengthAsBin( ) { - - return this.publicKeyLength; - } - - - public String getPublicKeyLengthAsStr( ) { - - if( null == this.publicKeyLength) return null; - return Arrays.toString(this.publicKeyLength); - } - - - public String getPublicKeyLengthAsHex( ) { - - if( null == this.publicKeyLength) return null; - return Util.bytes2HexString(publicKeyLength); - } - - - public Data setPublicKeyLength( byte[] bytes ) { - - this.publicKeyLength = bytes; - return this; - } - - - public byte[] getPublicKeyAsBin( ) { - - return this.publicKey; - } - - - public String getPublicKeyAsStr( ) { - - if( null == this.publicKey) return null; - return Arrays.toString(this.publicKey); - } - - - public String getPublicKeyAsHex( ) { - - if( null == this.publicKey) return null; - return Util.bytes2HexString(publicKey); - } - - - public Data setPublicKey( byte[] bytes ) { - - this.publicKey = bytes; - return this; - } - - - public byte[] getLmkAsBin( ) { - - return this.lmk; - } - - - public String getLmkAsStr( ) { - - if( null == this.lmk) return null; - return Arrays.toString(this.lmk); - } - - - public String getLmkAsHex( ) { - - if( null == this.lmk) return null; - return Util.bytes2HexString(lmk); - } - - - public Data setLmk( byte[] bytes ) { - - this.lmk = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != publicKeyLength ){ - soup.put("publicKeyLength", this.publicKeyLength); - } - - if( null != publicKey ){ - soup.put("publicKey", this.publicKey); - } - - if( null != lmk ){ - soup.put("lmk", this.lmk); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("publicKeyLength") ){ - this.publicKeyLength = ((PacketSection) soup.get("publicKeyLength")).getBytes(); - } - - if( soup.containsKey("publicKey") ){ - this.publicKey = ((PacketSection) soup.get("publicKey")).getBytes(); - } - - if( soup.containsKey("lmk") ){ - this.lmk = ((PacketSection) soup.get("lmk")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3732")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3732"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] keyLen = null; - private byte[] key = null; - private byte[] lmkHead = null; - private byte[] lmk = null; - private byte[] keyCheck = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV公钥不符合编码规则(Util.hexString2Bytes("3034")), - OPV无效的加密标识(Util.hexString2Bytes("3036")), - OPV无效的附加模式标识(Util.hexString2Bytes("3037")), - OPV密钥奇偶校验错误(Util.hexString2Bytes("3130")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVDSP错误(Util.hexString2Bytes("3437")), - OPV密钥块长度错误(Util.hexString2Bytes("3736")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return "公钥不符合编码规则"; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return "无效的加密标识"; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return "无效的附加模式标识"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "密钥奇偶校验错误"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return "DSP 错误"; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return "密钥块长度错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 9; - } - return null; - } - - - public byte[] getKeyLenAsBin( ) { - - return this.keyLen; - } - - - public String getKeyLenAsStr( ) { - - if( null == this.keyLen) return null; - return Arrays.toString(this.keyLen); - } - - - public String getKeyLenAsHex( ) { - - if( null == this.keyLen) return null; - return Util.bytes2HexString(keyLen); - } - - - public Data setKeyLen( byte[] bytes ) { - - this.keyLen = bytes; - return this; - } - - - public byte[] getKeyAsBin( ) { - - return this.key; - } - - - public String getKeyAsStr( ) { - - if( null == this.key) return null; - return Arrays.toString(this.key); - } - - - public String getKeyAsHex( ) { - - if( null == this.key) return null; - return Util.bytes2HexString(key); - } - - - public Data setKey( byte[] bytes ) { - - this.key = bytes; - return this; - } - - - public byte[] getLmkHeadAsBin( ) { - - return this.lmkHead; - } - - - public String getLmkHeadAsStr( ) { - - if( null == this.lmkHead) return null; - return Arrays.toString(this.lmkHead); - } - - - public String getLmkHeadAsHex( ) { - - if( null == this.lmkHead) return null; - return Util.bytes2HexString(lmkHead); - } - - - public Data setLmkHead( byte[] bytes ) { - - this.lmkHead = bytes; - return this; - } - - - public byte[] getLmkAsBin( ) { - - return this.lmk; - } - - - public String getLmkAsStr( ) { - - if( null == this.lmk) return null; - return Arrays.toString(this.lmk); - } - - - public String getLmkAsHex( ) { - - if( null == this.lmk) return null; - return Util.bytes2HexString(lmk); - } - - - public Data setLmk( byte[] bytes ) { - - this.lmk = bytes; - return this; - } - - - public byte[] getKeyCheckAsBin( ) { - - return this.keyCheck; - } - - - public String getKeyCheckAsStr( ) { - - if( null == this.keyCheck) return null; - return Arrays.toString(this.keyCheck); - } - - - public String getKeyCheckAsHex( ) { - - if( null == this.keyCheck) return null; - return Util.bytes2HexString(keyCheck); - } - - - public Data setKeyCheck( byte[] bytes ) { - - this.keyCheck = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != keyLen ){ - soup.put("keyLen", this.keyLen); - } - - if( null != key ){ - soup.put("key", this.key); - } - - if( null != lmkHead ){ - soup.put("lmkHead", this.lmkHead); - } - - if( null != lmk ){ - soup.put("lmk", this.lmk); - } - - if( null != keyCheck ){ - soup.put("keyCheck", this.keyCheck); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("keyLen") ){ - this.keyLen = ((PacketSection) soup.get("keyLen")).getBytes(); - } - - if( soup.containsKey("key") ){ - this.key = ((PacketSection) soup.get("key")).getBytes(); - } - - if( soup.containsKey("lmkHead") ){ - this.lmkHead = ((PacketSection) soup.get("lmkHead")).getBytes(); - } - - if( soup.containsKey("lmk") ){ - this.lmk = ((PacketSection) soup.get("lmk")).getBytes(); - } - - if( soup.containsKey("keyCheck") ){ - this.keyCheck = ((PacketSection) soup.get("keyCheck")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3733")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3733"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO73.java b/src/main/java/racal/sunyard/main/dto/DTO73.java deleted file mode 100644 index b07eded..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO73.java +++ /dev/null @@ -1,980 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO73 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] privateKeyTag = null; - private byte[] privateKeyLength = null; - private byte[] privateKey = null; - private byte[] cipherKeyLength = null; - private byte[] cipherKey = null; - private byte[] lmk = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getPrivateKeyTagAsBin( ) { - - return this.privateKeyTag; - } - - - public String getPrivateKeyTagAsStr( ) { - - if( null == this.privateKeyTag) return null; - return Arrays.toString(this.privateKeyTag); - } - - - public String getPrivateKeyTagAsHex( ) { - - if( null == this.privateKeyTag) return null; - return Util.bytes2HexString(privateKeyTag); - } - - - public Data setPrivateKeyTag( byte[] bytes ) { - - this.privateKeyTag = bytes; - return this; - } - - - public byte[] getPrivateKeyLengthAsBin( ) { - - return this.privateKeyLength; - } - - - public String getPrivateKeyLengthAsStr( ) { - - if( null == this.privateKeyLength) return null; - return Arrays.toString(this.privateKeyLength); - } - - - public String getPrivateKeyLengthAsHex( ) { - - if( null == this.privateKeyLength) return null; - return Util.bytes2HexString(privateKeyLength); - } - - - public Data setPrivateKeyLength( byte[] bytes ) { - - this.privateKeyLength = bytes; - return this; - } - - - public byte[] getPrivateKeyAsBin( ) { - - return this.privateKey; - } - - - public String getPrivateKeyAsStr( ) { - - if( null == this.privateKey) return null; - return Arrays.toString(this.privateKey); - } - - - public String getPrivateKeyAsHex( ) { - - if( null == this.privateKey) return null; - return Util.bytes2HexString(privateKey); - } - - - public Data setPrivateKey( byte[] bytes ) { - - this.privateKey = bytes; - return this; - } - - - public byte[] getCipherKeyLengthAsBin( ) { - - return this.cipherKeyLength; - } - - - public String getCipherKeyLengthAsStr( ) { - - if( null == this.cipherKeyLength) return null; - return Arrays.toString(this.cipherKeyLength); - } - - - public String getCipherKeyLengthAsHex( ) { - - if( null == this.cipherKeyLength) return null; - return Util.bytes2HexString(cipherKeyLength); - } - - - public Data setCipherKeyLength( byte[] bytes ) { - - this.cipherKeyLength = bytes; - return this; - } - - - public byte[] getCipherKeyAsBin( ) { - - return this.cipherKey; - } - - - public String getCipherKeyAsStr( ) { - - if( null == this.cipherKey) return null; - return Arrays.toString(this.cipherKey); - } - - - public String getCipherKeyAsHex( ) { - - if( null == this.cipherKey) return null; - return Util.bytes2HexString(cipherKey); - } - - - public Data setCipherKey( byte[] bytes ) { - - this.cipherKey = bytes; - return this; - } - - - public byte[] getLmkAsBin( ) { - - return this.lmk; - } - - - public String getLmkAsStr( ) { - - if( null == this.lmk) return null; - return Arrays.toString(this.lmk); - } - - - public String getLmkAsHex( ) { - - if( null == this.lmk) return null; - return Util.bytes2HexString(lmk); - } - - - public Data setLmk( byte[] bytes ) { - - this.lmk = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != privateKeyTag ){ - soup.put("privateKeyTag", this.privateKeyTag); - } - - if( null != privateKeyLength ){ - soup.put("privateKeyLength", this.privateKeyLength); - } - - if( null != privateKey ){ - soup.put("privateKey", this.privateKey); - } - - if( null != cipherKeyLength ){ - soup.put("cipherKeyLength", this.cipherKeyLength); - } - - if( null != cipherKey ){ - soup.put("cipherKey", this.cipherKey); - } - - if( null != lmk ){ - soup.put("lmk", this.lmk); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("privateKeyTag") ){ - this.privateKeyTag = ((PacketSection) soup.get("privateKeyTag")).getBytes(); - } - - if( soup.containsKey("privateKeyLength") ){ - this.privateKeyLength = ((PacketSection) soup.get("privateKeyLength")).getBytes(); - } - - if( soup.containsKey("privateKey") ){ - this.privateKey = ((PacketSection) soup.get("privateKey")).getBytes(); - } - - if( soup.containsKey("cipherKeyLength") ){ - this.cipherKeyLength = ((PacketSection) soup.get("cipherKeyLength")).getBytes(); - } - - if( soup.containsKey("cipherKey") ){ - this.cipherKey = ((PacketSection) soup.get("cipherKey")).getBytes(); - } - - if( soup.containsKey("lmk") ){ - this.lmk = ((PacketSection) soup.get("lmk")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3733")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3733"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] lmkHead = null; - private byte[] lmk = null; - private byte[] keyCheck = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV公钥不符合编码规则(Util.hexString2Bytes("3034")), - OPV无效的加密标识(Util.hexString2Bytes("3036")), - OPV无效的附加模式标识(Util.hexString2Bytes("3037")), - OPV密钥奇偶校验错误(Util.hexString2Bytes("3130")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVDSP错误(Util.hexString2Bytes("3437")), - OPV密钥块长度错误(Util.hexString2Bytes("3736")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return "公钥不符合编码规则"; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return "无效的加密标识"; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return "无效的附加模式标识"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "密钥奇偶校验错误"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return "DSP 错误"; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return "密钥块长度错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 9; - } - return null; - } - - - public byte[] getLmkHeadAsBin( ) { - - return this.lmkHead; - } - - - public String getLmkHeadAsStr( ) { - - if( null == this.lmkHead) return null; - return Arrays.toString(this.lmkHead); - } - - - public String getLmkHeadAsHex( ) { - - if( null == this.lmkHead) return null; - return Util.bytes2HexString(lmkHead); - } - - - public Data setLmkHead( byte[] bytes ) { - - this.lmkHead = bytes; - return this; - } - - - public byte[] getLmkAsBin( ) { - - return this.lmk; - } - - - public String getLmkAsStr( ) { - - if( null == this.lmk) return null; - return Arrays.toString(this.lmk); - } - - - public String getLmkAsHex( ) { - - if( null == this.lmk) return null; - return Util.bytes2HexString(lmk); - } - - - public Data setLmk( byte[] bytes ) { - - this.lmk = bytes; - return this; - } - - - public byte[] getKeyCheckAsBin( ) { - - return this.keyCheck; - } - - - public String getKeyCheckAsStr( ) { - - if( null == this.keyCheck) return null; - return Arrays.toString(this.keyCheck); - } - - - public String getKeyCheckAsHex( ) { - - if( null == this.keyCheck) return null; - return Util.bytes2HexString(keyCheck); - } - - - public Data setKeyCheck( byte[] bytes ) { - - this.keyCheck = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != lmkHead ){ - soup.put("lmkHead", this.lmkHead); - } - - if( null != lmk ){ - soup.put("lmk", this.lmk); - } - - if( null != keyCheck ){ - soup.put("keyCheck", this.keyCheck); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("lmkHead") ){ - this.lmkHead = ((PacketSection) soup.get("lmkHead")).getBytes(); - } - - if( soup.containsKey("lmk") ){ - this.lmk = ((PacketSection) soup.get("lmk")).getBytes(); - } - - if( soup.containsKey("keyCheck") ){ - this.keyCheck = ((PacketSection) soup.get("keyCheck")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3734")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3734"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO74.java b/src/main/java/racal/sunyard/main/dto/DTO74.java deleted file mode 100644 index b684a77..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO74.java +++ /dev/null @@ -1,1190 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO74 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] signatureDataType = null; - private byte[] hashData = null; - private byte[] userIdLength = null; - private byte[] userId = null; - private byte[] publicKeyLength = null; - private byte[] publicKey = null; - private byte[] dataLength = null; - private byte[] infoData = null; - private byte[] privateKeyTag = null; - private byte[] privateKeyLength = null; - private byte[] privateKey = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getSignatureDataTypeAsBin( ) { - - return this.signatureDataType; - } - - - public String getSignatureDataTypeAsStr( ) { - - if( null == this.signatureDataType) return null; - return Arrays.toString(this.signatureDataType); - } - - - public String getSignatureDataTypeAsHex( ) { - - if( null == this.signatureDataType) return null; - return Util.bytes2HexString(signatureDataType); - } - - - public Data setSignatureDataType( byte[] bytes ) { - - this.signatureDataType = bytes; - return this; - } -public enum SignatureDataTypeOptions { - - OPVHASH(Util.hexString2Bytes("30")), - OPV原数据(Util.hexString2Bytes("31")); - private byte[] bin; - SignatureDataTypeOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getSignatureDataTypeCn( ) { - - if( null == signatureDataType) { return null; } - if( "30".equals(Util.bytes2HexString(this.signatureDataType))) { - return "HASH"; - } - if( "31".equals(Util.bytes2HexString(this.signatureDataType))) { - return "原数据"; - } - return null; - } - - - public Integer getSignatureDataTypeOptionIndex( ) { - - if( null == signatureDataType) { return null; } - if( "30".equals(Util.bytes2HexString(this.signatureDataType))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.signatureDataType))) { - return 1; - } - return null; - } - - - public byte[] getHashDataAsBin( ) { - - return this.hashData; - } - - - public String getHashDataAsStr( ) { - - if( null == this.hashData) return null; - return Arrays.toString(this.hashData); - } - - - public String getHashDataAsHex( ) { - - if( null == this.hashData) return null; - return Util.bytes2HexString(hashData); - } - - - public Data setHashData( byte[] bytes ) { - - this.hashData = bytes; - return this; - } - - - public byte[] getUserIdLengthAsBin( ) { - - return this.userIdLength; - } - - - public String getUserIdLengthAsStr( ) { - - if( null == this.userIdLength) return null; - return Arrays.toString(this.userIdLength); - } - - - public String getUserIdLengthAsHex( ) { - - if( null == this.userIdLength) return null; - return Util.bytes2HexString(userIdLength); - } - - - public Data setUserIdLength( byte[] bytes ) { - - this.userIdLength = bytes; - return this; - } - - - public byte[] getUserIdAsBin( ) { - - return this.userId; - } - - - public String getUserIdAsStr( ) { - - if( null == this.userId) return null; - return Arrays.toString(this.userId); - } - - - public String getUserIdAsHex( ) { - - if( null == this.userId) return null; - return Util.bytes2HexString(userId); - } - - - public Data setUserId( byte[] bytes ) { - - this.userId = bytes; - return this; - } - - - public byte[] getPublicKeyLengthAsBin( ) { - - return this.publicKeyLength; - } - - - public String getPublicKeyLengthAsStr( ) { - - if( null == this.publicKeyLength) return null; - return Arrays.toString(this.publicKeyLength); - } - - - public String getPublicKeyLengthAsHex( ) { - - if( null == this.publicKeyLength) return null; - return Util.bytes2HexString(publicKeyLength); - } - - - public Data setPublicKeyLength( byte[] bytes ) { - - this.publicKeyLength = bytes; - return this; - } - - - public byte[] getPublicKeyAsBin( ) { - - return this.publicKey; - } - - - public String getPublicKeyAsStr( ) { - - if( null == this.publicKey) return null; - return Arrays.toString(this.publicKey); - } - - - public String getPublicKeyAsHex( ) { - - if( null == this.publicKey) return null; - return Util.bytes2HexString(publicKey); - } - - - public Data setPublicKey( byte[] bytes ) { - - this.publicKey = bytes; - return this; - } - - - public byte[] getDataLengthAsBin( ) { - - return this.dataLength; - } - - - public String getDataLengthAsStr( ) { - - if( null == this.dataLength) return null; - return Arrays.toString(this.dataLength); - } - - - public String getDataLengthAsHex( ) { - - if( null == this.dataLength) return null; - return Util.bytes2HexString(dataLength); - } - - - public Data setDataLength( byte[] bytes ) { - - this.dataLength = bytes; - return this; - } - - - public byte[] getInfoDataAsBin( ) { - - return this.infoData; - } - - - public String getInfoDataAsStr( ) { - - if( null == this.infoData) return null; - return Arrays.toString(this.infoData); - } - - - public String getInfoDataAsHex( ) { - - if( null == this.infoData) return null; - return Util.bytes2HexString(infoData); - } - - - public Data setInfoData( byte[] bytes ) { - - this.infoData = bytes; - return this; - } - - - public byte[] getPrivateKeyTagAsBin( ) { - - return this.privateKeyTag; - } - - - public String getPrivateKeyTagAsStr( ) { - - if( null == this.privateKeyTag) return null; - return Arrays.toString(this.privateKeyTag); - } - - - public String getPrivateKeyTagAsHex( ) { - - if( null == this.privateKeyTag) return null; - return Util.bytes2HexString(privateKeyTag); - } - - - public Data setPrivateKeyTag( byte[] bytes ) { - - this.privateKeyTag = bytes; - return this; - } - - - public byte[] getPrivateKeyLengthAsBin( ) { - - return this.privateKeyLength; - } - - - public String getPrivateKeyLengthAsStr( ) { - - if( null == this.privateKeyLength) return null; - return Arrays.toString(this.privateKeyLength); - } - - - public String getPrivateKeyLengthAsHex( ) { - - if( null == this.privateKeyLength) return null; - return Util.bytes2HexString(privateKeyLength); - } - - - public Data setPrivateKeyLength( byte[] bytes ) { - - this.privateKeyLength = bytes; - return this; - } - - - public byte[] getPrivateKeyAsBin( ) { - - return this.privateKey; - } - - - public String getPrivateKeyAsStr( ) { - - if( null == this.privateKey) return null; - return Arrays.toString(this.privateKey); - } - - - public String getPrivateKeyAsHex( ) { - - if( null == this.privateKey) return null; - return Util.bytes2HexString(privateKey); - } - - - public Data setPrivateKey( byte[] bytes ) { - - this.privateKey = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != signatureDataType ){ - soup.put("signatureDataType", this.signatureDataType); - soup.put("signatureDataType$option", getSignatureDataTypeOptionIndex()); - } - - if( null != hashData ){ - soup.put("hashData", this.hashData); - } - - if( null != userIdLength ){ - soup.put("userIdLength", this.userIdLength); - } - - if( null != userId ){ - soup.put("userId", this.userId); - } - - if( null != publicKeyLength ){ - soup.put("publicKeyLength", this.publicKeyLength); - } - - if( null != publicKey ){ - soup.put("publicKey", this.publicKey); - } - - if( null != dataLength ){ - soup.put("dataLength", this.dataLength); - } - - if( null != infoData ){ - soup.put("infoData", this.infoData); - } - - if( null != privateKeyTag ){ - soup.put("privateKeyTag", this.privateKeyTag); - } - - if( null != privateKeyLength ){ - soup.put("privateKeyLength", this.privateKeyLength); - } - - if( null != privateKey ){ - soup.put("privateKey", this.privateKey); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("signatureDataType") ){ - this.signatureDataType = ((PacketSection) soup.get("signatureDataType")).getBytes(); - } - - if( soup.containsKey("hashData") ){ - this.hashData = ((PacketSection) soup.get("hashData")).getBytes(); - } - - if( soup.containsKey("userIdLength") ){ - this.userIdLength = ((PacketSection) soup.get("userIdLength")).getBytes(); - } - - if( soup.containsKey("userId") ){ - this.userId = ((PacketSection) soup.get("userId")).getBytes(); - } - - if( soup.containsKey("publicKeyLength") ){ - this.publicKeyLength = ((PacketSection) soup.get("publicKeyLength")).getBytes(); - } - - if( soup.containsKey("publicKey") ){ - this.publicKey = ((PacketSection) soup.get("publicKey")).getBytes(); - } - - if( soup.containsKey("dataLength") ){ - this.dataLength = ((PacketSection) soup.get("dataLength")).getBytes(); - } - - if( soup.containsKey("infoData") ){ - this.infoData = ((PacketSection) soup.get("infoData")).getBytes(); - } - - if( soup.containsKey("privateKeyTag") ){ - this.privateKeyTag = ((PacketSection) soup.get("privateKeyTag")).getBytes(); - } - - if( soup.containsKey("privateKeyLength") ){ - this.privateKeyLength = ((PacketSection) soup.get("privateKeyLength")).getBytes(); - } - - if( soup.containsKey("privateKey") ){ - this.privateKey = ((PacketSection) soup.get("privateKey")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3734")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3734"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] signatureLen = null; - private byte[] signature = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV无效的私钥类型(Util.hexString2Bytes("3033")), - OPV无效私钥标记(Util.hexString2Bytes("3034")), - OPV无效的哈希标识(Util.hexString2Bytes("3035")), - OPV无效的签名标识(Util.hexString2Bytes("3036")), - OPV无效的附加标识(Util.hexString2Bytes("3037")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVDSP错误(Util.hexString2Bytes("3437")), - OPV私钥错误(Util.hexString2Bytes("3439")), - OPV无效摘要信息语法仅仅无哈希模式(Util.hexString2Bytes("3734")), - OPV公钥长度错误(Util.hexString2Bytes("3736")), - OPV私钥长度错误(Util.hexString2Bytes("3738")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3033".equals(Util.bytes2HexString(this.error))) { - return "无效的私钥类型"; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return "无效私钥标记"; - } - if( "3035".equals(Util.bytes2HexString(this.error))) { - return "无效的哈希标识"; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return "无效的签名标识"; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return "无效的附加标识"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return "DSP 错误"; - } - if( "3439".equals(Util.bytes2HexString(this.error))) { - return "私钥错误"; - } - if( "3734".equals(Util.bytes2HexString(this.error))) { - return "无效摘要信息语法(仅仅无哈希模式)"; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return "公钥长度错误"; - } - if( "3738".equals(Util.bytes2HexString(this.error))) { - return "私钥长度错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3033".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3035".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3439".equals(Util.bytes2HexString(this.error))) { - return 9; - } - if( "3734".equals(Util.bytes2HexString(this.error))) { - return 10; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return 11; - } - if( "3738".equals(Util.bytes2HexString(this.error))) { - return 12; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 13; - } - return null; - } - - - public byte[] getSignatureLenAsBin( ) { - - return this.signatureLen; - } - - - public String getSignatureLenAsStr( ) { - - if( null == this.signatureLen) return null; - return Arrays.toString(this.signatureLen); - } - - - public String getSignatureLenAsHex( ) { - - if( null == this.signatureLen) return null; - return Util.bytes2HexString(signatureLen); - } - - - public Data setSignatureLen( byte[] bytes ) { - - this.signatureLen = bytes; - return this; - } - - - public byte[] getSignatureAsBin( ) { - - return this.signature; - } - - - public String getSignatureAsStr( ) { - - if( null == this.signature) return null; - return Arrays.toString(this.signature); - } - - - public String getSignatureAsHex( ) { - - if( null == this.signature) return null; - return Util.bytes2HexString(signature); - } - - - public Data setSignature( byte[] bytes ) { - - this.signature = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != signatureLen ){ - soup.put("signatureLen", this.signatureLen); - } - - if( null != signature ){ - soup.put("signature", this.signature); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("signatureLen") ){ - this.signatureLen = ((PacketSection) soup.get("signatureLen")).getBytes(); - } - - if( soup.containsKey("signature") ){ - this.signature = ((PacketSection) soup.get("signature")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3735")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3735"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO75.java b/src/main/java/racal/sunyard/main/dto/DTO75.java deleted file mode 100644 index 8496a60..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO75.java +++ /dev/null @@ -1,1089 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO75 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] signatureLen = null; - private byte[] signature = null; - private byte[] signatureDataType = null; - private byte[] hashData = null; - private byte[] userIdLength = null; - private byte[] userId = null; - private byte[] dataLength = null; - private byte[] infoData = null; - private byte[] publicKeyLength = null; - private byte[] publicKey = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getSignatureLenAsBin( ) { - - return this.signatureLen; - } - - - public String getSignatureLenAsStr( ) { - - if( null == this.signatureLen) return null; - return Arrays.toString(this.signatureLen); - } - - - public String getSignatureLenAsHex( ) { - - if( null == this.signatureLen) return null; - return Util.bytes2HexString(signatureLen); - } - - - public Data setSignatureLen( byte[] bytes ) { - - this.signatureLen = bytes; - return this; - } - - - public byte[] getSignatureAsBin( ) { - - return this.signature; - } - - - public String getSignatureAsStr( ) { - - if( null == this.signature) return null; - return Arrays.toString(this.signature); - } - - - public String getSignatureAsHex( ) { - - if( null == this.signature) return null; - return Util.bytes2HexString(signature); - } - - - public Data setSignature( byte[] bytes ) { - - this.signature = bytes; - return this; - } - - - public byte[] getSignatureDataTypeAsBin( ) { - - return this.signatureDataType; - } - - - public String getSignatureDataTypeAsStr( ) { - - if( null == this.signatureDataType) return null; - return Arrays.toString(this.signatureDataType); - } - - - public String getSignatureDataTypeAsHex( ) { - - if( null == this.signatureDataType) return null; - return Util.bytes2HexString(signatureDataType); - } - - - public Data setSignatureDataType( byte[] bytes ) { - - this.signatureDataType = bytes; - return this; - } -public enum SignatureDataTypeOptions { - - OPVHASH(Util.hexString2Bytes("30")), - OPV原数据(Util.hexString2Bytes("31")); - private byte[] bin; - SignatureDataTypeOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getSignatureDataTypeCn( ) { - - if( null == signatureDataType) { return null; } - if( "30".equals(Util.bytes2HexString(this.signatureDataType))) { - return "HASH"; - } - if( "31".equals(Util.bytes2HexString(this.signatureDataType))) { - return "原数据"; - } - return null; - } - - - public Integer getSignatureDataTypeOptionIndex( ) { - - if( null == signatureDataType) { return null; } - if( "30".equals(Util.bytes2HexString(this.signatureDataType))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.signatureDataType))) { - return 1; - } - return null; - } - - - public byte[] getHashDataAsBin( ) { - - return this.hashData; - } - - - public String getHashDataAsStr( ) { - - if( null == this.hashData) return null; - return Arrays.toString(this.hashData); - } - - - public String getHashDataAsHex( ) { - - if( null == this.hashData) return null; - return Util.bytes2HexString(hashData); - } - - - public Data setHashData( byte[] bytes ) { - - this.hashData = bytes; - return this; - } - - - public byte[] getUserIdLengthAsBin( ) { - - return this.userIdLength; - } - - - public String getUserIdLengthAsStr( ) { - - if( null == this.userIdLength) return null; - return Arrays.toString(this.userIdLength); - } - - - public String getUserIdLengthAsHex( ) { - - if( null == this.userIdLength) return null; - return Util.bytes2HexString(userIdLength); - } - - - public Data setUserIdLength( byte[] bytes ) { - - this.userIdLength = bytes; - return this; - } - - - public byte[] getUserIdAsBin( ) { - - return this.userId; - } - - - public String getUserIdAsStr( ) { - - if( null == this.userId) return null; - return Arrays.toString(this.userId); - } - - - public String getUserIdAsHex( ) { - - if( null == this.userId) return null; - return Util.bytes2HexString(userId); - } - - - public Data setUserId( byte[] bytes ) { - - this.userId = bytes; - return this; - } - - - public byte[] getDataLengthAsBin( ) { - - return this.dataLength; - } - - - public String getDataLengthAsStr( ) { - - if( null == this.dataLength) return null; - return Arrays.toString(this.dataLength); - } - - - public String getDataLengthAsHex( ) { - - if( null == this.dataLength) return null; - return Util.bytes2HexString(dataLength); - } - - - public Data setDataLength( byte[] bytes ) { - - this.dataLength = bytes; - return this; - } - - - public byte[] getInfoDataAsBin( ) { - - return this.infoData; - } - - - public String getInfoDataAsStr( ) { - - if( null == this.infoData) return null; - return Arrays.toString(this.infoData); - } - - - public String getInfoDataAsHex( ) { - - if( null == this.infoData) return null; - return Util.bytes2HexString(infoData); - } - - - public Data setInfoData( byte[] bytes ) { - - this.infoData = bytes; - return this; - } - - - public byte[] getPublicKeyLengthAsBin( ) { - - return this.publicKeyLength; - } - - - public String getPublicKeyLengthAsStr( ) { - - if( null == this.publicKeyLength) return null; - return Arrays.toString(this.publicKeyLength); - } - - - public String getPublicKeyLengthAsHex( ) { - - if( null == this.publicKeyLength) return null; - return Util.bytes2HexString(publicKeyLength); - } - - - public Data setPublicKeyLength( byte[] bytes ) { - - this.publicKeyLength = bytes; - return this; - } - - - public byte[] getPublicKeyAsBin( ) { - - return this.publicKey; - } - - - public String getPublicKeyAsStr( ) { - - if( null == this.publicKey) return null; - return Arrays.toString(this.publicKey); - } - - - public String getPublicKeyAsHex( ) { - - if( null == this.publicKey) return null; - return Util.bytes2HexString(publicKey); - } - - - public Data setPublicKey( byte[] bytes ) { - - this.publicKey = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != signatureLen ){ - soup.put("signatureLen", this.signatureLen); - } - - if( null != signature ){ - soup.put("signature", this.signature); - } - - if( null != signatureDataType ){ - soup.put("signatureDataType", this.signatureDataType); - soup.put("signatureDataType$option", getSignatureDataTypeOptionIndex()); - } - - if( null != hashData ){ - soup.put("hashData", this.hashData); - } - - if( null != userIdLength ){ - soup.put("userIdLength", this.userIdLength); - } - - if( null != userId ){ - soup.put("userId", this.userId); - } - - if( null != dataLength ){ - soup.put("dataLength", this.dataLength); - } - - if( null != infoData ){ - soup.put("infoData", this.infoData); - } - - if( null != publicKeyLength ){ - soup.put("publicKeyLength", this.publicKeyLength); - } - - if( null != publicKey ){ - soup.put("publicKey", this.publicKey); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("signatureLen") ){ - this.signatureLen = ((PacketSection) soup.get("signatureLen")).getBytes(); - } - - if( soup.containsKey("signature") ){ - this.signature = ((PacketSection) soup.get("signature")).getBytes(); - } - - if( soup.containsKey("signatureDataType") ){ - this.signatureDataType = ((PacketSection) soup.get("signatureDataType")).getBytes(); - } - - if( soup.containsKey("hashData") ){ - this.hashData = ((PacketSection) soup.get("hashData")).getBytes(); - } - - if( soup.containsKey("userIdLength") ){ - this.userIdLength = ((PacketSection) soup.get("userIdLength")).getBytes(); - } - - if( soup.containsKey("userId") ){ - this.userId = ((PacketSection) soup.get("userId")).getBytes(); - } - - if( soup.containsKey("dataLength") ){ - this.dataLength = ((PacketSection) soup.get("dataLength")).getBytes(); - } - - if( soup.containsKey("infoData") ){ - this.infoData = ((PacketSection) soup.get("infoData")).getBytes(); - } - - if( soup.containsKey("publicKeyLength") ){ - this.publicKeyLength = ((PacketSection) soup.get("publicKeyLength")).getBytes(); - } - - if( soup.containsKey("publicKey") ){ - this.publicKey = ((PacketSection) soup.get("publicKey")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3735")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3735"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV签名校验失败(Util.hexString2Bytes("3032")), - OPV公钥不符合编码规则(Util.hexString2Bytes("3034")), - OPV无效的哈希标识(Util.hexString2Bytes("3035")), - OPV无效的签名标识(Util.hexString2Bytes("3036")), - OPV无效的附加标识(Util.hexString2Bytes("3037")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVDSP错误(Util.hexString2Bytes("3437")), - OPV无效摘要信息语法仅仅无哈希模式(Util.hexString2Bytes("3734")), - OPV公钥长度错误(Util.hexString2Bytes("3736")), - OPV明文数据块错误(Util.hexString2Bytes("3737")), - OPV哈希算法对象标识错误(Util.hexString2Bytes("3739")), - OPV信息长度错(Util.hexString2Bytes("3830")), - OPV签名长度错(Util.hexString2Bytes("3831")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3032".equals(Util.bytes2HexString(this.error))) { - return "签名校验失败"; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return "公钥不符合编码规则"; - } - if( "3035".equals(Util.bytes2HexString(this.error))) { - return "无效的哈希标识"; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return "无效的签名标识"; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return "无效的附加标识"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return "DSP 错误"; - } - if( "3734".equals(Util.bytes2HexString(this.error))) { - return "无效摘要信息语法(仅仅无哈希模式)"; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return "公钥长度错误"; - } - if( "3737".equals(Util.bytes2HexString(this.error))) { - return "明文数据块错误"; - } - if( "3739".equals(Util.bytes2HexString(this.error))) { - return "哈希算法对象标识错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "信息长度错"; - } - if( "3831".equals(Util.bytes2HexString(this.error))) { - return "签名长度错"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3032".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3035".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3734".equals(Util.bytes2HexString(this.error))) { - return 9; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return 10; - } - if( "3737".equals(Util.bytes2HexString(this.error))) { - return 11; - } - if( "3739".equals(Util.bytes2HexString(this.error))) { - return 12; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 13; - } - if( "3831".equals(Util.bytes2HexString(this.error))) { - return 14; - } - return null; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3736")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3736"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO76.java b/src/main/java/racal/sunyard/main/dto/DTO76.java deleted file mode 100644 index 7939fd5..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO76.java +++ /dev/null @@ -1,1017 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO76 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] packSn = null; - private byte[] dataLength = null; - private byte[] msg = null; - private byte[] userIdLength = null; - private byte[] userId = null; - private byte[] publicKeyLength = null; - private byte[] publicKey = null; - private byte[] filterDataLen = null; - private byte[] filterData = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getPackSnAsBin( ) { - - return this.packSn; - } - - - public String getPackSnAsStr( ) { - - if( null == this.packSn) return null; - return Arrays.toString(this.packSn); - } - - - public String getPackSnAsHex( ) { - - if( null == this.packSn) return null; - return Util.bytes2HexString(packSn); - } - - - public Data setPackSn( byte[] bytes ) { - - this.packSn = bytes; - return this; - } -public enum PackSnOptions { - - OPV仅一块(Util.hexString2Bytes("30")), - OPV第一块(Util.hexString2Bytes("31")), - OPV中间块(Util.hexString2Bytes("32")), - OPV最后块(Util.hexString2Bytes("33")); - private byte[] bin; - PackSnOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getPackSnCn( ) { - - if( null == packSn) { return null; } - if( "30".equals(Util.bytes2HexString(this.packSn))) { - return "仅一块"; - } - if( "31".equals(Util.bytes2HexString(this.packSn))) { - return "第一块"; - } - if( "32".equals(Util.bytes2HexString(this.packSn))) { - return "中间块"; - } - if( "33".equals(Util.bytes2HexString(this.packSn))) { - return "最后块"; - } - return null; - } - - - public Integer getPackSnOptionIndex( ) { - - if( null == packSn) { return null; } - if( "30".equals(Util.bytes2HexString(this.packSn))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.packSn))) { - return 1; - } - if( "32".equals(Util.bytes2HexString(this.packSn))) { - return 2; - } - if( "33".equals(Util.bytes2HexString(this.packSn))) { - return 3; - } - return null; - } - - - public byte[] getDataLengthAsBin( ) { - - return this.dataLength; - } - - - public String getDataLengthAsStr( ) { - - if( null == this.dataLength) return null; - return Arrays.toString(this.dataLength); - } - - - public String getDataLengthAsHex( ) { - - if( null == this.dataLength) return null; - return Util.bytes2HexString(dataLength); - } - - - public Data setDataLength( byte[] bytes ) { - - this.dataLength = bytes; - return this; - } - - - public byte[] getMsgAsBin( ) { - - return this.msg; - } - - - public String getMsgAsStr( ) { - - if( null == this.msg) return null; - return Arrays.toString(this.msg); - } - - - public String getMsgAsHex( ) { - - if( null == this.msg) return null; - return Util.bytes2HexString(msg); - } - - - public Data setMsg( byte[] bytes ) { - - this.msg = bytes; - return this; - } - - - public byte[] getUserIdLengthAsBin( ) { - - return this.userIdLength; - } - - - public String getUserIdLengthAsStr( ) { - - if( null == this.userIdLength) return null; - return Arrays.toString(this.userIdLength); - } - - - public String getUserIdLengthAsHex( ) { - - if( null == this.userIdLength) return null; - return Util.bytes2HexString(userIdLength); - } - - - public Data setUserIdLength( byte[] bytes ) { - - this.userIdLength = bytes; - return this; - } - - - public byte[] getUserIdAsBin( ) { - - return this.userId; - } - - - public String getUserIdAsStr( ) { - - if( null == this.userId) return null; - return Arrays.toString(this.userId); - } - - - public String getUserIdAsHex( ) { - - if( null == this.userId) return null; - return Util.bytes2HexString(userId); - } - - - public Data setUserId( byte[] bytes ) { - - this.userId = bytes; - return this; - } - - - public byte[] getPublicKeyLengthAsBin( ) { - - return this.publicKeyLength; - } - - - public String getPublicKeyLengthAsStr( ) { - - if( null == this.publicKeyLength) return null; - return Arrays.toString(this.publicKeyLength); - } - - - public String getPublicKeyLengthAsHex( ) { - - if( null == this.publicKeyLength) return null; - return Util.bytes2HexString(publicKeyLength); - } - - - public Data setPublicKeyLength( byte[] bytes ) { - - this.publicKeyLength = bytes; - return this; - } - - - public byte[] getPublicKeyAsBin( ) { - - return this.publicKey; - } - - - public String getPublicKeyAsStr( ) { - - if( null == this.publicKey) return null; - return Arrays.toString(this.publicKey); - } - - - public String getPublicKeyAsHex( ) { - - if( null == this.publicKey) return null; - return Util.bytes2HexString(publicKey); - } - - - public Data setPublicKey( byte[] bytes ) { - - this.publicKey = bytes; - return this; - } - - - public byte[] getFilterDataLenAsBin( ) { - - return this.filterDataLen; - } - - - public String getFilterDataLenAsStr( ) { - - if( null == this.filterDataLen) return null; - return Arrays.toString(this.filterDataLen); - } - - - public String getFilterDataLenAsHex( ) { - - if( null == this.filterDataLen) return null; - return Util.bytes2HexString(filterDataLen); - } - - - public Data setFilterDataLen( byte[] bytes ) { - - this.filterDataLen = bytes; - return this; - } - - - public byte[] getFilterDataAsBin( ) { - - return this.filterData; - } - - - public String getFilterDataAsStr( ) { - - if( null == this.filterData) return null; - return Arrays.toString(this.filterData); - } - - - public String getFilterDataAsHex( ) { - - if( null == this.filterData) return null; - return Util.bytes2HexString(filterData); - } - - - public Data setFilterData( byte[] bytes ) { - - this.filterData = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != packSn ){ - soup.put("packSn", this.packSn); - soup.put("packSn$option", getPackSnOptionIndex()); - } - - if( null != dataLength ){ - soup.put("dataLength", this.dataLength); - } - - if( null != msg ){ - soup.put("msg", this.msg); - } - - if( null != userIdLength ){ - soup.put("userIdLength", this.userIdLength); - } - - if( null != userId ){ - soup.put("userId", this.userId); - } - - if( null != publicKeyLength ){ - soup.put("publicKeyLength", this.publicKeyLength); - } - - if( null != publicKey ){ - soup.put("publicKey", this.publicKey); - } - - if( null != filterDataLen ){ - soup.put("filterDataLen", this.filterDataLen); - } - - if( null != filterData ){ - soup.put("filterData", this.filterData); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("packSn") ){ - this.packSn = ((PacketSection) soup.get("packSn")).getBytes(); - } - - if( soup.containsKey("dataLength") ){ - this.dataLength = ((PacketSection) soup.get("dataLength")).getBytes(); - } - - if( soup.containsKey("msg") ){ - this.msg = ((PacketSection) soup.get("msg")).getBytes(); - } - - if( soup.containsKey("userIdLength") ){ - this.userIdLength = ((PacketSection) soup.get("userIdLength")).getBytes(); - } - - if( soup.containsKey("userId") ){ - this.userId = ((PacketSection) soup.get("userId")).getBytes(); - } - - if( soup.containsKey("publicKeyLength") ){ - this.publicKeyLength = ((PacketSection) soup.get("publicKeyLength")).getBytes(); - } - - if( soup.containsKey("publicKey") ){ - this.publicKey = ((PacketSection) soup.get("publicKey")).getBytes(); - } - - if( soup.containsKey("filterDataLen") ){ - this.filterDataLen = ((PacketSection) soup.get("filterDataLen")).getBytes(); - } - - if( soup.containsKey("filterData") ){ - this.filterData = ((PacketSection) soup.get("filterData")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3736")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3736"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] hash = null; - private byte[] filterDataLen = null; - private byte[] filterData = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV数据长度错(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "数据长度错"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 2; - } - return null; - } - - - public byte[] getHashAsBin( ) { - - return this.hash; - } - - - public String getHashAsStr( ) { - - if( null == this.hash) return null; - return Arrays.toString(this.hash); - } - - - public String getHashAsHex( ) { - - if( null == this.hash) return null; - return Util.bytes2HexString(hash); - } - - - public Data setHash( byte[] bytes ) { - - this.hash = bytes; - return this; - } - - - public byte[] getFilterDataLenAsBin( ) { - - return this.filterDataLen; - } - - - public String getFilterDataLenAsStr( ) { - - if( null == this.filterDataLen) return null; - return Arrays.toString(this.filterDataLen); - } - - - public String getFilterDataLenAsHex( ) { - - if( null == this.filterDataLen) return null; - return Util.bytes2HexString(filterDataLen); - } - - - public Data setFilterDataLen( byte[] bytes ) { - - this.filterDataLen = bytes; - return this; - } - - - public byte[] getFilterDataAsBin( ) { - - return this.filterData; - } - - - public String getFilterDataAsStr( ) { - - if( null == this.filterData) return null; - return Arrays.toString(this.filterData); - } - - - public String getFilterDataAsHex( ) { - - if( null == this.filterData) return null; - return Util.bytes2HexString(filterData); - } - - - public Data setFilterData( byte[] bytes ) { - - this.filterData = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != hash ){ - soup.put("hash", this.hash); - } - - if( null != filterDataLen ){ - soup.put("filterDataLen", this.filterDataLen); - } - - if( null != filterData ){ - soup.put("filterData", this.filterData); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("hash") ){ - this.hash = ((PacketSection) soup.get("hash")).getBytes(); - } - - if( soup.containsKey("filterDataLen") ){ - this.filterDataLen = ((PacketSection) soup.get("filterDataLen")).getBytes(); - } - - if( soup.containsKey("filterData") ){ - this.filterData = ((PacketSection) soup.get("filterData")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3737")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3737"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO77.java b/src/main/java/racal/sunyard/main/dto/DTO77.java deleted file mode 100644 index 14f7d93..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO77.java +++ /dev/null @@ -1,865 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO77 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] algorithmKey = null; - private byte[] fillKey = null; - private byte[] publicKeyLength = null; - private byte[] publicKey = null; - private byte[] dataLength = null; - private byte[] infoData = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getAlgorithmKeyAsBin( ) { - - return this.algorithmKey; - } - - - public String getAlgorithmKeyAsStr( ) { - - if( null == this.algorithmKey) return null; - return Arrays.toString(this.algorithmKey); - } - - - public String getAlgorithmKeyAsHex( ) { - - if( null == this.algorithmKey) return null; - return Util.bytes2HexString(algorithmKey); - } - - - public Data setAlgorithmKey( byte[] bytes ) { - - this.algorithmKey = bytes; - return this; - } -public enum AlgorithmKeyOptions { - - OPVRSA(Util.hexString2Bytes("30")), - OPVSM2(Util.hexString2Bytes("31")); - private byte[] bin; - AlgorithmKeyOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getAlgorithmKeyCn( ) { - - if( null == algorithmKey) { return null; } - if( "30".equals(Util.bytes2HexString(this.algorithmKey))) { - return "RSA"; - } - if( "31".equals(Util.bytes2HexString(this.algorithmKey))) { - return "SM2"; - } - return null; - } - - - public Integer getAlgorithmKeyOptionIndex( ) { - - if( null == algorithmKey) { return null; } - if( "30".equals(Util.bytes2HexString(this.algorithmKey))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.algorithmKey))) { - return 1; - } - return null; - } - - - public byte[] getFillKeyAsBin( ) { - - return this.fillKey; - } - - - public String getFillKeyAsStr( ) { - - if( null == this.fillKey) return null; - return Arrays.toString(this.fillKey); - } - - - public String getFillKeyAsHex( ) { - - if( null == this.fillKey) return null; - return Util.bytes2HexString(fillKey); - } - - - public Data setFillKey( byte[] bytes ) { - - this.fillKey = bytes; - return this; - } -public enum FillKeyOptions { - - OPV数据长度必须等于密钥长度(Util.hexString2Bytes("30")), - OPVPKCS1v15填充方式(Util.hexString2Bytes("31")); - private byte[] bin; - FillKeyOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getFillKeyCn( ) { - - if( null == fillKey) { return null; } - if( "30".equals(Util.bytes2HexString(this.fillKey))) { - return "数据长度必须等于密钥长度"; - } - if( "31".equals(Util.bytes2HexString(this.fillKey))) { - return "PKCS#1 v1.5 填充方式"; - } - return null; - } - - - public Integer getFillKeyOptionIndex( ) { - - if( null == fillKey) { return null; } - if( "30".equals(Util.bytes2HexString(this.fillKey))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.fillKey))) { - return 1; - } - return null; - } - - - public byte[] getPublicKeyLengthAsBin( ) { - - return this.publicKeyLength; - } - - - public String getPublicKeyLengthAsStr( ) { - - if( null == this.publicKeyLength) return null; - return Arrays.toString(this.publicKeyLength); - } - - - public String getPublicKeyLengthAsHex( ) { - - if( null == this.publicKeyLength) return null; - return Util.bytes2HexString(publicKeyLength); - } - - - public Data setPublicKeyLength( byte[] bytes ) { - - this.publicKeyLength = bytes; - return this; - } - - - public byte[] getPublicKeyAsBin( ) { - - return this.publicKey; - } - - - public String getPublicKeyAsStr( ) { - - if( null == this.publicKey) return null; - return Arrays.toString(this.publicKey); - } - - - public String getPublicKeyAsHex( ) { - - if( null == this.publicKey) return null; - return Util.bytes2HexString(publicKey); - } - - - public Data setPublicKey( byte[] bytes ) { - - this.publicKey = bytes; - return this; - } - - - public byte[] getDataLengthAsBin( ) { - - return this.dataLength; - } - - - public String getDataLengthAsStr( ) { - - if( null == this.dataLength) return null; - return Arrays.toString(this.dataLength); - } - - - public String getDataLengthAsHex( ) { - - if( null == this.dataLength) return null; - return Util.bytes2HexString(dataLength); - } - - - public Data setDataLength( byte[] bytes ) { - - this.dataLength = bytes; - return this; - } - - - public byte[] getInfoDataAsBin( ) { - - return this.infoData; - } - - - public String getInfoDataAsStr( ) { - - if( null == this.infoData) return null; - return Arrays.toString(this.infoData); - } - - - public String getInfoDataAsHex( ) { - - if( null == this.infoData) return null; - return Util.bytes2HexString(infoData); - } - - - public Data setInfoData( byte[] bytes ) { - - this.infoData = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != algorithmKey ){ - soup.put("AlgorithmKey", this.algorithmKey); - soup.put("AlgorithmKey$option", getAlgorithmKeyOptionIndex()); - } - - if( null != fillKey ){ - soup.put("fillKey", this.fillKey); - soup.put("fillKey$option", getFillKeyOptionIndex()); - } - - if( null != publicKeyLength ){ - soup.put("publicKeyLength", this.publicKeyLength); - } - - if( null != publicKey ){ - soup.put("publicKey", this.publicKey); - } - - if( null != dataLength ){ - soup.put("dataLength", this.dataLength); - } - - if( null != infoData ){ - soup.put("infoData", this.infoData); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("AlgorithmKey") ){ - this.algorithmKey = ((PacketSection) soup.get("AlgorithmKey")).getBytes(); - } - - if( soup.containsKey("fillKey") ){ - this.fillKey = ((PacketSection) soup.get("fillKey")).getBytes(); - } - - if( soup.containsKey("publicKeyLength") ){ - this.publicKeyLength = ((PacketSection) soup.get("publicKeyLength")).getBytes(); - } - - if( soup.containsKey("publicKey") ){ - this.publicKey = ((PacketSection) soup.get("publicKey")).getBytes(); - } - - if( soup.containsKey("dataLength") ){ - this.dataLength = ((PacketSection) soup.get("dataLength")).getBytes(); - } - - if( soup.containsKey("infoData") ){ - this.infoData = ((PacketSection) soup.get("infoData")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3737")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3737"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] dataLen = null; - private byte[] cipherData = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV公钥不符合编码规则(Util.hexString2Bytes("3034")), - OPV无效的算法标识(Util.hexString2Bytes("3036")), - OPV无效的附加标识(Util.hexString2Bytes("3037")), - OPV密钥奇偶校验错误(Util.hexString2Bytes("3130")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVDSP错误(Util.hexString2Bytes("3437")), - OPV密钥块长度错误(Util.hexString2Bytes("3736")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return "公钥不符合编码规则"; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return "无效的算法标识"; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return "无效的附加标识"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "密钥奇偶校验错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return "DSP 错误"; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return "密钥块长度错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 8; - } - return null; - } - - - public byte[] getDataLenAsBin( ) { - - return this.dataLen; - } - - - public String getDataLenAsStr( ) { - - if( null == this.dataLen) return null; - return Arrays.toString(this.dataLen); - } - - - public String getDataLenAsHex( ) { - - if( null == this.dataLen) return null; - return Util.bytes2HexString(dataLen); - } - - - public Data setDataLen( byte[] bytes ) { - - this.dataLen = bytes; - return this; - } - - - public byte[] getCipherDataAsBin( ) { - - return this.cipherData; - } - - - public String getCipherDataAsStr( ) { - - if( null == this.cipherData) return null; - return Arrays.toString(this.cipherData); - } - - - public String getCipherDataAsHex( ) { - - if( null == this.cipherData) return null; - return Util.bytes2HexString(cipherData); - } - - - public Data setCipherData( byte[] bytes ) { - - this.cipherData = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != dataLen ){ - soup.put("dataLen", this.dataLen); - } - - if( null != cipherData ){ - soup.put("cipherData", this.cipherData); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("dataLen") ){ - this.dataLen = ((PacketSection) soup.get("dataLen")).getBytes(); - } - - if( soup.containsKey("cipherData") ){ - this.cipherData = ((PacketSection) soup.get("cipherData")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3738")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3738"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO78.java b/src/main/java/racal/sunyard/main/dto/DTO78.java deleted file mode 100644 index 775c761..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO78.java +++ /dev/null @@ -1,1056 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO78 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] algorithmKey = null; - private byte[] fillKey = null; - private byte[] privateKeyTag = null; - private byte[] privateKeyLength = null; - private byte[] privateKey = null; - private byte[] dataLength = null; - private byte[] infoData = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getAlgorithmKeyAsBin( ) { - - return this.algorithmKey; - } - - - public String getAlgorithmKeyAsStr( ) { - - if( null == this.algorithmKey) return null; - return Arrays.toString(this.algorithmKey); - } - - - public String getAlgorithmKeyAsHex( ) { - - if( null == this.algorithmKey) return null; - return Util.bytes2HexString(algorithmKey); - } - - - public Data setAlgorithmKey( byte[] bytes ) { - - this.algorithmKey = bytes; - return this; - } -public enum AlgorithmKeyOptions { - - OPVRSA(Util.hexString2Bytes("30")), - OPVSM2(Util.hexString2Bytes("31")); - private byte[] bin; - AlgorithmKeyOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getAlgorithmKeyCn( ) { - - if( null == algorithmKey) { return null; } - if( "30".equals(Util.bytes2HexString(this.algorithmKey))) { - return "RSA"; - } - if( "31".equals(Util.bytes2HexString(this.algorithmKey))) { - return "SM2"; - } - return null; - } - - - public Integer getAlgorithmKeyOptionIndex( ) { - - if( null == algorithmKey) { return null; } - if( "30".equals(Util.bytes2HexString(this.algorithmKey))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.algorithmKey))) { - return 1; - } - return null; - } - - - public byte[] getFillKeyAsBin( ) { - - return this.fillKey; - } - - - public String getFillKeyAsStr( ) { - - if( null == this.fillKey) return null; - return Arrays.toString(this.fillKey); - } - - - public String getFillKeyAsHex( ) { - - if( null == this.fillKey) return null; - return Util.bytes2HexString(fillKey); - } - - - public Data setFillKey( byte[] bytes ) { - - this.fillKey = bytes; - return this; - } -public enum FillKeyOptions { - - OPV数据长度必须等于密钥长度(Util.hexString2Bytes("30")), - OPVPKCS1v15填充方式(Util.hexString2Bytes("31")); - private byte[] bin; - FillKeyOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getFillKeyCn( ) { - - if( null == fillKey) { return null; } - if( "30".equals(Util.bytes2HexString(this.fillKey))) { - return "数据长度必须等于密钥长度"; - } - if( "31".equals(Util.bytes2HexString(this.fillKey))) { - return "PKCS#1 v1.5 填充方式"; - } - return null; - } - - - public Integer getFillKeyOptionIndex( ) { - - if( null == fillKey) { return null; } - if( "30".equals(Util.bytes2HexString(this.fillKey))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.fillKey))) { - return 1; - } - return null; - } - - - public byte[] getPrivateKeyTagAsBin( ) { - - return this.privateKeyTag; - } - - - public String getPrivateKeyTagAsStr( ) { - - if( null == this.privateKeyTag) return null; - return Arrays.toString(this.privateKeyTag); - } - - - public String getPrivateKeyTagAsHex( ) { - - if( null == this.privateKeyTag) return null; - return Util.bytes2HexString(privateKeyTag); - } - - - public Data setPrivateKeyTag( byte[] bytes ) { - - this.privateKeyTag = bytes; - return this; - } - - - public byte[] getPrivateKeyLengthAsBin( ) { - - return this.privateKeyLength; - } - - - public String getPrivateKeyLengthAsStr( ) { - - if( null == this.privateKeyLength) return null; - return Arrays.toString(this.privateKeyLength); - } - - - public String getPrivateKeyLengthAsHex( ) { - - if( null == this.privateKeyLength) return null; - return Util.bytes2HexString(privateKeyLength); - } - - - public Data setPrivateKeyLength( byte[] bytes ) { - - this.privateKeyLength = bytes; - return this; - } - - - public byte[] getPrivateKeyAsBin( ) { - - return this.privateKey; - } - - - public String getPrivateKeyAsStr( ) { - - if( null == this.privateKey) return null; - return Arrays.toString(this.privateKey); - } - - - public String getPrivateKeyAsHex( ) { - - if( null == this.privateKey) return null; - return Util.bytes2HexString(privateKey); - } - - - public Data setPrivateKey( byte[] bytes ) { - - this.privateKey = bytes; - return this; - } - - - public byte[] getDataLengthAsBin( ) { - - return this.dataLength; - } - - - public String getDataLengthAsStr( ) { - - if( null == this.dataLength) return null; - return Arrays.toString(this.dataLength); - } - - - public String getDataLengthAsHex( ) { - - if( null == this.dataLength) return null; - return Util.bytes2HexString(dataLength); - } - - - public Data setDataLength( byte[] bytes ) { - - this.dataLength = bytes; - return this; - } - - - public byte[] getInfoDataAsBin( ) { - - return this.infoData; - } - - - public String getInfoDataAsStr( ) { - - if( null == this.infoData) return null; - return Arrays.toString(this.infoData); - } - - - public String getInfoDataAsHex( ) { - - if( null == this.infoData) return null; - return Util.bytes2HexString(infoData); - } - - - public Data setInfoData( byte[] bytes ) { - - this.infoData = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != algorithmKey ){ - soup.put("AlgorithmKey", this.algorithmKey); - soup.put("AlgorithmKey$option", getAlgorithmKeyOptionIndex()); - } - - if( null != fillKey ){ - soup.put("fillKey", this.fillKey); - soup.put("fillKey$option", getFillKeyOptionIndex()); - } - - if( null != privateKeyTag ){ - soup.put("privateKeyTag", this.privateKeyTag); - } - - if( null != privateKeyLength ){ - soup.put("privateKeyLength", this.privateKeyLength); - } - - if( null != privateKey ){ - soup.put("privateKey", this.privateKey); - } - - if( null != dataLength ){ - soup.put("dataLength", this.dataLength); - } - - if( null != infoData ){ - soup.put("infoData", this.infoData); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("AlgorithmKey") ){ - this.algorithmKey = ((PacketSection) soup.get("AlgorithmKey")).getBytes(); - } - - if( soup.containsKey("fillKey") ){ - this.fillKey = ((PacketSection) soup.get("fillKey")).getBytes(); - } - - if( soup.containsKey("privateKeyTag") ){ - this.privateKeyTag = ((PacketSection) soup.get("privateKeyTag")).getBytes(); - } - - if( soup.containsKey("privateKeyLength") ){ - this.privateKeyLength = ((PacketSection) soup.get("privateKeyLength")).getBytes(); - } - - if( soup.containsKey("privateKey") ){ - this.privateKey = ((PacketSection) soup.get("privateKey")).getBytes(); - } - - if( soup.containsKey("dataLength") ){ - this.dataLength = ((PacketSection) soup.get("dataLength")).getBytes(); - } - - if( soup.containsKey("infoData") ){ - this.infoData = ((PacketSection) soup.get("infoData")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3738")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3738"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] dataLen = null; - private byte[] data = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV私钥格式不对(Util.hexString2Bytes("3034")), - OPV无效的算法标识(Util.hexString2Bytes("3036")), - OPV无效的附加标识(Util.hexString2Bytes("3037")), - OPV密钥奇偶校验错误(Util.hexString2Bytes("3130")), - OPV解密错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVDSP错误(Util.hexString2Bytes("3437")), - OPV密钥块长度错误(Util.hexString2Bytes("3736")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return "私钥格式不对"; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return "无效的算法标识"; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return "无效的附加标识"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "密钥奇偶校验错误"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "解密错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return "DSP 错误"; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return "密钥块长度错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 9; - } - return null; - } - - - public byte[] getDataLenAsBin( ) { - - return this.dataLen; - } - - - public String getDataLenAsStr( ) { - - if( null == this.dataLen) return null; - return Arrays.toString(this.dataLen); - } - - - public String getDataLenAsHex( ) { - - if( null == this.dataLen) return null; - return Util.bytes2HexString(dataLen); - } - - - public Data setDataLen( byte[] bytes ) { - - this.dataLen = bytes; - return this; - } - - - public byte[] getDataAsBin( ) { - - return this.data; - } - - - public String getDataAsStr( ) { - - if( null == this.data) return null; - return Arrays.toString(this.data); - } - - - public String getDataAsHex( ) { - - if( null == this.data) return null; - return Util.bytes2HexString(data); - } - - - public Data setData( byte[] bytes ) { - - this.data = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != dataLen ){ - soup.put("dataLen", this.dataLen); - } - - if( null != data ){ - soup.put("data", this.data); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("dataLen") ){ - this.dataLen = ((PacketSection) soup.get("dataLen")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = ((PacketSection) soup.get("data")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3739")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3739"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO79.java b/src/main/java/racal/sunyard/main/dto/DTO79.java deleted file mode 100644 index d07f585..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO79.java +++ /dev/null @@ -1,901 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO79 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] algorithmKey = null; - private byte[] fillKey = null; - private byte[] privateKeyTag = null; - private byte[] privateKeyLength = null; - private byte[] privateKey = null; - private byte[] dataLength = null; - private byte[] infoData = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getAlgorithmKeyAsBin( ) { - - return this.algorithmKey; - } - - - public String getAlgorithmKeyAsStr( ) { - - if( null == this.algorithmKey) return null; - return Arrays.toString(this.algorithmKey); - } - - - public String getAlgorithmKeyAsHex( ) { - - if( null == this.algorithmKey) return null; - return Util.bytes2HexString(algorithmKey); - } - - - public Data setAlgorithmKey( byte[] bytes ) { - - this.algorithmKey = bytes; - return this; - } -public enum AlgorithmKeyOptions { - - OPVRSA(Util.hexString2Bytes("30")), - OPVSM2(Util.hexString2Bytes("31")); - private byte[] bin; - AlgorithmKeyOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getAlgorithmKeyCn( ) { - - if( null == algorithmKey) { return null; } - if( "30".equals(Util.bytes2HexString(this.algorithmKey))) { - return "RSA"; - } - if( "31".equals(Util.bytes2HexString(this.algorithmKey))) { - return "SM2"; - } - return null; - } - - - public Integer getAlgorithmKeyOptionIndex( ) { - - if( null == algorithmKey) { return null; } - if( "30".equals(Util.bytes2HexString(this.algorithmKey))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.algorithmKey))) { - return 1; - } - return null; - } - - - public byte[] getFillKeyAsBin( ) { - - return this.fillKey; - } - - - public String getFillKeyAsStr( ) { - - if( null == this.fillKey) return null; - return Arrays.toString(this.fillKey); - } - - - public String getFillKeyAsHex( ) { - - if( null == this.fillKey) return null; - return Util.bytes2HexString(fillKey); - } - - - public Data setFillKey( byte[] bytes ) { - - this.fillKey = bytes; - return this; - } -public enum FillKeyOptions { - - OPV数据长度必须等于密钥长度(Util.hexString2Bytes("30")), - OPVPKCS1v15填充方式(Util.hexString2Bytes("31")); - private byte[] bin; - FillKeyOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getFillKeyCn( ) { - - if( null == fillKey) { return null; } - if( "30".equals(Util.bytes2HexString(this.fillKey))) { - return "数据长度必须等于密钥长度"; - } - if( "31".equals(Util.bytes2HexString(this.fillKey))) { - return "PKCS#1 v1.5 填充方式"; - } - return null; - } - - - public Integer getFillKeyOptionIndex( ) { - - if( null == fillKey) { return null; } - if( "30".equals(Util.bytes2HexString(this.fillKey))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.fillKey))) { - return 1; - } - return null; - } - - - public byte[] getPrivateKeyTagAsBin( ) { - - return this.privateKeyTag; - } - - - public String getPrivateKeyTagAsStr( ) { - - if( null == this.privateKeyTag) return null; - return Arrays.toString(this.privateKeyTag); - } - - - public String getPrivateKeyTagAsHex( ) { - - if( null == this.privateKeyTag) return null; - return Util.bytes2HexString(privateKeyTag); - } - - - public Data setPrivateKeyTag( byte[] bytes ) { - - this.privateKeyTag = bytes; - return this; - } - - - public byte[] getPrivateKeyLengthAsBin( ) { - - return this.privateKeyLength; - } - - - public String getPrivateKeyLengthAsStr( ) { - - if( null == this.privateKeyLength) return null; - return Arrays.toString(this.privateKeyLength); - } - - - public String getPrivateKeyLengthAsHex( ) { - - if( null == this.privateKeyLength) return null; - return Util.bytes2HexString(privateKeyLength); - } - - - public Data setPrivateKeyLength( byte[] bytes ) { - - this.privateKeyLength = bytes; - return this; - } - - - public byte[] getPrivateKeyAsBin( ) { - - return this.privateKey; - } - - - public String getPrivateKeyAsStr( ) { - - if( null == this.privateKey) return null; - return Arrays.toString(this.privateKey); - } - - - public String getPrivateKeyAsHex( ) { - - if( null == this.privateKey) return null; - return Util.bytes2HexString(privateKey); - } - - - public Data setPrivateKey( byte[] bytes ) { - - this.privateKey = bytes; - return this; - } - - - public byte[] getDataLengthAsBin( ) { - - return this.dataLength; - } - - - public String getDataLengthAsStr( ) { - - if( null == this.dataLength) return null; - return Arrays.toString(this.dataLength); - } - - - public String getDataLengthAsHex( ) { - - if( null == this.dataLength) return null; - return Util.bytes2HexString(dataLength); - } - - - public Data setDataLength( byte[] bytes ) { - - this.dataLength = bytes; - return this; - } - - - public byte[] getInfoDataAsBin( ) { - - return this.infoData; - } - - - public String getInfoDataAsStr( ) { - - if( null == this.infoData) return null; - return Arrays.toString(this.infoData); - } - - - public String getInfoDataAsHex( ) { - - if( null == this.infoData) return null; - return Util.bytes2HexString(infoData); - } - - - public Data setInfoData( byte[] bytes ) { - - this.infoData = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != algorithmKey ){ - soup.put("AlgorithmKey", this.algorithmKey); - soup.put("AlgorithmKey$option", getAlgorithmKeyOptionIndex()); - } - - if( null != fillKey ){ - soup.put("fillKey", this.fillKey); - soup.put("fillKey$option", getFillKeyOptionIndex()); - } - - if( null != privateKeyTag ){ - soup.put("privateKeyTag", this.privateKeyTag); - } - - if( null != privateKeyLength ){ - soup.put("privateKeyLength", this.privateKeyLength); - } - - if( null != privateKey ){ - soup.put("privateKey", this.privateKey); - } - - if( null != dataLength ){ - soup.put("dataLength", this.dataLength); - } - - if( null != infoData ){ - soup.put("infoData", this.infoData); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("AlgorithmKey") ){ - this.algorithmKey = ((PacketSection) soup.get("AlgorithmKey")).getBytes(); - } - - if( soup.containsKey("fillKey") ){ - this.fillKey = ((PacketSection) soup.get("fillKey")).getBytes(); - } - - if( soup.containsKey("privateKeyTag") ){ - this.privateKeyTag = ((PacketSection) soup.get("privateKeyTag")).getBytes(); - } - - if( soup.containsKey("privateKeyLength") ){ - this.privateKeyLength = ((PacketSection) soup.get("privateKeyLength")).getBytes(); - } - - if( soup.containsKey("privateKey") ){ - this.privateKey = ((PacketSection) soup.get("privateKey")).getBytes(); - } - - if( soup.containsKey("dataLength") ){ - this.dataLength = ((PacketSection) soup.get("dataLength")).getBytes(); - } - - if( soup.containsKey("infoData") ){ - this.infoData = ((PacketSection) soup.get("infoData")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3739")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3739"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] dataLen = null; - private byte[] cipherData = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV私钥格式不对(Util.hexString2Bytes("3034")), - OPV无效的算法标识(Util.hexString2Bytes("3036")), - OPV无效的附加标识(Util.hexString2Bytes("3037")), - OPV密钥奇偶校验错误(Util.hexString2Bytes("3130")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVDSP错误(Util.hexString2Bytes("3437")), - OPV密钥块长度错误(Util.hexString2Bytes("3736")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return "私钥格式不对"; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return "无效的算法标识"; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return "无效的附加标识"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "密钥奇偶校验错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return "DSP 错误"; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return "密钥块长度错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 8; - } - return null; - } - - - public byte[] getDataLenAsBin( ) { - - return this.dataLen; - } - - - public String getDataLenAsStr( ) { - - if( null == this.dataLen) return null; - return Arrays.toString(this.dataLen); - } - - - public String getDataLenAsHex( ) { - - if( null == this.dataLen) return null; - return Util.bytes2HexString(dataLen); - } - - - public Data setDataLen( byte[] bytes ) { - - this.dataLen = bytes; - return this; - } - - - public byte[] getCipherDataAsBin( ) { - - return this.cipherData; - } - - - public String getCipherDataAsStr( ) { - - if( null == this.cipherData) return null; - return Arrays.toString(this.cipherData); - } - - - public String getCipherDataAsHex( ) { - - if( null == this.cipherData) return null; - return Util.bytes2HexString(cipherData); - } - - - public Data setCipherData( byte[] bytes ) { - - this.cipherData = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != dataLen ){ - soup.put("dataLen", this.dataLen); - } - - if( null != cipherData ){ - soup.put("cipherData", this.cipherData); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("dataLen") ){ - this.dataLen = ((PacketSection) soup.get("dataLen")).getBytes(); - } - - if( soup.containsKey("cipherData") ){ - this.cipherData = ((PacketSection) soup.get("cipherData")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3741")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3741"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO7A.java b/src/main/java/racal/sunyard/main/dto/DTO7A.java deleted file mode 100644 index 0b2b14e..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO7A.java +++ /dev/null @@ -1,865 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO7A { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] algorithmKey = null; - private byte[] fillKey = null; - private byte[] publicKeyLength = null; - private byte[] publicKey = null; - private byte[] dataLength = null; - private byte[] infoData = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getAlgorithmKeyAsBin( ) { - - return this.algorithmKey; - } - - - public String getAlgorithmKeyAsStr( ) { - - if( null == this.algorithmKey) return null; - return Arrays.toString(this.algorithmKey); - } - - - public String getAlgorithmKeyAsHex( ) { - - if( null == this.algorithmKey) return null; - return Util.bytes2HexString(algorithmKey); - } - - - public Data setAlgorithmKey( byte[] bytes ) { - - this.algorithmKey = bytes; - return this; - } -public enum AlgorithmKeyOptions { - - OPVRSA(Util.hexString2Bytes("30")), - OPVSM2(Util.hexString2Bytes("31")); - private byte[] bin; - AlgorithmKeyOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getAlgorithmKeyCn( ) { - - if( null == algorithmKey) { return null; } - if( "30".equals(Util.bytes2HexString(this.algorithmKey))) { - return "RSA"; - } - if( "31".equals(Util.bytes2HexString(this.algorithmKey))) { - return "SM2"; - } - return null; - } - - - public Integer getAlgorithmKeyOptionIndex( ) { - - if( null == algorithmKey) { return null; } - if( "30".equals(Util.bytes2HexString(this.algorithmKey))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.algorithmKey))) { - return 1; - } - return null; - } - - - public byte[] getFillKeyAsBin( ) { - - return this.fillKey; - } - - - public String getFillKeyAsStr( ) { - - if( null == this.fillKey) return null; - return Arrays.toString(this.fillKey); - } - - - public String getFillKeyAsHex( ) { - - if( null == this.fillKey) return null; - return Util.bytes2HexString(fillKey); - } - - - public Data setFillKey( byte[] bytes ) { - - this.fillKey = bytes; - return this; - } -public enum FillKeyOptions { - - OPV数据长度必须等于密钥长度(Util.hexString2Bytes("30")), - OPVPKCS1v15填充方式(Util.hexString2Bytes("31")); - private byte[] bin; - FillKeyOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getFillKeyCn( ) { - - if( null == fillKey) { return null; } - if( "30".equals(Util.bytes2HexString(this.fillKey))) { - return "数据长度必须等于密钥长度"; - } - if( "31".equals(Util.bytes2HexString(this.fillKey))) { - return "PKCS#1 v1.5 填充方式"; - } - return null; - } - - - public Integer getFillKeyOptionIndex( ) { - - if( null == fillKey) { return null; } - if( "30".equals(Util.bytes2HexString(this.fillKey))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.fillKey))) { - return 1; - } - return null; - } - - - public byte[] getPublicKeyLengthAsBin( ) { - - return this.publicKeyLength; - } - - - public String getPublicKeyLengthAsStr( ) { - - if( null == this.publicKeyLength) return null; - return Arrays.toString(this.publicKeyLength); - } - - - public String getPublicKeyLengthAsHex( ) { - - if( null == this.publicKeyLength) return null; - return Util.bytes2HexString(publicKeyLength); - } - - - public Data setPublicKeyLength( byte[] bytes ) { - - this.publicKeyLength = bytes; - return this; - } - - - public byte[] getPublicKeyAsBin( ) { - - return this.publicKey; - } - - - public String getPublicKeyAsStr( ) { - - if( null == this.publicKey) return null; - return Arrays.toString(this.publicKey); - } - - - public String getPublicKeyAsHex( ) { - - if( null == this.publicKey) return null; - return Util.bytes2HexString(publicKey); - } - - - public Data setPublicKey( byte[] bytes ) { - - this.publicKey = bytes; - return this; - } - - - public byte[] getDataLengthAsBin( ) { - - return this.dataLength; - } - - - public String getDataLengthAsStr( ) { - - if( null == this.dataLength) return null; - return Arrays.toString(this.dataLength); - } - - - public String getDataLengthAsHex( ) { - - if( null == this.dataLength) return null; - return Util.bytes2HexString(dataLength); - } - - - public Data setDataLength( byte[] bytes ) { - - this.dataLength = bytes; - return this; - } - - - public byte[] getInfoDataAsBin( ) { - - return this.infoData; - } - - - public String getInfoDataAsStr( ) { - - if( null == this.infoData) return null; - return Arrays.toString(this.infoData); - } - - - public String getInfoDataAsHex( ) { - - if( null == this.infoData) return null; - return Util.bytes2HexString(infoData); - } - - - public Data setInfoData( byte[] bytes ) { - - this.infoData = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != algorithmKey ){ - soup.put("AlgorithmKey", this.algorithmKey); - soup.put("AlgorithmKey$option", getAlgorithmKeyOptionIndex()); - } - - if( null != fillKey ){ - soup.put("fillKey", this.fillKey); - soup.put("fillKey$option", getFillKeyOptionIndex()); - } - - if( null != publicKeyLength ){ - soup.put("publicKeyLength", this.publicKeyLength); - } - - if( null != publicKey ){ - soup.put("publicKey", this.publicKey); - } - - if( null != dataLength ){ - soup.put("dataLength", this.dataLength); - } - - if( null != infoData ){ - soup.put("infoData", this.infoData); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("AlgorithmKey") ){ - this.algorithmKey = ((PacketSection) soup.get("AlgorithmKey")).getBytes(); - } - - if( soup.containsKey("fillKey") ){ - this.fillKey = ((PacketSection) soup.get("fillKey")).getBytes(); - } - - if( soup.containsKey("publicKeyLength") ){ - this.publicKeyLength = ((PacketSection) soup.get("publicKeyLength")).getBytes(); - } - - if( soup.containsKey("publicKey") ){ - this.publicKey = ((PacketSection) soup.get("publicKey")).getBytes(); - } - - if( soup.containsKey("dataLength") ){ - this.dataLength = ((PacketSection) soup.get("dataLength")).getBytes(); - } - - if( soup.containsKey("infoData") ){ - this.infoData = ((PacketSection) soup.get("infoData")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3741")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3741"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] dataLen = null; - private byte[] cipherData = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV公钥不符合编码规则(Util.hexString2Bytes("3034")), - OPV无效的算法标识(Util.hexString2Bytes("3036")), - OPV无效的附加标识(Util.hexString2Bytes("3037")), - OPV密钥奇偶校验错误(Util.hexString2Bytes("3130")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVDSP错误(Util.hexString2Bytes("3437")), - OPV密钥块长度错误(Util.hexString2Bytes("3736")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return "公钥不符合编码规则"; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return "无效的算法标识"; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return "无效的附加标识"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "密钥奇偶校验错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return "DSP 错误"; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return "密钥块长度错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 8; - } - return null; - } - - - public byte[] getDataLenAsBin( ) { - - return this.dataLen; - } - - - public String getDataLenAsStr( ) { - - if( null == this.dataLen) return null; - return Arrays.toString(this.dataLen); - } - - - public String getDataLenAsHex( ) { - - if( null == this.dataLen) return null; - return Util.bytes2HexString(dataLen); - } - - - public Data setDataLen( byte[] bytes ) { - - this.dataLen = bytes; - return this; - } - - - public byte[] getCipherDataAsBin( ) { - - return this.cipherData; - } - - - public String getCipherDataAsStr( ) { - - if( null == this.cipherData) return null; - return Arrays.toString(this.cipherData); - } - - - public String getCipherDataAsHex( ) { - - if( null == this.cipherData) return null; - return Util.bytes2HexString(cipherData); - } - - - public Data setCipherData( byte[] bytes ) { - - this.cipherData = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != dataLen ){ - soup.put("dataLen", this.dataLen); - } - - if( null != cipherData ){ - soup.put("cipherData", this.cipherData); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("dataLen") ){ - this.dataLen = ((PacketSection) soup.get("dataLen")).getBytes(); - } - - if( soup.containsKey("cipherData") ){ - this.cipherData = ((PacketSection) soup.get("cipherData")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3742")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3742"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO7B.java b/src/main/java/racal/sunyard/main/dto/DTO7B.java deleted file mode 100644 index 8dccb70..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO7B.java +++ /dev/null @@ -1,1092 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO7B { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] signatureDataType = null; - private byte[] hashMark = null; - private byte[] hashData = null; - private byte[] dataLength = null; - private byte[] infoData = null; - private byte[] privateKeyTag = null; - private byte[] privateKeyLength = null; - private byte[] privateKey = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getSignatureDataTypeAsBin( ) { - - return this.signatureDataType; - } - - - public String getSignatureDataTypeAsStr( ) { - - if( null == this.signatureDataType) return null; - return Arrays.toString(this.signatureDataType); - } - - - public String getSignatureDataTypeAsHex( ) { - - if( null == this.signatureDataType) return null; - return Util.bytes2HexString(signatureDataType); - } - - - public Data setSignatureDataType( byte[] bytes ) { - - this.signatureDataType = bytes; - return this; - } -public enum SignatureDataTypeOptions { - - OPVHASH(Util.hexString2Bytes("30")), - OPV原数据(Util.hexString2Bytes("31")); - private byte[] bin; - SignatureDataTypeOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getSignatureDataTypeCn( ) { - - if( null == signatureDataType) { return null; } - if( "30".equals(Util.bytes2HexString(this.signatureDataType))) { - return "HASH"; - } - if( "31".equals(Util.bytes2HexString(this.signatureDataType))) { - return "原数据"; - } - return null; - } - - - public Integer getSignatureDataTypeOptionIndex( ) { - - if( null == signatureDataType) { return null; } - if( "30".equals(Util.bytes2HexString(this.signatureDataType))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.signatureDataType))) { - return 1; - } - return null; - } - - - public byte[] getHashMarkAsBin( ) { - - return this.hashMark; - } - - - public String getHashMarkAsStr( ) { - - if( null == this.hashMark) return null; - return Arrays.toString(this.hashMark); - } - - - public String getHashMarkAsHex( ) { - - if( null == this.hashMark) return null; - return Util.bytes2HexString(hashMark); - } - - - public Data setHashMark( byte[] bytes ) { - - this.hashMark = bytes; - return this; - } -public enum HashMarkOptions { - - OPVSHA1(Util.hexString2Bytes("30")), - OPVSHA256(Util.hexString2Bytes("31")), - OPVMD5(Util.hexString2Bytes("32")); - private byte[] bin; - HashMarkOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getHashMarkCn( ) { - - if( null == hashMark) { return null; } - if( "30".equals(Util.bytes2HexString(this.hashMark))) { - return "SHA1"; - } - if( "31".equals(Util.bytes2HexString(this.hashMark))) { - return "SHA256"; - } - if( "32".equals(Util.bytes2HexString(this.hashMark))) { - return "MD5"; - } - return null; - } - - - public Integer getHashMarkOptionIndex( ) { - - if( null == hashMark) { return null; } - if( "30".equals(Util.bytes2HexString(this.hashMark))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.hashMark))) { - return 1; - } - if( "32".equals(Util.bytes2HexString(this.hashMark))) { - return 2; - } - return null; - } - - - public byte[] getHashDataAsBin( ) { - - return this.hashData; - } - - - public String getHashDataAsStr( ) { - - if( null == this.hashData) return null; - return Arrays.toString(this.hashData); - } - - - public String getHashDataAsHex( ) { - - if( null == this.hashData) return null; - return Util.bytes2HexString(hashData); - } - - - public Data setHashData( byte[] bytes ) { - - this.hashData = bytes; - return this; - } - - - public byte[] getDataLengthAsBin( ) { - - return this.dataLength; - } - - - public String getDataLengthAsStr( ) { - - if( null == this.dataLength) return null; - return Arrays.toString(this.dataLength); - } - - - public String getDataLengthAsHex( ) { - - if( null == this.dataLength) return null; - return Util.bytes2HexString(dataLength); - } - - - public Data setDataLength( byte[] bytes ) { - - this.dataLength = bytes; - return this; - } - - - public byte[] getInfoDataAsBin( ) { - - return this.infoData; - } - - - public String getInfoDataAsStr( ) { - - if( null == this.infoData) return null; - return Arrays.toString(this.infoData); - } - - - public String getInfoDataAsHex( ) { - - if( null == this.infoData) return null; - return Util.bytes2HexString(infoData); - } - - - public Data setInfoData( byte[] bytes ) { - - this.infoData = bytes; - return this; - } - - - public byte[] getPrivateKeyTagAsBin( ) { - - return this.privateKeyTag; - } - - - public String getPrivateKeyTagAsStr( ) { - - if( null == this.privateKeyTag) return null; - return Arrays.toString(this.privateKeyTag); - } - - - public String getPrivateKeyTagAsHex( ) { - - if( null == this.privateKeyTag) return null; - return Util.bytes2HexString(privateKeyTag); - } - - - public Data setPrivateKeyTag( byte[] bytes ) { - - this.privateKeyTag = bytes; - return this; - } - - - public byte[] getPrivateKeyLengthAsBin( ) { - - return this.privateKeyLength; - } - - - public String getPrivateKeyLengthAsStr( ) { - - if( null == this.privateKeyLength) return null; - return Arrays.toString(this.privateKeyLength); - } - - - public String getPrivateKeyLengthAsHex( ) { - - if( null == this.privateKeyLength) return null; - return Util.bytes2HexString(privateKeyLength); - } - - - public Data setPrivateKeyLength( byte[] bytes ) { - - this.privateKeyLength = bytes; - return this; - } - - - public byte[] getPrivateKeyAsBin( ) { - - return this.privateKey; - } - - - public String getPrivateKeyAsStr( ) { - - if( null == this.privateKey) return null; - return Arrays.toString(this.privateKey); - } - - - public String getPrivateKeyAsHex( ) { - - if( null == this.privateKey) return null; - return Util.bytes2HexString(privateKey); - } - - - public Data setPrivateKey( byte[] bytes ) { - - this.privateKey = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != signatureDataType ){ - soup.put("signatureDataType", this.signatureDataType); - soup.put("signatureDataType$option", getSignatureDataTypeOptionIndex()); - } - - if( null != hashMark ){ - soup.put("hashMark", this.hashMark); - soup.put("hashMark$option", getHashMarkOptionIndex()); - } - - if( null != hashData ){ - soup.put("hashData", this.hashData); - } - - if( null != dataLength ){ - soup.put("dataLength", this.dataLength); - } - - if( null != infoData ){ - soup.put("infoData", this.infoData); - } - - if( null != privateKeyTag ){ - soup.put("privateKeyTag", this.privateKeyTag); - } - - if( null != privateKeyLength ){ - soup.put("privateKeyLength", this.privateKeyLength); - } - - if( null != privateKey ){ - soup.put("privateKey", this.privateKey); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("signatureDataType") ){ - this.signatureDataType = ((PacketSection) soup.get("signatureDataType")).getBytes(); - } - - if( soup.containsKey("hashMark") ){ - this.hashMark = ((PacketSection) soup.get("hashMark")).getBytes(); - } - - if( soup.containsKey("hashData") ){ - this.hashData = ((PacketSection) soup.get("hashData")).getBytes(); - } - - if( soup.containsKey("dataLength") ){ - this.dataLength = ((PacketSection) soup.get("dataLength")).getBytes(); - } - - if( soup.containsKey("infoData") ){ - this.infoData = ((PacketSection) soup.get("infoData")).getBytes(); - } - - if( soup.containsKey("privateKeyTag") ){ - this.privateKeyTag = ((PacketSection) soup.get("privateKeyTag")).getBytes(); - } - - if( soup.containsKey("privateKeyLength") ){ - this.privateKeyLength = ((PacketSection) soup.get("privateKeyLength")).getBytes(); - } - - if( soup.containsKey("privateKey") ){ - this.privateKey = ((PacketSection) soup.get("privateKey")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3742")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3742"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] signatureLen = null; - private byte[] signature = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV私钥格式不对(Util.hexString2Bytes("3034")), - OPV无效的算法标识(Util.hexString2Bytes("3036")), - OPV无效的附加标识(Util.hexString2Bytes("3037")), - OPV密钥奇偶校验错误(Util.hexString2Bytes("3130")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVDSP错误(Util.hexString2Bytes("3437")), - OPV公钥长度错误(Util.hexString2Bytes("3736")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return "私钥格式不对"; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return "无效的算法标识"; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return "无效的附加标识"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "密钥奇偶校验错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return "DSP 错误"; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return "公钥长度错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 8; - } - return null; - } - - - public byte[] getSignatureLenAsBin( ) { - - return this.signatureLen; - } - - - public String getSignatureLenAsStr( ) { - - if( null == this.signatureLen) return null; - return Arrays.toString(this.signatureLen); - } - - - public String getSignatureLenAsHex( ) { - - if( null == this.signatureLen) return null; - return Util.bytes2HexString(signatureLen); - } - - - public Data setSignatureLen( byte[] bytes ) { - - this.signatureLen = bytes; - return this; - } - - - public byte[] getSignatureAsBin( ) { - - return this.signature; - } - - - public String getSignatureAsStr( ) { - - if( null == this.signature) return null; - return Arrays.toString(this.signature); - } - - - public String getSignatureAsHex( ) { - - if( null == this.signature) return null; - return Util.bytes2HexString(signature); - } - - - public Data setSignature( byte[] bytes ) { - - this.signature = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != signatureLen ){ - soup.put("signatureLen", this.signatureLen); - } - - if( null != signature ){ - soup.put("signature", this.signature); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("signatureLen") ){ - this.signatureLen = ((PacketSection) soup.get("signatureLen")).getBytes(); - } - - if( soup.containsKey("signature") ){ - this.signature = ((PacketSection) soup.get("signature")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3743")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3743"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO7C.java b/src/main/java/racal/sunyard/main/dto/DTO7C.java deleted file mode 100644 index ab2015b..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO7C.java +++ /dev/null @@ -1,1098 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO7C { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] signatureLen = null; - private byte[] signature = null; - private byte[] signatureDataType = null; - private byte[] hashMark = null; - private byte[] hashData = null; - private byte[] dataLength = null; - private byte[] infoData = null; - private byte[] publicKeyLength = null; - private byte[] publicKey = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getSignatureLenAsBin( ) { - - return this.signatureLen; - } - - - public String getSignatureLenAsStr( ) { - - if( null == this.signatureLen) return null; - return Arrays.toString(this.signatureLen); - } - - - public String getSignatureLenAsHex( ) { - - if( null == this.signatureLen) return null; - return Util.bytes2HexString(signatureLen); - } - - - public Data setSignatureLen( byte[] bytes ) { - - this.signatureLen = bytes; - return this; - } - - - public byte[] getSignatureAsBin( ) { - - return this.signature; - } - - - public String getSignatureAsStr( ) { - - if( null == this.signature) return null; - return Arrays.toString(this.signature); - } - - - public String getSignatureAsHex( ) { - - if( null == this.signature) return null; - return Util.bytes2HexString(signature); - } - - - public Data setSignature( byte[] bytes ) { - - this.signature = bytes; - return this; - } - - - public byte[] getSignatureDataTypeAsBin( ) { - - return this.signatureDataType; - } - - - public String getSignatureDataTypeAsStr( ) { - - if( null == this.signatureDataType) return null; - return Arrays.toString(this.signatureDataType); - } - - - public String getSignatureDataTypeAsHex( ) { - - if( null == this.signatureDataType) return null; - return Util.bytes2HexString(signatureDataType); - } - - - public Data setSignatureDataType( byte[] bytes ) { - - this.signatureDataType = bytes; - return this; - } -public enum SignatureDataTypeOptions { - - OPVHASH(Util.hexString2Bytes("30")), - OPV原数据(Util.hexString2Bytes("31")); - private byte[] bin; - SignatureDataTypeOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getSignatureDataTypeCn( ) { - - if( null == signatureDataType) { return null; } - if( "30".equals(Util.bytes2HexString(this.signatureDataType))) { - return "HASH"; - } - if( "31".equals(Util.bytes2HexString(this.signatureDataType))) { - return "原数据"; - } - return null; - } - - - public Integer getSignatureDataTypeOptionIndex( ) { - - if( null == signatureDataType) { return null; } - if( "30".equals(Util.bytes2HexString(this.signatureDataType))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.signatureDataType))) { - return 1; - } - return null; - } - - - public byte[] getHashMarkAsBin( ) { - - return this.hashMark; - } - - - public String getHashMarkAsStr( ) { - - if( null == this.hashMark) return null; - return Arrays.toString(this.hashMark); - } - - - public String getHashMarkAsHex( ) { - - if( null == this.hashMark) return null; - return Util.bytes2HexString(hashMark); - } - - - public Data setHashMark( byte[] bytes ) { - - this.hashMark = bytes; - return this; - } -public enum HashMarkOptions { - - OPVSHA1(Util.hexString2Bytes("30")), - OPVSHA256(Util.hexString2Bytes("31")), - OPVMD5(Util.hexString2Bytes("32")); - private byte[] bin; - HashMarkOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getHashMarkCn( ) { - - if( null == hashMark) { return null; } - if( "30".equals(Util.bytes2HexString(this.hashMark))) { - return "SHA1"; - } - if( "31".equals(Util.bytes2HexString(this.hashMark))) { - return "SHA256"; - } - if( "32".equals(Util.bytes2HexString(this.hashMark))) { - return "MD5"; - } - return null; - } - - - public Integer getHashMarkOptionIndex( ) { - - if( null == hashMark) { return null; } - if( "30".equals(Util.bytes2HexString(this.hashMark))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.hashMark))) { - return 1; - } - if( "32".equals(Util.bytes2HexString(this.hashMark))) { - return 2; - } - return null; - } - - - public byte[] getHashDataAsBin( ) { - - return this.hashData; - } - - - public String getHashDataAsStr( ) { - - if( null == this.hashData) return null; - return Arrays.toString(this.hashData); - } - - - public String getHashDataAsHex( ) { - - if( null == this.hashData) return null; - return Util.bytes2HexString(hashData); - } - - - public Data setHashData( byte[] bytes ) { - - this.hashData = bytes; - return this; - } - - - public byte[] getDataLengthAsBin( ) { - - return this.dataLength; - } - - - public String getDataLengthAsStr( ) { - - if( null == this.dataLength) return null; - return Arrays.toString(this.dataLength); - } - - - public String getDataLengthAsHex( ) { - - if( null == this.dataLength) return null; - return Util.bytes2HexString(dataLength); - } - - - public Data setDataLength( byte[] bytes ) { - - this.dataLength = bytes; - return this; - } - - - public byte[] getInfoDataAsBin( ) { - - return this.infoData; - } - - - public String getInfoDataAsStr( ) { - - if( null == this.infoData) return null; - return Arrays.toString(this.infoData); - } - - - public String getInfoDataAsHex( ) { - - if( null == this.infoData) return null; - return Util.bytes2HexString(infoData); - } - - - public Data setInfoData( byte[] bytes ) { - - this.infoData = bytes; - return this; - } - - - public byte[] getPublicKeyLengthAsBin( ) { - - return this.publicKeyLength; - } - - - public String getPublicKeyLengthAsStr( ) { - - if( null == this.publicKeyLength) return null; - return Arrays.toString(this.publicKeyLength); - } - - - public String getPublicKeyLengthAsHex( ) { - - if( null == this.publicKeyLength) return null; - return Util.bytes2HexString(publicKeyLength); - } - - - public Data setPublicKeyLength( byte[] bytes ) { - - this.publicKeyLength = bytes; - return this; - } - - - public byte[] getPublicKeyAsBin( ) { - - return this.publicKey; - } - - - public String getPublicKeyAsStr( ) { - - if( null == this.publicKey) return null; - return Arrays.toString(this.publicKey); - } - - - public String getPublicKeyAsHex( ) { - - if( null == this.publicKey) return null; - return Util.bytes2HexString(publicKey); - } - - - public Data setPublicKey( byte[] bytes ) { - - this.publicKey = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != signatureLen ){ - soup.put("signatureLen", this.signatureLen); - } - - if( null != signature ){ - soup.put("signature", this.signature); - } - - if( null != signatureDataType ){ - soup.put("signatureDataType", this.signatureDataType); - soup.put("signatureDataType$option", getSignatureDataTypeOptionIndex()); - } - - if( null != hashMark ){ - soup.put("hashMark", this.hashMark); - soup.put("hashMark$option", getHashMarkOptionIndex()); - } - - if( null != hashData ){ - soup.put("hashData", this.hashData); - } - - if( null != dataLength ){ - soup.put("dataLength", this.dataLength); - } - - if( null != infoData ){ - soup.put("infoData", this.infoData); - } - - if( null != publicKeyLength ){ - soup.put("publicKeyLength", this.publicKeyLength); - } - - if( null != publicKey ){ - soup.put("publicKey", this.publicKey); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("signatureLen") ){ - this.signatureLen = ((PacketSection) soup.get("signatureLen")).getBytes(); - } - - if( soup.containsKey("signature") ){ - this.signature = ((PacketSection) soup.get("signature")).getBytes(); - } - - if( soup.containsKey("signatureDataType") ){ - this.signatureDataType = ((PacketSection) soup.get("signatureDataType")).getBytes(); - } - - if( soup.containsKey("hashMark") ){ - this.hashMark = ((PacketSection) soup.get("hashMark")).getBytes(); - } - - if( soup.containsKey("hashData") ){ - this.hashData = ((PacketSection) soup.get("hashData")).getBytes(); - } - - if( soup.containsKey("dataLength") ){ - this.dataLength = ((PacketSection) soup.get("dataLength")).getBytes(); - } - - if( soup.containsKey("infoData") ){ - this.infoData = ((PacketSection) soup.get("infoData")).getBytes(); - } - - if( soup.containsKey("publicKeyLength") ){ - this.publicKeyLength = ((PacketSection) soup.get("publicKeyLength")).getBytes(); - } - - if( soup.containsKey("publicKey") ){ - this.publicKey = ((PacketSection) soup.get("publicKey")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3743")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3743"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV签名校验失败(Util.hexString2Bytes("3032")), - OPV公钥不符合编码规则(Util.hexString2Bytes("3034")), - OPV无效的哈希标识(Util.hexString2Bytes("3035")), - OPV无效的签名标识(Util.hexString2Bytes("3036")), - OPV无效的附加标识(Util.hexString2Bytes("3037")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVDSP错误(Util.hexString2Bytes("3437")), - OPV无效摘要信息语法仅仅无哈希模式(Util.hexString2Bytes("3734")), - OPV公钥长度错误(Util.hexString2Bytes("3736")), - OPV明文数据块错误(Util.hexString2Bytes("3737")), - OPV哈希算法对象标识错误(Util.hexString2Bytes("3739")), - OPV信息长度错(Util.hexString2Bytes("3830")), - OPV签名长度错(Util.hexString2Bytes("3831")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3032".equals(Util.bytes2HexString(this.error))) { - return "签名校验失败"; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return "公钥不符合编码规则"; - } - if( "3035".equals(Util.bytes2HexString(this.error))) { - return "无效的哈希标识"; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return "无效的签名标识"; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return "无效的附加标识"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return "DSP 错误"; - } - if( "3734".equals(Util.bytes2HexString(this.error))) { - return "无效摘要信息语法(仅仅无哈希模式)"; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return "公钥长度错误"; - } - if( "3737".equals(Util.bytes2HexString(this.error))) { - return "明文数据块错误"; - } - if( "3739".equals(Util.bytes2HexString(this.error))) { - return "哈希算法对象标识错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "信息长度错"; - } - if( "3831".equals(Util.bytes2HexString(this.error))) { - return "签名长度错"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3032".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3035".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3734".equals(Util.bytes2HexString(this.error))) { - return 9; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return 10; - } - if( "3737".equals(Util.bytes2HexString(this.error))) { - return 11; - } - if( "3739".equals(Util.bytes2HexString(this.error))) { - return 12; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 13; - } - if( "3831".equals(Util.bytes2HexString(this.error))) { - return 14; - } - return null; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3744")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3744"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO7D.java b/src/main/java/racal/sunyard/main/dto/DTO7D.java deleted file mode 100644 index 96a2568..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO7D.java +++ /dev/null @@ -1,954 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO7D { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] hashType = null; - private byte[] packSn = null; - private byte[] dataLength = null; - private byte[] msg = null; - private byte[] filterDataLen = null; - private byte[] filterData = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getHashTypeAsBin( ) { - - return this.hashType; - } - - - public String getHashTypeAsStr( ) { - - if( null == this.hashType) return null; - return Arrays.toString(this.hashType); - } - - - public String getHashTypeAsHex( ) { - - if( null == this.hashType) return null; - return Util.bytes2HexString(hashType); - } - - - public Data setHashType( byte[] bytes ) { - - this.hashType = bytes; - return this; - } -public enum HashTypeOptions { - - OPVSHA1(Util.hexString2Bytes("30")), - OPVSHA256(Util.hexString2Bytes("31")), - OPVMD5(Util.hexString2Bytes("32")); - private byte[] bin; - HashTypeOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getHashTypeCn( ) { - - if( null == hashType) { return null; } - if( "30".equals(Util.bytes2HexString(this.hashType))) { - return "SHA1"; - } - if( "31".equals(Util.bytes2HexString(this.hashType))) { - return "SHA256"; - } - if( "32".equals(Util.bytes2HexString(this.hashType))) { - return "MD5"; - } - return null; - } - - - public Integer getHashTypeOptionIndex( ) { - - if( null == hashType) { return null; } - if( "30".equals(Util.bytes2HexString(this.hashType))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.hashType))) { - return 1; - } - if( "32".equals(Util.bytes2HexString(this.hashType))) { - return 2; - } - return null; - } - - - public byte[] getPackSnAsBin( ) { - - return this.packSn; - } - - - public String getPackSnAsStr( ) { - - if( null == this.packSn) return null; - return Arrays.toString(this.packSn); - } - - - public String getPackSnAsHex( ) { - - if( null == this.packSn) return null; - return Util.bytes2HexString(packSn); - } - - - public Data setPackSn( byte[] bytes ) { - - this.packSn = bytes; - return this; - } -public enum PackSnOptions { - - OPV仅一块(Util.hexString2Bytes("30")), - OPV第一块(Util.hexString2Bytes("31")), - OPV中间块(Util.hexString2Bytes("32")), - OPV最后块(Util.hexString2Bytes("33")); - private byte[] bin; - PackSnOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getPackSnCn( ) { - - if( null == packSn) { return null; } - if( "30".equals(Util.bytes2HexString(this.packSn))) { - return "仅一块"; - } - if( "31".equals(Util.bytes2HexString(this.packSn))) { - return "第一块"; - } - if( "32".equals(Util.bytes2HexString(this.packSn))) { - return "中间块"; - } - if( "33".equals(Util.bytes2HexString(this.packSn))) { - return "最后块"; - } - return null; - } - - - public Integer getPackSnOptionIndex( ) { - - if( null == packSn) { return null; } - if( "30".equals(Util.bytes2HexString(this.packSn))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.packSn))) { - return 1; - } - if( "32".equals(Util.bytes2HexString(this.packSn))) { - return 2; - } - if( "33".equals(Util.bytes2HexString(this.packSn))) { - return 3; - } - return null; - } - - - public byte[] getDataLengthAsBin( ) { - - return this.dataLength; - } - - - public String getDataLengthAsStr( ) { - - if( null == this.dataLength) return null; - return Arrays.toString(this.dataLength); - } - - - public String getDataLengthAsHex( ) { - - if( null == this.dataLength) return null; - return Util.bytes2HexString(dataLength); - } - - - public Data setDataLength( byte[] bytes ) { - - this.dataLength = bytes; - return this; - } - - - public byte[] getMsgAsBin( ) { - - return this.msg; - } - - - public String getMsgAsStr( ) { - - if( null == this.msg) return null; - return Arrays.toString(this.msg); - } - - - public String getMsgAsHex( ) { - - if( null == this.msg) return null; - return Util.bytes2HexString(msg); - } - - - public Data setMsg( byte[] bytes ) { - - this.msg = bytes; - return this; - } - - - public byte[] getFilterDataLenAsBin( ) { - - return this.filterDataLen; - } - - - public String getFilterDataLenAsStr( ) { - - if( null == this.filterDataLen) return null; - return Arrays.toString(this.filterDataLen); - } - - - public String getFilterDataLenAsHex( ) { - - if( null == this.filterDataLen) return null; - return Util.bytes2HexString(filterDataLen); - } - - - public Data setFilterDataLen( byte[] bytes ) { - - this.filterDataLen = bytes; - return this; - } - - - public byte[] getFilterDataAsBin( ) { - - return this.filterData; - } - - - public String getFilterDataAsStr( ) { - - if( null == this.filterData) return null; - return Arrays.toString(this.filterData); - } - - - public String getFilterDataAsHex( ) { - - if( null == this.filterData) return null; - return Util.bytes2HexString(filterData); - } - - - public Data setFilterData( byte[] bytes ) { - - this.filterData = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != hashType ){ - soup.put("hashType", this.hashType); - soup.put("hashType$option", getHashTypeOptionIndex()); - } - - if( null != packSn ){ - soup.put("packSn", this.packSn); - soup.put("packSn$option", getPackSnOptionIndex()); - } - - if( null != dataLength ){ - soup.put("dataLength", this.dataLength); - } - - if( null != msg ){ - soup.put("msg", this.msg); - } - - if( null != filterDataLen ){ - soup.put("filterDataLen", this.filterDataLen); - } - - if( null != filterData ){ - soup.put("filterData", this.filterData); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("hashType") ){ - this.hashType = ((PacketSection) soup.get("hashType")).getBytes(); - } - - if( soup.containsKey("packSn") ){ - this.packSn = ((PacketSection) soup.get("packSn")).getBytes(); - } - - if( soup.containsKey("dataLength") ){ - this.dataLength = ((PacketSection) soup.get("dataLength")).getBytes(); - } - - if( soup.containsKey("msg") ){ - this.msg = ((PacketSection) soup.get("msg")).getBytes(); - } - - if( soup.containsKey("filterDataLen") ){ - this.filterDataLen = ((PacketSection) soup.get("filterDataLen")).getBytes(); - } - - if( soup.containsKey("filterData") ){ - this.filterData = ((PacketSection) soup.get("filterData")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3744")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3744"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] hash = null; - private byte[] filterDataLen = null; - private byte[] filterData = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV数据长度错(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "数据长度错"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 2; - } - return null; - } - - - public byte[] getHashAsBin( ) { - - return this.hash; - } - - - public String getHashAsStr( ) { - - if( null == this.hash) return null; - return Arrays.toString(this.hash); - } - - - public String getHashAsHex( ) { - - if( null == this.hash) return null; - return Util.bytes2HexString(hash); - } - - - public Data setHash( byte[] bytes ) { - - this.hash = bytes; - return this; - } - - - public byte[] getFilterDataLenAsBin( ) { - - return this.filterDataLen; - } - - - public String getFilterDataLenAsStr( ) { - - if( null == this.filterDataLen) return null; - return Arrays.toString(this.filterDataLen); - } - - - public String getFilterDataLenAsHex( ) { - - if( null == this.filterDataLen) return null; - return Util.bytes2HexString(filterDataLen); - } - - - public Data setFilterDataLen( byte[] bytes ) { - - this.filterDataLen = bytes; - return this; - } - - - public byte[] getFilterDataAsBin( ) { - - return this.filterData; - } - - - public String getFilterDataAsStr( ) { - - if( null == this.filterData) return null; - return Arrays.toString(this.filterData); - } - - - public String getFilterDataAsHex( ) { - - if( null == this.filterData) return null; - return Util.bytes2HexString(filterData); - } - - - public Data setFilterData( byte[] bytes ) { - - this.filterData = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != hash ){ - soup.put("hash", this.hash); - } - - if( null != filterDataLen ){ - soup.put("filterDataLen", this.filterDataLen); - } - - if( null != filterData ){ - soup.put("filterData", this.filterData); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("hash") ){ - this.hash = ((PacketSection) soup.get("hash")).getBytes(); - } - - if( soup.containsKey("filterDataLen") ){ - this.filterDataLen = ((PacketSection) soup.get("filterDataLen")).getBytes(); - } - - if( soup.containsKey("filterData") ){ - this.filterData = ((PacketSection) soup.get("filterData")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3745")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3745"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO7E.java b/src/main/java/racal/sunyard/main/dto/DTO7E.java deleted file mode 100644 index 3176070..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO7E.java +++ /dev/null @@ -1,818 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO7E { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] userCertificateType = null; - private byte[] dNLen = null; - private byte[] dN = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getUserCertificateTypeAsBin( ) { - - return this.userCertificateType; - } - - - public String getUserCertificateTypeAsStr( ) { - - if( null == this.userCertificateType) return null; - return Arrays.toString(this.userCertificateType); - } - - - public String getUserCertificateTypeAsHex( ) { - - if( null == this.userCertificateType) return null; - return Util.bytes2HexString(userCertificateType); - } - - - public Data setUserCertificateType( byte[] bytes ) { - - this.userCertificateType = bytes; - return this; - } -public enum UserCertificateTypeOptions { - - OPV签名证书(Util.hexString2Bytes("30")), - OPV加密证书(Util.hexString2Bytes("31")); - private byte[] bin; - UserCertificateTypeOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getUserCertificateTypeCn( ) { - - if( null == userCertificateType) { return null; } - if( "30".equals(Util.bytes2HexString(this.userCertificateType))) { - return "签名证书"; - } - if( "31".equals(Util.bytes2HexString(this.userCertificateType))) { - return "加密证书"; - } - return null; - } - - - public Integer getUserCertificateTypeOptionIndex( ) { - - if( null == userCertificateType) { return null; } - if( "30".equals(Util.bytes2HexString(this.userCertificateType))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.userCertificateType))) { - return 1; - } - return null; - } - - - public byte[] getDNLenAsBin( ) { - - return this.dNLen; - } - - - public String getDNLenAsStr( ) { - - if( null == this.dNLen) return null; - return Arrays.toString(this.dNLen); - } - - - public String getDNLenAsHex( ) { - - if( null == this.dNLen) return null; - return Util.bytes2HexString(dNLen); - } - - - public Data setDNLen( byte[] bytes ) { - - this.dNLen = bytes; - return this; - } - - - public byte[] getDNAsBin( ) { - - return this.dN; - } - - - public String getDNAsStr( ) { - - if( null == this.dN) return null; - return Arrays.toString(this.dN); - } - - - public String getDNAsHex( ) { - - if( null == this.dN) return null; - return Util.bytes2HexString(dN); - } - - - public Data setDN( byte[] bytes ) { - - this.dN = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != userCertificateType ){ - soup.put("userCertificateType", this.userCertificateType); - soup.put("userCertificateType$option", getUserCertificateTypeOptionIndex()); - } - - if( null != dNLen ){ - soup.put("DNLen", this.dNLen); - } - - if( null != dN ){ - soup.put("DN", this.dN); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("userCertificateType") ){ - this.userCertificateType = ((PacketSection) soup.get("userCertificateType")).getBytes(); - } - - if( soup.containsKey("DNLen") ){ - this.dNLen = ((PacketSection) soup.get("DNLen")).getBytes(); - } - - if( soup.containsKey("DN") ){ - this.dN = ((PacketSection) soup.get("DN")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3745")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3745"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] publicKeyLen = null; - private byte[] publicKey = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV无效的索引值(Util.hexString2Bytes("3231")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效的索引值"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 1; - } - return null; - } - - - public byte[] getPublicKeyLenAsBin( ) { - - return this.publicKeyLen; - } - - - public String getPublicKeyLenAsStr( ) { - - if( null == this.publicKeyLen) return null; - return Arrays.toString(this.publicKeyLen); - } - - - public String getPublicKeyLenAsHex( ) { - - if( null == this.publicKeyLen) return null; - return Util.bytes2HexString(publicKeyLen); - } - - - public Data setPublicKeyLen( byte[] bytes ) { - - this.publicKeyLen = bytes; - return this; - } - - - public byte[] getPublicKeyAsBin( ) { - - return this.publicKey; - } - - - public String getPublicKeyAsStr( ) { - - if( null == this.publicKey) return null; - return Arrays.toString(this.publicKey); - } - - - public String getPublicKeyAsHex( ) { - - if( null == this.publicKey) return null; - return Util.bytes2HexString(publicKey); - } - - - public Data setPublicKey( byte[] bytes ) { - - this.publicKey = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != publicKeyLen ){ - soup.put("publicKeyLen", this.publicKeyLen); - } - - if( null != publicKey ){ - soup.put("publicKey", this.publicKey); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("publicKeyLen") ){ - this.publicKeyLen = ((PacketSection) soup.get("publicKeyLen")).getBytes(); - } - - if( soup.containsKey("publicKey") ){ - this.publicKey = ((PacketSection) soup.get("publicKey")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3746")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3746"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO80.java b/src/main/java/racal/sunyard/main/dto/DTO80.java deleted file mode 100644 index cd66fb9..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO80.java +++ /dev/null @@ -1,879 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO80 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] certificateNoLen = null; - private byte[] certificateNo = null; - private byte[] dataLen = null; - private byte[] infoData = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getCertificateNoLenAsBin( ) { - - return this.certificateNoLen; - } - - - public String getCertificateNoLenAsStr( ) { - - if( null == this.certificateNoLen) return null; - return Arrays.toString(this.certificateNoLen); - } - - - public String getCertificateNoLenAsHex( ) { - - if( null == this.certificateNoLen) return null; - return Util.bytes2HexString(certificateNoLen); - } - - - public Data setCertificateNoLen( byte[] bytes ) { - - this.certificateNoLen = bytes; - return this; - } - - - public byte[] getCertificateNoAsBin( ) { - - return this.certificateNo; - } - - - public String getCertificateNoAsStr( ) { - - if( null == this.certificateNo) return null; - return Arrays.toString(this.certificateNo); - } - - - public String getCertificateNoAsHex( ) { - - if( null == this.certificateNo) return null; - return Util.bytes2HexString(certificateNo); - } - - - public Data setCertificateNo( byte[] bytes ) { - - this.certificateNo = bytes; - return this; - } - - - public byte[] getDataLenAsBin( ) { - - return this.dataLen; - } - - - public String getDataLenAsStr( ) { - - if( null == this.dataLen) return null; - return Arrays.toString(this.dataLen); - } - - - public String getDataLenAsHex( ) { - - if( null == this.dataLen) return null; - return Util.bytes2HexString(dataLen); - } - - - public Data setDataLen( byte[] bytes ) { - - this.dataLen = bytes; - return this; - } - - - public byte[] getInfoDataAsBin( ) { - - return this.infoData; - } - - - public String getInfoDataAsStr( ) { - - if( null == this.infoData) return null; - return Arrays.toString(this.infoData); - } - - - public String getInfoDataAsHex( ) { - - if( null == this.infoData) return null; - return Util.bytes2HexString(infoData); - } - - - public Data setInfoData( byte[] bytes ) { - - this.infoData = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != certificateNoLen ){ - soup.put("certificateNoLen", this.certificateNoLen); - } - - if( null != certificateNo ){ - soup.put("certificateNo", this.certificateNo); - } - - if( null != dataLen ){ - soup.put("dataLen", this.dataLen); - } - - if( null != infoData ){ - soup.put("infoData", this.infoData); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("certificateNoLen") ){ - this.certificateNoLen = ((PacketSection) soup.get("certificateNoLen")).getBytes(); - } - - if( soup.containsKey("certificateNo") ){ - this.certificateNo = ((PacketSection) soup.get("certificateNo")).getBytes(); - } - - if( soup.containsKey("dataLen") ){ - this.dataLen = ((PacketSection) soup.get("dataLen")).getBytes(); - } - - if( soup.containsKey("infoData") ){ - this.infoData = ((PacketSection) soup.get("infoData")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3830")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3830"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] signatureLen = null; - private byte[] signature = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV公钥不符合编码规则(Util.hexString2Bytes("3034")), - OPV无效的加密标识(Util.hexString2Bytes("3036")), - OPV无效的附加模式标识(Util.hexString2Bytes("3037")), - OPV密钥奇偶校验错误(Util.hexString2Bytes("3130")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVDSP错误(Util.hexString2Bytes("3437")), - OPV私钥错误(Util.hexString2Bytes("3439")), - OPV密钥块长度错误(Util.hexString2Bytes("3736")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return "公钥不符合编码规则"; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return "无效的加密标识"; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return "无效的附加模式标识"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "密钥奇偶校验错误"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return "DSP 错误"; - } - if( "3439".equals(Util.bytes2HexString(this.error))) { - return "私钥错误"; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return "密钥块长度错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3439".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return 9; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 10; - } - return null; - } - - - public byte[] getSignatureLenAsBin( ) { - - return this.signatureLen; - } - - - public String getSignatureLenAsStr( ) { - - if( null == this.signatureLen) return null; - return Arrays.toString(this.signatureLen); - } - - - public String getSignatureLenAsHex( ) { - - if( null == this.signatureLen) return null; - return Util.bytes2HexString(signatureLen); - } - - - public Data setSignatureLen( byte[] bytes ) { - - this.signatureLen = bytes; - return this; - } - - - public byte[] getSignatureAsBin( ) { - - return this.signature; - } - - - public String getSignatureAsStr( ) { - - if( null == this.signature) return null; - return Arrays.toString(this.signature); - } - - - public String getSignatureAsHex( ) { - - if( null == this.signature) return null; - return Util.bytes2HexString(signature); - } - - - public Data setSignature( byte[] bytes ) { - - this.signature = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != signatureLen ){ - soup.put("signatureLen", this.signatureLen); - } - - if( null != signature ){ - soup.put("signature", this.signature); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("signatureLen") ){ - this.signatureLen = ((PacketSection) soup.get("signatureLen")).getBytes(); - } - - if( soup.containsKey("signature") ){ - this.signature = ((PacketSection) soup.get("signature")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3831")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3831"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO8003.java b/src/main/java/racal/sunyard/main/dto/DTO8003.java deleted file mode 100644 index 5d459a3..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO8003.java +++ /dev/null @@ -1,864 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO8003 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] signatureDataType = null; - private byte[] dN = null; - private byte[] dataLength = null; - private byte[] data = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getSignatureDataTypeAsBin( ) { - - return this.signatureDataType; - } - - - public String getSignatureDataTypeAsStr( ) { - - if( null == this.signatureDataType) return null; - return Arrays.toString(this.signatureDataType); - } - - - public String getSignatureDataTypeAsHex( ) { - - if( null == this.signatureDataType) return null; - return Util.bytes2HexString(signatureDataType); - } - - - public Data setSignatureDataType( byte[] bytes ) { - - this.signatureDataType = bytes; - return this; - } -public enum SignatureDataTypeOptions { - - OPV索引方式(Util.hexString2Bytes("30")), - OPVDN方式(Util.hexString2Bytes("31")); - private byte[] bin; - SignatureDataTypeOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getSignatureDataTypeCn( ) { - - if( null == signatureDataType) { return null; } - if( "30".equals(Util.bytes2HexString(this.signatureDataType))) { - return "索引方式"; - } - if( "31".equals(Util.bytes2HexString(this.signatureDataType))) { - return "DN 方式"; - } - return null; - } - - - public Integer getSignatureDataTypeOptionIndex( ) { - - if( null == signatureDataType) { return null; } - if( "30".equals(Util.bytes2HexString(this.signatureDataType))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.signatureDataType))) { - return 1; - } - return null; - } - - - public byte[] getDNAsBin( ) { - - return this.dN; - } - - - public String getDNAsStr( ) { - - if( null == this.dN) return null; - return Arrays.toString(this.dN); - } - - - public String getDNAsHex( ) { - - if( null == this.dN) return null; - return Util.bytes2HexString(dN); - } - - - public Data setDN( byte[] bytes ) { - - this.dN = bytes; - return this; - } - - - public byte[] getDataLengthAsBin( ) { - - return this.dataLength; - } - - - public String getDataLengthAsStr( ) { - - if( null == this.dataLength) return null; - return Arrays.toString(this.dataLength); - } - - - public String getDataLengthAsHex( ) { - - if( null == this.dataLength) return null; - return Util.bytes2HexString(dataLength); - } - - - public Data setDataLength( byte[] bytes ) { - - this.dataLength = bytes; - return this; - } - - - public byte[] getDataAsBin( ) { - - return this.data; - } - - - public String getDataAsStr( ) { - - if( null == this.data) return null; - return Arrays.toString(this.data); - } - - - public String getDataAsHex( ) { - - if( null == this.data) return null; - return Util.bytes2HexString(data); - } - - - public Data setData( byte[] bytes ) { - - this.data = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != signatureDataType ){ - soup.put("signatureDataType", this.signatureDataType); - soup.put("signatureDataType$option", getSignatureDataTypeOptionIndex()); - } - - if( null != dN ){ - soup.put("DN", this.dN); - } - - if( null != dataLength ){ - soup.put("dataLength", this.dataLength); - } - - if( null != data ){ - soup.put("data", this.data); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("signatureDataType") ){ - this.signatureDataType = ((PacketSection) soup.get("signatureDataType")).getBytes(); - } - - if( soup.containsKey("DN") ){ - this.dN = ((PacketSection) soup.get("DN")).getBytes(); - } - - if( soup.containsKey("dataLength") ){ - this.dataLength = ((PacketSection) soup.get("dataLength")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = ((PacketSection) soup.get("data")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("8003")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("8003"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] signatureLen = null; - private byte[] signature = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV无效的私钥类型(Util.hexString2Bytes("3033")), - OPV无效私钥标记(Util.hexString2Bytes("3034")), - OPV无效的哈希标识(Util.hexString2Bytes("3035")), - OPV无效的签名标识(Util.hexString2Bytes("3036")), - OPV无效的附加标识(Util.hexString2Bytes("3037")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVDSP错误(Util.hexString2Bytes("3437")), - OPV私钥错误(Util.hexString2Bytes("3439")), - OPV无效摘要信息语法仅仅无哈希模式(Util.hexString2Bytes("3734")), - OPV公钥长度错误(Util.hexString2Bytes("3736")), - OPV私钥长度错误(Util.hexString2Bytes("3738")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3033".equals(Util.bytes2HexString(this.error))) { - return "无效的私钥类型"; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return "无效私钥标记"; - } - if( "3035".equals(Util.bytes2HexString(this.error))) { - return "无效的哈希标识"; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return "无效的签名标识"; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return "无效的附加标识"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return "DSP 错误"; - } - if( "3439".equals(Util.bytes2HexString(this.error))) { - return "私钥错误"; - } - if( "3734".equals(Util.bytes2HexString(this.error))) { - return "无效摘要信息语法(仅仅无哈希模式)"; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return "公钥长度错误"; - } - if( "3738".equals(Util.bytes2HexString(this.error))) { - return "私钥长度错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3033".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3035".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3439".equals(Util.bytes2HexString(this.error))) { - return 9; - } - if( "3734".equals(Util.bytes2HexString(this.error))) { - return 10; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return 11; - } - if( "3738".equals(Util.bytes2HexString(this.error))) { - return 12; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 13; - } - return null; - } - - - public byte[] getSignatureLenAsBin( ) { - - return this.signatureLen; - } - - - public String getSignatureLenAsStr( ) { - - if( null == this.signatureLen) return null; - return Arrays.toString(this.signatureLen); - } - - - public String getSignatureLenAsHex( ) { - - if( null == this.signatureLen) return null; - return Util.bytes2HexString(signatureLen); - } - - - public Data setSignatureLen( byte[] bytes ) { - - this.signatureLen = bytes; - return this; - } - - - public byte[] getSignatureAsBin( ) { - - return this.signature; - } - - - public String getSignatureAsStr( ) { - - if( null == this.signature) return null; - return Arrays.toString(this.signature); - } - - - public String getSignatureAsHex( ) { - - if( null == this.signature) return null; - return Util.bytes2HexString(signature); - } - - - public Data setSignature( byte[] bytes ) { - - this.signature = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != signatureLen ){ - soup.put("signatureLen", this.signatureLen); - } - - if( null != signature ){ - soup.put("signature", this.signature); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("signatureLen") ){ - this.signatureLen = ((PacketSection) soup.get("signatureLen")).getBytes(); - } - - if( soup.containsKey("signature") ){ - this.signature = ((PacketSection) soup.get("signature")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("8004")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("8004"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO8004.java b/src/main/java/racal/sunyard/main/dto/DTO8004.java deleted file mode 100644 index 5fa8fb1..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO8004.java +++ /dev/null @@ -1,994 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO8004 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] signatureDataType = null; - private byte[] dN = null; - private byte[] organizationNumLen = null; - private byte[] organizationNum = null; - private byte[] dataLength = null; - private byte[] data = null; - private byte[] signatureLen = null; - private byte[] signature = null; - private byte[] returnSign = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getSignatureDataTypeAsBin( ) { - - return this.signatureDataType; - } - - - public String getSignatureDataTypeAsStr( ) { - - if( null == this.signatureDataType) return null; - return Arrays.toString(this.signatureDataType); - } - - - public String getSignatureDataTypeAsHex( ) { - - if( null == this.signatureDataType) return null; - return Util.bytes2HexString(signatureDataType); - } - - - public Data setSignatureDataType( byte[] bytes ) { - - this.signatureDataType = bytes; - return this; - } -public enum SignatureDataTypeOptions { - - OPV索引方式(Util.hexString2Bytes("30")), - OPVDN方式(Util.hexString2Bytes("31")), - OPV通过机构号获取(Util.hexString2Bytes("32")); - private byte[] bin; - SignatureDataTypeOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getSignatureDataTypeCn( ) { - - if( null == signatureDataType) { return null; } - if( "30".equals(Util.bytes2HexString(this.signatureDataType))) { - return "索引方式"; - } - if( "31".equals(Util.bytes2HexString(this.signatureDataType))) { - return "DN 方式"; - } - if( "32".equals(Util.bytes2HexString(this.signatureDataType))) { - return "通过机构号获取"; - } - return null; - } - - - public Integer getSignatureDataTypeOptionIndex( ) { - - if( null == signatureDataType) { return null; } - if( "30".equals(Util.bytes2HexString(this.signatureDataType))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.signatureDataType))) { - return 1; - } - if( "32".equals(Util.bytes2HexString(this.signatureDataType))) { - return 2; - } - return null; - } - - - public byte[] getDNAsBin( ) { - - return this.dN; - } - - - public String getDNAsStr( ) { - - if( null == this.dN) return null; - return Arrays.toString(this.dN); - } - - - public String getDNAsHex( ) { - - if( null == this.dN) return null; - return Util.bytes2HexString(dN); - } - - - public Data setDN( byte[] bytes ) { - - this.dN = bytes; - return this; - } - - - public byte[] getOrganizationNumLenAsBin( ) { - - return this.organizationNumLen; - } - - - public String getOrganizationNumLenAsStr( ) { - - if( null == this.organizationNumLen) return null; - return Arrays.toString(this.organizationNumLen); - } - - - public String getOrganizationNumLenAsHex( ) { - - if( null == this.organizationNumLen) return null; - return Util.bytes2HexString(organizationNumLen); - } - - - public Data setOrganizationNumLen( byte[] bytes ) { - - this.organizationNumLen = bytes; - return this; - } - - - public byte[] getOrganizationNumAsBin( ) { - - return this.organizationNum; - } - - - public String getOrganizationNumAsStr( ) { - - if( null == this.organizationNum) return null; - return Arrays.toString(this.organizationNum); - } - - - public String getOrganizationNumAsHex( ) { - - if( null == this.organizationNum) return null; - return Util.bytes2HexString(organizationNum); - } - - - public Data setOrganizationNum( byte[] bytes ) { - - this.organizationNum = bytes; - return this; - } - - - public byte[] getDataLengthAsBin( ) { - - return this.dataLength; - } - - - public String getDataLengthAsStr( ) { - - if( null == this.dataLength) return null; - return Arrays.toString(this.dataLength); - } - - - public String getDataLengthAsHex( ) { - - if( null == this.dataLength) return null; - return Util.bytes2HexString(dataLength); - } - - - public Data setDataLength( byte[] bytes ) { - - this.dataLength = bytes; - return this; - } - - - public byte[] getDataAsBin( ) { - - return this.data; - } - - - public String getDataAsStr( ) { - - if( null == this.data) return null; - return Arrays.toString(this.data); - } - - - public String getDataAsHex( ) { - - if( null == this.data) return null; - return Util.bytes2HexString(data); - } - - - public Data setData( byte[] bytes ) { - - this.data = bytes; - return this; - } - - - public byte[] getSignatureLenAsBin( ) { - - return this.signatureLen; - } - - - public String getSignatureLenAsStr( ) { - - if( null == this.signatureLen) return null; - return Arrays.toString(this.signatureLen); - } - - - public String getSignatureLenAsHex( ) { - - if( null == this.signatureLen) return null; - return Util.bytes2HexString(signatureLen); - } - - - public Data setSignatureLen( byte[] bytes ) { - - this.signatureLen = bytes; - return this; - } - - - public byte[] getSignatureAsBin( ) { - - return this.signature; - } - - - public String getSignatureAsStr( ) { - - if( null == this.signature) return null; - return Arrays.toString(this.signature); - } - - - public String getSignatureAsHex( ) { - - if( null == this.signature) return null; - return Util.bytes2HexString(signature); - } - - - public Data setSignature( byte[] bytes ) { - - this.signature = bytes; - return this; - } - - - public byte[] getReturnSignAsBin( ) { - - return this.returnSign; - } - - - public String getReturnSignAsStr( ) { - - if( null == this.returnSign) return null; - return Arrays.toString(this.returnSign); - } - - - public String getReturnSignAsHex( ) { - - if( null == this.returnSign) return null; - return Util.bytes2HexString(returnSign); - } - - - public Data setReturnSign( byte[] bytes ) { - - this.returnSign = bytes; - return this; - } -public enum ReturnSignOptions { - - OPV不返回(Util.hexString2Bytes("0000")), - OPV返回(Util.hexString2Bytes("0001")); - private byte[] bin; - ReturnSignOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getReturnSignCn( ) { - - if( null == returnSign) { return null; } - if( "0000".equals(Util.bytes2HexString(this.returnSign))) { - return "不返回"; - } - if( "0001".equals(Util.bytes2HexString(this.returnSign))) { - return "返回"; - } - return null; - } - - - public Integer getReturnSignOptionIndex( ) { - - if( null == returnSign) { return null; } - if( "0000".equals(Util.bytes2HexString(this.returnSign))) { - return 0; - } - if( "0001".equals(Util.bytes2HexString(this.returnSign))) { - return 1; - } - return null; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != signatureDataType ){ - soup.put("signatureDataType", this.signatureDataType); - soup.put("signatureDataType$option", getSignatureDataTypeOptionIndex()); - } - - if( null != dN ){ - soup.put("DN", this.dN); - } - - if( null != organizationNumLen ){ - soup.put("organizationNumLen", this.organizationNumLen); - } - - if( null != organizationNum ){ - soup.put("organizationNum", this.organizationNum); - } - - if( null != dataLength ){ - soup.put("dataLength", this.dataLength); - } - - if( null != data ){ - soup.put("data", this.data); - } - - if( null != signatureLen ){ - soup.put("signatureLen", this.signatureLen); - } - - if( null != signature ){ - soup.put("signature", this.signature); - } - - if( null != returnSign ){ - soup.put("returnSign", this.returnSign); - soup.put("returnSign$option", getReturnSignOptionIndex()); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("signatureDataType") ){ - this.signatureDataType = ((PacketSection) soup.get("signatureDataType")).getBytes(); - } - - if( soup.containsKey("DN") ){ - this.dN = ((PacketSection) soup.get("DN")).getBytes(); - } - - if( soup.containsKey("organizationNumLen") ){ - this.organizationNumLen = ((PacketSection) soup.get("organizationNumLen")).getBytes(); - } - - if( soup.containsKey("organizationNum") ){ - this.organizationNum = ((PacketSection) soup.get("organizationNum")).getBytes(); - } - - if( soup.containsKey("dataLength") ){ - this.dataLength = ((PacketSection) soup.get("dataLength")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = ((PacketSection) soup.get("data")).getBytes(); - } - - if( soup.containsKey("signatureLen") ){ - this.signatureLen = ((PacketSection) soup.get("signatureLen")).getBytes(); - } - - if( soup.containsKey("signature") ){ - this.signature = ((PacketSection) soup.get("signature")).getBytes(); - } - - if( soup.containsKey("returnSign") ){ - this.returnSign = ((PacketSection) soup.get("returnSign")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("8004")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("8004"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] infoLen = null; - private byte[] info = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV公钥不符合编码规则(Util.hexString2Bytes("3034")), - OPV无效的加密标识(Util.hexString2Bytes("3036")), - OPV无效的附加模式标识(Util.hexString2Bytes("3037")), - OPV密钥奇偶校验错误(Util.hexString2Bytes("3130")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVDSP错误(Util.hexString2Bytes("3437")), - OPV私钥错误(Util.hexString2Bytes("3439")), - OPV密钥块长度错误(Util.hexString2Bytes("3736")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return "公钥不符合编码规则"; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return "无效的加密标识"; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return "无效的附加模式标识"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "密钥奇偶校验错误"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return "DSP 错误"; - } - if( "3439".equals(Util.bytes2HexString(this.error))) { - return "私钥错误"; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return "密钥块长度错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3439".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return 9; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 10; - } - return null; - } - - - public byte[] getInfoLenAsBin( ) { - - return this.infoLen; - } - - - public String getInfoLenAsStr( ) { - - if( null == this.infoLen) return null; - return Arrays.toString(this.infoLen); - } - - - public String getInfoLenAsHex( ) { - - if( null == this.infoLen) return null; - return Util.bytes2HexString(infoLen); - } - - - public Data setInfoLen( byte[] bytes ) { - - this.infoLen = bytes; - return this; - } - - - public byte[] getInfoAsBin( ) { - - return this.info; - } - - - public String getInfoAsStr( ) { - - if( null == this.info) return null; - return Arrays.toString(this.info); - } - - - public String getInfoAsHex( ) { - - if( null == this.info) return null; - return Util.bytes2HexString(info); - } - - - public Data setInfo( byte[] bytes ) { - - this.info = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != infoLen ){ - soup.put("infoLen", this.infoLen); - } - - if( null != info ){ - soup.put("info", this.info); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("infoLen") ){ - this.infoLen = ((PacketSection) soup.get("infoLen")).getBytes(); - } - - if( soup.containsKey("info") ){ - this.info = ((PacketSection) soup.get("info")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("8005")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("8005"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO8005.java b/src/main/java/racal/sunyard/main/dto/DTO8005.java deleted file mode 100644 index e0f4db7..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO8005.java +++ /dev/null @@ -1,767 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO8005 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] dN = null; - private byte[] hashFlag = null; - private byte[] hash = null; - private byte[] dataLen = null; - private byte[] infoData = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getDNAsBin( ) { - - return this.dN; - } - - - public String getDNAsStr( ) { - - if( null == this.dN) return null; - return Arrays.toString(this.dN); - } - - - public String getDNAsHex( ) { - - if( null == this.dN) return null; - return Util.bytes2HexString(dN); - } - - - public Data setDN( byte[] bytes ) { - - this.dN = bytes; - return this; - } - - - public byte[] getHashFlagAsBin( ) { - - return this.hashFlag; - } - - - public String getHashFlagAsStr( ) { - - if( null == this.hashFlag) return null; - return Arrays.toString(this.hashFlag); - } - - - public String getHashFlagAsHex( ) { - - if( null == this.hashFlag) return null; - return Util.bytes2HexString(hashFlag); - } - - - public Data setHashFlag( byte[] bytes ) { - - this.hashFlag = bytes; - return this; - } - - - public byte[] getHashAsBin( ) { - - return this.hash; - } - - - public String getHashAsStr( ) { - - if( null == this.hash) return null; - return Arrays.toString(this.hash); - } - - - public String getHashAsHex( ) { - - if( null == this.hash) return null; - return Util.bytes2HexString(hash); - } - - - public Data setHash( byte[] bytes ) { - - this.hash = bytes; - return this; - } - - - public byte[] getDataLenAsBin( ) { - - return this.dataLen; - } - - - public String getDataLenAsStr( ) { - - if( null == this.dataLen) return null; - return Arrays.toString(this.dataLen); - } - - - public String getDataLenAsHex( ) { - - if( null == this.dataLen) return null; - return Util.bytes2HexString(dataLen); - } - - - public Data setDataLen( byte[] bytes ) { - - this.dataLen = bytes; - return this; - } - - - public byte[] getInfoDataAsBin( ) { - - return this.infoData; - } - - - public String getInfoDataAsStr( ) { - - if( null == this.infoData) return null; - return Arrays.toString(this.infoData); - } - - - public String getInfoDataAsHex( ) { - - if( null == this.infoData) return null; - return Util.bytes2HexString(infoData); - } - - - public Data setInfoData( byte[] bytes ) { - - this.infoData = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != dN ){ - soup.put("DN", this.dN); - } - - if( null != hashFlag ){ - soup.put("hashFlag", this.hashFlag); - } - - if( null != hash ){ - soup.put("hash", this.hash); - } - - if( null != dataLen ){ - soup.put("dataLen", this.dataLen); - } - - if( null != infoData ){ - soup.put("infoData", this.infoData); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("DN") ){ - this.dN = ((PacketSection) soup.get("DN")).getBytes(); - } - - if( soup.containsKey("hashFlag") ){ - this.hashFlag = ((PacketSection) soup.get("hashFlag")).getBytes(); - } - - if( soup.containsKey("hash") ){ - this.hash = ((PacketSection) soup.get("hash")).getBytes(); - } - - if( soup.containsKey("dataLen") ){ - this.dataLen = ((PacketSection) soup.get("dataLen")).getBytes(); - } - - if( soup.containsKey("infoData") ){ - this.infoData = ((PacketSection) soup.get("infoData")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("8005")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("8005"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] signatureLen = null; - private byte[] signature = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV公钥不符合编码规则(Util.hexString2Bytes("3034")), - OPV无效的加密标识(Util.hexString2Bytes("3036")), - OPV无效的附加模式标识(Util.hexString2Bytes("3037")), - OPV密钥奇偶校验错误(Util.hexString2Bytes("3130")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVDSP错误(Util.hexString2Bytes("3437")), - OPV私钥错误(Util.hexString2Bytes("3439")), - OPV密钥块长度错误(Util.hexString2Bytes("3736")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return "公钥不符合编码规则"; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return "无效的加密标识"; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return "无效的附加模式标识"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "密钥奇偶校验错误"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return "DSP 错误"; - } - if( "3439".equals(Util.bytes2HexString(this.error))) { - return "私钥错误"; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return "密钥块长度错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3439".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return 9; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 10; - } - return null; - } - - - public byte[] getSignatureLenAsBin( ) { - - return this.signatureLen; - } - - - public String getSignatureLenAsStr( ) { - - if( null == this.signatureLen) return null; - return Arrays.toString(this.signatureLen); - } - - - public String getSignatureLenAsHex( ) { - - if( null == this.signatureLen) return null; - return Util.bytes2HexString(signatureLen); - } - - - public Data setSignatureLen( byte[] bytes ) { - - this.signatureLen = bytes; - return this; - } - - - public byte[] getSignatureAsBin( ) { - - return this.signature; - } - - - public String getSignatureAsStr( ) { - - if( null == this.signature) return null; - return Arrays.toString(this.signature); - } - - - public String getSignatureAsHex( ) { - - if( null == this.signature) return null; - return Util.bytes2HexString(signature); - } - - - public Data setSignature( byte[] bytes ) { - - this.signature = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != signatureLen ){ - soup.put("signatureLen", this.signatureLen); - } - - if( null != signature ){ - soup.put("signature", this.signature); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("signatureLen") ){ - this.signatureLen = ((PacketSection) soup.get("signatureLen")).getBytes(); - } - - if( soup.containsKey("signature") ){ - this.signature = ((PacketSection) soup.get("signature")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("8006")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("8006"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO8006.java b/src/main/java/racal/sunyard/main/dto/DTO8006.java deleted file mode 100644 index 33285f0..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO8006.java +++ /dev/null @@ -1,877 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO8006 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] hashFlag = null; - private byte[] hash = null; - private byte[] originLen = null; - private byte[] originData = null; - private byte[] signLen = null; - private byte[] signData = null; - private byte[] flag = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getHashFlagAsBin( ) { - - return this.hashFlag; - } - - - public String getHashFlagAsStr( ) { - - if( null == this.hashFlag) return null; - return Arrays.toString(this.hashFlag); - } - - - public String getHashFlagAsHex( ) { - - if( null == this.hashFlag) return null; - return Util.bytes2HexString(hashFlag); - } - - - public Data setHashFlag( byte[] bytes ) { - - this.hashFlag = bytes; - return this; - } - - - public byte[] getHashAsBin( ) { - - return this.hash; - } - - - public String getHashAsStr( ) { - - if( null == this.hash) return null; - return Arrays.toString(this.hash); - } - - - public String getHashAsHex( ) { - - if( null == this.hash) return null; - return Util.bytes2HexString(hash); - } - - - public Data setHash( byte[] bytes ) { - - this.hash = bytes; - return this; - } - - - public byte[] getOriginLenAsBin( ) { - - return this.originLen; - } - - - public String getOriginLenAsStr( ) { - - if( null == this.originLen) return null; - return Arrays.toString(this.originLen); - } - - - public String getOriginLenAsHex( ) { - - if( null == this.originLen) return null; - return Util.bytes2HexString(originLen); - } - - - public Data setOriginLen( byte[] bytes ) { - - this.originLen = bytes; - return this; - } - - - public byte[] getOriginDataAsBin( ) { - - return this.originData; - } - - - public String getOriginDataAsStr( ) { - - if( null == this.originData) return null; - return Arrays.toString(this.originData); - } - - - public String getOriginDataAsHex( ) { - - if( null == this.originData) return null; - return Util.bytes2HexString(originData); - } - - - public Data setOriginData( byte[] bytes ) { - - this.originData = bytes; - return this; - } - - - public byte[] getSignLenAsBin( ) { - - return this.signLen; - } - - - public String getSignLenAsStr( ) { - - if( null == this.signLen) return null; - return Arrays.toString(this.signLen); - } - - - public String getSignLenAsHex( ) { - - if( null == this.signLen) return null; - return Util.bytes2HexString(signLen); - } - - - public Data setSignLen( byte[] bytes ) { - - this.signLen = bytes; - return this; - } - - - public byte[] getSignDataAsBin( ) { - - return this.signData; - } - - - public String getSignDataAsStr( ) { - - if( null == this.signData) return null; - return Arrays.toString(this.signData); - } - - - public String getSignDataAsHex( ) { - - if( null == this.signData) return null; - return Util.bytes2HexString(signData); - } - - - public Data setSignData( byte[] bytes ) { - - this.signData = bytes; - return this; - } - - - public byte[] getFlagAsBin( ) { - - return this.flag; - } - - - public String getFlagAsStr( ) { - - if( null == this.flag) return null; - return Arrays.toString(this.flag); - } - - - public String getFlagAsHex( ) { - - if( null == this.flag) return null; - return Util.bytes2HexString(flag); - } - - - public Data setFlag( byte[] bytes ) { - - this.flag = bytes; - return this; - } -public enum FlagOptions { - - OPV不返回(Util.hexString2Bytes("0000")), - OPV返回(Util.hexString2Bytes("0001")); - private byte[] bin; - FlagOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getFlagCn( ) { - - if( null == flag) { return null; } - if( "0000".equals(Util.bytes2HexString(this.flag))) { - return "不返回"; - } - if( "0001".equals(Util.bytes2HexString(this.flag))) { - return "返回"; - } - return null; - } - - - public Integer getFlagOptionIndex( ) { - - if( null == flag) { return null; } - if( "0000".equals(Util.bytes2HexString(this.flag))) { - return 0; - } - if( "0001".equals(Util.bytes2HexString(this.flag))) { - return 1; - } - return null; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != hashFlag ){ - soup.put("hashFlag", this.hashFlag); - } - - if( null != hash ){ - soup.put("hash", this.hash); - } - - if( null != originLen ){ - soup.put("originLen", this.originLen); - } - - if( null != originData ){ - soup.put("originData", this.originData); - } - - if( null != signLen ){ - soup.put("signLen", this.signLen); - } - - if( null != signData ){ - soup.put("signData", this.signData); - } - - if( null != flag ){ - soup.put("flag", this.flag); - soup.put("flag$option", getFlagOptionIndex()); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("hashFlag") ){ - this.hashFlag = ((PacketSection) soup.get("hashFlag")).getBytes(); - } - - if( soup.containsKey("hash") ){ - this.hash = ((PacketSection) soup.get("hash")).getBytes(); - } - - if( soup.containsKey("originLen") ){ - this.originLen = ((PacketSection) soup.get("originLen")).getBytes(); - } - - if( soup.containsKey("originData") ){ - this.originData = ((PacketSection) soup.get("originData")).getBytes(); - } - - if( soup.containsKey("signLen") ){ - this.signLen = ((PacketSection) soup.get("signLen")).getBytes(); - } - - if( soup.containsKey("signData") ){ - this.signData = ((PacketSection) soup.get("signData")).getBytes(); - } - - if( soup.containsKey("flag") ){ - this.flag = ((PacketSection) soup.get("flag")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("8006")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("8006"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] infoLen = null; - private byte[] info = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV公钥不符合编码规则(Util.hexString2Bytes("3034")), - OPV无效的加密标识(Util.hexString2Bytes("3036")), - OPV无效的附加模式标识(Util.hexString2Bytes("3037")), - OPV密钥奇偶校验错误(Util.hexString2Bytes("3130")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVDSP错误(Util.hexString2Bytes("3437")), - OPV私钥错误(Util.hexString2Bytes("3439")), - OPV密钥块长度错误(Util.hexString2Bytes("3736")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return "公钥不符合编码规则"; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return "无效的加密标识"; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return "无效的附加模式标识"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "密钥奇偶校验错误"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return "DSP 错误"; - } - if( "3439".equals(Util.bytes2HexString(this.error))) { - return "私钥错误"; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return "密钥块长度错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3439".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return 9; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 10; - } - return null; - } - - - public byte[] getInfoLenAsBin( ) { - - return this.infoLen; - } - - - public String getInfoLenAsStr( ) { - - if( null == this.infoLen) return null; - return Arrays.toString(this.infoLen); - } - - - public String getInfoLenAsHex( ) { - - if( null == this.infoLen) return null; - return Util.bytes2HexString(infoLen); - } - - - public Data setInfoLen( byte[] bytes ) { - - this.infoLen = bytes; - return this; - } - - - public byte[] getInfoAsBin( ) { - - return this.info; - } - - - public String getInfoAsStr( ) { - - if( null == this.info) return null; - return Arrays.toString(this.info); - } - - - public String getInfoAsHex( ) { - - if( null == this.info) return null; - return Util.bytes2HexString(info); - } - - - public Data setInfo( byte[] bytes ) { - - this.info = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != infoLen ){ - soup.put("infoLen", this.infoLen); - } - - if( null != info ){ - soup.put("info", this.info); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("infoLen") ){ - this.infoLen = ((PacketSection) soup.get("infoLen")).getBytes(); - } - - if( soup.containsKey("info") ){ - this.info = ((PacketSection) soup.get("info")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("8007")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("8007"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO8012.java b/src/main/java/racal/sunyard/main/dto/DTO8012.java deleted file mode 100644 index fb41647..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO8012.java +++ /dev/null @@ -1,884 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO8012 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] originLen = null; - private byte[] originData = null; - private byte[] signLen = null; - private byte[] signData = null; - private byte[] flag = null; - private byte[] organizationNumLen = null; - private byte[] organizationNum = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getOriginLenAsBin( ) { - - return this.originLen; - } - - - public String getOriginLenAsStr( ) { - - if( null == this.originLen) return null; - return Arrays.toString(this.originLen); - } - - - public String getOriginLenAsHex( ) { - - if( null == this.originLen) return null; - return Util.bytes2HexString(originLen); - } - - - public Data setOriginLen( byte[] bytes ) { - - this.originLen = bytes; - return this; - } - - - public byte[] getOriginDataAsBin( ) { - - return this.originData; - } - - - public String getOriginDataAsStr( ) { - - if( null == this.originData) return null; - return Arrays.toString(this.originData); - } - - - public String getOriginDataAsHex( ) { - - if( null == this.originData) return null; - return Util.bytes2HexString(originData); - } - - - public Data setOriginData( byte[] bytes ) { - - this.originData = bytes; - return this; - } - - - public byte[] getSignLenAsBin( ) { - - return this.signLen; - } - - - public String getSignLenAsStr( ) { - - if( null == this.signLen) return null; - return Arrays.toString(this.signLen); - } - - - public String getSignLenAsHex( ) { - - if( null == this.signLen) return null; - return Util.bytes2HexString(signLen); - } - - - public Data setSignLen( byte[] bytes ) { - - this.signLen = bytes; - return this; - } - - - public byte[] getSignDataAsBin( ) { - - return this.signData; - } - - - public String getSignDataAsStr( ) { - - if( null == this.signData) return null; - return Arrays.toString(this.signData); - } - - - public String getSignDataAsHex( ) { - - if( null == this.signData) return null; - return Util.bytes2HexString(signData); - } - - - public Data setSignData( byte[] bytes ) { - - this.signData = bytes; - return this; - } - - - public byte[] getFlagAsBin( ) { - - return this.flag; - } - - - public String getFlagAsStr( ) { - - if( null == this.flag) return null; - return Arrays.toString(this.flag); - } - - - public String getFlagAsHex( ) { - - if( null == this.flag) return null; - return Util.bytes2HexString(flag); - } - - - public Data setFlag( byte[] bytes ) { - - this.flag = bytes; - return this; - } -public enum FlagOptions { - - OPV不上载(Util.hexString2Bytes("0000")), - OPV上载并返回证书内容(Util.hexString2Bytes("0001")), - OPV上传并返回证书内容并更新机构号(Util.hexString2Bytes("0002")); - private byte[] bin; - FlagOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getFlagCn( ) { - - if( null == flag) { return null; } - if( "0000".equals(Util.bytes2HexString(this.flag))) { - return "不上载"; - } - if( "0001".equals(Util.bytes2HexString(this.flag))) { - return "上载并返回证书内容"; - } - if( "0002".equals(Util.bytes2HexString(this.flag))) { - return "上传并返回证书内容,并更新机构号"; - } - return null; - } - - - public Integer getFlagOptionIndex( ) { - - if( null == flag) { return null; } - if( "0000".equals(Util.bytes2HexString(this.flag))) { - return 0; - } - if( "0001".equals(Util.bytes2HexString(this.flag))) { - return 1; - } - if( "0002".equals(Util.bytes2HexString(this.flag))) { - return 2; - } - return null; - } - - - public byte[] getOrganizationNumLenAsBin( ) { - - return this.organizationNumLen; - } - - - public String getOrganizationNumLenAsStr( ) { - - if( null == this.organizationNumLen) return null; - return Arrays.toString(this.organizationNumLen); - } - - - public String getOrganizationNumLenAsHex( ) { - - if( null == this.organizationNumLen) return null; - return Util.bytes2HexString(organizationNumLen); - } - - - public Data setOrganizationNumLen( byte[] bytes ) { - - this.organizationNumLen = bytes; - return this; - } - - - public byte[] getOrganizationNumAsBin( ) { - - return this.organizationNum; - } - - - public String getOrganizationNumAsStr( ) { - - if( null == this.organizationNum) return null; - return Arrays.toString(this.organizationNum); - } - - - public String getOrganizationNumAsHex( ) { - - if( null == this.organizationNum) return null; - return Util.bytes2HexString(organizationNum); - } - - - public Data setOrganizationNum( byte[] bytes ) { - - this.organizationNum = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != originLen ){ - soup.put("originLen", this.originLen); - } - - if( null != originData ){ - soup.put("originData", this.originData); - } - - if( null != signLen ){ - soup.put("signLen", this.signLen); - } - - if( null != signData ){ - soup.put("signData", this.signData); - } - - if( null != flag ){ - soup.put("flag", this.flag); - soup.put("flag$option", getFlagOptionIndex()); - } - - if( null != organizationNumLen ){ - soup.put("organizationNumLen", this.organizationNumLen); - } - - if( null != organizationNum ){ - soup.put("organizationNum", this.organizationNum); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("originLen") ){ - this.originLen = ((PacketSection) soup.get("originLen")).getBytes(); - } - - if( soup.containsKey("originData") ){ - this.originData = ((PacketSection) soup.get("originData")).getBytes(); - } - - if( soup.containsKey("signLen") ){ - this.signLen = ((PacketSection) soup.get("signLen")).getBytes(); - } - - if( soup.containsKey("signData") ){ - this.signData = ((PacketSection) soup.get("signData")).getBytes(); - } - - if( soup.containsKey("flag") ){ - this.flag = ((PacketSection) soup.get("flag")).getBytes(); - } - - if( soup.containsKey("organizationNumLen") ){ - this.organizationNumLen = ((PacketSection) soup.get("organizationNumLen")).getBytes(); - } - - if( soup.containsKey("organizationNum") ){ - this.organizationNum = ((PacketSection) soup.get("organizationNum")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("8012")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("8012"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] infoLen = null; - private byte[] info = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV公钥不符合编码规则(Util.hexString2Bytes("3034")), - OPV无效的加密标识(Util.hexString2Bytes("3036")), - OPV无效的附加模式标识(Util.hexString2Bytes("3037")), - OPV密钥奇偶校验错误(Util.hexString2Bytes("3130")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVDSP错误(Util.hexString2Bytes("3437")), - OPV私钥错误(Util.hexString2Bytes("3439")), - OPV密钥块长度错误(Util.hexString2Bytes("3736")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return "公钥不符合编码规则"; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return "无效的加密标识"; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return "无效的附加模式标识"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "密钥奇偶校验错误"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return "DSP 错误"; - } - if( "3439".equals(Util.bytes2HexString(this.error))) { - return "私钥错误"; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return "密钥块长度错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3439".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return 9; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 10; - } - return null; - } - - - public byte[] getInfoLenAsBin( ) { - - return this.infoLen; - } - - - public String getInfoLenAsStr( ) { - - if( null == this.infoLen) return null; - return Arrays.toString(this.infoLen); - } - - - public String getInfoLenAsHex( ) { - - if( null == this.infoLen) return null; - return Util.bytes2HexString(infoLen); - } - - - public Data setInfoLen( byte[] bytes ) { - - this.infoLen = bytes; - return this; - } - - - public byte[] getInfoAsBin( ) { - - return this.info; - } - - - public String getInfoAsStr( ) { - - if( null == this.info) return null; - return Arrays.toString(this.info); - } - - - public String getInfoAsHex( ) { - - if( null == this.info) return null; - return Util.bytes2HexString(info); - } - - - public Data setInfo( byte[] bytes ) { - - this.info = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != infoLen ){ - soup.put("infoLen", this.infoLen); - } - - if( null != info ){ - soup.put("info", this.info); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("infoLen") ){ - this.infoLen = ((PacketSection) soup.get("infoLen")).getBytes(); - } - - if( soup.containsKey("info") ){ - this.info = ((PacketSection) soup.get("info")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("8013")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("8013"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO8016.java b/src/main/java/racal/sunyard/main/dto/DTO8016.java deleted file mode 100644 index 81d2ddb..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO8016.java +++ /dev/null @@ -1,680 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO8016 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] certLen = null; - private byte[] cert = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getCertLenAsBin( ) { - - return this.certLen; - } - - - public String getCertLenAsStr( ) { - - if( null == this.certLen) return null; - return Arrays.toString(this.certLen); - } - - - public String getCertLenAsHex( ) { - - if( null == this.certLen) return null; - return Util.bytes2HexString(certLen); - } - - - public Data setCertLen( byte[] bytes ) { - - this.certLen = bytes; - return this; - } - - - public byte[] getCertAsBin( ) { - - return this.cert; - } - - - public String getCertAsStr( ) { - - if( null == this.cert) return null; - return Arrays.toString(this.cert); - } - - - public String getCertAsHex( ) { - - if( null == this.cert) return null; - return Util.bytes2HexString(cert); - } - - - public Data setCert( byte[] bytes ) { - - this.cert = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != certLen ){ - soup.put("certLen", this.certLen); - } - - if( null != cert ){ - soup.put("cert", this.cert); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("certLen") ){ - this.certLen = ((PacketSection) soup.get("certLen")).getBytes(); - } - - if( soup.containsKey("cert") ){ - this.cert = ((PacketSection) soup.get("cert")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("8016")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("8016"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] certInfoLen = null; - private byte[] certInfo = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV无效的私钥类型(Util.hexString2Bytes("3033")), - OPV无效私钥标记(Util.hexString2Bytes("3034")), - OPV无效的哈希标识(Util.hexString2Bytes("3035")), - OPV无效的签名标识(Util.hexString2Bytes("3036")), - OPV无效的附加标识(Util.hexString2Bytes("3037")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVDSP错误(Util.hexString2Bytes("3437")), - OPV私钥错误(Util.hexString2Bytes("3439")), - OPV无效摘要信息语法仅仅无哈希模式(Util.hexString2Bytes("3734")), - OPV公钥长度错误(Util.hexString2Bytes("3736")), - OPV私钥长度错误(Util.hexString2Bytes("3738")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3033".equals(Util.bytes2HexString(this.error))) { - return "无效的私钥类型"; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return "无效私钥标记"; - } - if( "3035".equals(Util.bytes2HexString(this.error))) { - return "无效的哈希标识"; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return "无效的签名标识"; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return "无效的附加标识"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return "DSP 错误"; - } - if( "3439".equals(Util.bytes2HexString(this.error))) { - return "私钥错误"; - } - if( "3734".equals(Util.bytes2HexString(this.error))) { - return "无效摘要信息语法(仅仅无哈希模式)"; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return "公钥长度错误"; - } - if( "3738".equals(Util.bytes2HexString(this.error))) { - return "私钥长度错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3033".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3035".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3439".equals(Util.bytes2HexString(this.error))) { - return 9; - } - if( "3734".equals(Util.bytes2HexString(this.error))) { - return 10; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return 11; - } - if( "3738".equals(Util.bytes2HexString(this.error))) { - return 12; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 13; - } - return null; - } - - - public byte[] getCertInfoLenAsBin( ) { - - return this.certInfoLen; - } - - - public String getCertInfoLenAsStr( ) { - - if( null == this.certInfoLen) return null; - return Arrays.toString(this.certInfoLen); - } - - - public String getCertInfoLenAsHex( ) { - - if( null == this.certInfoLen) return null; - return Util.bytes2HexString(certInfoLen); - } - - - public Data setCertInfoLen( byte[] bytes ) { - - this.certInfoLen = bytes; - return this; - } - - - public byte[] getCertInfoAsBin( ) { - - return this.certInfo; - } - - - public String getCertInfoAsStr( ) { - - if( null == this.certInfo) return null; - return Arrays.toString(this.certInfo); - } - - - public String getCertInfoAsHex( ) { - - if( null == this.certInfo) return null; - return Util.bytes2HexString(certInfo); - } - - - public Data setCertInfo( byte[] bytes ) { - - this.certInfo = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != certInfoLen ){ - soup.put("certInfoLen", this.certInfoLen); - } - - if( null != certInfo ){ - soup.put("certInfo", this.certInfo); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("certInfoLen") ){ - this.certInfoLen = ((PacketSection) soup.get("certInfoLen")).getBytes(); - } - - if( soup.containsKey("certInfo") ){ - this.certInfo = ((PacketSection) soup.get("certInfo")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("8017")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("8017"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO8017.java b/src/main/java/racal/sunyard/main/dto/DTO8017.java deleted file mode 100644 index aa0f29d..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO8017.java +++ /dev/null @@ -1,754 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO8017 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] userId = null; - private byte[] type = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getUserIdAsBin( ) { - - return this.userId; - } - - - public String getUserIdAsStr( ) { - - if( null == this.userId) return null; - return Arrays.toString(this.userId); - } - - - public String getUserIdAsHex( ) { - - if( null == this.userId) return null; - return Util.bytes2HexString(userId); - } - - - public Data setUserId( byte[] bytes ) { - - this.userId = bytes; - return this; - } - - - public byte[] getTypeAsBin( ) { - - return this.type; - } - - - public String getTypeAsStr( ) { - - if( null == this.type) return null; - return Arrays.toString(this.type); - } - - - public String getTypeAsHex( ) { - - if( null == this.type) return null; - return Util.bytes2HexString(type); - } - - - public Data setType( byte[] bytes ) { - - this.type = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != userId ){ - soup.put("userId", this.userId); - } - - if( null != type ){ - soup.put("type", this.type); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("userId") ){ - this.userId = ((PacketSection) soup.get("userId")).getBytes(); - } - - if( soup.containsKey("type") ){ - this.type = ((PacketSection) soup.get("type")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("8017")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("8017"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] certLen = null; - private byte[] cert = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV无效的私钥类型(Util.hexString2Bytes("3033")), - OPV无效私钥标记(Util.hexString2Bytes("3034")), - OPV无效的哈希标识(Util.hexString2Bytes("3035")), - OPV无效的签名标识(Util.hexString2Bytes("3036")), - OPV无效的附加标识(Util.hexString2Bytes("3037")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVDSP错误(Util.hexString2Bytes("3437")), - OPV私钥错误(Util.hexString2Bytes("3439")), - OPV无效摘要信息语法仅仅无哈希模式(Util.hexString2Bytes("3734")), - OPV公钥长度错误(Util.hexString2Bytes("3736")), - OPV私钥长度错误(Util.hexString2Bytes("3738")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3033".equals(Util.bytes2HexString(this.error))) { - return "无效的私钥类型"; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return "无效私钥标记"; - } - if( "3035".equals(Util.bytes2HexString(this.error))) { - return "无效的哈希标识"; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return "无效的签名标识"; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return "无效的附加标识"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return "DSP 错误"; - } - if( "3439".equals(Util.bytes2HexString(this.error))) { - return "私钥错误"; - } - if( "3734".equals(Util.bytes2HexString(this.error))) { - return "无效摘要信息语法(仅仅无哈希模式)"; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return "公钥长度错误"; - } - if( "3738".equals(Util.bytes2HexString(this.error))) { - return "私钥长度错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3033".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3035".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3439".equals(Util.bytes2HexString(this.error))) { - return 9; - } - if( "3734".equals(Util.bytes2HexString(this.error))) { - return 10; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return 11; - } - if( "3738".equals(Util.bytes2HexString(this.error))) { - return 12; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 13; - } - return null; - } - - - public byte[] getCertLenAsBin( ) { - - return this.certLen; - } - - - public String getCertLenAsStr( ) { - - if( null == this.certLen) return null; - return Arrays.toString(this.certLen); - } - - - public String getCertLenAsHex( ) { - - if( null == this.certLen) return null; - return Util.bytes2HexString(certLen); - } - - - public Data setCertLen( byte[] bytes ) { - - this.certLen = bytes; - return this; - } - - - public byte[] getCertAsBin( ) { - - return this.cert; - } - - - public String getCertAsStr( ) { - - if( null == this.cert) return null; - return Arrays.toString(this.cert); - } - - - public String getCertAsHex( ) { - - if( null == this.cert) return null; - return Util.bytes2HexString(cert); - } - - - public Data setCert( byte[] bytes ) { - - this.cert = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != certLen ){ - soup.put("certLen", this.certLen); - } - - if( null != cert ){ - soup.put("cert", this.cert); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("certLen") ){ - this.certLen = ((PacketSection) soup.get("certLen")).getBytes(); - } - - if( soup.containsKey("cert") ){ - this.cert = ((PacketSection) soup.get("cert")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("8018")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("8018"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO8018.java b/src/main/java/racal/sunyard/main/dto/DTO8018.java deleted file mode 100644 index f14993b..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO8018.java +++ /dev/null @@ -1,695 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO8018 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] dN = null; - private byte[] dataLen = null; - private byte[] infoData = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getDNAsBin( ) { - - return this.dN; - } - - - public String getDNAsStr( ) { - - if( null == this.dN) return null; - return Arrays.toString(this.dN); - } - - - public String getDNAsHex( ) { - - if( null == this.dN) return null; - return Util.bytes2HexString(dN); - } - - - public Data setDN( byte[] bytes ) { - - this.dN = bytes; - return this; - } - - - public byte[] getDataLenAsBin( ) { - - return this.dataLen; - } - - - public String getDataLenAsStr( ) { - - if( null == this.dataLen) return null; - return Arrays.toString(this.dataLen); - } - - - public String getDataLenAsHex( ) { - - if( null == this.dataLen) return null; - return Util.bytes2HexString(dataLen); - } - - - public Data setDataLen( byte[] bytes ) { - - this.dataLen = bytes; - return this; - } - - - public byte[] getInfoDataAsBin( ) { - - return this.infoData; - } - - - public String getInfoDataAsStr( ) { - - if( null == this.infoData) return null; - return Arrays.toString(this.infoData); - } - - - public String getInfoDataAsHex( ) { - - if( null == this.infoData) return null; - return Util.bytes2HexString(infoData); - } - - - public Data setInfoData( byte[] bytes ) { - - this.infoData = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != dN ){ - soup.put("DN", this.dN); - } - - if( null != dataLen ){ - soup.put("dataLen", this.dataLen); - } - - if( null != infoData ){ - soup.put("infoData", this.infoData); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("DN") ){ - this.dN = ((PacketSection) soup.get("DN")).getBytes(); - } - - if( soup.containsKey("dataLen") ){ - this.dataLen = ((PacketSection) soup.get("dataLen")).getBytes(); - } - - if( soup.containsKey("infoData") ){ - this.infoData = ((PacketSection) soup.get("infoData")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("8018")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("8018"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] signatureLen = null; - private byte[] signature = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV公钥不符合编码规则(Util.hexString2Bytes("3034")), - OPV无效的加密标识(Util.hexString2Bytes("3036")), - OPV无效的附加模式标识(Util.hexString2Bytes("3037")), - OPV密钥奇偶校验错误(Util.hexString2Bytes("3130")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVDSP错误(Util.hexString2Bytes("3437")), - OPV私钥错误(Util.hexString2Bytes("3439")), - OPV密钥块长度错误(Util.hexString2Bytes("3736")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return "公钥不符合编码规则"; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return "无效的加密标识"; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return "无效的附加模式标识"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "密钥奇偶校验错误"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return "DSP 错误"; - } - if( "3439".equals(Util.bytes2HexString(this.error))) { - return "私钥错误"; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return "密钥块长度错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3439".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return 9; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 10; - } - return null; - } - - - public byte[] getSignatureLenAsBin( ) { - - return this.signatureLen; - } - - - public String getSignatureLenAsStr( ) { - - if( null == this.signatureLen) return null; - return Arrays.toString(this.signatureLen); - } - - - public String getSignatureLenAsHex( ) { - - if( null == this.signatureLen) return null; - return Util.bytes2HexString(signatureLen); - } - - - public Data setSignatureLen( byte[] bytes ) { - - this.signatureLen = bytes; - return this; - } - - - public byte[] getSignatureAsBin( ) { - - return this.signature; - } - - - public String getSignatureAsStr( ) { - - if( null == this.signature) return null; - return Arrays.toString(this.signature); - } - - - public String getSignatureAsHex( ) { - - if( null == this.signature) return null; - return Util.bytes2HexString(signature); - } - - - public Data setSignature( byte[] bytes ) { - - this.signature = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != signatureLen ){ - soup.put("signatureLen", this.signatureLen); - } - - if( null != signature ){ - soup.put("signature", this.signature); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("signatureLen") ){ - this.signatureLen = ((PacketSection) soup.get("signatureLen")).getBytes(); - } - - if( soup.containsKey("signature") ){ - this.signature = ((PacketSection) soup.get("signature")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("8006")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("8006"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO8019.java b/src/main/java/racal/sunyard/main/dto/DTO8019.java deleted file mode 100644 index 589d97c..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO8019.java +++ /dev/null @@ -1,769 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO8019 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] dN = null; - private byte[] dataLen = null; - private byte[] infoData = null; - private byte[] flag = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getDNAsBin( ) { - - return this.dN; - } - - - public String getDNAsStr( ) { - - if( null == this.dN) return null; - return Arrays.toString(this.dN); - } - - - public String getDNAsHex( ) { - - if( null == this.dN) return null; - return Util.bytes2HexString(dN); - } - - - public Data setDN( byte[] bytes ) { - - this.dN = bytes; - return this; - } - - - public byte[] getDataLenAsBin( ) { - - return this.dataLen; - } - - - public String getDataLenAsStr( ) { - - if( null == this.dataLen) return null; - return Arrays.toString(this.dataLen); - } - - - public String getDataLenAsHex( ) { - - if( null == this.dataLen) return null; - return Util.bytes2HexString(dataLen); - } - - - public Data setDataLen( byte[] bytes ) { - - this.dataLen = bytes; - return this; - } - - - public byte[] getInfoDataAsBin( ) { - - return this.infoData; - } - - - public String getInfoDataAsStr( ) { - - if( null == this.infoData) return null; - return Arrays.toString(this.infoData); - } - - - public String getInfoDataAsHex( ) { - - if( null == this.infoData) return null; - return Util.bytes2HexString(infoData); - } - - - public Data setInfoData( byte[] bytes ) { - - this.infoData = bytes; - return this; - } - - - public byte[] getFlagAsBin( ) { - - return this.flag; - } - - - public String getFlagAsStr( ) { - - if( null == this.flag) return null; - return Arrays.toString(this.flag); - } - - - public String getFlagAsHex( ) { - - if( null == this.flag) return null; - return Util.bytes2HexString(flag); - } - - - public Data setFlag( byte[] bytes ) { - - this.flag = bytes; - return this; - } -public enum FlagOptions { - - OPV不返回(Util.hexString2Bytes("0000")), - OPV返回(Util.hexString2Bytes("0001")); - private byte[] bin; - FlagOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getFlagCn( ) { - - if( null == flag) { return null; } - if( "0000".equals(Util.bytes2HexString(this.flag))) { - return "不返回"; - } - if( "0001".equals(Util.bytes2HexString(this.flag))) { - return "返回"; - } - return null; - } - - - public Integer getFlagOptionIndex( ) { - - if( null == flag) { return null; } - if( "0000".equals(Util.bytes2HexString(this.flag))) { - return 0; - } - if( "0001".equals(Util.bytes2HexString(this.flag))) { - return 1; - } - return null; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != dN ){ - soup.put("DN", this.dN); - } - - if( null != dataLen ){ - soup.put("dataLen", this.dataLen); - } - - if( null != infoData ){ - soup.put("infoData", this.infoData); - } - - if( null != flag ){ - soup.put("flag", this.flag); - soup.put("flag$option", getFlagOptionIndex()); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("DN") ){ - this.dN = ((PacketSection) soup.get("DN")).getBytes(); - } - - if( soup.containsKey("dataLen") ){ - this.dataLen = ((PacketSection) soup.get("dataLen")).getBytes(); - } - - if( soup.containsKey("infoData") ){ - this.infoData = ((PacketSection) soup.get("infoData")).getBytes(); - } - - if( soup.containsKey("flag") ){ - this.flag = ((PacketSection) soup.get("flag")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("8019")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("8019"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] infoLen = null; - private byte[] info = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV公钥不符合编码规则(Util.hexString2Bytes("3034")), - OPV无效的加密标识(Util.hexString2Bytes("3036")), - OPV无效的附加模式标识(Util.hexString2Bytes("3037")), - OPV密钥奇偶校验错误(Util.hexString2Bytes("3130")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVDSP错误(Util.hexString2Bytes("3437")), - OPV私钥错误(Util.hexString2Bytes("3439")), - OPV密钥块长度错误(Util.hexString2Bytes("3736")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return "公钥不符合编码规则"; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return "无效的加密标识"; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return "无效的附加模式标识"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "密钥奇偶校验错误"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return "DSP 错误"; - } - if( "3439".equals(Util.bytes2HexString(this.error))) { - return "私钥错误"; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return "密钥块长度错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3439".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return 9; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 10; - } - return null; - } - - - public byte[] getInfoLenAsBin( ) { - - return this.infoLen; - } - - - public String getInfoLenAsStr( ) { - - if( null == this.infoLen) return null; - return Arrays.toString(this.infoLen); - } - - - public String getInfoLenAsHex( ) { - - if( null == this.infoLen) return null; - return Util.bytes2HexString(infoLen); - } - - - public Data setInfoLen( byte[] bytes ) { - - this.infoLen = bytes; - return this; - } - - - public byte[] getInfoAsBin( ) { - - return this.info; - } - - - public String getInfoAsStr( ) { - - if( null == this.info) return null; - return Arrays.toString(this.info); - } - - - public String getInfoAsHex( ) { - - if( null == this.info) return null; - return Util.bytes2HexString(info); - } - - - public Data setInfo( byte[] bytes ) { - - this.info = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != infoLen ){ - soup.put("infoLen", this.infoLen); - } - - if( null != info ){ - soup.put("info", this.info); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("infoLen") ){ - this.infoLen = ((PacketSection) soup.get("infoLen")).getBytes(); - } - - if( soup.containsKey("info") ){ - this.info = ((PacketSection) soup.get("info")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("8007")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("8007"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO8024.java b/src/main/java/racal/sunyard/main/dto/DTO8024.java deleted file mode 100644 index c99ab0d..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO8024.java +++ /dev/null @@ -1,767 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO8024 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] keyTag = null; - private byte[] hashFlag = null; - private byte[] hash = null; - private byte[] dataLen = null; - private byte[] infoData = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getKeyTagAsBin( ) { - - return this.keyTag; - } - - - public String getKeyTagAsStr( ) { - - if( null == this.keyTag) return null; - return Arrays.toString(this.keyTag); - } - - - public String getKeyTagAsHex( ) { - - if( null == this.keyTag) return null; - return Util.bytes2HexString(keyTag); - } - - - public Data setKeyTag( byte[] bytes ) { - - this.keyTag = bytes; - return this; - } - - - public byte[] getHashFlagAsBin( ) { - - return this.hashFlag; - } - - - public String getHashFlagAsStr( ) { - - if( null == this.hashFlag) return null; - return Arrays.toString(this.hashFlag); - } - - - public String getHashFlagAsHex( ) { - - if( null == this.hashFlag) return null; - return Util.bytes2HexString(hashFlag); - } - - - public Data setHashFlag( byte[] bytes ) { - - this.hashFlag = bytes; - return this; - } - - - public byte[] getHashAsBin( ) { - - return this.hash; - } - - - public String getHashAsStr( ) { - - if( null == this.hash) return null; - return Arrays.toString(this.hash); - } - - - public String getHashAsHex( ) { - - if( null == this.hash) return null; - return Util.bytes2HexString(hash); - } - - - public Data setHash( byte[] bytes ) { - - this.hash = bytes; - return this; - } - - - public byte[] getDataLenAsBin( ) { - - return this.dataLen; - } - - - public String getDataLenAsStr( ) { - - if( null == this.dataLen) return null; - return Arrays.toString(this.dataLen); - } - - - public String getDataLenAsHex( ) { - - if( null == this.dataLen) return null; - return Util.bytes2HexString(dataLen); - } - - - public Data setDataLen( byte[] bytes ) { - - this.dataLen = bytes; - return this; - } - - - public byte[] getInfoDataAsBin( ) { - - return this.infoData; - } - - - public String getInfoDataAsStr( ) { - - if( null == this.infoData) return null; - return Arrays.toString(this.infoData); - } - - - public String getInfoDataAsHex( ) { - - if( null == this.infoData) return null; - return Util.bytes2HexString(infoData); - } - - - public Data setInfoData( byte[] bytes ) { - - this.infoData = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != keyTag ){ - soup.put("keyTag", this.keyTag); - } - - if( null != hashFlag ){ - soup.put("hashFlag", this.hashFlag); - } - - if( null != hash ){ - soup.put("hash", this.hash); - } - - if( null != dataLen ){ - soup.put("dataLen", this.dataLen); - } - - if( null != infoData ){ - soup.put("infoData", this.infoData); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("keyTag") ){ - this.keyTag = ((PacketSection) soup.get("keyTag")).getBytes(); - } - - if( soup.containsKey("hashFlag") ){ - this.hashFlag = ((PacketSection) soup.get("hashFlag")).getBytes(); - } - - if( soup.containsKey("hash") ){ - this.hash = ((PacketSection) soup.get("hash")).getBytes(); - } - - if( soup.containsKey("dataLen") ){ - this.dataLen = ((PacketSection) soup.get("dataLen")).getBytes(); - } - - if( soup.containsKey("infoData") ){ - this.infoData = ((PacketSection) soup.get("infoData")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("8024")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("8024"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] signatureLen = null; - private byte[] signature = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV公钥不符合编码规则(Util.hexString2Bytes("3034")), - OPV无效的加密标识(Util.hexString2Bytes("3036")), - OPV无效的附加模式标识(Util.hexString2Bytes("3037")), - OPV密钥奇偶校验错误(Util.hexString2Bytes("3130")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVDSP错误(Util.hexString2Bytes("3437")), - OPV私钥错误(Util.hexString2Bytes("3439")), - OPV密钥块长度错误(Util.hexString2Bytes("3736")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return "公钥不符合编码规则"; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return "无效的加密标识"; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return "无效的附加模式标识"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "密钥奇偶校验错误"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return "DSP 错误"; - } - if( "3439".equals(Util.bytes2HexString(this.error))) { - return "私钥错误"; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return "密钥块长度错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3439".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return 9; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 10; - } - return null; - } - - - public byte[] getSignatureLenAsBin( ) { - - return this.signatureLen; - } - - - public String getSignatureLenAsStr( ) { - - if( null == this.signatureLen) return null; - return Arrays.toString(this.signatureLen); - } - - - public String getSignatureLenAsHex( ) { - - if( null == this.signatureLen) return null; - return Util.bytes2HexString(signatureLen); - } - - - public Data setSignatureLen( byte[] bytes ) { - - this.signatureLen = bytes; - return this; - } - - - public byte[] getSignatureAsBin( ) { - - return this.signature; - } - - - public String getSignatureAsStr( ) { - - if( null == this.signature) return null; - return Arrays.toString(this.signature); - } - - - public String getSignatureAsHex( ) { - - if( null == this.signature) return null; - return Util.bytes2HexString(signature); - } - - - public Data setSignature( byte[] bytes ) { - - this.signature = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != signatureLen ){ - soup.put("signatureLen", this.signatureLen); - } - - if( null != signature ){ - soup.put("signature", this.signature); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("signatureLen") ){ - this.signatureLen = ((PacketSection) soup.get("signatureLen")).getBytes(); - } - - if( soup.containsKey("signature") ){ - this.signature = ((PacketSection) soup.get("signature")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("8025")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("8025"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO8025.java b/src/main/java/racal/sunyard/main/dto/DTO8025.java deleted file mode 100644 index bc5fe8f..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO8025.java +++ /dev/null @@ -1,877 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO8025 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] hashFlag = null; - private byte[] hash = null; - private byte[] originLen = null; - private byte[] originData = null; - private byte[] signLen = null; - private byte[] signData = null; - private byte[] flag = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getHashFlagAsBin( ) { - - return this.hashFlag; - } - - - public String getHashFlagAsStr( ) { - - if( null == this.hashFlag) return null; - return Arrays.toString(this.hashFlag); - } - - - public String getHashFlagAsHex( ) { - - if( null == this.hashFlag) return null; - return Util.bytes2HexString(hashFlag); - } - - - public Data setHashFlag( byte[] bytes ) { - - this.hashFlag = bytes; - return this; - } - - - public byte[] getHashAsBin( ) { - - return this.hash; - } - - - public String getHashAsStr( ) { - - if( null == this.hash) return null; - return Arrays.toString(this.hash); - } - - - public String getHashAsHex( ) { - - if( null == this.hash) return null; - return Util.bytes2HexString(hash); - } - - - public Data setHash( byte[] bytes ) { - - this.hash = bytes; - return this; - } - - - public byte[] getOriginLenAsBin( ) { - - return this.originLen; - } - - - public String getOriginLenAsStr( ) { - - if( null == this.originLen) return null; - return Arrays.toString(this.originLen); - } - - - public String getOriginLenAsHex( ) { - - if( null == this.originLen) return null; - return Util.bytes2HexString(originLen); - } - - - public Data setOriginLen( byte[] bytes ) { - - this.originLen = bytes; - return this; - } - - - public byte[] getOriginDataAsBin( ) { - - return this.originData; - } - - - public String getOriginDataAsStr( ) { - - if( null == this.originData) return null; - return Arrays.toString(this.originData); - } - - - public String getOriginDataAsHex( ) { - - if( null == this.originData) return null; - return Util.bytes2HexString(originData); - } - - - public Data setOriginData( byte[] bytes ) { - - this.originData = bytes; - return this; - } - - - public byte[] getSignLenAsBin( ) { - - return this.signLen; - } - - - public String getSignLenAsStr( ) { - - if( null == this.signLen) return null; - return Arrays.toString(this.signLen); - } - - - public String getSignLenAsHex( ) { - - if( null == this.signLen) return null; - return Util.bytes2HexString(signLen); - } - - - public Data setSignLen( byte[] bytes ) { - - this.signLen = bytes; - return this; - } - - - public byte[] getSignDataAsBin( ) { - - return this.signData; - } - - - public String getSignDataAsStr( ) { - - if( null == this.signData) return null; - return Arrays.toString(this.signData); - } - - - public String getSignDataAsHex( ) { - - if( null == this.signData) return null; - return Util.bytes2HexString(signData); - } - - - public Data setSignData( byte[] bytes ) { - - this.signData = bytes; - return this; - } - - - public byte[] getFlagAsBin( ) { - - return this.flag; - } - - - public String getFlagAsStr( ) { - - if( null == this.flag) return null; - return Arrays.toString(this.flag); - } - - - public String getFlagAsHex( ) { - - if( null == this.flag) return null; - return Util.bytes2HexString(flag); - } - - - public Data setFlag( byte[] bytes ) { - - this.flag = bytes; - return this; - } -public enum FlagOptions { - - OPV不返回(Util.hexString2Bytes("0000")), - OPV返回(Util.hexString2Bytes("0001")); - private byte[] bin; - FlagOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getFlagCn( ) { - - if( null == flag) { return null; } - if( "0000".equals(Util.bytes2HexString(this.flag))) { - return "不返回"; - } - if( "0001".equals(Util.bytes2HexString(this.flag))) { - return "返回"; - } - return null; - } - - - public Integer getFlagOptionIndex( ) { - - if( null == flag) { return null; } - if( "0000".equals(Util.bytes2HexString(this.flag))) { - return 0; - } - if( "0001".equals(Util.bytes2HexString(this.flag))) { - return 1; - } - return null; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != hashFlag ){ - soup.put("hashFlag", this.hashFlag); - } - - if( null != hash ){ - soup.put("hash", this.hash); - } - - if( null != originLen ){ - soup.put("originLen", this.originLen); - } - - if( null != originData ){ - soup.put("originData", this.originData); - } - - if( null != signLen ){ - soup.put("signLen", this.signLen); - } - - if( null != signData ){ - soup.put("signData", this.signData); - } - - if( null != flag ){ - soup.put("flag", this.flag); - soup.put("flag$option", getFlagOptionIndex()); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("hashFlag") ){ - this.hashFlag = ((PacketSection) soup.get("hashFlag")).getBytes(); - } - - if( soup.containsKey("hash") ){ - this.hash = ((PacketSection) soup.get("hash")).getBytes(); - } - - if( soup.containsKey("originLen") ){ - this.originLen = ((PacketSection) soup.get("originLen")).getBytes(); - } - - if( soup.containsKey("originData") ){ - this.originData = ((PacketSection) soup.get("originData")).getBytes(); - } - - if( soup.containsKey("signLen") ){ - this.signLen = ((PacketSection) soup.get("signLen")).getBytes(); - } - - if( soup.containsKey("signData") ){ - this.signData = ((PacketSection) soup.get("signData")).getBytes(); - } - - if( soup.containsKey("flag") ){ - this.flag = ((PacketSection) soup.get("flag")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("8025")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("8025"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] infoLen = null; - private byte[] info = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV公钥不符合编码规则(Util.hexString2Bytes("3034")), - OPV无效的加密标识(Util.hexString2Bytes("3036")), - OPV无效的附加模式标识(Util.hexString2Bytes("3037")), - OPV密钥奇偶校验错误(Util.hexString2Bytes("3130")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVDSP错误(Util.hexString2Bytes("3437")), - OPV私钥错误(Util.hexString2Bytes("3439")), - OPV密钥块长度错误(Util.hexString2Bytes("3736")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return "公钥不符合编码规则"; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return "无效的加密标识"; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return "无效的附加模式标识"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "密钥奇偶校验错误"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return "DSP 错误"; - } - if( "3439".equals(Util.bytes2HexString(this.error))) { - return "私钥错误"; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return "密钥块长度错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3439".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return 9; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 10; - } - return null; - } - - - public byte[] getInfoLenAsBin( ) { - - return this.infoLen; - } - - - public String getInfoLenAsStr( ) { - - if( null == this.infoLen) return null; - return Arrays.toString(this.infoLen); - } - - - public String getInfoLenAsHex( ) { - - if( null == this.infoLen) return null; - return Util.bytes2HexString(infoLen); - } - - - public Data setInfoLen( byte[] bytes ) { - - this.infoLen = bytes; - return this; - } - - - public byte[] getInfoAsBin( ) { - - return this.info; - } - - - public String getInfoAsStr( ) { - - if( null == this.info) return null; - return Arrays.toString(this.info); - } - - - public String getInfoAsHex( ) { - - if( null == this.info) return null; - return Util.bytes2HexString(info); - } - - - public Data setInfo( byte[] bytes ) { - - this.info = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != infoLen ){ - soup.put("infoLen", this.infoLen); - } - - if( null != info ){ - soup.put("info", this.info); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("infoLen") ){ - this.infoLen = ((PacketSection) soup.get("infoLen")).getBytes(); - } - - if( soup.containsKey("info") ){ - this.info = ((PacketSection) soup.get("info")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("8026")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("8026"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO8026.java b/src/main/java/racal/sunyard/main/dto/DTO8026.java deleted file mode 100644 index 153ba17..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO8026.java +++ /dev/null @@ -1,807 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO8026 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] certificateNoLen = null; - private byte[] certificateNo = null; - private byte[] dataSign = null; - private byte[] hash = null; - private byte[] dataLength = null; - private byte[] infoData = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getCertificateNoLenAsBin( ) { - - return this.certificateNoLen; - } - - - public String getCertificateNoLenAsStr( ) { - - if( null == this.certificateNoLen) return null; - return Arrays.toString(this.certificateNoLen); - } - - - public String getCertificateNoLenAsHex( ) { - - if( null == this.certificateNoLen) return null; - return Util.bytes2HexString(certificateNoLen); - } - - - public Data setCertificateNoLen( byte[] bytes ) { - - this.certificateNoLen = bytes; - return this; - } - - - public byte[] getCertificateNoAsBin( ) { - - return this.certificateNo; - } - - - public String getCertificateNoAsStr( ) { - - if( null == this.certificateNo) return null; - return Arrays.toString(this.certificateNo); - } - - - public String getCertificateNoAsHex( ) { - - if( null == this.certificateNo) return null; - return Util.bytes2HexString(certificateNo); - } - - - public Data setCertificateNo( byte[] bytes ) { - - this.certificateNo = bytes; - return this; - } - - - public byte[] getDataSignAsBin( ) { - - return this.dataSign; - } - - - public String getDataSignAsStr( ) { - - if( null == this.dataSign) return null; - return Arrays.toString(this.dataSign); - } - - - public String getDataSignAsHex( ) { - - if( null == this.dataSign) return null; - return Util.bytes2HexString(dataSign); - } - - - public Data setDataSign( byte[] bytes ) { - - this.dataSign = bytes; - return this; - } - - - public byte[] getHashAsBin( ) { - - return this.hash; - } - - - public String getHashAsStr( ) { - - if( null == this.hash) return null; - return Arrays.toString(this.hash); - } - - - public String getHashAsHex( ) { - - if( null == this.hash) return null; - return Util.bytes2HexString(hash); - } - - - public Data setHash( byte[] bytes ) { - - this.hash = bytes; - return this; - } - - - public byte[] getDataLengthAsBin( ) { - - return this.dataLength; - } - - - public String getDataLengthAsStr( ) { - - if( null == this.dataLength) return null; - return Arrays.toString(this.dataLength); - } - - - public String getDataLengthAsHex( ) { - - if( null == this.dataLength) return null; - return Util.bytes2HexString(dataLength); - } - - - public Data setDataLength( byte[] bytes ) { - - this.dataLength = bytes; - return this; - } - - - public byte[] getInfoDataAsBin( ) { - - return this.infoData; - } - - - public String getInfoDataAsStr( ) { - - if( null == this.infoData) return null; - return Arrays.toString(this.infoData); - } - - - public String getInfoDataAsHex( ) { - - if( null == this.infoData) return null; - return Util.bytes2HexString(infoData); - } - - - public Data setInfoData( byte[] bytes ) { - - this.infoData = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != certificateNoLen ){ - soup.put("certificateNoLen", this.certificateNoLen); - } - - if( null != certificateNo ){ - soup.put("certificateNo", this.certificateNo); - } - - if( null != dataSign ){ - soup.put("dataSign", this.dataSign); - } - - if( null != hash ){ - soup.put("hash", this.hash); - } - - if( null != dataLength ){ - soup.put("dataLength", this.dataLength); - } - - if( null != infoData ){ - soup.put("infoData", this.infoData); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("certificateNoLen") ){ - this.certificateNoLen = ((PacketSection) soup.get("certificateNoLen")).getBytes(); - } - - if( soup.containsKey("certificateNo") ){ - this.certificateNo = ((PacketSection) soup.get("certificateNo")).getBytes(); - } - - if( soup.containsKey("dataSign") ){ - this.dataSign = ((PacketSection) soup.get("dataSign")).getBytes(); - } - - if( soup.containsKey("hash") ){ - this.hash = ((PacketSection) soup.get("hash")).getBytes(); - } - - if( soup.containsKey("dataLength") ){ - this.dataLength = ((PacketSection) soup.get("dataLength")).getBytes(); - } - - if( soup.containsKey("infoData") ){ - this.infoData = ((PacketSection) soup.get("infoData")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("8026")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("8026"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] signatureLen = null; - private byte[] signature = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - return null; - } - - - public byte[] getSignatureLenAsBin( ) { - - return this.signatureLen; - } - - - public String getSignatureLenAsStr( ) { - - if( null == this.signatureLen) return null; - return Arrays.toString(this.signatureLen); - } - - - public String getSignatureLenAsHex( ) { - - if( null == this.signatureLen) return null; - return Util.bytes2HexString(signatureLen); - } - - - public Data setSignatureLen( byte[] bytes ) { - - this.signatureLen = bytes; - return this; - } - - - public byte[] getSignatureAsBin( ) { - - return this.signature; - } - - - public String getSignatureAsStr( ) { - - if( null == this.signature) return null; - return Arrays.toString(this.signature); - } - - - public String getSignatureAsHex( ) { - - if( null == this.signature) return null; - return Util.bytes2HexString(signature); - } - - - public Data setSignature( byte[] bytes ) { - - this.signature = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != signatureLen ){ - soup.put("signatureLen", this.signatureLen); - } - - if( null != signature ){ - soup.put("signature", this.signature); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("signatureLen") ){ - this.signatureLen = ((PacketSection) soup.get("signatureLen")).getBytes(); - } - - if( soup.containsKey("signature") ){ - this.signature = ((PacketSection) soup.get("signature")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("8027")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("8027"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO81.java b/src/main/java/racal/sunyard/main/dto/DTO81.java deleted file mode 100644 index 9f35aea..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO81.java +++ /dev/null @@ -1,872 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO81 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] certificateNoLen = null; - private byte[] certificateNo = null; - private byte[] dataLength = null; - private byte[] infoData = null; - private byte[] signatureLen = null; - private byte[] signature = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getCertificateNoLenAsBin( ) { - - return this.certificateNoLen; - } - - - public String getCertificateNoLenAsStr( ) { - - if( null == this.certificateNoLen) return null; - return Arrays.toString(this.certificateNoLen); - } - - - public String getCertificateNoLenAsHex( ) { - - if( null == this.certificateNoLen) return null; - return Util.bytes2HexString(certificateNoLen); - } - - - public Data setCertificateNoLen( byte[] bytes ) { - - this.certificateNoLen = bytes; - return this; - } - - - public byte[] getCertificateNoAsBin( ) { - - return this.certificateNo; - } - - - public String getCertificateNoAsStr( ) { - - if( null == this.certificateNo) return null; - return Arrays.toString(this.certificateNo); - } - - - public String getCertificateNoAsHex( ) { - - if( null == this.certificateNo) return null; - return Util.bytes2HexString(certificateNo); - } - - - public Data setCertificateNo( byte[] bytes ) { - - this.certificateNo = bytes; - return this; - } - - - public byte[] getDataLengthAsBin( ) { - - return this.dataLength; - } - - - public String getDataLengthAsStr( ) { - - if( null == this.dataLength) return null; - return Arrays.toString(this.dataLength); - } - - - public String getDataLengthAsHex( ) { - - if( null == this.dataLength) return null; - return Util.bytes2HexString(dataLength); - } - - - public Data setDataLength( byte[] bytes ) { - - this.dataLength = bytes; - return this; - } - - - public byte[] getInfoDataAsBin( ) { - - return this.infoData; - } - - - public String getInfoDataAsStr( ) { - - if( null == this.infoData) return null; - return Arrays.toString(this.infoData); - } - - - public String getInfoDataAsHex( ) { - - if( null == this.infoData) return null; - return Util.bytes2HexString(infoData); - } - - - public Data setInfoData( byte[] bytes ) { - - this.infoData = bytes; - return this; - } - - - public byte[] getSignatureLenAsBin( ) { - - return this.signatureLen; - } - - - public String getSignatureLenAsStr( ) { - - if( null == this.signatureLen) return null; - return Arrays.toString(this.signatureLen); - } - - - public String getSignatureLenAsHex( ) { - - if( null == this.signatureLen) return null; - return Util.bytes2HexString(signatureLen); - } - - - public Data setSignatureLen( byte[] bytes ) { - - this.signatureLen = bytes; - return this; - } - - - public byte[] getSignatureAsBin( ) { - - return this.signature; - } - - - public String getSignatureAsStr( ) { - - if( null == this.signature) return null; - return Arrays.toString(this.signature); - } - - - public String getSignatureAsHex( ) { - - if( null == this.signature) return null; - return Util.bytes2HexString(signature); - } - - - public Data setSignature( byte[] bytes ) { - - this.signature = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != certificateNoLen ){ - soup.put("certificateNoLen", this.certificateNoLen); - } - - if( null != certificateNo ){ - soup.put("certificateNo", this.certificateNo); - } - - if( null != dataLength ){ - soup.put("dataLength", this.dataLength); - } - - if( null != infoData ){ - soup.put("infoData", this.infoData); - } - - if( null != signatureLen ){ - soup.put("signatureLen", this.signatureLen); - } - - if( null != signature ){ - soup.put("signature", this.signature); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("certificateNoLen") ){ - this.certificateNoLen = ((PacketSection) soup.get("certificateNoLen")).getBytes(); - } - - if( soup.containsKey("certificateNo") ){ - this.certificateNo = ((PacketSection) soup.get("certificateNo")).getBytes(); - } - - if( soup.containsKey("dataLength") ){ - this.dataLength = ((PacketSection) soup.get("dataLength")).getBytes(); - } - - if( soup.containsKey("infoData") ){ - this.infoData = ((PacketSection) soup.get("infoData")).getBytes(); - } - - if( soup.containsKey("signatureLen") ){ - this.signatureLen = ((PacketSection) soup.get("signatureLen")).getBytes(); - } - - if( soup.containsKey("signature") ){ - this.signature = ((PacketSection) soup.get("signature")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3831")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3831"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV公钥不符合编码规则(Util.hexString2Bytes("3034")), - OPV无效的签名标识(Util.hexString2Bytes("3036")), - OPV无效的附加标识(Util.hexString2Bytes("3037")), - OPV密钥奇偶校验错误(Util.hexString2Bytes("3130")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVDSP错误(Util.hexString2Bytes("3437")), - OPV密钥块长度错误(Util.hexString2Bytes("3736")), - OPV信息长度错(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return "公钥不符合编码规则"; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return "无效的签名标识"; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return "无效的附加标识"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "密钥奇偶校验错误"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return "DSP 错误"; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return "密钥块长度错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "信息长度错"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 9; - } - return null; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3832")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3832"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO82.java b/src/main/java/racal/sunyard/main/dto/DTO82.java deleted file mode 100644 index 51cc031..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO82.java +++ /dev/null @@ -1,914 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO82 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] key_Length = null; - private byte[] key = null; - private byte[] hashType = null; - private byte[] contextInfo_Len = null; - private byte[] contextInfo = null; - private byte[] infoData_Len = null; - private byte[] infoData = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getKey_LengthAsBin( ) { - - return this.key_Length; - } - - - public String getKey_LengthAsStr( ) { - - if( null == this.key_Length) return null; - return Arrays.toString(this.key_Length); - } - - - public String getKey_LengthAsHex( ) { - - if( null == this.key_Length) return null; - return Util.bytes2HexString(key_Length); - } - - - public Data setKey_Length( byte[] bytes ) { - - this.key_Length = bytes; - return this; - } - - - public byte[] getKeyAsBin( ) { - - return this.key; - } - - - public String getKeyAsStr( ) { - - if( null == this.key) return null; - return Arrays.toString(this.key); - } - - - public String getKeyAsHex( ) { - - if( null == this.key) return null; - return Util.bytes2HexString(key); - } - - - public Data setKey( byte[] bytes ) { - - this.key = bytes; - return this; - } - - - public byte[] getHashTypeAsBin( ) { - - return this.hashType; - } - - - public String getHashTypeAsStr( ) { - - if( null == this.hashType) return null; - return Arrays.toString(this.hashType); - } - - - public String getHashTypeAsHex( ) { - - if( null == this.hashType) return null; - return Util.bytes2HexString(hashType); - } - - - public Data setHashType( byte[] bytes ) { - - this.hashType = bytes; - return this; - } -public enum HashTypeOptions { - - OPVSHA1(Util.hexString2Bytes("31")), - OPVSHA256(Util.hexString2Bytes("32")), - OPVSHA384(Util.hexString2Bytes("33")), - OPVSHA512(Util.hexString2Bytes("34")), - OPVSM3(Util.hexString2Bytes("35")); - private byte[] bin; - HashTypeOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getHashTypeCn( ) { - - if( null == hashType) { return null; } - if( "31".equals(Util.bytes2HexString(this.hashType))) { - return "SHA1"; - } - if( "32".equals(Util.bytes2HexString(this.hashType))) { - return "SHA256"; - } - if( "33".equals(Util.bytes2HexString(this.hashType))) { - return "SHA384"; - } - if( "34".equals(Util.bytes2HexString(this.hashType))) { - return "SHA512"; - } - if( "35".equals(Util.bytes2HexString(this.hashType))) { - return "SM3"; - } - return null; - } - - - public Integer getHashTypeOptionIndex( ) { - - if( null == hashType) { return null; } - if( "31".equals(Util.bytes2HexString(this.hashType))) { - return 0; - } - if( "32".equals(Util.bytes2HexString(this.hashType))) { - return 1; - } - if( "33".equals(Util.bytes2HexString(this.hashType))) { - return 2; - } - if( "34".equals(Util.bytes2HexString(this.hashType))) { - return 3; - } - if( "35".equals(Util.bytes2HexString(this.hashType))) { - return 4; - } - return null; - } - - - public byte[] getContextInfo_LenAsBin( ) { - - return this.contextInfo_Len; - } - - - public String getContextInfo_LenAsStr( ) { - - if( null == this.contextInfo_Len) return null; - return Arrays.toString(this.contextInfo_Len); - } - - - public String getContextInfo_LenAsHex( ) { - - if( null == this.contextInfo_Len) return null; - return Util.bytes2HexString(contextInfo_Len); - } - - - public Data setContextInfo_Len( byte[] bytes ) { - - this.contextInfo_Len = bytes; - return this; - } - - - public byte[] getContextInfoAsBin( ) { - - return this.contextInfo; - } - - - public String getContextInfoAsStr( ) { - - if( null == this.contextInfo) return null; - return Arrays.toString(this.contextInfo); - } - - - public String getContextInfoAsHex( ) { - - if( null == this.contextInfo) return null; - return Util.bytes2HexString(contextInfo); - } - - - public Data setContextInfo( byte[] bytes ) { - - this.contextInfo = bytes; - return this; - } - - - public byte[] getInfoData_LenAsBin( ) { - - return this.infoData_Len; - } - - - public String getInfoData_LenAsStr( ) { - - if( null == this.infoData_Len) return null; - return Arrays.toString(this.infoData_Len); - } - - - public String getInfoData_LenAsHex( ) { - - if( null == this.infoData_Len) return null; - return Util.bytes2HexString(infoData_Len); - } - - - public Data setInfoData_Len( byte[] bytes ) { - - this.infoData_Len = bytes; - return this; - } - - - public byte[] getInfoDataAsBin( ) { - - return this.infoData; - } - - - public String getInfoDataAsStr( ) { - - if( null == this.infoData) return null; - return Arrays.toString(this.infoData); - } - - - public String getInfoDataAsHex( ) { - - if( null == this.infoData) return null; - return Util.bytes2HexString(infoData); - } - - - public Data setInfoData( byte[] bytes ) { - - this.infoData = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != key_Length ){ - soup.put("key_Length", this.key_Length); - } - - if( null != key ){ - soup.put("key", this.key); - } - - if( null != hashType ){ - soup.put("hashType", this.hashType); - soup.put("hashType$option", getHashTypeOptionIndex()); - } - - if( null != contextInfo_Len ){ - soup.put("contextInfo_Len", this.contextInfo_Len); - } - - if( null != contextInfo ){ - soup.put("contextInfo", this.contextInfo); - } - - if( null != infoData_Len ){ - soup.put("infoData_Len", this.infoData_Len); - } - - if( null != infoData ){ - soup.put("infoData", this.infoData); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("key_Length") ){ - this.key_Length = ((PacketSection) soup.get("key_Length")).getBytes(); - } - - if( soup.containsKey("key") ){ - this.key = ((PacketSection) soup.get("key")).getBytes(); - } - - if( soup.containsKey("hashType") ){ - this.hashType = ((PacketSection) soup.get("hashType")).getBytes(); - } - - if( soup.containsKey("contextInfo_Len") ){ - this.contextInfo_Len = ((PacketSection) soup.get("contextInfo_Len")).getBytes(); - } - - if( soup.containsKey("contextInfo") ){ - this.contextInfo = ((PacketSection) soup.get("contextInfo")).getBytes(); - } - - if( soup.containsKey("infoData_Len") ){ - this.infoData_Len = ((PacketSection) soup.get("infoData_Len")).getBytes(); - } - - if( soup.containsKey("infoData") ){ - this.infoData = ((PacketSection) soup.get("infoData")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3832")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3832"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] contextInfo_Length = null; - private byte[] contextInfo = null; - private byte[] hMAC_LEN = null; - private byte[] hAMC = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV数据长度错(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "数据长度错"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 2; - } - return null; - } - - - public byte[] getContextInfo_LengthAsBin( ) { - - return this.contextInfo_Length; - } - - - public String getContextInfo_LengthAsStr( ) { - - if( null == this.contextInfo_Length) return null; - return Arrays.toString(this.contextInfo_Length); - } - - - public String getContextInfo_LengthAsHex( ) { - - if( null == this.contextInfo_Length) return null; - return Util.bytes2HexString(contextInfo_Length); - } - - - public Data setContextInfo_Length( byte[] bytes ) { - - this.contextInfo_Length = bytes; - return this; - } - - - public byte[] getContextInfoAsBin( ) { - - return this.contextInfo; - } - - - public String getContextInfoAsStr( ) { - - if( null == this.contextInfo) return null; - return Arrays.toString(this.contextInfo); - } - - - public String getContextInfoAsHex( ) { - - if( null == this.contextInfo) return null; - return Util.bytes2HexString(contextInfo); - } - - - public Data setContextInfo( byte[] bytes ) { - - this.contextInfo = bytes; - return this; - } - - - public byte[] getHMAC_LENAsBin( ) { - - return this.hMAC_LEN; - } - - - public String getHMAC_LENAsStr( ) { - - if( null == this.hMAC_LEN) return null; - return Arrays.toString(this.hMAC_LEN); - } - - - public String getHMAC_LENAsHex( ) { - - if( null == this.hMAC_LEN) return null; - return Util.bytes2HexString(hMAC_LEN); - } - - - public Data setHMAC_LEN( byte[] bytes ) { - - this.hMAC_LEN = bytes; - return this; - } - - - public byte[] getHAMCAsBin( ) { - - return this.hAMC; - } - - - public String getHAMCAsStr( ) { - - if( null == this.hAMC) return null; - return Arrays.toString(this.hAMC); - } - - - public String getHAMCAsHex( ) { - - if( null == this.hAMC) return null; - return Util.bytes2HexString(hAMC); - } - - - public Data setHAMC( byte[] bytes ) { - - this.hAMC = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != contextInfo_Length ){ - soup.put("contextInfo_Length", this.contextInfo_Length); - } - - if( null != contextInfo ){ - soup.put("contextInfo", this.contextInfo); - } - - if( null != hMAC_LEN ){ - soup.put("HMAC_LEN", this.hMAC_LEN); - } - - if( null != hAMC ){ - soup.put("HAMC", this.hAMC); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("contextInfo_Length") ){ - this.contextInfo_Length = ((PacketSection) soup.get("contextInfo_Length")).getBytes(); - } - - if( soup.containsKey("contextInfo") ){ - this.contextInfo = ((PacketSection) soup.get("contextInfo")).getBytes(); - } - - if( soup.containsKey("HMAC_LEN") ){ - this.hMAC_LEN = ((PacketSection) soup.get("HMAC_LEN")).getBytes(); - } - - if( soup.containsKey("HAMC") ){ - this.hAMC = ((PacketSection) soup.get("HAMC")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3833")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3833"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO83.java b/src/main/java/racal/sunyard/main/dto/DTO83.java deleted file mode 100644 index 43c71f1..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO83.java +++ /dev/null @@ -1,1033 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO83 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] cardType = null; - private byte[] algorithmType = null; - private byte[] pattern = null; - private byte[] keyType = null; - private byte[] key = null; - private byte[] cardDispersionFactor = null; - private byte[] aTC = null; - private byte[] aRQC = null; - private byte[] messageLength = null; - private byte[] message = null; - private byte[] aRC = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getCardTypeAsBin( ) { - - return this.cardType; - } - - - public String getCardTypeAsStr( ) { - - if( null == this.cardType) return null; - return Arrays.toString(this.cardType); - } - - - public String getCardTypeAsHex( ) { - - if( null == this.cardType) return null; - return Util.bytes2HexString(cardType); - } - - - public Data setCardType( byte[] bytes ) { - - this.cardType = bytes; - return this; - } -public enum CardTypeOptions { - - OPVVisa(Util.hexString2Bytes("30")), - OPVMaster(Util.hexString2Bytes("31")), - OPVPBOC(Util.hexString2Bytes("32")); - private byte[] bin; - CardTypeOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getCardTypeCn( ) { - - if( null == cardType) { return null; } - if( "30".equals(Util.bytes2HexString(this.cardType))) { - return "Visa"; - } - if( "31".equals(Util.bytes2HexString(this.cardType))) { - return "Master"; - } - if( "32".equals(Util.bytes2HexString(this.cardType))) { - return "PBOC"; - } - return null; - } - - - public Integer getCardTypeOptionIndex( ) { - - if( null == cardType) { return null; } - if( "30".equals(Util.bytes2HexString(this.cardType))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.cardType))) { - return 1; - } - if( "32".equals(Util.bytes2HexString(this.cardType))) { - return 2; - } - return null; - } - - - public byte[] getAlgorithmTypeAsBin( ) { - - return this.algorithmType; - } - - - public String getAlgorithmTypeAsStr( ) { - - if( null == this.algorithmType) return null; - return Arrays.toString(this.algorithmType); - } - - - public String getAlgorithmTypeAsHex( ) { - - if( null == this.algorithmType) return null; - return Util.bytes2HexString(algorithmType); - } - - - public Data setAlgorithmType( byte[] bytes ) { - - this.algorithmType = bytes; - return this; - } -public enum AlgorithmTypeOptions { - - OPV3DES(Util.hexString2Bytes("30")), - OPVSM4(Util.hexString2Bytes("31")); - private byte[] bin; - AlgorithmTypeOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getAlgorithmTypeCn( ) { - - if( null == algorithmType) { return null; } - if( "30".equals(Util.bytes2HexString(this.algorithmType))) { - return "3DES"; - } - if( "31".equals(Util.bytes2HexString(this.algorithmType))) { - return "SM4"; - } - return null; - } - - - public Integer getAlgorithmTypeOptionIndex( ) { - - if( null == algorithmType) { return null; } - if( "30".equals(Util.bytes2HexString(this.algorithmType))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.algorithmType))) { - return 1; - } - return null; - } - - - public byte[] getPatternAsBin( ) { - - return this.pattern; - } - - - public String getPatternAsStr( ) { - - if( null == this.pattern) return null; - return Arrays.toString(this.pattern); - } - - - public String getPatternAsHex( ) { - - if( null == this.pattern) return null; - return Util.bytes2HexString(pattern); - } - - - public Data setPattern( byte[] bytes ) { - - this.pattern = bytes; - return this; - } -public enum PatternOptions { - - OPV只验证ARQC(Util.hexString2Bytes("30")), - OPV验证ARQC验证成功后生成ARPC(Util.hexString2Bytes("31")), - OPV只产生ARPC(Util.hexString2Bytes("32")); - private byte[] bin; - PatternOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getPatternCn( ) { - - if( null == pattern) { return null; } - if( "30".equals(Util.bytes2HexString(this.pattern))) { - return "只验证ARQC"; - } - if( "31".equals(Util.bytes2HexString(this.pattern))) { - return "验证ARQC,验证成功后生成 ARPC"; - } - if( "32".equals(Util.bytes2HexString(this.pattern))) { - return "只产生ARPC"; - } - return null; - } - - - public Integer getPatternOptionIndex( ) { - - if( null == pattern) { return null; } - if( "30".equals(Util.bytes2HexString(this.pattern))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.pattern))) { - return 1; - } - if( "32".equals(Util.bytes2HexString(this.pattern))) { - return 2; - } - return null; - } - - - public byte[] getKeyTypeAsBin( ) { - - return this.keyType; - } - - - public String getKeyTypeAsStr( ) { - - if( null == this.keyType) return null; - return Arrays.toString(this.keyType); - } - - - public String getKeyTypeAsHex( ) { - - if( null == this.keyType) return null; - return Util.bytes2HexString(keyType); - } - - - public Data setKeyType( byte[] bytes ) { - - this.keyType = bytes; - return this; - } - - - public byte[] getKeyAsBin( ) { - - return this.key; - } - - - public String getKeyAsStr( ) { - - if( null == this.key) return null; - return Arrays.toString(this.key); - } - - - public String getKeyAsHex( ) { - - if( null == this.key) return null; - return Util.bytes2HexString(key); - } - - - public Data setKey( byte[] bytes ) { - - this.key = bytes; - return this; - } - - - public byte[] getCardDispersionFactorAsBin( ) { - - return this.cardDispersionFactor; - } - - - public String getCardDispersionFactorAsStr( ) { - - if( null == this.cardDispersionFactor) return null; - return Arrays.toString(this.cardDispersionFactor); - } - - - public String getCardDispersionFactorAsHex( ) { - - if( null == this.cardDispersionFactor) return null; - return Util.bytes2HexString(cardDispersionFactor); - } - - - public Data setCardDispersionFactor( byte[] bytes ) { - - this.cardDispersionFactor = bytes; - return this; - } - - - public byte[] getATCAsBin( ) { - - return this.aTC; - } - - - public String getATCAsStr( ) { - - if( null == this.aTC) return null; - return Arrays.toString(this.aTC); - } - - - public String getATCAsHex( ) { - - if( null == this.aTC) return null; - return Util.bytes2HexString(aTC); - } - - - public Data setATC( byte[] bytes ) { - - this.aTC = bytes; - return this; - } - - - public byte[] getARQCAsBin( ) { - - return this.aRQC; - } - - - public String getARQCAsStr( ) { - - if( null == this.aRQC) return null; - return Arrays.toString(this.aRQC); - } - - - public String getARQCAsHex( ) { - - if( null == this.aRQC) return null; - return Util.bytes2HexString(aRQC); - } - - - public Data setARQC( byte[] bytes ) { - - this.aRQC = bytes; - return this; - } - - - public byte[] getMessageLengthAsBin( ) { - - return this.messageLength; - } - - - public String getMessageLengthAsStr( ) { - - if( null == this.messageLength) return null; - return Arrays.toString(this.messageLength); - } - - - public String getMessageLengthAsHex( ) { - - if( null == this.messageLength) return null; - return Util.bytes2HexString(messageLength); - } - - - public Data setMessageLength( byte[] bytes ) { - - this.messageLength = bytes; - return this; - } - - - public byte[] getMessageAsBin( ) { - - return this.message; - } - - - public String getMessageAsStr( ) { - - if( null == this.message) return null; - return Arrays.toString(this.message); - } - - - public String getMessageAsHex( ) { - - if( null == this.message) return null; - return Util.bytes2HexString(message); - } - - - public Data setMessage( byte[] bytes ) { - - this.message = bytes; - return this; - } - - - public byte[] getARCAsBin( ) { - - return this.aRC; - } - - - public String getARCAsStr( ) { - - if( null == this.aRC) return null; - return Arrays.toString(this.aRC); - } - - - public String getARCAsHex( ) { - - if( null == this.aRC) return null; - return Util.bytes2HexString(aRC); - } - - - public Data setARC( byte[] bytes ) { - - this.aRC = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != cardType ){ - soup.put("cardType", this.cardType); - soup.put("cardType$option", getCardTypeOptionIndex()); - } - - if( null != algorithmType ){ - soup.put("AlgorithmType", this.algorithmType); - soup.put("AlgorithmType$option", getAlgorithmTypeOptionIndex()); - } - - if( null != pattern ){ - soup.put("pattern", this.pattern); - soup.put("pattern$option", getPatternOptionIndex()); - } - - if( null != keyType ){ - soup.put("keyType", this.keyType); - } - - if( null != key ){ - soup.put("key", this.key); - } - - if( null != cardDispersionFactor ){ - soup.put("cardDispersionFactor", this.cardDispersionFactor); - } - - if( null != aTC ){ - soup.put("ATC", this.aTC); - } - - if( null != aRQC ){ - soup.put("ARQC", this.aRQC); - } - - if( null != messageLength ){ - soup.put("messageLength", this.messageLength); - } - - if( null != message ){ - soup.put("message", this.message); - } - - if( null != aRC ){ - soup.put("ARC", this.aRC); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("cardType") ){ - this.cardType = ((PacketSection) soup.get("cardType")).getBytes(); - } - - if( soup.containsKey("AlgorithmType") ){ - this.algorithmType = ((PacketSection) soup.get("AlgorithmType")).getBytes(); - } - - if( soup.containsKey("pattern") ){ - this.pattern = ((PacketSection) soup.get("pattern")).getBytes(); - } - - if( soup.containsKey("keyType") ){ - this.keyType = ((PacketSection) soup.get("keyType")).getBytes(); - } - - if( soup.containsKey("key") ){ - this.key = ((PacketSection) soup.get("key")).getBytes(); - } - - if( soup.containsKey("cardDispersionFactor") ){ - this.cardDispersionFactor = ((PacketSection) soup.get("cardDispersionFactor")).getBytes(); - } - - if( soup.containsKey("ATC") ){ - this.aTC = ((PacketSection) soup.get("ATC")).getBytes(); - } - - if( soup.containsKey("ARQC") ){ - this.aRQC = ((PacketSection) soup.get("ARQC")).getBytes(); - } - - if( soup.containsKey("messageLength") ){ - this.messageLength = ((PacketSection) soup.get("messageLength")).getBytes(); - } - - if( soup.containsKey("message") ){ - this.message = ((PacketSection) soup.get("message")).getBytes(); - } - - if( soup.containsKey("ARC") ){ - this.aRC = ((PacketSection) soup.get("ARC")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3833")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3833"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] aPRC = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPVARQC校验失败(Util.hexString2Bytes("3037")), - OPVLMK运算错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV数据长度错(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return "ARQC校验失败"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK运算错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "数据长度错"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 4; - } - return null; - } - - - public byte[] getAPRCAsBin( ) { - - return this.aPRC; - } - - - public String getAPRCAsStr( ) { - - if( null == this.aPRC) return null; - return Arrays.toString(this.aPRC); - } - - - public String getAPRCAsHex( ) { - - if( null == this.aPRC) return null; - return Util.bytes2HexString(aPRC); - } - - - public Data setAPRC( byte[] bytes ) { - - this.aPRC = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != aPRC ){ - soup.put("APRC", this.aPRC); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("APRC") ){ - this.aPRC = ((PacketSection) soup.get("APRC")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3834")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3834"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO93.java b/src/main/java/racal/sunyard/main/dto/DTO93.java deleted file mode 100644 index 1f03426..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO93.java +++ /dev/null @@ -1,832 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO93 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] privateKeyLength = null; - private byte[] privateKey = null; - private byte[] publicKeyLength = null; - private byte[] publicKey = null; - private byte[] dataLength = null; - private byte[] data = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getPrivateKeyLengthAsBin( ) { - - return this.privateKeyLength; - } - - - public String getPrivateKeyLengthAsStr( ) { - - if( null == this.privateKeyLength) return null; - return Arrays.toString(this.privateKeyLength); - } - - - public String getPrivateKeyLengthAsHex( ) { - - if( null == this.privateKeyLength) return null; - return Util.bytes2HexString(privateKeyLength); - } - - - public Data setPrivateKeyLength( byte[] bytes ) { - - this.privateKeyLength = bytes; - return this; - } - - - public byte[] getPrivateKeyAsBin( ) { - - return this.privateKey; - } - - - public String getPrivateKeyAsStr( ) { - - if( null == this.privateKey) return null; - return Arrays.toString(this.privateKey); - } - - - public String getPrivateKeyAsHex( ) { - - if( null == this.privateKey) return null; - return Util.bytes2HexString(privateKey); - } - - - public Data setPrivateKey( byte[] bytes ) { - - this.privateKey = bytes; - return this; - } - - - public byte[] getPublicKeyLengthAsBin( ) { - - return this.publicKeyLength; - } - - - public String getPublicKeyLengthAsStr( ) { - - if( null == this.publicKeyLength) return null; - return Arrays.toString(this.publicKeyLength); - } - - - public String getPublicKeyLengthAsHex( ) { - - if( null == this.publicKeyLength) return null; - return Util.bytes2HexString(publicKeyLength); - } - - - public Data setPublicKeyLength( byte[] bytes ) { - - this.publicKeyLength = bytes; - return this; - } - - - public byte[] getPublicKeyAsBin( ) { - - return this.publicKey; - } - - - public String getPublicKeyAsStr( ) { - - if( null == this.publicKey) return null; - return Arrays.toString(this.publicKey); - } - - - public String getPublicKeyAsHex( ) { - - if( null == this.publicKey) return null; - return Util.bytes2HexString(publicKey); - } - - - public Data setPublicKey( byte[] bytes ) { - - this.publicKey = bytes; - return this; - } - - - public byte[] getDataLengthAsBin( ) { - - return this.dataLength; - } - - - public String getDataLengthAsStr( ) { - - if( null == this.dataLength) return null; - return Arrays.toString(this.dataLength); - } - - - public String getDataLengthAsHex( ) { - - if( null == this.dataLength) return null; - return Util.bytes2HexString(dataLength); - } - - - public Data setDataLength( byte[] bytes ) { - - this.dataLength = bytes; - return this; - } - - - public byte[] getDataAsBin( ) { - - return this.data; - } - - - public String getDataAsStr( ) { - - if( null == this.data) return null; - return Arrays.toString(this.data); - } - - - public String getDataAsHex( ) { - - if( null == this.data) return null; - return Util.bytes2HexString(data); - } - - - public Data setData( byte[] bytes ) { - - this.data = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != privateKeyLength ){ - soup.put("privateKeyLength", this.privateKeyLength); - } - - if( null != privateKey ){ - soup.put("privateKey", this.privateKey); - } - - if( null != publicKeyLength ){ - soup.put("publicKeyLength", this.publicKeyLength); - } - - if( null != publicKey ){ - soup.put("publicKey", this.publicKey); - } - - if( null != dataLength ){ - soup.put("dataLength", this.dataLength); - } - - if( null != data ){ - soup.put("data", this.data); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("privateKeyLength") ){ - this.privateKeyLength = ((PacketSection) soup.get("privateKeyLength")).getBytes(); - } - - if( soup.containsKey("privateKey") ){ - this.privateKey = ((PacketSection) soup.get("privateKey")).getBytes(); - } - - if( soup.containsKey("publicKeyLength") ){ - this.publicKeyLength = ((PacketSection) soup.get("publicKeyLength")).getBytes(); - } - - if( soup.containsKey("publicKey") ){ - this.publicKey = ((PacketSection) soup.get("publicKey")).getBytes(); - } - - if( soup.containsKey("dataLength") ){ - this.dataLength = ((PacketSection) soup.get("dataLength")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = ((PacketSection) soup.get("data")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3933")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3933"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] dev = null; - private byte[] signLength = null; - private byte[] sign = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV公钥不符合编码规则(Util.hexString2Bytes("3034")), - OPV无效的签名标识(Util.hexString2Bytes("3036")), - OPV无效的附加标识(Util.hexString2Bytes("3037")), - OPV密钥奇偶校验错误(Util.hexString2Bytes("3130")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVDSP错误(Util.hexString2Bytes("3437")), - OPV密钥块长度错误(Util.hexString2Bytes("3736")), - OPV信息长度错(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return "公钥不符合编码规则"; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return "无效的签名标识"; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return "无效的附加标识"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "密钥奇偶校验错误"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return "DSP 错误"; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return "密钥块长度错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "信息长度错"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 9; - } - return null; - } - - - public byte[] getDevAsBin( ) { - - return this.dev; - } - - - public String getDevAsStr( ) { - - if( null == this.dev) return null; - return Arrays.toString(this.dev); - } - - - public String getDevAsHex( ) { - - if( null == this.dev) return null; - return Util.bytes2HexString(dev); - } - - - public Data setDev( byte[] bytes ) { - - this.dev = bytes; - return this; - } - - - public byte[] getSignLengthAsBin( ) { - - return this.signLength; - } - - - public String getSignLengthAsStr( ) { - - if( null == this.signLength) return null; - return Arrays.toString(this.signLength); - } - - - public String getSignLengthAsHex( ) { - - if( null == this.signLength) return null; - return Util.bytes2HexString(signLength); - } - - - public Data setSignLength( byte[] bytes ) { - - this.signLength = bytes; - return this; - } - - - public byte[] getSignAsBin( ) { - - return this.sign; - } - - - public String getSignAsStr( ) { - - if( null == this.sign) return null; - return Arrays.toString(this.sign); - } - - - public String getSignAsHex( ) { - - if( null == this.sign) return null; - return Util.bytes2HexString(sign); - } - - - public Data setSign( byte[] bytes ) { - - this.sign = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != dev ){ - soup.put("dev", this.dev); - } - - if( null != signLength ){ - soup.put("signLength", this.signLength); - } - - if( null != sign ){ - soup.put("sign", this.sign); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("dev") ){ - this.dev = ((PacketSection) soup.get("dev")).getBytes(); - } - - if( soup.containsKey("signLength") ){ - this.signLength = ((PacketSection) soup.get("signLength")).getBytes(); - } - - if( soup.containsKey("sign") ){ - this.sign = ((PacketSection) soup.get("sign")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3934")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3934"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO94.java b/src/main/java/racal/sunyard/main/dto/DTO94.java deleted file mode 100644 index d260dcb..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO94.java +++ /dev/null @@ -1,868 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO94 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] pkLen = null; - private byte[] pk = null; - private byte[] infoLen = null; - private byte[] info = null; - private byte[] sln = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getPkLenAsBin( ) { - - return this.pkLen; - } - - - public String getPkLenAsStr( ) { - - if( null == this.pkLen) return null; - return Arrays.toString(this.pkLen); - } - - - public String getPkLenAsHex( ) { - - if( null == this.pkLen) return null; - return Util.bytes2HexString(pkLen); - } - - - public Data setPkLen( byte[] bytes ) { - - this.pkLen = bytes; - return this; - } - - - public byte[] getPkAsBin( ) { - - return this.pk; - } - - - public String getPkAsStr( ) { - - if( null == this.pk) return null; - return Arrays.toString(this.pk); - } - - - public String getPkAsHex( ) { - - if( null == this.pk) return null; - return Util.bytes2HexString(pk); - } - - - public Data setPk( byte[] bytes ) { - - this.pk = bytes; - return this; - } - - - public byte[] getInfoLenAsBin( ) { - - return this.infoLen; - } - - - public String getInfoLenAsStr( ) { - - if( null == this.infoLen) return null; - return Arrays.toString(this.infoLen); - } - - - public String getInfoLenAsHex( ) { - - if( null == this.infoLen) return null; - return Util.bytes2HexString(infoLen); - } - - - public Data setInfoLen( byte[] bytes ) { - - this.infoLen = bytes; - return this; - } - - - public byte[] getInfoAsBin( ) { - - return this.info; - } - - - public String getInfoAsStr( ) { - - if( null == this.info) return null; - return Arrays.toString(this.info); - } - - - public String getInfoAsHex( ) { - - if( null == this.info) return null; - return Util.bytes2HexString(info); - } - - - public Data setInfo( byte[] bytes ) { - - this.info = bytes; - return this; - } - - - public byte[] getSlnAsBin( ) { - - return this.sln; - } - - - public String getSlnAsStr( ) { - - if( null == this.sln) return null; - return Arrays.toString(this.sln); - } - - - public String getSlnAsHex( ) { - - if( null == this.sln) return null; - return Util.bytes2HexString(sln); - } - - - public Data setSln( byte[] bytes ) { - - this.sln = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != pkLen ){ - soup.put("pkLen", this.pkLen); - } - - if( null != pk ){ - soup.put("pk", this.pk); - } - - if( null != infoLen ){ - soup.put("infoLen", this.infoLen); - } - - if( null != info ){ - soup.put("info", this.info); - } - - if( null != sln ){ - soup.put("sln", this.sln); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("pkLen") ){ - this.pkLen = ((PacketSection) soup.get("pkLen")).getBytes(); - } - - if( soup.containsKey("pk") ){ - this.pk = ((PacketSection) soup.get("pk")).getBytes(); - } - - if( soup.containsKey("infoLen") ){ - this.infoLen = ((PacketSection) soup.get("infoLen")).getBytes(); - } - - if( soup.containsKey("info") ){ - this.info = ((PacketSection) soup.get("info")).getBytes(); - } - - if( soup.containsKey("sln") ){ - this.sln = ((PacketSection) soup.get("sln")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3934")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3934"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] keyLength = null; - private byte[] key = null; - private byte[] takLmkHead = null; - private byte[] takLmk = null; - private byte[] keyCheck = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV公钥不符合编码规则(Util.hexString2Bytes("3034")), - OPV无效的签名标识(Util.hexString2Bytes("3036")), - OPV无效的附加标识(Util.hexString2Bytes("3037")), - OPV密钥奇偶校验错误(Util.hexString2Bytes("3130")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVDSP错误(Util.hexString2Bytes("3437")), - OPV密钥块长度错误(Util.hexString2Bytes("3736")), - OPV信息长度错(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return "公钥不符合编码规则"; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return "无效的签名标识"; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return "无效的附加标识"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "密钥奇偶校验错误"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return "DSP 错误"; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return "密钥块长度错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "信息长度错"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 9; - } - return null; - } - - - public byte[] getKeyLengthAsBin( ) { - - return this.keyLength; - } - - - public String getKeyLengthAsStr( ) { - - if( null == this.keyLength) return null; - return Arrays.toString(this.keyLength); - } - - - public String getKeyLengthAsHex( ) { - - if( null == this.keyLength) return null; - return Util.bytes2HexString(keyLength); - } - - - public Data setKeyLength( byte[] bytes ) { - - this.keyLength = bytes; - return this; - } - - - public byte[] getKeyAsBin( ) { - - return this.key; - } - - - public String getKeyAsStr( ) { - - if( null == this.key) return null; - return Arrays.toString(this.key); - } - - - public String getKeyAsHex( ) { - - if( null == this.key) return null; - return Util.bytes2HexString(key); - } - - - public Data setKey( byte[] bytes ) { - - this.key = bytes; - return this; - } - - - public byte[] getTakLmkHeadAsBin( ) { - - return this.takLmkHead; - } - - - public String getTakLmkHeadAsStr( ) { - - if( null == this.takLmkHead) return null; - return Arrays.toString(this.takLmkHead); - } - - - public String getTakLmkHeadAsHex( ) { - - if( null == this.takLmkHead) return null; - return Util.bytes2HexString(takLmkHead); - } - - - public Data setTakLmkHead( byte[] bytes ) { - - this.takLmkHead = bytes; - return this; - } - - - public byte[] getTakLmkAsBin( ) { - - return this.takLmk; - } - - - public String getTakLmkAsStr( ) { - - if( null == this.takLmk) return null; - return Arrays.toString(this.takLmk); - } - - - public String getTakLmkAsHex( ) { - - if( null == this.takLmk) return null; - return Util.bytes2HexString(takLmk); - } - - - public Data setTakLmk( byte[] bytes ) { - - this.takLmk = bytes; - return this; - } - - - public byte[] getKeyCheckAsBin( ) { - - return this.keyCheck; - } - - - public String getKeyCheckAsStr( ) { - - if( null == this.keyCheck) return null; - return Arrays.toString(this.keyCheck); - } - - - public String getKeyCheckAsHex( ) { - - if( null == this.keyCheck) return null; - return Util.bytes2HexString(keyCheck); - } - - - public Data setKeyCheck( byte[] bytes ) { - - this.keyCheck = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != keyLength ){ - soup.put("keyLength", this.keyLength); - } - - if( null != key ){ - soup.put("key", this.key); - } - - if( null != takLmkHead ){ - soup.put("takLmkHead", this.takLmkHead); - } - - if( null != takLmk ){ - soup.put("takLmk", this.takLmk); - } - - if( null != keyCheck ){ - soup.put("keyCheck", this.keyCheck); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("keyLength") ){ - this.keyLength = ((PacketSection) soup.get("keyLength")).getBytes(); - } - - if( soup.containsKey("key") ){ - this.key = ((PacketSection) soup.get("key")).getBytes(); - } - - if( soup.containsKey("takLmkHead") ){ - this.takLmkHead = ((PacketSection) soup.get("takLmkHead")).getBytes(); - } - - if( soup.containsKey("takLmk") ){ - this.takLmk = ((PacketSection) soup.get("takLmk")).getBytes(); - } - - if( soup.containsKey("keyCheck") ){ - this.keyCheck = ((PacketSection) soup.get("keyCheck")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3935")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3935"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO95.java b/src/main/java/racal/sunyard/main/dto/DTO95.java deleted file mode 100644 index 2d036ae..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO95.java +++ /dev/null @@ -1,942 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO95 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] privateKeyLength = null; - private byte[] privateKey = null; - private byte[] keyLength = null; - private byte[] key = null; - private byte[] sln = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getPrivateKeyLengthAsBin( ) { - - return this.privateKeyLength; - } - - - public String getPrivateKeyLengthAsStr( ) { - - if( null == this.privateKeyLength) return null; - return Arrays.toString(this.privateKeyLength); - } - - - public String getPrivateKeyLengthAsHex( ) { - - if( null == this.privateKeyLength) return null; - return Util.bytes2HexString(privateKeyLength); - } - - - public Data setPrivateKeyLength( byte[] bytes ) { - - this.privateKeyLength = bytes; - return this; - } - - - public byte[] getPrivateKeyAsBin( ) { - - return this.privateKey; - } - - - public String getPrivateKeyAsStr( ) { - - if( null == this.privateKey) return null; - return Arrays.toString(this.privateKey); - } - - - public String getPrivateKeyAsHex( ) { - - if( null == this.privateKey) return null; - return Util.bytes2HexString(privateKey); - } - - - public Data setPrivateKey( byte[] bytes ) { - - this.privateKey = bytes; - return this; - } - - - public byte[] getKeyLengthAsBin( ) { - - return this.keyLength; - } - - - public String getKeyLengthAsStr( ) { - - if( null == this.keyLength) return null; - return Arrays.toString(this.keyLength); - } - - - public String getKeyLengthAsHex( ) { - - if( null == this.keyLength) return null; - return Util.bytes2HexString(keyLength); - } - - - public Data setKeyLength( byte[] bytes ) { - - this.keyLength = bytes; - return this; - } - - - public byte[] getKeyAsBin( ) { - - return this.key; - } - - - public String getKeyAsStr( ) { - - if( null == this.key) return null; - return Arrays.toString(this.key); - } - - - public String getKeyAsHex( ) { - - if( null == this.key) return null; - return Util.bytes2HexString(key); - } - - - public Data setKey( byte[] bytes ) { - - this.key = bytes; - return this; - } - - - public byte[] getSlnAsBin( ) { - - return this.sln; - } - - - public String getSlnAsStr( ) { - - if( null == this.sln) return null; - return Arrays.toString(this.sln); - } - - - public String getSlnAsHex( ) { - - if( null == this.sln) return null; - return Util.bytes2HexString(sln); - } - - - public Data setSln( byte[] bytes ) { - - this.sln = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != privateKeyLength ){ - soup.put("privateKeyLength", this.privateKeyLength); - } - - if( null != privateKey ){ - soup.put("privateKey", this.privateKey); - } - - if( null != keyLength ){ - soup.put("keyLength", this.keyLength); - } - - if( null != key ){ - soup.put("key", this.key); - } - - if( null != sln ){ - soup.put("sln", this.sln); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("privateKeyLength") ){ - this.privateKeyLength = ((PacketSection) soup.get("privateKeyLength")).getBytes(); - } - - if( soup.containsKey("privateKey") ){ - this.privateKey = ((PacketSection) soup.get("privateKey")).getBytes(); - } - - if( soup.containsKey("keyLength") ){ - this.keyLength = ((PacketSection) soup.get("keyLength")).getBytes(); - } - - if( soup.containsKey("key") ){ - this.key = ((PacketSection) soup.get("key")).getBytes(); - } - - if( soup.containsKey("sln") ){ - this.sln = ((PacketSection) soup.get("sln")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3935")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3935"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] lmkHead = null; - private byte[] lmk = null; - private byte[] keyCheck = null; - private byte[] infoLen = null; - private byte[] info = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV公钥不符合编码规则(Util.hexString2Bytes("3034")), - OPV无效的加密标识(Util.hexString2Bytes("3036")), - OPV无效的附加模式标识(Util.hexString2Bytes("3037")), - OPV密钥奇偶校验错误(Util.hexString2Bytes("3130")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVDSP错误(Util.hexString2Bytes("3437")), - OPV密钥块长度错误(Util.hexString2Bytes("3736")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return "公钥不符合编码规则"; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return "无效的加密标识"; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return "无效的附加模式标识"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "密钥奇偶校验错误"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return "DSP 错误"; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return "密钥块长度错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 9; - } - return null; - } - - - public byte[] getLmkHeadAsBin( ) { - - return this.lmkHead; - } - - - public String getLmkHeadAsStr( ) { - - if( null == this.lmkHead) return null; - return Arrays.toString(this.lmkHead); - } - - - public String getLmkHeadAsHex( ) { - - if( null == this.lmkHead) return null; - return Util.bytes2HexString(lmkHead); - } - - - public Data setLmkHead( byte[] bytes ) { - - this.lmkHead = bytes; - return this; - } - - - public byte[] getLmkAsBin( ) { - - return this.lmk; - } - - - public String getLmkAsStr( ) { - - if( null == this.lmk) return null; - return Arrays.toString(this.lmk); - } - - - public String getLmkAsHex( ) { - - if( null == this.lmk) return null; - return Util.bytes2HexString(lmk); - } - - - public Data setLmk( byte[] bytes ) { - - this.lmk = bytes; - return this; - } - - - public byte[] getKeyCheckAsBin( ) { - - return this.keyCheck; - } - - - public String getKeyCheckAsStr( ) { - - if( null == this.keyCheck) return null; - return Arrays.toString(this.keyCheck); - } - - - public String getKeyCheckAsHex( ) { - - if( null == this.keyCheck) return null; - return Util.bytes2HexString(keyCheck); - } - - - public Data setKeyCheck( byte[] bytes ) { - - this.keyCheck = bytes; - return this; - } - - - public byte[] getInfoLenAsBin( ) { - - return this.infoLen; - } - - - public String getInfoLenAsStr( ) { - - if( null == this.infoLen) return null; - return Arrays.toString(this.infoLen); - } - - - public String getInfoLenAsHex( ) { - - if( null == this.infoLen) return null; - return Util.bytes2HexString(infoLen); - } - - - public Data setInfoLen( byte[] bytes ) { - - this.infoLen = bytes; - return this; - } - - - public byte[] getInfoAsBin( ) { - - return this.info; - } - - - public String getInfoAsStr( ) { - - if( null == this.info) return null; - return Arrays.toString(this.info); - } - - - public String getInfoAsHex( ) { - - if( null == this.info) return null; - return Util.bytes2HexString(info); - } - - - public Data setInfo( byte[] bytes ) { - - this.info = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != lmkHead ){ - soup.put("lmkHead", this.lmkHead); - } - - if( null != lmk ){ - soup.put("lmk", this.lmk); - } - - if( null != keyCheck ){ - soup.put("keyCheck", this.keyCheck); - } - - if( null != infoLen ){ - soup.put("infoLen", this.infoLen); - } - - if( null != info ){ - soup.put("info", this.info); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("lmkHead") ){ - this.lmkHead = ((PacketSection) soup.get("lmkHead")).getBytes(); - } - - if( soup.containsKey("lmk") ){ - this.lmk = ((PacketSection) soup.get("lmk")).getBytes(); - } - - if( soup.containsKey("keyCheck") ){ - this.keyCheck = ((PacketSection) soup.get("keyCheck")).getBytes(); - } - - if( soup.containsKey("infoLen") ){ - this.infoLen = ((PacketSection) soup.get("infoLen")).getBytes(); - } - - if( soup.containsKey("info") ){ - this.info = ((PacketSection) soup.get("info")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3936")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3936"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTO96.java b/src/main/java/racal/sunyard/main/dto/DTO96.java deleted file mode 100644 index 61408ae..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTO96.java +++ /dev/null @@ -1,796 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTO96 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] keyA = null; - private byte[] keyB = null; - private byte[] sln = null; - private byte[] alg = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getKeyAAsBin( ) { - - return this.keyA; - } - - - public String getKeyAAsStr( ) { - - if( null == this.keyA) return null; - return Arrays.toString(this.keyA); - } - - - public String getKeyAAsHex( ) { - - if( null == this.keyA) return null; - return Util.bytes2HexString(keyA); - } - - - public Data setKeyA( byte[] bytes ) { - - this.keyA = bytes; - return this; - } - - - public byte[] getKeyBAsBin( ) { - - return this.keyB; - } - - - public String getKeyBAsStr( ) { - - if( null == this.keyB) return null; - return Arrays.toString(this.keyB); - } - - - public String getKeyBAsHex( ) { - - if( null == this.keyB) return null; - return Util.bytes2HexString(keyB); - } - - - public Data setKeyB( byte[] bytes ) { - - this.keyB = bytes; - return this; - } - - - public byte[] getSlnAsBin( ) { - - return this.sln; - } - - - public String getSlnAsStr( ) { - - if( null == this.sln) return null; - return Arrays.toString(this.sln); - } - - - public String getSlnAsHex( ) { - - if( null == this.sln) return null; - return Util.bytes2HexString(sln); - } - - - public Data setSln( byte[] bytes ) { - - this.sln = bytes; - return this; - } - - - public byte[] getAlgAsBin( ) { - - return this.alg; - } - - - public String getAlgAsStr( ) { - - if( null == this.alg) return null; - return Arrays.toString(this.alg); - } - - - public String getAlgAsHex( ) { - - if( null == this.alg) return null; - return Util.bytes2HexString(alg); - } - - - public Data setAlg( byte[] bytes ) { - - this.alg = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != keyA ){ - soup.put("keyA", this.keyA); - } - - if( null != keyB ){ - soup.put("keyB", this.keyB); - } - - if( null != sln ){ - soup.put("sln", this.sln); - } - - if( null != alg ){ - soup.put("alg", this.alg); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("keyA") ){ - this.keyA = ((PacketSection) soup.get("keyA")).getBytes(); - } - - if( soup.containsKey("keyB") ){ - this.keyB = ((PacketSection) soup.get("keyB")).getBytes(); - } - - if( soup.containsKey("sln") ){ - this.sln = ((PacketSection) soup.get("sln")).getBytes(); - } - - if( soup.containsKey("alg") ){ - this.alg = ((PacketSection) soup.get("alg")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3936")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3936"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] keyC = null; - private byte[] keyCheck = null; - private byte[] infoLen = null; - private byte[] info = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV公钥不符合编码规则(Util.hexString2Bytes("3034")), - OPV无效的加密标识(Util.hexString2Bytes("3036")), - OPV无效的附加模式标识(Util.hexString2Bytes("3037")), - OPV密钥奇偶校验错误(Util.hexString2Bytes("3130")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVDSP错误(Util.hexString2Bytes("3437")), - OPV密钥块长度错误(Util.hexString2Bytes("3736")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return "公钥不符合编码规则"; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return "无效的加密标识"; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return "无效的附加模式标识"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "密钥奇偶校验错误"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return "DSP 错误"; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return "密钥块长度错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 9; - } - return null; - } - - - public byte[] getKeyCAsBin( ) { - - return this.keyC; - } - - - public String getKeyCAsStr( ) { - - if( null == this.keyC) return null; - return Arrays.toString(this.keyC); - } - - - public String getKeyCAsHex( ) { - - if( null == this.keyC) return null; - return Util.bytes2HexString(keyC); - } - - - public Data setKeyC( byte[] bytes ) { - - this.keyC = bytes; - return this; - } - - - public byte[] getKeyCheckAsBin( ) { - - return this.keyCheck; - } - - - public String getKeyCheckAsStr( ) { - - if( null == this.keyCheck) return null; - return Arrays.toString(this.keyCheck); - } - - - public String getKeyCheckAsHex( ) { - - if( null == this.keyCheck) return null; - return Util.bytes2HexString(keyCheck); - } - - - public Data setKeyCheck( byte[] bytes ) { - - this.keyCheck = bytes; - return this; - } - - - public byte[] getInfoLenAsBin( ) { - - return this.infoLen; - } - - - public String getInfoLenAsStr( ) { - - if( null == this.infoLen) return null; - return Arrays.toString(this.infoLen); - } - - - public String getInfoLenAsHex( ) { - - if( null == this.infoLen) return null; - return Util.bytes2HexString(infoLen); - } - - - public Data setInfoLen( byte[] bytes ) { - - this.infoLen = bytes; - return this; - } - - - public byte[] getInfoAsBin( ) { - - return this.info; - } - - - public String getInfoAsStr( ) { - - if( null == this.info) return null; - return Arrays.toString(this.info); - } - - - public String getInfoAsHex( ) { - - if( null == this.info) return null; - return Util.bytes2HexString(info); - } - - - public Data setInfo( byte[] bytes ) { - - this.info = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != keyC ){ - soup.put("keyC", this.keyC); - } - - if( null != keyCheck ){ - soup.put("keyCheck", this.keyCheck); - } - - if( null != infoLen ){ - soup.put("infoLen", this.infoLen); - } - - if( null != info ){ - soup.put("info", this.info); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("keyC") ){ - this.keyC = ((PacketSection) soup.get("keyC")).getBytes(); - } - - if( soup.containsKey("keyCheck") ){ - this.keyCheck = ((PacketSection) soup.get("keyCheck")).getBytes(); - } - - if( soup.containsKey("infoLen") ){ - this.infoLen = ((PacketSection) soup.get("infoLen")).getBytes(); - } - - if( soup.containsKey("info") ){ - this.info = ((PacketSection) soup.get("info")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("3937")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("3937"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOA0.java b/src/main/java/racal/sunyard/main/dto/DTOA0.java deleted file mode 100644 index 6f3d220..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOA0.java +++ /dev/null @@ -1,1071 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOA0 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] mode = null; - private byte[] keyType = null; - private byte[] solution = null; - private byte[] zmk = null; - private byte[] keySolution = null; - private byte[] businessKey = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getModeAsBin( ) { - - return this.mode; - } - - - public String getModeAsStr( ) { - - if( null == this.mode) return null; - return Arrays.toString(this.mode); - } - - - public String getModeAsHex( ) { - - if( null == this.mode) return null; - return Util.bytes2HexString(mode); - } - - - public Data setMode( byte[] bytes ) { - - this.mode = bytes; - return this; - } -public enum ModeOptions { - - OPV产生密钥(Util.hexString2Bytes("30")), - OPV产生密钥并在ZMK下加密(Util.hexString2Bytes("31")); - private byte[] bin; - ModeOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getModeCn( ) { - - if( null == mode) { return null; } - if( "30".equals(Util.bytes2HexString(this.mode))) { - return "产生密钥"; - } - if( "31".equals(Util.bytes2HexString(this.mode))) { - return "产生密钥并在 ZMK 下加密"; - } - return null; - } - - - public Integer getModeOptionIndex( ) { - - if( null == mode) { return null; } - if( "30".equals(Util.bytes2HexString(this.mode))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.mode))) { - return 1; - } - return null; - } - - - public byte[] getKeyTypeAsBin( ) { - - return this.keyType; - } - - - public String getKeyTypeAsStr( ) { - - if( null == this.keyType) return null; - return Arrays.toString(this.keyType); - } - - - public String getKeyTypeAsHex( ) { - - if( null == this.keyType) return null; - return Util.bytes2HexString(keyType); - } - - - public Data setKeyType( byte[] bytes ) { - - this.keyType = bytes; - return this; - } - - - public byte[] getSolutionAsBin( ) { - - return this.solution; - } - - - public String getSolutionAsStr( ) { - - if( null == this.solution) return null; - return Arrays.toString(this.solution); - } - - - public String getSolutionAsHex( ) { - - if( null == this.solution) return null; - return Util.bytes2HexString(solution); - } - - - public Data setSolution( byte[] bytes ) { - - this.solution = bytes; - return this; - } - - - public byte[] getZmkAsBin( ) { - - return this.zmk; - } - - - public String getZmkAsStr( ) { - - if( null == this.zmk) return null; - return Arrays.toString(this.zmk); - } - - - public String getZmkAsHex( ) { - - if( null == this.zmk) return null; - return Util.bytes2HexString(zmk); - } - - - public Data setZmk( byte[] bytes ) { - - this.zmk = bytes; - return this; - } - - - public byte[] getKeySolutionAsBin( ) { - - return this.keySolution; - } - - - public String getKeySolutionAsStr( ) { - - if( null == this.keySolution) return null; - return Arrays.toString(this.keySolution); - } - - - public String getKeySolutionAsHex( ) { - - if( null == this.keySolution) return null; - return Util.bytes2HexString(keySolution); - } - - - public Data setKeySolution( byte[] bytes ) { - - this.keySolution = bytes; - return this; - } - - - public byte[] getBusinessKeyAsBin( ) { - - return this.businessKey; - } - - - public String getBusinessKeyAsStr( ) { - - if( null == this.businessKey) return null; - return Arrays.toString(this.businessKey); - } - - - public String getBusinessKeyAsHex( ) { - - if( null == this.businessKey) return null; - return Util.bytes2HexString(businessKey); - } - - - public Data setBusinessKey( byte[] bytes ) { - - this.businessKey = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != mode ){ - soup.put("mode", this.mode); - soup.put("mode$option", getModeOptionIndex()); - } - - if( null != keyType ){ - soup.put("keyType", this.keyType); - } - - if( null != solution ){ - soup.put("solution", this.solution); - } - - if( null != zmk ){ - soup.put("zmk", this.zmk); - } - - if( null != keySolution ){ - soup.put("keySolution", this.keySolution); - } - - soup.put("businessKey", Util.hexString2Bytes("4E")); - if( null != businessKey ){ - soup.put("businessKey", this.businessKey); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("mode") ){ - this.mode = ((PacketSection) soup.get("mode")).getBytes(); - } - - if( soup.containsKey("keyType") ){ - this.keyType = ((PacketSection) soup.get("keyType")).getBytes(); - } - - if( soup.containsKey("solution") ){ - this.solution = ((PacketSection) soup.get("solution")).getBytes(); - } - - if( soup.containsKey("zmk") ){ - this.zmk = ((PacketSection) soup.get("zmk")).getBytes(); - } - - if( soup.containsKey("keySolution") ){ - this.keySolution = ((PacketSection) soup.get("keySolution")).getBytes(); - } - - this.businessKey = Util.hexString2Bytes("4E"); - if( soup.containsKey("businessKey") ){ - this.businessKey = ((PacketSection) soup.get("businessKey")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4130")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4130"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] lmkHead = null; - private byte[] lmk = null; - private byte[] zmkHead = null; - private byte[] zmk = null; - private byte[] keyCheck = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPVZMK奇偶校验错(Util.hexString2Bytes("3130")), - OPV用户存储区中没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV无效用户存储区索引(Util.hexString2Bytes("3231")), - OPV无效的密钥方案(Util.hexString2Bytes("3236")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "ZMK 奇偶校验错"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区中没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效用户存储区索引"; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return "无效的密钥方案"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return 6; - } - return null; - } - - - public byte[] getLmkHeadAsBin( ) { - - return this.lmkHead; - } - - - public String getLmkHeadAsStr( ) { - - if( null == this.lmkHead) return null; - return Arrays.toString(this.lmkHead); - } - - - public String getLmkHeadAsHex( ) { - - if( null == this.lmkHead) return null; - return Util.bytes2HexString(lmkHead); - } - - - public Data setLmkHead( byte[] bytes ) { - - this.lmkHead = bytes; - return this; - } - - - public byte[] getLmkAsBin( ) { - - return this.lmk; - } - - - public String getLmkAsStr( ) { - - if( null == this.lmk) return null; - return Arrays.toString(this.lmk); - } - - - public String getLmkAsHex( ) { - - if( null == this.lmk) return null; - return Util.bytes2HexString(lmk); - } - - - public Data setLmk( byte[] bytes ) { - - this.lmk = bytes; - return this; - } - - - public byte[] getZmkHeadAsBin( ) { - - return this.zmkHead; - } - - - public String getZmkHeadAsStr( ) { - - if( null == this.zmkHead) return null; - return Arrays.toString(this.zmkHead); - } - - - public String getZmkHeadAsHex( ) { - - if( null == this.zmkHead) return null; - return Util.bytes2HexString(zmkHead); - } - - - public Data setZmkHead( byte[] bytes ) { - - this.zmkHead = bytes; - return this; - } - - - public byte[] getZmkAsBin( ) { - - return this.zmk; - } - - - public String getZmkAsStr( ) { - - if( null == this.zmk) return null; - return Arrays.toString(this.zmk); - } - - - public String getZmkAsHex( ) { - - if( null == this.zmk) return null; - return Util.bytes2HexString(zmk); - } - - - public Data setZmk( byte[] bytes ) { - - this.zmk = bytes; - return this; - } - - - public byte[] getKeyCheckAsBin( ) { - - return this.keyCheck; - } - - - public String getKeyCheckAsStr( ) { - - if( null == this.keyCheck) return null; - return Arrays.toString(this.keyCheck); - } - - - public String getKeyCheckAsHex( ) { - - if( null == this.keyCheck) return null; - return Util.bytes2HexString(keyCheck); - } - - - public Data setKeyCheck( byte[] bytes ) { - - this.keyCheck = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != lmkHead ){ - soup.put("lmkHead", this.lmkHead); - } - - if( null != lmk ){ - soup.put("lmk", this.lmk); - } - - if( null != zmkHead ){ - soup.put("zmkHead", this.zmkHead); - } - - if( null != zmk ){ - soup.put("zmk", this.zmk); - } - - if( null != keyCheck ){ - soup.put("keyCheck", this.keyCheck); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("lmkHead") ){ - this.lmkHead = ((PacketSection) soup.get("lmkHead")).getBytes(); - } - - if( soup.containsKey("lmk") ){ - this.lmk = ((PacketSection) soup.get("lmk")).getBytes(); - } - - if( soup.containsKey("zmkHead") ){ - this.zmkHead = ((PacketSection) soup.get("zmkHead")).getBytes(); - } - - if( soup.containsKey("zmk") ){ - this.zmk = ((PacketSection) soup.get("zmk")).getBytes(); - } - - if( soup.containsKey("keyCheck") ){ - this.keyCheck = ((PacketSection) soup.get("keyCheck")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4131")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4131"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOA2.java b/src/main/java/racal/sunyard/main/dto/DTOA2.java deleted file mode 100644 index 53beb91..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOA2.java +++ /dev/null @@ -1,879 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOA2 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] keyType = null; - private byte[] solution = null; - private byte[] flag = null; - private byte[] print = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getKeyTypeAsBin( ) { - - return this.keyType; - } - - - public String getKeyTypeAsStr( ) { - - if( null == this.keyType) return null; - return Arrays.toString(this.keyType); - } - - - public String getKeyTypeAsHex( ) { - - if( null == this.keyType) return null; - return Util.bytes2HexString(keyType); - } - - - public Data setKeyType( byte[] bytes ) { - - this.keyType = bytes; - return this; - } - - - public byte[] getSolutionAsBin( ) { - - return this.solution; - } - - - public String getSolutionAsStr( ) { - - if( null == this.solution) return null; - return Arrays.toString(this.solution); - } - - - public String getSolutionAsHex( ) { - - if( null == this.solution) return null; - return Util.bytes2HexString(solution); - } - - - public Data setSolution( byte[] bytes ) { - - this.solution = bytes; - return this; - } - - - public byte[] getFlagAsBin( ) { - - return this.flag; - } - - - public String getFlagAsStr( ) { - - if( null == this.flag) return null; - return Arrays.toString(this.flag); - } - - - public String getFlagAsHex( ) { - - if( null == this.flag) return null; - return Util.bytes2HexString(flag); - } - - - public Data setFlag( byte[] bytes ) { - - this.flag = bytes; - return this; - } - - - public byte[] getPrintAsBin( ) { - - return this.print; - } - - - public String getPrintAsStr( ) { - - if( null == this.print) return null; - return Arrays.toString(this.print); - } - - - public String getPrintAsHex( ) { - - if( null == this.print) return null; - return Util.bytes2HexString(print); - } - - - public Data setPrint( byte[] bytes ) { - - this.print = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != keyType ){ - soup.put("keyType", this.keyType); - } - - if( null != solution ){ - soup.put("solution", this.solution); - } - - if( null != flag ){ - soup.put("flag", this.flag); - } - - if( null != print ){ - soup.put("print", this.print); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("keyType") ){ - this.keyType = ((PacketSection) soup.get("keyType")).getBytes(); - } - - if( soup.containsKey("solution") ){ - this.solution = ((PacketSection) soup.get("solution")).getBytes(); - } - - if( soup.containsKey("flag") ){ - this.flag = ((PacketSection) soup.get("flag")).getBytes(); - } - - if( soup.containsKey("print") ){ - this.print = ((PacketSection) soup.get("print")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4132")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4132"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] keyHead = null; - private byte[] key = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV密钥奇偶校验错(Util.hexString2Bytes("3031")), - OPVZMK奇偶校验错(Util.hexString2Bytes("3130")), - OPV用户存储区中没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV不在授权状态(Util.hexString2Bytes("3137")), - OPV无效用户存储区索引(Util.hexString2Bytes("3231")), - OPV无效的密钥类型(Util.hexString2Bytes("3238")), - OPV无效的密钥方案(Util.hexString2Bytes("3236")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3031".equals(Util.bytes2HexString(this.error))) { - return "密钥奇偶校验错"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "ZMK 奇偶校验错"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区中没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3137".equals(Util.bytes2HexString(this.error))) { - return "不在授权状态"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效用户存储区索引"; - } - if( "3238".equals(Util.bytes2HexString(this.error))) { - return "无效的密钥类型"; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return "无效的密钥方案"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3031".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3137".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3238".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return 9; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 10; - } - return null; - } - - - public byte[] getKeyHeadAsBin( ) { - - return this.keyHead; - } - - - public String getKeyHeadAsStr( ) { - - if( null == this.keyHead) return null; - return Arrays.toString(this.keyHead); - } - - - public String getKeyHeadAsHex( ) { - - if( null == this.keyHead) return null; - return Util.bytes2HexString(keyHead); - } - - - public Data setKeyHead( byte[] bytes ) { - - this.keyHead = bytes; - return this; - } - - - public byte[] getKeyAsBin( ) { - - return this.key; - } - - - public String getKeyAsStr( ) { - - if( null == this.key) return null; - return Arrays.toString(this.key); - } - - - public String getKeyAsHex( ) { - - if( null == this.key) return null; - return Util.bytes2HexString(key); - } - - - public Data setKey( byte[] bytes ) { - - this.key = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != keyHead ){ - soup.put("keyHead", this.keyHead); - } - - if( null != key ){ - soup.put("key", this.key); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("keyHead") ){ - this.keyHead = ((PacketSection) soup.get("keyHead")).getBytes(); - } - - if( soup.containsKey("key") ){ - this.key = ((PacketSection) soup.get("key")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4133")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4133"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOA4.java b/src/main/java/racal/sunyard/main/dto/DTOA4.java deleted file mode 100644 index a31771d..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOA4.java +++ /dev/null @@ -1,944 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOA4 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] num = null; - private byte[] keyType = null; - private byte[] lmkSolution = null; - private byte[] keys = null; - private byte[] businessKey = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getNumAsBin( ) { - - return this.num; - } - - - public String getNumAsStr( ) { - - if( null == this.num) return null; - return Arrays.toString(this.num); - } - - - public String getNumAsHex( ) { - - if( null == this.num) return null; - return Util.bytes2HexString(num); - } - - - public Data setNum( byte[] bytes ) { - - this.num = bytes; - return this; - } - - - public byte[] getKeyTypeAsBin( ) { - - return this.keyType; - } - - - public String getKeyTypeAsStr( ) { - - if( null == this.keyType) return null; - return Arrays.toString(this.keyType); - } - - - public String getKeyTypeAsHex( ) { - - if( null == this.keyType) return null; - return Util.bytes2HexString(keyType); - } - - - public Data setKeyType( byte[] bytes ) { - - this.keyType = bytes; - return this; - } - - - public byte[] getLmkSolutionAsBin( ) { - - return this.lmkSolution; - } - - - public String getLmkSolutionAsStr( ) { - - if( null == this.lmkSolution) return null; - return Arrays.toString(this.lmkSolution); - } - - - public String getLmkSolutionAsHex( ) { - - if( null == this.lmkSolution) return null; - return Util.bytes2HexString(lmkSolution); - } - - - public Data setLmkSolution( byte[] bytes ) { - - this.lmkSolution = bytes; - return this; - } - - - public byte[] getKeysAsBin( ) { - - return this.keys; - } - - - public String getKeysAsStr( ) { - - if( null == this.keys) return null; - return Arrays.toString(this.keys); - } - - - public String getKeysAsHex( ) { - - if( null == this.keys) return null; - return Util.bytes2HexString(keys); - } - - - public Data setKeys( byte[] bytes ) { - - this.keys = bytes; - return this; - } - - - public byte[] getBusinessKeyAsBin( ) { - - return this.businessKey; - } - - - public String getBusinessKeyAsStr( ) { - - if( null == this.businessKey) return null; - return Arrays.toString(this.businessKey); - } - - - public String getBusinessKeyAsHex( ) { - - if( null == this.businessKey) return null; - return Util.bytes2HexString(businessKey); - } - - - public Data setBusinessKey( byte[] bytes ) { - - this.businessKey = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != num ){ - soup.put("num", this.num); - } - - if( null != keyType ){ - soup.put("keyType", this.keyType); - } - - if( null != lmkSolution ){ - soup.put("lmkSolution", this.lmkSolution); - } - - if( null != keys ){ - soup.put("keys", this.keys); - } - - if( null != businessKey ){ - soup.put("businessKey", this.businessKey); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("num") ){ - this.num = ((PacketSection) soup.get("num")).getBytes(); - } - - if( soup.containsKey("keyType") ){ - this.keyType = ((PacketSection) soup.get("keyType")).getBytes(); - } - - if( soup.containsKey("lmkSolution") ){ - this.lmkSolution = ((PacketSection) soup.get("lmkSolution")).getBytes(); - } - - if( soup.containsKey("keys") ){ - this.keys = ((PacketSection) soup.get("keys")).getBytes(); - } - - if( soup.containsKey("businessKey") ){ - this.businessKey = ((PacketSection) soup.get("businessKey")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4134")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4134"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] keyHead = null; - private byte[] key = null; - private byte[] kcv = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV无效的成份号(Util.hexString2Bytes("3033")), - OPV成份奇偶校验错(Util.hexString2Bytes("3130")), - OPV用户存储区中没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV不在授权状态(Util.hexString2Bytes("3137")), - OPV无效用户存储区索引(Util.hexString2Bytes("3231")), - OPV无效的密钥方案(Util.hexString2Bytes("3236")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3033".equals(Util.bytes2HexString(this.error))) { - return "无效的成份号"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "成份奇偶校验错"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区中没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3137".equals(Util.bytes2HexString(this.error))) { - return "不在授权状态"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效用户存储区索引"; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return "无效的密钥方案"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3033".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3137".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 9; - } - return null; - } - - - public byte[] getKeyHeadAsBin( ) { - - return this.keyHead; - } - - - public String getKeyHeadAsStr( ) { - - if( null == this.keyHead) return null; - return Arrays.toString(this.keyHead); - } - - - public String getKeyHeadAsHex( ) { - - if( null == this.keyHead) return null; - return Util.bytes2HexString(keyHead); - } - - - public Data setKeyHead( byte[] bytes ) { - - this.keyHead = bytes; - return this; - } - - - public byte[] getKeyAsBin( ) { - - return this.key; - } - - - public String getKeyAsStr( ) { - - if( null == this.key) return null; - return Arrays.toString(this.key); - } - - - public String getKeyAsHex( ) { - - if( null == this.key) return null; - return Util.bytes2HexString(key); - } - - - public Data setKey( byte[] bytes ) { - - this.key = bytes; - return this; - } - - - public byte[] getKcvAsBin( ) { - - return this.kcv; - } - - - public String getKcvAsStr( ) { - - if( null == this.kcv) return null; - return Arrays.toString(this.kcv); - } - - - public String getKcvAsHex( ) { - - if( null == this.kcv) return null; - return Util.bytes2HexString(kcv); - } - - - public Data setKcv( byte[] bytes ) { - - this.kcv = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != keyHead ){ - soup.put("keyHead", this.keyHead); - } - - if( null != key ){ - soup.put("key", this.key); - } - - if( null != kcv ){ - soup.put("kcv", this.kcv); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("keyHead") ){ - this.keyHead = ((PacketSection) soup.get("keyHead")).getBytes(); - } - - if( soup.containsKey("key") ){ - this.key = ((PacketSection) soup.get("key")).getBytes(); - } - - if( soup.containsKey("kcv") ){ - this.kcv = ((PacketSection) soup.get("kcv")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4135")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4135"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOA6.java b/src/main/java/racal/sunyard/main/dto/DTOA6.java deleted file mode 100644 index 3814e67..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOA6.java +++ /dev/null @@ -1,951 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOA6 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] keyType = null; - private byte[] zmk = null; - private byte[] key = null; - private byte[] keySolution = null; - private byte[] businessKey = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getKeyTypeAsBin( ) { - - return this.keyType; - } - - - public String getKeyTypeAsStr( ) { - - if( null == this.keyType) return null; - return Arrays.toString(this.keyType); - } - - - public String getKeyTypeAsHex( ) { - - if( null == this.keyType) return null; - return Util.bytes2HexString(keyType); - } - - - public Data setKeyType( byte[] bytes ) { - - this.keyType = bytes; - return this; - } - - - public byte[] getZmkAsBin( ) { - - return this.zmk; - } - - - public String getZmkAsStr( ) { - - if( null == this.zmk) return null; - return Arrays.toString(this.zmk); - } - - - public String getZmkAsHex( ) { - - if( null == this.zmk) return null; - return Util.bytes2HexString(zmk); - } - - - public Data setZmk( byte[] bytes ) { - - this.zmk = bytes; - return this; - } - - - public byte[] getKeyAsBin( ) { - - return this.key; - } - - - public String getKeyAsStr( ) { - - if( null == this.key) return null; - return Arrays.toString(this.key); - } - - - public String getKeyAsHex( ) { - - if( null == this.key) return null; - return Util.bytes2HexString(key); - } - - - public Data setKey( byte[] bytes ) { - - this.key = bytes; - return this; - } - - - public byte[] getKeySolutionAsBin( ) { - - return this.keySolution; - } - - - public String getKeySolutionAsStr( ) { - - if( null == this.keySolution) return null; - return Arrays.toString(this.keySolution); - } - - - public String getKeySolutionAsHex( ) { - - if( null == this.keySolution) return null; - return Util.bytes2HexString(keySolution); - } - - - public Data setKeySolution( byte[] bytes ) { - - this.keySolution = bytes; - return this; - } - - - public byte[] getBusinessKeyAsBin( ) { - - return this.businessKey; - } - - - public String getBusinessKeyAsStr( ) { - - if( null == this.businessKey) return null; - return Arrays.toString(this.businessKey); - } - - - public String getBusinessKeyAsHex( ) { - - if( null == this.businessKey) return null; - return Util.bytes2HexString(businessKey); - } - - - public Data setBusinessKey( byte[] bytes ) { - - this.businessKey = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != keyType ){ - soup.put("keyType", this.keyType); - } - - if( null != zmk ){ - soup.put("zmk", this.zmk); - } - - if( null != key ){ - soup.put("key", this.key); - } - - if( null != keySolution ){ - soup.put("keySolution", this.keySolution); - } - - if( null != businessKey ){ - soup.put("businessKey", this.businessKey); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("keyType") ){ - this.keyType = ((PacketSection) soup.get("keyType")).getBytes(); - } - - if( soup.containsKey("zmk") ){ - this.zmk = ((PacketSection) soup.get("zmk")).getBytes(); - } - - if( soup.containsKey("key") ){ - this.key = ((PacketSection) soup.get("key")).getBytes(); - } - - if( soup.containsKey("keySolution") ){ - this.keySolution = ((PacketSection) soup.get("keySolution")).getBytes(); - } - - if( soup.containsKey("businessKey") ){ - this.businessKey = ((PacketSection) soup.get("businessKey")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4136")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4136"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] lmkHead = null; - private byte[] lmk = null; - private byte[] keyCheck = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV密钥奇偶校验错(Util.hexString2Bytes("3031")), - OPVZMK奇偶校验错(Util.hexString2Bytes("3130")), - OPV用户存储区中没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV不在授权状态(Util.hexString2Bytes("3137")), - OPV无效用户存储区索引(Util.hexString2Bytes("3231")), - OPV无效的密钥类型(Util.hexString2Bytes("3238")), - OPV无效的密钥方案(Util.hexString2Bytes("3236")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3031".equals(Util.bytes2HexString(this.error))) { - return "密钥奇偶校验错"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "ZMK 奇偶校验错"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区中没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3137".equals(Util.bytes2HexString(this.error))) { - return "不在授权状态"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效用户存储区索引"; - } - if( "3238".equals(Util.bytes2HexString(this.error))) { - return "无效的密钥类型"; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return "无效的密钥方案"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3031".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3137".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3238".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return 9; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 10; - } - return null; - } - - - public byte[] getLmkHeadAsBin( ) { - - return this.lmkHead; - } - - - public String getLmkHeadAsStr( ) { - - if( null == this.lmkHead) return null; - return Arrays.toString(this.lmkHead); - } - - - public String getLmkHeadAsHex( ) { - - if( null == this.lmkHead) return null; - return Util.bytes2HexString(lmkHead); - } - - - public Data setLmkHead( byte[] bytes ) { - - this.lmkHead = bytes; - return this; - } - - - public byte[] getLmkAsBin( ) { - - return this.lmk; - } - - - public String getLmkAsStr( ) { - - if( null == this.lmk) return null; - return Arrays.toString(this.lmk); - } - - - public String getLmkAsHex( ) { - - if( null == this.lmk) return null; - return Util.bytes2HexString(lmk); - } - - - public Data setLmk( byte[] bytes ) { - - this.lmk = bytes; - return this; - } - - - public byte[] getKeyCheckAsBin( ) { - - return this.keyCheck; - } - - - public String getKeyCheckAsStr( ) { - - if( null == this.keyCheck) return null; - return Arrays.toString(this.keyCheck); - } - - - public String getKeyCheckAsHex( ) { - - if( null == this.keyCheck) return null; - return Util.bytes2HexString(keyCheck); - } - - - public Data setKeyCheck( byte[] bytes ) { - - this.keyCheck = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != lmkHead ){ - soup.put("lmkHead", this.lmkHead); - } - - if( null != lmk ){ - soup.put("lmk", this.lmk); - } - - if( null != keyCheck ){ - soup.put("keyCheck", this.keyCheck); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("lmkHead") ){ - this.lmkHead = ((PacketSection) soup.get("lmkHead")).getBytes(); - } - - if( soup.containsKey("lmk") ){ - this.lmk = ((PacketSection) soup.get("lmk")).getBytes(); - } - - if( soup.containsKey("keyCheck") ){ - this.keyCheck = ((PacketSection) soup.get("keyCheck")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4137")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4137"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOA8.java b/src/main/java/racal/sunyard/main/dto/DTOA8.java deleted file mode 100644 index c6fac70..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOA8.java +++ /dev/null @@ -1,944 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOA8 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] keyType = null; - private byte[] zmk = null; - private byte[] key = null; - private byte[] keySolution = null; - private byte[] businessKey = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getKeyTypeAsBin( ) { - - return this.keyType; - } - - - public String getKeyTypeAsStr( ) { - - if( null == this.keyType) return null; - return Arrays.toString(this.keyType); - } - - - public String getKeyTypeAsHex( ) { - - if( null == this.keyType) return null; - return Util.bytes2HexString(keyType); - } - - - public Data setKeyType( byte[] bytes ) { - - this.keyType = bytes; - return this; - } - - - public byte[] getZmkAsBin( ) { - - return this.zmk; - } - - - public String getZmkAsStr( ) { - - if( null == this.zmk) return null; - return Arrays.toString(this.zmk); - } - - - public String getZmkAsHex( ) { - - if( null == this.zmk) return null; - return Util.bytes2HexString(zmk); - } - - - public Data setZmk( byte[] bytes ) { - - this.zmk = bytes; - return this; - } - - - public byte[] getKeyAsBin( ) { - - return this.key; - } - - - public String getKeyAsStr( ) { - - if( null == this.key) return null; - return Arrays.toString(this.key); - } - - - public String getKeyAsHex( ) { - - if( null == this.key) return null; - return Util.bytes2HexString(key); - } - - - public Data setKey( byte[] bytes ) { - - this.key = bytes; - return this; - } - - - public byte[] getKeySolutionAsBin( ) { - - return this.keySolution; - } - - - public String getKeySolutionAsStr( ) { - - if( null == this.keySolution) return null; - return Arrays.toString(this.keySolution); - } - - - public String getKeySolutionAsHex( ) { - - if( null == this.keySolution) return null; - return Util.bytes2HexString(keySolution); - } - - - public Data setKeySolution( byte[] bytes ) { - - this.keySolution = bytes; - return this; - } - - - public byte[] getBusinessKeyAsBin( ) { - - return this.businessKey; - } - - - public String getBusinessKeyAsStr( ) { - - if( null == this.businessKey) return null; - return Arrays.toString(this.businessKey); - } - - - public String getBusinessKeyAsHex( ) { - - if( null == this.businessKey) return null; - return Util.bytes2HexString(businessKey); - } - - - public Data setBusinessKey( byte[] bytes ) { - - this.businessKey = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != keyType ){ - soup.put("keyType", this.keyType); - } - - if( null != zmk ){ - soup.put("zmk", this.zmk); - } - - if( null != key ){ - soup.put("key", this.key); - } - - if( null != keySolution ){ - soup.put("keySolution", this.keySolution); - } - - if( null != businessKey ){ - soup.put("businessKey", this.businessKey); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("keyType") ){ - this.keyType = ((PacketSection) soup.get("keyType")).getBytes(); - } - - if( soup.containsKey("zmk") ){ - this.zmk = ((PacketSection) soup.get("zmk")).getBytes(); - } - - if( soup.containsKey("key") ){ - this.key = ((PacketSection) soup.get("key")).getBytes(); - } - - if( soup.containsKey("keySolution") ){ - this.keySolution = ((PacketSection) soup.get("keySolution")).getBytes(); - } - - if( soup.containsKey("businessKey") ){ - this.businessKey = ((PacketSection) soup.get("businessKey")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4138")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4138"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] zmkHead = null; - private byte[] zmk = null; - private byte[] keyCheck = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPVZMK奇偶校验错(Util.hexString2Bytes("3130")), - OPV密钥校验错(Util.hexString2Bytes("3131")), - OPV用户存储区中没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV不在授权状态(Util.hexString2Bytes("3137")), - OPV无效用户存储区索引(Util.hexString2Bytes("3231")), - OPV无效的密钥方案(Util.hexString2Bytes("3236")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "ZMK 奇偶校验错"; - } - if( "3131".equals(Util.bytes2HexString(this.error))) { - return "密钥校验错"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区中没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3137".equals(Util.bytes2HexString(this.error))) { - return "不在授权状态"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效用户存储区索引"; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return "无效的密钥方案"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3131".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3137".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 9; - } - return null; - } - - - public byte[] getZmkHeadAsBin( ) { - - return this.zmkHead; - } - - - public String getZmkHeadAsStr( ) { - - if( null == this.zmkHead) return null; - return Arrays.toString(this.zmkHead); - } - - - public String getZmkHeadAsHex( ) { - - if( null == this.zmkHead) return null; - return Util.bytes2HexString(zmkHead); - } - - - public Data setZmkHead( byte[] bytes ) { - - this.zmkHead = bytes; - return this; - } - - - public byte[] getZmkAsBin( ) { - - return this.zmk; - } - - - public String getZmkAsStr( ) { - - if( null == this.zmk) return null; - return Arrays.toString(this.zmk); - } - - - public String getZmkAsHex( ) { - - if( null == this.zmk) return null; - return Util.bytes2HexString(zmk); - } - - - public Data setZmk( byte[] bytes ) { - - this.zmk = bytes; - return this; - } - - - public byte[] getKeyCheckAsBin( ) { - - return this.keyCheck; - } - - - public String getKeyCheckAsStr( ) { - - if( null == this.keyCheck) return null; - return Arrays.toString(this.keyCheck); - } - - - public String getKeyCheckAsHex( ) { - - if( null == this.keyCheck) return null; - return Util.bytes2HexString(keyCheck); - } - - - public Data setKeyCheck( byte[] bytes ) { - - this.keyCheck = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != zmkHead ){ - soup.put("zmkHead", this.zmkHead); - } - - if( null != zmk ){ - soup.put("zmk", this.zmk); - } - - if( null != keyCheck ){ - soup.put("keyCheck", this.keyCheck); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("zmkHead") ){ - this.zmkHead = ((PacketSection) soup.get("zmkHead")).getBytes(); - } - - if( soup.containsKey("zmk") ){ - this.zmk = ((PacketSection) soup.get("zmk")).getBytes(); - } - - if( soup.containsKey("keyCheck") ){ - this.keyCheck = ((PacketSection) soup.get("keyCheck")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4139")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4139"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOAA.java b/src/main/java/racal/sunyard/main/dto/DTOAA.java deleted file mode 100644 index 29daaf9..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOAA.java +++ /dev/null @@ -1,873 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOAA { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] keyType = null; - private byte[] keySolution = null; - private byte[] keyClearPattern = null; - private byte[] businessKey = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getKeyTypeAsBin( ) { - - return this.keyType; - } - - - public String getKeyTypeAsStr( ) { - - if( null == this.keyType) return null; - return Arrays.toString(this.keyType); - } - - - public String getKeyTypeAsHex( ) { - - if( null == this.keyType) return null; - return Util.bytes2HexString(keyType); - } - - - public Data setKeyType( byte[] bytes ) { - - this.keyType = bytes; - return this; - } - - - public byte[] getKeySolutionAsBin( ) { - - return this.keySolution; - } - - - public String getKeySolutionAsStr( ) { - - if( null == this.keySolution) return null; - return Arrays.toString(this.keySolution); - } - - - public String getKeySolutionAsHex( ) { - - if( null == this.keySolution) return null; - return Util.bytes2HexString(keySolution); - } - - - public Data setKeySolution( byte[] bytes ) { - - this.keySolution = bytes; - return this; - } - - - public byte[] getKeyClearPatternAsBin( ) { - - return this.keyClearPattern; - } - - - public String getKeyClearPatternAsStr( ) { - - if( null == this.keyClearPattern) return null; - return Arrays.toString(this.keyClearPattern); - } - - - public String getKeyClearPatternAsHex( ) { - - if( null == this.keyClearPattern) return null; - return Util.bytes2HexString(keyClearPattern); - } - - - public Data setKeyClearPattern( byte[] bytes ) { - - this.keyClearPattern = bytes; - return this; - } - - - public byte[] getBusinessKeyAsBin( ) { - - return this.businessKey; - } - - - public String getBusinessKeyAsStr( ) { - - if( null == this.businessKey) return null; - return Arrays.toString(this.businessKey); - } - - - public String getBusinessKeyAsHex( ) { - - if( null == this.businessKey) return null; - return Util.bytes2HexString(businessKey); - } - - - public Data setBusinessKey( byte[] bytes ) { - - this.businessKey = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != keyType ){ - soup.put("keyType", this.keyType); - } - - if( null != keySolution ){ - soup.put("keySolution", this.keySolution); - } - - if( null != keyClearPattern ){ - soup.put("keyClearPattern", this.keyClearPattern); - } - - if( null != businessKey ){ - soup.put("businessKey", this.businessKey); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("keyType") ){ - this.keyType = ((PacketSection) soup.get("keyType")).getBytes(); - } - - if( soup.containsKey("keySolution") ){ - this.keySolution = ((PacketSection) soup.get("keySolution")).getBytes(); - } - - if( soup.containsKey("keyClearPattern") ){ - this.keyClearPattern = ((PacketSection) soup.get("keyClearPattern")).getBytes(); - } - - if( soup.containsKey("businessKey") ){ - this.businessKey = ((PacketSection) soup.get("businessKey")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4141")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4141"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] lmkHead = null; - private byte[] lmk = null; - private byte[] keyCheck = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV用户存储区中没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV无效的密钥方案(Util.hexString2Bytes("3236")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区中没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return "无效的密钥方案"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return 4; - } - return null; - } - - - public byte[] getLmkHeadAsBin( ) { - - return this.lmkHead; - } - - - public String getLmkHeadAsStr( ) { - - if( null == this.lmkHead) return null; - return Arrays.toString(this.lmkHead); - } - - - public String getLmkHeadAsHex( ) { - - if( null == this.lmkHead) return null; - return Util.bytes2HexString(lmkHead); - } - - - public Data setLmkHead( byte[] bytes ) { - - this.lmkHead = bytes; - return this; - } - - - public byte[] getLmkAsBin( ) { - - return this.lmk; - } - - - public String getLmkAsStr( ) { - - if( null == this.lmk) return null; - return Arrays.toString(this.lmk); - } - - - public String getLmkAsHex( ) { - - if( null == this.lmk) return null; - return Util.bytes2HexString(lmk); - } - - - public Data setLmk( byte[] bytes ) { - - this.lmk = bytes; - return this; - } - - - public byte[] getKeyCheckAsBin( ) { - - return this.keyCheck; - } - - - public String getKeyCheckAsStr( ) { - - if( null == this.keyCheck) return null; - return Arrays.toString(this.keyCheck); - } - - - public String getKeyCheckAsHex( ) { - - if( null == this.keyCheck) return null; - return Util.bytes2HexString(keyCheck); - } - - - public Data setKeyCheck( byte[] bytes ) { - - this.keyCheck = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != lmkHead ){ - soup.put("lmkHead", this.lmkHead); - } - - if( null != lmk ){ - soup.put("lmk", this.lmk); - } - - if( null != keyCheck ){ - soup.put("keyCheck", this.keyCheck); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("lmkHead") ){ - this.lmkHead = ((PacketSection) soup.get("lmkHead")).getBytes(); - } - - if( soup.containsKey("lmk") ){ - this.lmk = ((PacketSection) soup.get("lmk")).getBytes(); - } - - if( soup.containsKey("keyCheck") ){ - this.keyCheck = ((PacketSection) soup.get("keyCheck")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4142")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4142"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOAB.java b/src/main/java/racal/sunyard/main/dto/DTOAB.java deleted file mode 100644 index 35a9697..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOAB.java +++ /dev/null @@ -1,947 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOAB { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] keyType = null; - private byte[] key = null; - private byte[] keyCheck = null; - private byte[] checkAlg = null; - private byte[] businessKey = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getKeyTypeAsBin( ) { - - return this.keyType; - } - - - public String getKeyTypeAsStr( ) { - - if( null == this.keyType) return null; - return Arrays.toString(this.keyType); - } - - - public String getKeyTypeAsHex( ) { - - if( null == this.keyType) return null; - return Util.bytes2HexString(keyType); - } - - - public Data setKeyType( byte[] bytes ) { - - this.keyType = bytes; - return this; - } - - - public byte[] getKeyAsBin( ) { - - return this.key; - } - - - public String getKeyAsStr( ) { - - if( null == this.key) return null; - return Arrays.toString(this.key); - } - - - public String getKeyAsHex( ) { - - if( null == this.key) return null; - return Util.bytes2HexString(key); - } - - - public Data setKey( byte[] bytes ) { - - this.key = bytes; - return this; - } - - - public byte[] getKeyCheckAsBin( ) { - - return this.keyCheck; - } - - - public String getKeyCheckAsStr( ) { - - if( null == this.keyCheck) return null; - return Arrays.toString(this.keyCheck); - } - - - public String getKeyCheckAsHex( ) { - - if( null == this.keyCheck) return null; - return Util.bytes2HexString(keyCheck); - } - - - public Data setKeyCheck( byte[] bytes ) { - - this.keyCheck = bytes; - return this; - } - - - public byte[] getCheckAlgAsBin( ) { - - return this.checkAlg; - } - - - public String getCheckAlgAsStr( ) { - - if( null == this.checkAlg) return null; - return Arrays.toString(this.checkAlg); - } - - - public String getCheckAlgAsHex( ) { - - if( null == this.checkAlg) return null; - return Util.bytes2HexString(checkAlg); - } - - - public Data setCheckAlg( byte[] bytes ) { - - this.checkAlg = bytes; - return this; - } -public enum CheckAlgOptions { - - OPV3DES(Util.hexString2Bytes("30")), - OPVSM4(Util.hexString2Bytes("31")); - private byte[] bin; - CheckAlgOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getCheckAlgCn( ) { - - if( null == checkAlg) { return null; } - if( "30".equals(Util.bytes2HexString(this.checkAlg))) { - return "3DES"; - } - if( "31".equals(Util.bytes2HexString(this.checkAlg))) { - return "SM4"; - } - return null; - } - - - public Integer getCheckAlgOptionIndex( ) { - - if( null == checkAlg) { return null; } - if( "30".equals(Util.bytes2HexString(this.checkAlg))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.checkAlg))) { - return 1; - } - return null; - } - - - public byte[] getBusinessKeyAsBin( ) { - - return this.businessKey; - } - - - public String getBusinessKeyAsStr( ) { - - if( null == this.businessKey) return null; - return Arrays.toString(this.businessKey); - } - - - public String getBusinessKeyAsHex( ) { - - if( null == this.businessKey) return null; - return Util.bytes2HexString(businessKey); - } - - - public Data setBusinessKey( byte[] bytes ) { - - this.businessKey = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != keyType ){ - soup.put("keyType", this.keyType); - } - - if( null != key ){ - soup.put("key", this.key); - } - - if( null != keyCheck ){ - soup.put("keyCheck", this.keyCheck); - } - - if( null != checkAlg ){ - soup.put("checkAlg", this.checkAlg); - soup.put("checkAlg$option", getCheckAlgOptionIndex()); - } - - if( null != businessKey ){ - soup.put("businessKey", this.businessKey); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("keyType") ){ - this.keyType = ((PacketSection) soup.get("keyType")).getBytes(); - } - - if( soup.containsKey("key") ){ - this.key = ((PacketSection) soup.get("key")).getBytes(); - } - - if( soup.containsKey("keyCheck") ){ - this.keyCheck = ((PacketSection) soup.get("keyCheck")).getBytes(); - } - - if( soup.containsKey("checkAlg") ){ - this.checkAlg = ((PacketSection) soup.get("checkAlg")).getBytes(); - } - - if( soup.containsKey("businessKey") ){ - this.businessKey = ((PacketSection) soup.get("businessKey")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4142")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4142"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] key1 = null; - private byte[] key2 = null; - private byte[] keyCheck = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV用户存储区没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误报告给管理员(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV无效的密钥方案(Util.hexString2Bytes("3236")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK错误;报告给管理员"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return "无效的密钥方案"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return 4; - } - return null; - } - - - public byte[] getKey1AsBin( ) { - - return this.key1; - } - - - public String getKey1AsStr( ) { - - if( null == this.key1) return null; - return Arrays.toString(this.key1); - } - - - public String getKey1AsHex( ) { - - if( null == this.key1) return null; - return Util.bytes2HexString(key1); - } - - - public Data setKey1( byte[] bytes ) { - - this.key1 = bytes; - return this; - } - - - public byte[] getKey2AsBin( ) { - - return this.key2; - } - - - public String getKey2AsStr( ) { - - if( null == this.key2) return null; - return Arrays.toString(this.key2); - } - - - public String getKey2AsHex( ) { - - if( null == this.key2) return null; - return Util.bytes2HexString(key2); - } - - - public Data setKey2( byte[] bytes ) { - - this.key2 = bytes; - return this; - } - - - public byte[] getKeyCheckAsBin( ) { - - return this.keyCheck; - } - - - public String getKeyCheckAsStr( ) { - - if( null == this.keyCheck) return null; - return Arrays.toString(this.keyCheck); - } - - - public String getKeyCheckAsHex( ) { - - if( null == this.keyCheck) return null; - return Util.bytes2HexString(keyCheck); - } - - - public Data setKeyCheck( byte[] bytes ) { - - this.keyCheck = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != key1 ){ - soup.put("key1", this.key1); - } - - if( null != key2 ){ - soup.put("key2", this.key2); - } - - if( null != keyCheck ){ - soup.put("keyCheck", this.keyCheck); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("key1") ){ - this.key1 = ((PacketSection) soup.get("key1")).getBytes(); - } - - if( soup.containsKey("key2") ){ - this.key2 = ((PacketSection) soup.get("key2")).getBytes(); - } - - if( soup.containsKey("keyCheck") ){ - this.keyCheck = ((PacketSection) soup.get("keyCheck")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4143")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4143"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOAE.java b/src/main/java/racal/sunyard/main/dto/DTOAE.java deleted file mode 100644 index 8372e5d..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOAE.java +++ /dev/null @@ -1,959 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOAE { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] tmkNow = null; - private byte[] tmkStorage = null; - private byte[] separator = null; - private byte[] tmkSolution = null; - private byte[] lmkSolution = null; - private byte[] keyCheckType = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getTmkNowAsBin( ) { - - return this.tmkNow; - } - - - public String getTmkNowAsStr( ) { - - if( null == this.tmkNow) return null; - return Arrays.toString(this.tmkNow); - } - - - public String getTmkNowAsHex( ) { - - if( null == this.tmkNow) return null; - return Util.bytes2HexString(tmkNow); - } - - - public Data setTmkNow( byte[] bytes ) { - - this.tmkNow = bytes; - return this; - } - - - public byte[] getTmkStorageAsBin( ) { - - return this.tmkStorage; - } - - - public String getTmkStorageAsStr( ) { - - if( null == this.tmkStorage) return null; - return Arrays.toString(this.tmkStorage); - } - - - public String getTmkStorageAsHex( ) { - - if( null == this.tmkStorage) return null; - return Util.bytes2HexString(tmkStorage); - } - - - public Data setTmkStorage( byte[] bytes ) { - - this.tmkStorage = bytes; - return this; - } - - - public byte[] getSeparatorAsBin( ) { - - return this.separator; - } - - - public String getSeparatorAsStr( ) { - - if( null == this.separator) return null; - return Arrays.toString(this.separator); - } - - - public String getSeparatorAsHex( ) { - - if( null == this.separator) return null; - return Util.bytes2HexString(separator); - } - - - public Data setSeparator( byte[] bytes ) { - - this.separator = bytes; - return this; - } - - - public byte[] getTmkSolutionAsBin( ) { - - return this.tmkSolution; - } - - - public String getTmkSolutionAsStr( ) { - - if( null == this.tmkSolution) return null; - return Arrays.toString(this.tmkSolution); - } - - - public String getTmkSolutionAsHex( ) { - - if( null == this.tmkSolution) return null; - return Util.bytes2HexString(tmkSolution); - } - - - public Data setTmkSolution( byte[] bytes ) { - - this.tmkSolution = bytes; - return this; - } - - - public byte[] getLmkSolutionAsBin( ) { - - return this.lmkSolution; - } - - - public String getLmkSolutionAsStr( ) { - - if( null == this.lmkSolution) return null; - return Arrays.toString(this.lmkSolution); - } - - - public String getLmkSolutionAsHex( ) { - - if( null == this.lmkSolution) return null; - return Util.bytes2HexString(lmkSolution); - } - - - public Data setLmkSolution( byte[] bytes ) { - - this.lmkSolution = bytes; - return this; - } - - - public byte[] getKeyCheckTypeAsBin( ) { - - return this.keyCheckType; - } - - - public String getKeyCheckTypeAsStr( ) { - - if( null == this.keyCheckType) return null; - return Arrays.toString(this.keyCheckType); - } - - - public String getKeyCheckTypeAsHex( ) { - - if( null == this.keyCheckType) return null; - return Util.bytes2HexString(keyCheckType); - } - - - public Data setKeyCheckType( byte[] bytes ) { - - this.keyCheckType = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != tmkNow ){ - soup.put("tmkNow", this.tmkNow); - } - - if( null != tmkStorage ){ - soup.put("tmkStorage", this.tmkStorage); - } - - if( null != separator ){ - soup.put("separator", this.separator); - } - - if( null != tmkSolution ){ - soup.put("tmkSolution", this.tmkSolution); - } - - if( null != lmkSolution ){ - soup.put("lmkSolution", this.lmkSolution); - } - - if( null != keyCheckType ){ - soup.put("keyCheckType", this.keyCheckType); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("tmkNow") ){ - this.tmkNow = ((PacketSection) soup.get("tmkNow")).getBytes(); - } - - if( soup.containsKey("tmkStorage") ){ - this.tmkStorage = ((PacketSection) soup.get("tmkStorage")).getBytes(); - } - - if( soup.containsKey("separator") ){ - this.separator = ((PacketSection) soup.get("separator")).getBytes(); - } - - if( soup.containsKey("tmkSolution") ){ - this.tmkSolution = ((PacketSection) soup.get("tmkSolution")).getBytes(); - } - - if( soup.containsKey("lmkSolution") ){ - this.lmkSolution = ((PacketSection) soup.get("lmkSolution")).getBytes(); - } - - if( soup.containsKey("keyCheckType") ){ - this.keyCheckType = ((PacketSection) soup.get("keyCheckType")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4145")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4145"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] tmkHead = null; - private byte[] tmkKey = null; - private byte[] keyCheck = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV当前TMKTPK或PVK奇偶校验错(Util.hexString2Bytes("3130")), - OPV存储TMKTPK或PVK奇偶校验错(Util.hexString2Bytes("3131")), - OPV用户存储区中没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV无效用户存储区索引(Util.hexString2Bytes("3231")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "当前 TMK、 TPK 或 PVK 奇偶校验错"; - } - if( "3131".equals(Util.bytes2HexString(this.error))) { - return "存储 TMK、 TPK 或 PVK 奇偶校验错"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区中没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效用户存储区索引"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3131".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 6; - } - return null; - } - - - public byte[] getTmkHeadAsBin( ) { - - return this.tmkHead; - } - - - public String getTmkHeadAsStr( ) { - - if( null == this.tmkHead) return null; - return Arrays.toString(this.tmkHead); - } - - - public String getTmkHeadAsHex( ) { - - if( null == this.tmkHead) return null; - return Util.bytes2HexString(tmkHead); - } - - - public Data setTmkHead( byte[] bytes ) { - - this.tmkHead = bytes; - return this; - } - - - public byte[] getTmkKeyAsBin( ) { - - return this.tmkKey; - } - - - public String getTmkKeyAsStr( ) { - - if( null == this.tmkKey) return null; - return Arrays.toString(this.tmkKey); - } - - - public String getTmkKeyAsHex( ) { - - if( null == this.tmkKey) return null; - return Util.bytes2HexString(tmkKey); - } - - - public Data setTmkKey( byte[] bytes ) { - - this.tmkKey = bytes; - return this; - } - - - public byte[] getKeyCheckAsBin( ) { - - return this.keyCheck; - } - - - public String getKeyCheckAsStr( ) { - - if( null == this.keyCheck) return null; - return Arrays.toString(this.keyCheck); - } - - - public String getKeyCheckAsHex( ) { - - if( null == this.keyCheck) return null; - return Util.bytes2HexString(keyCheck); - } - - - public Data setKeyCheck( byte[] bytes ) { - - this.keyCheck = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != tmkHead ){ - soup.put("tmkHead", this.tmkHead); - } - - if( null != tmkKey ){ - soup.put("tmkKey", this.tmkKey); - } - - if( null != keyCheck ){ - soup.put("keyCheck", this.keyCheck); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("tmkHead") ){ - this.tmkHead = ((PacketSection) soup.get("tmkHead")).getBytes(); - } - - if( soup.containsKey("tmkKey") ){ - this.tmkKey = ((PacketSection) soup.get("tmkKey")).getBytes(); - } - - if( soup.containsKey("keyCheck") ){ - this.keyCheck = ((PacketSection) soup.get("keyCheck")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4146")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4146"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOAG.java b/src/main/java/racal/sunyard/main/dto/DTOAG.java deleted file mode 100644 index 780b7dc..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOAG.java +++ /dev/null @@ -1,1009 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOAG { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] tmk = null; - private byte[] tak = null; - private byte[] businessKey = null; - private byte[] separator = null; - private byte[] tmkSolution = null; - private byte[] lmkSolution = null; - private byte[] keyCheckType = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getTmkAsBin( ) { - - return this.tmk; - } - - - public String getTmkAsStr( ) { - - if( null == this.tmk) return null; - return Arrays.toString(this.tmk); - } - - - public String getTmkAsHex( ) { - - if( null == this.tmk) return null; - return Util.bytes2HexString(tmk); - } - - - public Data setTmk( byte[] bytes ) { - - this.tmk = bytes; - return this; - } - - - public byte[] getTakAsBin( ) { - - return this.tak; - } - - - public String getTakAsStr( ) { - - if( null == this.tak) return null; - return Arrays.toString(this.tak); - } - - - public String getTakAsHex( ) { - - if( null == this.tak) return null; - return Util.bytes2HexString(tak); - } - - - public Data setTak( byte[] bytes ) { - - this.tak = bytes; - return this; - } - - - public byte[] getBusinessKeyAsBin( ) { - - return this.businessKey; - } - - - public String getBusinessKeyAsStr( ) { - - if( null == this.businessKey) return null; - return Arrays.toString(this.businessKey); - } - - - public String getBusinessKeyAsHex( ) { - - if( null == this.businessKey) return null; - return Util.bytes2HexString(businessKey); - } - - - public Data setBusinessKey( byte[] bytes ) { - - this.businessKey = bytes; - return this; - } - - - public byte[] getSeparatorAsBin( ) { - - return this.separator; - } - - - public String getSeparatorAsStr( ) { - - if( null == this.separator) return null; - return Arrays.toString(this.separator); - } - - - public String getSeparatorAsHex( ) { - - if( null == this.separator) return null; - return Util.bytes2HexString(separator); - } - - - public Data setSeparator( byte[] bytes ) { - - this.separator = bytes; - return this; - } - - - public byte[] getTmkSolutionAsBin( ) { - - return this.tmkSolution; - } - - - public String getTmkSolutionAsStr( ) { - - if( null == this.tmkSolution) return null; - return Arrays.toString(this.tmkSolution); - } - - - public String getTmkSolutionAsHex( ) { - - if( null == this.tmkSolution) return null; - return Util.bytes2HexString(tmkSolution); - } - - - public Data setTmkSolution( byte[] bytes ) { - - this.tmkSolution = bytes; - return this; - } - - - public byte[] getLmkSolutionAsBin( ) { - - return this.lmkSolution; - } - - - public String getLmkSolutionAsStr( ) { - - if( null == this.lmkSolution) return null; - return Arrays.toString(this.lmkSolution); - } - - - public String getLmkSolutionAsHex( ) { - - if( null == this.lmkSolution) return null; - return Util.bytes2HexString(lmkSolution); - } - - - public Data setLmkSolution( byte[] bytes ) { - - this.lmkSolution = bytes; - return this; - } - - - public byte[] getKeyCheckTypeAsBin( ) { - - return this.keyCheckType; - } - - - public String getKeyCheckTypeAsStr( ) { - - if( null == this.keyCheckType) return null; - return Arrays.toString(this.keyCheckType); - } - - - public String getKeyCheckTypeAsHex( ) { - - if( null == this.keyCheckType) return null; - return Util.bytes2HexString(keyCheckType); - } - - - public Data setKeyCheckType( byte[] bytes ) { - - this.keyCheckType = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != tmk ){ - soup.put("tmk", this.tmk); - } - - if( null != tak ){ - soup.put("tak", this.tak); - } - - if( null != businessKey ){ - soup.put("businessKey", this.businessKey); - } - - if( null != separator ){ - soup.put("separator", this.separator); - } - - if( null != tmkSolution ){ - soup.put("tmkSolution", this.tmkSolution); - } - - if( null != lmkSolution ){ - soup.put("lmkSolution", this.lmkSolution); - } - - if( null != keyCheckType ){ - soup.put("keyCheckType", this.keyCheckType); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("tmk") ){ - this.tmk = ((PacketSection) soup.get("tmk")).getBytes(); - } - - if( soup.containsKey("tak") ){ - this.tak = ((PacketSection) soup.get("tak")).getBytes(); - } - - if( soup.containsKey("businessKey") ){ - this.businessKey = ((PacketSection) soup.get("businessKey")).getBytes(); - } - - if( soup.containsKey("separator") ){ - this.separator = ((PacketSection) soup.get("separator")).getBytes(); - } - - if( soup.containsKey("tmkSolution") ){ - this.tmkSolution = ((PacketSection) soup.get("tmkSolution")).getBytes(); - } - - if( soup.containsKey("lmkSolution") ){ - this.lmkSolution = ((PacketSection) soup.get("lmkSolution")).getBytes(); - } - - if( soup.containsKey("keyCheckType") ){ - this.keyCheckType = ((PacketSection) soup.get("keyCheckType")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4147")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4147"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] tmkTakHead = null; - private byte[] tmkTak = null; - private byte[] keyCheck = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPVZMK奇偶校验错(Util.hexString2Bytes("3130")), - OPVTMKTPK或PVK奇偶校验错(Util.hexString2Bytes("3131")), - OPV用户存储区没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV无效的用户存储索引(Util.hexString2Bytes("3231")), - OPV密钥方案错误(Util.hexString2Bytes("3236")), - OPV数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "ZMK 奇偶校验错"; - } - if( "3131".equals(Util.bytes2HexString(this.error))) { - return "TMK、TPK 或 PVK 奇偶校验错"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效的用户存储索引"; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return "密钥方案错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3131".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 8; - } - return null; - } - - - public byte[] getTmkTakHeadAsBin( ) { - - return this.tmkTakHead; - } - - - public String getTmkTakHeadAsStr( ) { - - if( null == this.tmkTakHead) return null; - return Arrays.toString(this.tmkTakHead); - } - - - public String getTmkTakHeadAsHex( ) { - - if( null == this.tmkTakHead) return null; - return Util.bytes2HexString(tmkTakHead); - } - - - public Data setTmkTakHead( byte[] bytes ) { - - this.tmkTakHead = bytes; - return this; - } - - - public byte[] getTmkTakAsBin( ) { - - return this.tmkTak; - } - - - public String getTmkTakAsStr( ) { - - if( null == this.tmkTak) return null; - return Arrays.toString(this.tmkTak); - } - - - public String getTmkTakAsHex( ) { - - if( null == this.tmkTak) return null; - return Util.bytes2HexString(tmkTak); - } - - - public Data setTmkTak( byte[] bytes ) { - - this.tmkTak = bytes; - return this; - } - - - public byte[] getKeyCheckAsBin( ) { - - return this.keyCheck; - } - - - public String getKeyCheckAsStr( ) { - - if( null == this.keyCheck) return null; - return Arrays.toString(this.keyCheck); - } - - - public String getKeyCheckAsHex( ) { - - if( null == this.keyCheck) return null; - return Util.bytes2HexString(keyCheck); - } - - - public Data setKeyCheck( byte[] bytes ) { - - this.keyCheck = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != tmkTakHead ){ - soup.put("tmkTakHead", this.tmkTakHead); - } - - if( null != tmkTak ){ - soup.put("tmkTak", this.tmkTak); - } - - if( null != keyCheck ){ - soup.put("keyCheck", this.keyCheck); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("tmkTakHead") ){ - this.tmkTakHead = ((PacketSection) soup.get("tmkTakHead")).getBytes(); - } - - if( soup.containsKey("tmkTak") ){ - this.tmkTak = ((PacketSection) soup.get("tmkTak")).getBytes(); - } - - if( soup.containsKey("keyCheck") ){ - this.keyCheck = ((PacketSection) soup.get("keyCheck")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4148")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4148"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOB0.java b/src/main/java/racal/sunyard/main/dto/DTOB0.java deleted file mode 100644 index 80b1a32..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOB0.java +++ /dev/null @@ -1,815 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOB0 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] keyType = null; - private byte[] key = null; - private byte[] keySolution = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getKeyTypeAsBin( ) { - - return this.keyType; - } - - - public String getKeyTypeAsStr( ) { - - if( null == this.keyType) return null; - return Arrays.toString(this.keyType); - } - - - public String getKeyTypeAsHex( ) { - - if( null == this.keyType) return null; - return Util.bytes2HexString(keyType); - } - - - public Data setKeyType( byte[] bytes ) { - - this.keyType = bytes; - return this; - } - - - public byte[] getKeyAsBin( ) { - - return this.key; - } - - - public String getKeyAsStr( ) { - - if( null == this.key) return null; - return Arrays.toString(this.key); - } - - - public String getKeyAsHex( ) { - - if( null == this.key) return null; - return Util.bytes2HexString(key); - } - - - public Data setKey( byte[] bytes ) { - - this.key = bytes; - return this; - } - - - public byte[] getKeySolutionAsBin( ) { - - return this.keySolution; - } - - - public String getKeySolutionAsStr( ) { - - if( null == this.keySolution) return null; - return Arrays.toString(this.keySolution); - } - - - public String getKeySolutionAsHex( ) { - - if( null == this.keySolution) return null; - return Util.bytes2HexString(keySolution); - } - - - public Data setKeySolution( byte[] bytes ) { - - this.keySolution = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != keyType ){ - soup.put("keyType", this.keyType); - } - - if( null != key ){ - soup.put("key", this.key); - } - - if( null != keySolution ){ - soup.put("keySolution", this.keySolution); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("keyType") ){ - this.keyType = ((PacketSection) soup.get("keyType")).getBytes(); - } - - if( soup.containsKey("key") ){ - this.key = ((PacketSection) soup.get("key")).getBytes(); - } - - if( soup.containsKey("keySolution") ){ - this.keySolution = ((PacketSection) soup.get("keySolution")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4230")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4230"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] lmkHead = null; - private byte[] lmk = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPVZMK奇偶校验错(Util.hexString2Bytes("3130")), - OPV用户存储区中没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV不在授权状态(Util.hexString2Bytes("3137")), - OPV无效用户存储区索引(Util.hexString2Bytes("3231")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "ZMK 奇偶校验错"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区中没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3137".equals(Util.bytes2HexString(this.error))) { - return "不在授权状态"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效用户存储区索引"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3137".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 6; - } - return null; - } - - - public byte[] getLmkHeadAsBin( ) { - - return this.lmkHead; - } - - - public String getLmkHeadAsStr( ) { - - if( null == this.lmkHead) return null; - return Arrays.toString(this.lmkHead); - } - - - public String getLmkHeadAsHex( ) { - - if( null == this.lmkHead) return null; - return Util.bytes2HexString(lmkHead); - } - - - public Data setLmkHead( byte[] bytes ) { - - this.lmkHead = bytes; - return this; - } - - - public byte[] getLmkAsBin( ) { - - return this.lmk; - } - - - public String getLmkAsStr( ) { - - if( null == this.lmk) return null; - return Arrays.toString(this.lmk); - } - - - public String getLmkAsHex( ) { - - if( null == this.lmk) return null; - return Util.bytes2HexString(lmk); - } - - - public Data setLmk( byte[] bytes ) { - - this.lmk = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != lmkHead ){ - soup.put("lmkHead", this.lmkHead); - } - - if( null != lmk ){ - soup.put("lmk", this.lmk); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("lmkHead") ){ - this.lmkHead = ((PacketSection) soup.get("lmkHead")).getBytes(); - } - - if( soup.containsKey("lmk") ){ - this.lmk = ((PacketSection) soup.get("lmk")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4231")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4231"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOBA.java b/src/main/java/racal/sunyard/main/dto/DTOBA.java deleted file mode 100644 index 48ad39c..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOBA.java +++ /dev/null @@ -1,796 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOBA { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] alg = null; - private byte[] pin = null; - private byte[] account = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getAlgAsBin( ) { - - return this.alg; - } - - - public String getAlgAsStr( ) { - - if( null == this.alg) return null; - return Arrays.toString(this.alg); - } - - - public String getAlgAsHex( ) { - - if( null == this.alg) return null; - return Util.bytes2HexString(alg); - } - - - public Data setAlg( byte[] bytes ) { - - this.alg = bytes; - return this; - } -public enum AlgOptions { - - OPV3DES(Util.hexString2Bytes("30")), - OPVSM4(Util.hexString2Bytes("31")); - private byte[] bin; - AlgOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getAlgCn( ) { - - if( null == alg) { return null; } - if( "30".equals(Util.bytes2HexString(this.alg))) { - return "3DES"; - } - if( "31".equals(Util.bytes2HexString(this.alg))) { - return "SM4"; - } - return null; - } - - - public Integer getAlgOptionIndex( ) { - - if( null == alg) { return null; } - if( "30".equals(Util.bytes2HexString(this.alg))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.alg))) { - return 1; - } - return null; - } - - - public byte[] getPinAsBin( ) { - - return this.pin; - } - - - public String getPinAsStr( ) { - - if( null == this.pin) return null; - return Arrays.toString(this.pin); - } - - - public String getPinAsHex( ) { - - if( null == this.pin) return null; - return Util.bytes2HexString(pin); - } - - - public Data setPin( byte[] bytes ) { - - this.pin = bytes; - return this; - } - - - public byte[] getAccountAsBin( ) { - - return this.account; - } - - - public String getAccountAsStr( ) { - - if( null == this.account) return null; - return Arrays.toString(this.account); - } - - - public String getAccountAsHex( ) { - - if( null == this.account) return null; - return Util.bytes2HexString(account); - } - - - public Data setAccount( byte[] bytes ) { - - this.account = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != alg ){ - soup.put("alg", this.alg); - soup.put("alg$option", getAlgOptionIndex()); - } - - if( null != pin ){ - soup.put("pin", this.pin); - } - - if( null != account ){ - soup.put("account", this.account); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("alg") ){ - this.alg = ((PacketSection) soup.get("alg")).getBytes(); - } - - if( soup.containsKey("pin") ){ - this.pin = ((PacketSection) soup.get("pin")).getBytes(); - } - - if( soup.containsKey("account") ){ - this.account = ((PacketSection) soup.get("account")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4241")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4241"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] pinBlock = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV不在授权状态(Util.hexString2Bytes("3137")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3137".equals(Util.bytes2HexString(this.error))) { - return "不在授权状态"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3137".equals(Util.bytes2HexString(this.error))) { - return 3; - } - return null; - } - - - public byte[] getPinBlockAsBin( ) { - - return this.pinBlock; - } - - - public String getPinBlockAsStr( ) { - - if( null == this.pinBlock) return null; - return Arrays.toString(this.pinBlock); - } - - - public String getPinBlockAsHex( ) { - - if( null == this.pinBlock) return null; - return Util.bytes2HexString(pinBlock); - } - - - public Data setPinBlock( byte[] bytes ) { - - this.pinBlock = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != pinBlock ){ - soup.put("pinBlock", this.pinBlock); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("pinBlock") ){ - this.pinBlock = ((PacketSection) soup.get("pinBlock")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4242")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4242"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOBY.java b/src/main/java/racal/sunyard/main/dto/DTOBY.java deleted file mode 100644 index 5cd3ec2..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOBY.java +++ /dev/null @@ -1,973 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOBY { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] zmki = null; - private byte[] zmk = null; - private byte[] separator = null; - private byte[] zmkSolution = null; - private byte[] lmkSolution = null; - private byte[] keyCheckType = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getZmkiAsBin( ) { - - return this.zmki; - } - - - public String getZmkiAsStr( ) { - - if( null == this.zmki) return null; - return Arrays.toString(this.zmki); - } - - - public String getZmkiAsHex( ) { - - if( null == this.zmki) return null; - return Util.bytes2HexString(zmki); - } - - - public Data setZmki( byte[] bytes ) { - - this.zmki = bytes; - return this; - } - - - public byte[] getZmkAsBin( ) { - - return this.zmk; - } - - - public String getZmkAsStr( ) { - - if( null == this.zmk) return null; - return Arrays.toString(this.zmk); - } - - - public String getZmkAsHex( ) { - - if( null == this.zmk) return null; - return Util.bytes2HexString(zmk); - } - - - public Data setZmk( byte[] bytes ) { - - this.zmk = bytes; - return this; - } - - - public byte[] getSeparatorAsBin( ) { - - return this.separator; - } - - - public String getSeparatorAsStr( ) { - - if( null == this.separator) return null; - return Arrays.toString(this.separator); - } - - - public String getSeparatorAsHex( ) { - - if( null == this.separator) return null; - return Util.bytes2HexString(separator); - } - - - public Data setSeparator( byte[] bytes ) { - - this.separator = bytes; - return this; - } - - - public byte[] getZmkSolutionAsBin( ) { - - return this.zmkSolution; - } - - - public String getZmkSolutionAsStr( ) { - - if( null == this.zmkSolution) return null; - return Arrays.toString(this.zmkSolution); - } - - - public String getZmkSolutionAsHex( ) { - - if( null == this.zmkSolution) return null; - return Util.bytes2HexString(zmkSolution); - } - - - public Data setZmkSolution( byte[] bytes ) { - - this.zmkSolution = bytes; - return this; - } - - - public byte[] getLmkSolutionAsBin( ) { - - return this.lmkSolution; - } - - - public String getLmkSolutionAsStr( ) { - - if( null == this.lmkSolution) return null; - return Arrays.toString(this.lmkSolution); - } - - - public String getLmkSolutionAsHex( ) { - - if( null == this.lmkSolution) return null; - return Util.bytes2HexString(lmkSolution); - } - - - public Data setLmkSolution( byte[] bytes ) { - - this.lmkSolution = bytes; - return this; - } - - - public byte[] getKeyCheckTypeAsBin( ) { - - return this.keyCheckType; - } - - - public String getKeyCheckTypeAsStr( ) { - - if( null == this.keyCheckType) return null; - return Arrays.toString(this.keyCheckType); - } - - - public String getKeyCheckTypeAsHex( ) { - - if( null == this.keyCheckType) return null; - return Util.bytes2HexString(keyCheckType); - } - - - public Data setKeyCheckType( byte[] bytes ) { - - this.keyCheckType = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != zmki ){ - soup.put("zmki", this.zmki); - } - - if( null != zmk ){ - soup.put("zmk", this.zmk); - } - - if( null != separator ){ - soup.put("separator", this.separator); - } - - if( null != zmkSolution ){ - soup.put("zmkSolution", this.zmkSolution); - } - - if( null != lmkSolution ){ - soup.put("lmkSolution", this.lmkSolution); - } - - if( null != keyCheckType ){ - soup.put("keyCheckType", this.keyCheckType); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("zmki") ){ - this.zmki = ((PacketSection) soup.get("zmki")).getBytes(); - } - - if( soup.containsKey("zmk") ){ - this.zmk = ((PacketSection) soup.get("zmk")).getBytes(); - } - - if( soup.containsKey("separator") ){ - this.separator = ((PacketSection) soup.get("separator")).getBytes(); - } - - if( soup.containsKey("zmkSolution") ){ - this.zmkSolution = ((PacketSection) soup.get("zmkSolution")).getBytes(); - } - - if( soup.containsKey("lmkSolution") ){ - this.lmkSolution = ((PacketSection) soup.get("lmkSolution")).getBytes(); - } - - if( soup.containsKey("keyCheckType") ){ - this.keyCheckType = ((PacketSection) soup.get("keyCheckType")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4259")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4259"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] zmkHead = null; - private byte[] zmk = null; - private byte[] keyCheck = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV密钥奇偶校验错仅仅是报告错误并不影响结果(Util.hexString2Bytes("3031")), - OPV第一个成份奇偶校验错(Util.hexString2Bytes("3130")), - OPV第二或第三个成份奇偶校验错(Util.hexString2Bytes("3131")), - OPV用户存储区中没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV不在授权状态(Util.hexString2Bytes("3137")), - OPV无效用户存储区索引(Util.hexString2Bytes("3231")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3031".equals(Util.bytes2HexString(this.error))) { - return "密钥奇偶校验错,仅仅是报告错误,并不影响结果"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "第一个成份奇偶校验错"; - } - if( "3131".equals(Util.bytes2HexString(this.error))) { - return "第二或第三个成份奇偶校验错"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区中没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3137".equals(Util.bytes2HexString(this.error))) { - return "不在授权状态"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效用户存储区索引"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3031".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3131".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3137".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 8; - } - return null; - } - - - public byte[] getZmkHeadAsBin( ) { - - return this.zmkHead; - } - - - public String getZmkHeadAsStr( ) { - - if( null == this.zmkHead) return null; - return Arrays.toString(this.zmkHead); - } - - - public String getZmkHeadAsHex( ) { - - if( null == this.zmkHead) return null; - return Util.bytes2HexString(zmkHead); - } - - - public Data setZmkHead( byte[] bytes ) { - - this.zmkHead = bytes; - return this; - } - - - public byte[] getZmkAsBin( ) { - - return this.zmk; - } - - - public String getZmkAsStr( ) { - - if( null == this.zmk) return null; - return Arrays.toString(this.zmk); - } - - - public String getZmkAsHex( ) { - - if( null == this.zmk) return null; - return Util.bytes2HexString(zmk); - } - - - public Data setZmk( byte[] bytes ) { - - this.zmk = bytes; - return this; - } - - - public byte[] getKeyCheckAsBin( ) { - - return this.keyCheck; - } - - - public String getKeyCheckAsStr( ) { - - if( null == this.keyCheck) return null; - return Arrays.toString(this.keyCheck); - } - - - public String getKeyCheckAsHex( ) { - - if( null == this.keyCheck) return null; - return Util.bytes2HexString(keyCheck); - } - - - public Data setKeyCheck( byte[] bytes ) { - - this.keyCheck = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != zmkHead ){ - soup.put("zmkHead", this.zmkHead); - } - - if( null != zmk ){ - soup.put("zmk", this.zmk); - } - - if( null != keyCheck ){ - soup.put("keyCheck", this.keyCheck); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("zmkHead") ){ - this.zmkHead = ((PacketSection) soup.get("zmkHead")).getBytes(); - } - - if( soup.containsKey("zmk") ){ - this.zmk = ((PacketSection) soup.get("zmk")).getBytes(); - } - - if( soup.containsKey("keyCheck") ){ - this.keyCheck = ((PacketSection) soup.get("keyCheck")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("425A")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("425A"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOCA.java b/src/main/java/racal/sunyard/main/dto/DTOCA.java deleted file mode 100644 index 4c510e3..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOCA.java +++ /dev/null @@ -1,1259 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOCA { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] sourceZpk = null; - private byte[] purposeZpk = null; - private byte[] algorithmKey = null; - private byte[] sca = null; - private byte[] dca = null; - private byte[] businessKey = null; - private byte[] maxLength = null; - private byte[] sourcePinBlock = null; - private byte[] sourcePinBlockFormat = null; - private byte[] purposePinBlockFormat = null; - private byte[] account = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getSourceZpkAsBin( ) { - - return this.sourceZpk; - } - - - public String getSourceZpkAsStr( ) { - - if( null == this.sourceZpk) return null; - return Arrays.toString(this.sourceZpk); - } - - - public String getSourceZpkAsHex( ) { - - if( null == this.sourceZpk) return null; - return Util.bytes2HexString(sourceZpk); - } - - - public Data setSourceZpk( byte[] bytes ) { - - this.sourceZpk = bytes; - return this; - } - - - public byte[] getPurposeZpkAsBin( ) { - - return this.purposeZpk; - } - - - public String getPurposeZpkAsStr( ) { - - if( null == this.purposeZpk) return null; - return Arrays.toString(this.purposeZpk); - } - - - public String getPurposeZpkAsHex( ) { - - if( null == this.purposeZpk) return null; - return Util.bytes2HexString(purposeZpk); - } - - - public Data setPurposeZpk( byte[] bytes ) { - - this.purposeZpk = bytes; - return this; - } - - - public byte[] getAlgorithmKeyAsBin( ) { - - return this.algorithmKey; - } - - - public String getAlgorithmKeyAsStr( ) { - - if( null == this.algorithmKey) return null; - return Arrays.toString(this.algorithmKey); - } - - - public String getAlgorithmKeyAsHex( ) { - - if( null == this.algorithmKey) return null; - return Util.bytes2HexString(algorithmKey); - } - - - public Data setAlgorithmKey( byte[] bytes ) { - - this.algorithmKey = bytes; - return this; - } - - - public byte[] getScaAsBin( ) { - - return this.sca; - } - - - public String getScaAsStr( ) { - - if( null == this.sca) return null; - return Arrays.toString(this.sca); - } - - - public String getScaAsHex( ) { - - if( null == this.sca) return null; - return Util.bytes2HexString(sca); - } - - - public Data setSca( byte[] bytes ) { - - this.sca = bytes; - return this; - } -public enum ScaOptions { - - OPV3DES默认(Util.hexString2Bytes("31")), - OPVSM4(Util.hexString2Bytes("32")); - private byte[] bin; - ScaOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getScaCn( ) { - - if( null == sca) { return null; } - if( "31".equals(Util.bytes2HexString(this.sca))) { - return "3DES(默认)"; - } - if( "32".equals(Util.bytes2HexString(this.sca))) { - return "SM4"; - } - return null; - } - - - public Integer getScaOptionIndex( ) { - - if( null == sca) { return null; } - if( "31".equals(Util.bytes2HexString(this.sca))) { - return 0; - } - if( "32".equals(Util.bytes2HexString(this.sca))) { - return 1; - } - return null; - } - - - public byte[] getDcaAsBin( ) { - - return this.dca; - } - - - public String getDcaAsStr( ) { - - if( null == this.dca) return null; - return Arrays.toString(this.dca); - } - - - public String getDcaAsHex( ) { - - if( null == this.dca) return null; - return Util.bytes2HexString(dca); - } - - - public Data setDca( byte[] bytes ) { - - this.dca = bytes; - return this; - } -public enum DcaOptions { - - OPV3DES默认(Util.hexString2Bytes("31")), - OPVSM4(Util.hexString2Bytes("32")); - private byte[] bin; - DcaOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getDcaCn( ) { - - if( null == dca) { return null; } - if( "31".equals(Util.bytes2HexString(this.dca))) { - return "3DES(默认)"; - } - if( "32".equals(Util.bytes2HexString(this.dca))) { - return "SM4"; - } - return null; - } - - - public Integer getDcaOptionIndex( ) { - - if( null == dca) { return null; } - if( "31".equals(Util.bytes2HexString(this.dca))) { - return 0; - } - if( "32".equals(Util.bytes2HexString(this.dca))) { - return 1; - } - return null; - } - - - public byte[] getBusinessKeyAsBin( ) { - - return this.businessKey; - } - - - public String getBusinessKeyAsStr( ) { - - if( null == this.businessKey) return null; - return Arrays.toString(this.businessKey); - } - - - public String getBusinessKeyAsHex( ) { - - if( null == this.businessKey) return null; - return Util.bytes2HexString(businessKey); - } - - - public Data setBusinessKey( byte[] bytes ) { - - this.businessKey = bytes; - return this; - } - - - public byte[] getMaxLengthAsBin( ) { - - return this.maxLength; - } - - - public String getMaxLengthAsStr( ) { - - if( null == this.maxLength) return null; - return Arrays.toString(this.maxLength); - } - - - public String getMaxLengthAsHex( ) { - - if( null == this.maxLength) return null; - return Util.bytes2HexString(maxLength); - } - - - public Data setMaxLength( byte[] bytes ) { - - this.maxLength = bytes; - return this; - } - - - public byte[] getSourcePinBlockAsBin( ) { - - return this.sourcePinBlock; - } - - - public String getSourcePinBlockAsStr( ) { - - if( null == this.sourcePinBlock) return null; - return Arrays.toString(this.sourcePinBlock); - } - - - public String getSourcePinBlockAsHex( ) { - - if( null == this.sourcePinBlock) return null; - return Util.bytes2HexString(sourcePinBlock); - } - - - public Data setSourcePinBlock( byte[] bytes ) { - - this.sourcePinBlock = bytes; - return this; - } - - - public byte[] getSourcePinBlockFormatAsBin( ) { - - return this.sourcePinBlockFormat; - } - - - public String getSourcePinBlockFormatAsStr( ) { - - if( null == this.sourcePinBlockFormat) return null; - return Arrays.toString(this.sourcePinBlockFormat); - } - - - public String getSourcePinBlockFormatAsHex( ) { - - if( null == this.sourcePinBlockFormat) return null; - return Util.bytes2HexString(sourcePinBlockFormat); - } - - - public Data setSourcePinBlockFormat( byte[] bytes ) { - - this.sourcePinBlockFormat = bytes; - return this; - } - - - public byte[] getPurposePinBlockFormatAsBin( ) { - - return this.purposePinBlockFormat; - } - - - public String getPurposePinBlockFormatAsStr( ) { - - if( null == this.purposePinBlockFormat) return null; - return Arrays.toString(this.purposePinBlockFormat); - } - - - public String getPurposePinBlockFormatAsHex( ) { - - if( null == this.purposePinBlockFormat) return null; - return Util.bytes2HexString(purposePinBlockFormat); - } - - - public Data setPurposePinBlockFormat( byte[] bytes ) { - - this.purposePinBlockFormat = bytes; - return this; - } - - - public byte[] getAccountAsBin( ) { - - return this.account; - } - - - public String getAccountAsStr( ) { - - if( null == this.account) return null; - return Arrays.toString(this.account); - } - - - public String getAccountAsHex( ) { - - if( null == this.account) return null; - return Util.bytes2HexString(account); - } - - - public Data setAccount( byte[] bytes ) { - - this.account = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != sourceZpk ){ - soup.put("sourceZpk", this.sourceZpk); - } - - if( null != purposeZpk ){ - soup.put("purposeZpk", this.purposeZpk); - } - - if( null != algorithmKey ){ - soup.put("algorithmKey", this.algorithmKey); - } - - if( null != sca ){ - soup.put("sca", this.sca); - soup.put("sca$option", getScaOptionIndex()); - } - - if( null != dca ){ - soup.put("dca", this.dca); - soup.put("dca$option", getDcaOptionIndex()); - } - - if( null != businessKey ){ - soup.put("businessKey", this.businessKey); - } - - soup.put("maxLength", Util.hexString2Bytes("3132")); - if( null != maxLength ){ - soup.put("maxLength", this.maxLength); - } - - if( null != sourcePinBlock ){ - soup.put("sourcePinBlock", this.sourcePinBlock); - } - - if( null != sourcePinBlockFormat ){ - soup.put("sourcePinBlockFormat", this.sourcePinBlockFormat); - } - - if( null != purposePinBlockFormat ){ - soup.put("purposePinBlockFormat", this.purposePinBlockFormat); - } - - if( null != account ){ - soup.put("account", this.account); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("sourceZpk") ){ - this.sourceZpk = ((PacketSection) soup.get("sourceZpk")).getBytes(); - } - - if( soup.containsKey("purposeZpk") ){ - this.purposeZpk = ((PacketSection) soup.get("purposeZpk")).getBytes(); - } - - if( soup.containsKey("algorithmKey") ){ - this.algorithmKey = ((PacketSection) soup.get("algorithmKey")).getBytes(); - } - - if( soup.containsKey("sca") ){ - this.sca = ((PacketSection) soup.get("sca")).getBytes(); - } - - if( soup.containsKey("dca") ){ - this.dca = ((PacketSection) soup.get("dca")).getBytes(); - } - - if( soup.containsKey("businessKey") ){ - this.businessKey = ((PacketSection) soup.get("businessKey")).getBytes(); - } - - this.maxLength = Util.hexString2Bytes("3132"); - if( soup.containsKey("maxLength") ){ - this.maxLength = ((PacketSection) soup.get("maxLength")).getBytes(); - } - - if( soup.containsKey("sourcePinBlock") ){ - this.sourcePinBlock = ((PacketSection) soup.get("sourcePinBlock")).getBytes(); - } - - if( soup.containsKey("sourcePinBlockFormat") ){ - this.sourcePinBlockFormat = ((PacketSection) soup.get("sourcePinBlockFormat")).getBytes(); - } - - if( soup.containsKey("purposePinBlockFormat") ){ - this.purposePinBlockFormat = ((PacketSection) soup.get("purposePinBlockFormat")).getBytes(); - } - - if( soup.containsKey("account") ){ - this.account = ((PacketSection) soup.get("account")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4341")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4341"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] pinLen = null; - private byte[] purposePinBlock = null; - private byte[] purposePinBlockFormat = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV源ZPK奇偶校验错(Util.hexString2Bytes("3130")), - OPV目的ZPK奇偶校验错(Util.hexString2Bytes("3131")), - OPV用户存储区中没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVPIN块错误(Util.hexString2Bytes("3230")), - OPV无效的用户存储索引(Util.hexString2Bytes("3231")), - OPV帐号无效(Util.hexString2Bytes("3232")), - OPV无效PIN块格式代码(Util.hexString2Bytes("3233")), - OPVPIN小于4位或大于12位(Util.hexString2Bytes("3234")), - OPV无效的密钥方案(Util.hexString2Bytes("3236")), - OPV数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "源 ZPK 奇偶校验错"; - } - if( "3131".equals(Util.bytes2HexString(this.error))) { - return "目的 ZPK 奇偶校验错"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区中没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3230".equals(Util.bytes2HexString(this.error))) { - return "PIN块错误"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效的用户存储索引"; - } - if( "3232".equals(Util.bytes2HexString(this.error))) { - return "帐号无效"; - } - if( "3233".equals(Util.bytes2HexString(this.error))) { - return "无效 PIN 块格式代码"; - } - if( "3234".equals(Util.bytes2HexString(this.error))) { - return "PIN 小于 4 位或大于 12 位。"; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return "无效的密钥方案"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3131".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3230".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3232".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3233".equals(Util.bytes2HexString(this.error))) { - return 9; - } - if( "3234".equals(Util.bytes2HexString(this.error))) { - return 10; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return 11; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 12; - } - return null; - } - - - public byte[] getPinLenAsBin( ) { - - return this.pinLen; - } - - - public String getPinLenAsStr( ) { - - if( null == this.pinLen) return null; - return Arrays.toString(this.pinLen); - } - - - public String getPinLenAsHex( ) { - - if( null == this.pinLen) return null; - return Util.bytes2HexString(pinLen); - } - - - public Data setPinLen( byte[] bytes ) { - - this.pinLen = bytes; - return this; - } - - - public byte[] getPurposePinBlockAsBin( ) { - - return this.purposePinBlock; - } - - - public String getPurposePinBlockAsStr( ) { - - if( null == this.purposePinBlock) return null; - return Arrays.toString(this.purposePinBlock); - } - - - public String getPurposePinBlockAsHex( ) { - - if( null == this.purposePinBlock) return null; - return Util.bytes2HexString(purposePinBlock); - } - - - public Data setPurposePinBlock( byte[] bytes ) { - - this.purposePinBlock = bytes; - return this; - } - - - public byte[] getPurposePinBlockFormatAsBin( ) { - - return this.purposePinBlockFormat; - } - - - public String getPurposePinBlockFormatAsStr( ) { - - if( null == this.purposePinBlockFormat) return null; - return Arrays.toString(this.purposePinBlockFormat); - } - - - public String getPurposePinBlockFormatAsHex( ) { - - if( null == this.purposePinBlockFormat) return null; - return Util.bytes2HexString(purposePinBlockFormat); - } - - - public Data setPurposePinBlockFormat( byte[] bytes ) { - - this.purposePinBlockFormat = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != pinLen ){ - soup.put("pinLen", this.pinLen); - } - - if( null != purposePinBlock ){ - soup.put("purposePinBlock", this.purposePinBlock); - } - - if( null != purposePinBlockFormat ){ - soup.put("purposePinBlockFormat", this.purposePinBlockFormat); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("pinLen") ){ - this.pinLen = ((PacketSection) soup.get("pinLen")).getBytes(); - } - - if( soup.containsKey("purposePinBlock") ){ - this.purposePinBlock = ((PacketSection) soup.get("purposePinBlock")).getBytes(); - } - - if( soup.containsKey("purposePinBlockFormat") ){ - this.purposePinBlockFormat = ((PacketSection) soup.get("purposePinBlockFormat")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4342")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4342"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOCB.java b/src/main/java/racal/sunyard/main/dto/DTOCB.java deleted file mode 100644 index fd97792..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOCB.java +++ /dev/null @@ -1,1418 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOCB { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] srcKeyType = null; - private byte[] desKeyType = null; - private byte[] srcKey = null; - private byte[] desKey = null; - private byte[] algorithmKey = null; - private byte[] sca = null; - private byte[] dca = null; - private byte[] sPin = null; - private byte[] sPinType = null; - private byte[] dPinType = null; - private byte[] primaryAccount = null; - private byte[] businessKey = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getSrcKeyTypeAsBin( ) { - - return this.srcKeyType; - } - - - public String getSrcKeyTypeAsStr( ) { - - if( null == this.srcKeyType) return null; - return Arrays.toString(this.srcKeyType); - } - - - public String getSrcKeyTypeAsHex( ) { - - if( null == this.srcKeyType) return null; - return Util.bytes2HexString(srcKeyType); - } - - - public Data setSrcKeyType( byte[] bytes ) { - - this.srcKeyType = bytes; - return this; - } - - - public byte[] getDesKeyTypeAsBin( ) { - - return this.desKeyType; - } - - - public String getDesKeyTypeAsStr( ) { - - if( null == this.desKeyType) return null; - return Arrays.toString(this.desKeyType); - } - - - public String getDesKeyTypeAsHex( ) { - - if( null == this.desKeyType) return null; - return Util.bytes2HexString(desKeyType); - } - - - public Data setDesKeyType( byte[] bytes ) { - - this.desKeyType = bytes; - return this; - } - - - public byte[] getSrcKeyAsBin( ) { - - return this.srcKey; - } - - - public String getSrcKeyAsStr( ) { - - if( null == this.srcKey) return null; - return Arrays.toString(this.srcKey); - } - - - public String getSrcKeyAsHex( ) { - - if( null == this.srcKey) return null; - return Util.bytes2HexString(srcKey); - } - - - public Data setSrcKey( byte[] bytes ) { - - this.srcKey = bytes; - return this; - } - - - public byte[] getDesKeyAsBin( ) { - - return this.desKey; - } - - - public String getDesKeyAsStr( ) { - - if( null == this.desKey) return null; - return Arrays.toString(this.desKey); - } - - - public String getDesKeyAsHex( ) { - - if( null == this.desKey) return null; - return Util.bytes2HexString(desKey); - } - - - public Data setDesKey( byte[] bytes ) { - - this.desKey = bytes; - return this; - } - - - public byte[] getAlgorithmKeyAsBin( ) { - - return this.algorithmKey; - } - - - public String getAlgorithmKeyAsStr( ) { - - if( null == this.algorithmKey) return null; - return Arrays.toString(this.algorithmKey); - } - - - public String getAlgorithmKeyAsHex( ) { - - if( null == this.algorithmKey) return null; - return Util.bytes2HexString(algorithmKey); - } - - - public Data setAlgorithmKey( byte[] bytes ) { - - this.algorithmKey = bytes; - return this; - } - - - public byte[] getScaAsBin( ) { - - return this.sca; - } - - - public String getScaAsStr( ) { - - if( null == this.sca) return null; - return Arrays.toString(this.sca); - } - - - public String getScaAsHex( ) { - - if( null == this.sca) return null; - return Util.bytes2HexString(sca); - } - - - public Data setSca( byte[] bytes ) { - - this.sca = bytes; - return this; - } -public enum ScaOptions { - - OPV3DES(Util.hexString2Bytes("31")), - OPVSM4(Util.hexString2Bytes("32")); - private byte[] bin; - ScaOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getScaCn( ) { - - if( null == sca) { return null; } - if( "31".equals(Util.bytes2HexString(this.sca))) { - return "3DES"; - } - if( "32".equals(Util.bytes2HexString(this.sca))) { - return "SM4"; - } - return null; - } - - - public Integer getScaOptionIndex( ) { - - if( null == sca) { return null; } - if( "31".equals(Util.bytes2HexString(this.sca))) { - return 0; - } - if( "32".equals(Util.bytes2HexString(this.sca))) { - return 1; - } - return null; - } - - - public byte[] getDcaAsBin( ) { - - return this.dca; - } - - - public String getDcaAsStr( ) { - - if( null == this.dca) return null; - return Arrays.toString(this.dca); - } - - - public String getDcaAsHex( ) { - - if( null == this.dca) return null; - return Util.bytes2HexString(dca); - } - - - public Data setDca( byte[] bytes ) { - - this.dca = bytes; - return this; - } -public enum DcaOptions { - - OPV3DES(Util.hexString2Bytes("31")), - OPVSM4(Util.hexString2Bytes("32")); - private byte[] bin; - DcaOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getDcaCn( ) { - - if( null == dca) { return null; } - if( "31".equals(Util.bytes2HexString(this.dca))) { - return "3DES"; - } - if( "32".equals(Util.bytes2HexString(this.dca))) { - return "SM4"; - } - return null; - } - - - public Integer getDcaOptionIndex( ) { - - if( null == dca) { return null; } - if( "31".equals(Util.bytes2HexString(this.dca))) { - return 0; - } - if( "32".equals(Util.bytes2HexString(this.dca))) { - return 1; - } - return null; - } - - - public byte[] getSPinAsBin( ) { - - return this.sPin; - } - - - public String getSPinAsStr( ) { - - if( null == this.sPin) return null; - return Arrays.toString(this.sPin); - } - - - public String getSPinAsHex( ) { - - if( null == this.sPin) return null; - return Util.bytes2HexString(sPin); - } - - - public Data setSPin( byte[] bytes ) { - - this.sPin = bytes; - return this; - } - - - public byte[] getSPinTypeAsBin( ) { - - return this.sPinType; - } - - - public String getSPinTypeAsStr( ) { - - if( null == this.sPinType) return null; - return Arrays.toString(this.sPinType); - } - - - public String getSPinTypeAsHex( ) { - - if( null == this.sPinType) return null; - return Util.bytes2HexString(sPinType); - } - - - public Data setSPinType( byte[] bytes ) { - - this.sPinType = bytes; - return this; - } -public enum SPinTypeOptions { - - OPV带主帐号的ANSI98格式(Util.hexString2Bytes("3031")), - OPVDocutelATM(Util.hexString2Bytes("3032")), - OPVDieboldandIBMATM(Util.hexString2Bytes("3033")), - OPVPlusNetwork(Util.hexString2Bytes("3034")), - OPVISO956411格式1NPPRR(Util.hexString2Bytes("3035")), - OPV不带主帐号的ANSI98格式(Util.hexString2Bytes("3036")); - private byte[] bin; - SPinTypeOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getSPinTypeCn( ) { - - if( null == sPinType) { return null; } - if( "3031".equals(Util.bytes2HexString(this.sPinType))) { - return "带主帐号的ANSI9.8格式"; - } - if( "3032".equals(Util.bytes2HexString(this.sPinType))) { - return "Docutel ATM"; - } - if( "3033".equals(Util.bytes2HexString(this.sPinType))) { - return "Diebold and IBM ATM"; - } - if( "3034".equals(Util.bytes2HexString(this.sPinType))) { - return "Plus Network"; - } - if( "3035".equals(Util.bytes2HexString(this.sPinType))) { - return "ISO9564-1-1格式,1NP..PR...R"; - } - if( "3036".equals(Util.bytes2HexString(this.sPinType))) { - return "不带主帐号的ANSI9.8格式"; - } - return null; - } - - - public Integer getSPinTypeOptionIndex( ) { - - if( null == sPinType) { return null; } - if( "3031".equals(Util.bytes2HexString(this.sPinType))) { - return 0; - } - if( "3032".equals(Util.bytes2HexString(this.sPinType))) { - return 1; - } - if( "3033".equals(Util.bytes2HexString(this.sPinType))) { - return 2; - } - if( "3034".equals(Util.bytes2HexString(this.sPinType))) { - return 3; - } - if( "3035".equals(Util.bytes2HexString(this.sPinType))) { - return 4; - } - if( "3036".equals(Util.bytes2HexString(this.sPinType))) { - return 5; - } - return null; - } - - - public byte[] getDPinTypeAsBin( ) { - - return this.dPinType; - } - - - public String getDPinTypeAsStr( ) { - - if( null == this.dPinType) return null; - return Arrays.toString(this.dPinType); - } - - - public String getDPinTypeAsHex( ) { - - if( null == this.dPinType) return null; - return Util.bytes2HexString(dPinType); - } - - - public Data setDPinType( byte[] bytes ) { - - this.dPinType = bytes; - return this; - } -public enum DPinTypeOptions { - - OPV带主帐号的ANSI98格式(Util.hexString2Bytes("3031")), - OPVDocutelATM(Util.hexString2Bytes("3032")), - OPVDieboldandIBMATM(Util.hexString2Bytes("3033")), - OPVPlusNetwork(Util.hexString2Bytes("3034")), - OPVISO95641format1格式1NPPRR(Util.hexString2Bytes("3035")), - OPV不带主帐号的ANSI98格式(Util.hexString2Bytes("3036")); - private byte[] bin; - DPinTypeOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getDPinTypeCn( ) { - - if( null == dPinType) { return null; } - if( "3031".equals(Util.bytes2HexString(this.dPinType))) { - return "带主帐号的ANSI9.8格式"; - } - if( "3032".equals(Util.bytes2HexString(this.dPinType))) { - return "Docutel ATM"; - } - if( "3033".equals(Util.bytes2HexString(this.dPinType))) { - return "Diebold and IBM ATM"; - } - if( "3034".equals(Util.bytes2HexString(this.dPinType))) { - return "Plus Network"; - } - if( "3035".equals(Util.bytes2HexString(this.dPinType))) { - return "ISO95641-format 1格式,1NP..PR...R"; - } - if( "3036".equals(Util.bytes2HexString(this.dPinType))) { - return "不带主帐号的ANSI9.8格式"; - } - return null; - } - - - public Integer getDPinTypeOptionIndex( ) { - - if( null == dPinType) { return null; } - if( "3031".equals(Util.bytes2HexString(this.dPinType))) { - return 0; - } - if( "3032".equals(Util.bytes2HexString(this.dPinType))) { - return 1; - } - if( "3033".equals(Util.bytes2HexString(this.dPinType))) { - return 2; - } - if( "3034".equals(Util.bytes2HexString(this.dPinType))) { - return 3; - } - if( "3035".equals(Util.bytes2HexString(this.dPinType))) { - return 4; - } - if( "3036".equals(Util.bytes2HexString(this.dPinType))) { - return 5; - } - return null; - } - - - public byte[] getPrimaryAccountAsBin( ) { - - return this.primaryAccount; - } - - - public String getPrimaryAccountAsStr( ) { - - if( null == this.primaryAccount) return null; - return Arrays.toString(this.primaryAccount); - } - - - public String getPrimaryAccountAsHex( ) { - - if( null == this.primaryAccount) return null; - return Util.bytes2HexString(primaryAccount); - } - - - public Data setPrimaryAccount( byte[] bytes ) { - - this.primaryAccount = bytes; - return this; - } - - - public byte[] getBusinessKeyAsBin( ) { - - return this.businessKey; - } - - - public String getBusinessKeyAsStr( ) { - - if( null == this.businessKey) return null; - return Arrays.toString(this.businessKey); - } - - - public String getBusinessKeyAsHex( ) { - - if( null == this.businessKey) return null; - return Util.bytes2HexString(businessKey); - } - - - public Data setBusinessKey( byte[] bytes ) { - - this.businessKey = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != srcKeyType ){ - soup.put("srcKeyType", this.srcKeyType); - } - - if( null != desKeyType ){ - soup.put("desKeyType", this.desKeyType); - } - - if( null != srcKey ){ - soup.put("srcKey", this.srcKey); - } - - if( null != desKey ){ - soup.put("desKey", this.desKey); - } - - if( null != algorithmKey ){ - soup.put("algorithmKey", this.algorithmKey); - } - - if( null != sca ){ - soup.put("sca", this.sca); - soup.put("sca$option", getScaOptionIndex()); - } - - if( null != dca ){ - soup.put("dca", this.dca); - soup.put("dca$option", getDcaOptionIndex()); - } - - if( null != sPin ){ - soup.put("sPin", this.sPin); - } - - if( null != sPinType ){ - soup.put("sPinType", this.sPinType); - soup.put("sPinType$option", getSPinTypeOptionIndex()); - } - - if( null != dPinType ){ - soup.put("dPinType", this.dPinType); - soup.put("dPinType$option", getDPinTypeOptionIndex()); - } - - if( null != primaryAccount ){ - soup.put("primaryAccount", this.primaryAccount); - } - - if( null != businessKey ){ - soup.put("businessKey", this.businessKey); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("srcKeyType") ){ - this.srcKeyType = ((PacketSection) soup.get("srcKeyType")).getBytes(); - } - - if( soup.containsKey("desKeyType") ){ - this.desKeyType = ((PacketSection) soup.get("desKeyType")).getBytes(); - } - - if( soup.containsKey("srcKey") ){ - this.srcKey = ((PacketSection) soup.get("srcKey")).getBytes(); - } - - if( soup.containsKey("desKey") ){ - this.desKey = ((PacketSection) soup.get("desKey")).getBytes(); - } - - if( soup.containsKey("algorithmKey") ){ - this.algorithmKey = ((PacketSection) soup.get("algorithmKey")).getBytes(); - } - - if( soup.containsKey("sca") ){ - this.sca = ((PacketSection) soup.get("sca")).getBytes(); - } - - if( soup.containsKey("dca") ){ - this.dca = ((PacketSection) soup.get("dca")).getBytes(); - } - - if( soup.containsKey("sPin") ){ - this.sPin = ((PacketSection) soup.get("sPin")).getBytes(); - } - - if( soup.containsKey("sPinType") ){ - this.sPinType = ((PacketSection) soup.get("sPinType")).getBytes(); - } - - if( soup.containsKey("dPinType") ){ - this.dPinType = ((PacketSection) soup.get("dPinType")).getBytes(); - } - - if( soup.containsKey("primaryAccount") ){ - this.primaryAccount = ((PacketSection) soup.get("primaryAccount")).getBytes(); - } - - if( soup.containsKey("businessKey") ){ - this.businessKey = ((PacketSection) soup.get("businessKey")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4342")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4342"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] pinLen = null; - private byte[] dPin = null; - private byte[] dPinType = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV源ZPK奇偶校验错(Util.hexString2Bytes("3130")), - OPV目的ZPK奇偶校验错(Util.hexString2Bytes("3131")), - OPV用户存储区中没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误报告给管理员(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV无效的用户存储索引(Util.hexString2Bytes("3231")), - OPV帐号无效(Util.hexString2Bytes("3232")), - OPV无效PIN块格式代码(Util.hexString2Bytes("3233")), - OPVPIN小于4位或大于12位(Util.hexString2Bytes("3234")), - OPV无效的密钥方案(Util.hexString2Bytes("3236")), - OPV数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "源ZPK奇偶校验错"; - } - if( "3131".equals(Util.bytes2HexString(this.error))) { - return "目的ZPK奇偶校验错"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区中没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK错误;报告给管理员"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效的用户存储索引"; - } - if( "3232".equals(Util.bytes2HexString(this.error))) { - return "帐号无效"; - } - if( "3233".equals(Util.bytes2HexString(this.error))) { - return "无效PIN块格式代码"; - } - if( "3234".equals(Util.bytes2HexString(this.error))) { - return "PIN小于4位或大于12位"; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return "无效的密钥方案"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3131".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3232".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3233".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3234".equals(Util.bytes2HexString(this.error))) { - return 9; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return 10; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 11; - } - return null; - } - - - public byte[] getPinLenAsBin( ) { - - return this.pinLen; - } - - - public String getPinLenAsStr( ) { - - if( null == this.pinLen) return null; - return Arrays.toString(this.pinLen); - } - - - public String getPinLenAsHex( ) { - - if( null == this.pinLen) return null; - return Util.bytes2HexString(pinLen); - } - - - public Data setPinLen( byte[] bytes ) { - - this.pinLen = bytes; - return this; - } - - - public byte[] getDPinAsBin( ) { - - return this.dPin; - } - - - public String getDPinAsStr( ) { - - if( null == this.dPin) return null; - return Arrays.toString(this.dPin); - } - - - public String getDPinAsHex( ) { - - if( null == this.dPin) return null; - return Util.bytes2HexString(dPin); - } - - - public Data setDPin( byte[] bytes ) { - - this.dPin = bytes; - return this; - } - - - public byte[] getDPinTypeAsBin( ) { - - return this.dPinType; - } - - - public String getDPinTypeAsStr( ) { - - if( null == this.dPinType) return null; - return Arrays.toString(this.dPinType); - } - - - public String getDPinTypeAsHex( ) { - - if( null == this.dPinType) return null; - return Util.bytes2HexString(dPinType); - } - - - public Data setDPinType( byte[] bytes ) { - - this.dPinType = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != pinLen ){ - soup.put("pinLen", this.pinLen); - } - - if( null != dPin ){ - soup.put("dPin", this.dPin); - } - - if( null != dPinType ){ - soup.put("dPinType", this.dPinType); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("pinLen") ){ - this.pinLen = ((PacketSection) soup.get("pinLen")).getBytes(); - } - - if( soup.containsKey("dPin") ){ - this.dPin = ((PacketSection) soup.get("dPin")).getBytes(); - } - - if( soup.containsKey("dPinType") ){ - this.dPinType = ((PacketSection) soup.get("dPinType")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4343")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4343"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOCC.java b/src/main/java/racal/sunyard/main/dto/DTOCC.java deleted file mode 100644 index d8f899e..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOCC.java +++ /dev/null @@ -1,1252 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOCC { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] sourceZpk = null; - private byte[] purposeZpk = null; - private byte[] algorithmKey = null; - private byte[] sca = null; - private byte[] dca = null; - private byte[] businessKey = null; - private byte[] maxLength = null; - private byte[] sourcePinBlock = null; - private byte[] sourcePinBlockFormat = null; - private byte[] purposePinBlockFormat = null; - private byte[] account = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getSourceZpkAsBin( ) { - - return this.sourceZpk; - } - - - public String getSourceZpkAsStr( ) { - - if( null == this.sourceZpk) return null; - return Arrays.toString(this.sourceZpk); - } - - - public String getSourceZpkAsHex( ) { - - if( null == this.sourceZpk) return null; - return Util.bytes2HexString(sourceZpk); - } - - - public Data setSourceZpk( byte[] bytes ) { - - this.sourceZpk = bytes; - return this; - } - - - public byte[] getPurposeZpkAsBin( ) { - - return this.purposeZpk; - } - - - public String getPurposeZpkAsStr( ) { - - if( null == this.purposeZpk) return null; - return Arrays.toString(this.purposeZpk); - } - - - public String getPurposeZpkAsHex( ) { - - if( null == this.purposeZpk) return null; - return Util.bytes2HexString(purposeZpk); - } - - - public Data setPurposeZpk( byte[] bytes ) { - - this.purposeZpk = bytes; - return this; - } - - - public byte[] getAlgorithmKeyAsBin( ) { - - return this.algorithmKey; - } - - - public String getAlgorithmKeyAsStr( ) { - - if( null == this.algorithmKey) return null; - return Arrays.toString(this.algorithmKey); - } - - - public String getAlgorithmKeyAsHex( ) { - - if( null == this.algorithmKey) return null; - return Util.bytes2HexString(algorithmKey); - } - - - public Data setAlgorithmKey( byte[] bytes ) { - - this.algorithmKey = bytes; - return this; - } - - - public byte[] getScaAsBin( ) { - - return this.sca; - } - - - public String getScaAsStr( ) { - - if( null == this.sca) return null; - return Arrays.toString(this.sca); - } - - - public String getScaAsHex( ) { - - if( null == this.sca) return null; - return Util.bytes2HexString(sca); - } - - - public Data setSca( byte[] bytes ) { - - this.sca = bytes; - return this; - } -public enum ScaOptions { - - OPV3DES默认(Util.hexString2Bytes("31")), - OPVSM4(Util.hexString2Bytes("32")); - private byte[] bin; - ScaOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getScaCn( ) { - - if( null == sca) { return null; } - if( "31".equals(Util.bytes2HexString(this.sca))) { - return "3DES(默认)"; - } - if( "32".equals(Util.bytes2HexString(this.sca))) { - return "SM4"; - } - return null; - } - - - public Integer getScaOptionIndex( ) { - - if( null == sca) { return null; } - if( "31".equals(Util.bytes2HexString(this.sca))) { - return 0; - } - if( "32".equals(Util.bytes2HexString(this.sca))) { - return 1; - } - return null; - } - - - public byte[] getDcaAsBin( ) { - - return this.dca; - } - - - public String getDcaAsStr( ) { - - if( null == this.dca) return null; - return Arrays.toString(this.dca); - } - - - public String getDcaAsHex( ) { - - if( null == this.dca) return null; - return Util.bytes2HexString(dca); - } - - - public Data setDca( byte[] bytes ) { - - this.dca = bytes; - return this; - } -public enum DcaOptions { - - OPV3DES默认(Util.hexString2Bytes("31")), - OPVSM4(Util.hexString2Bytes("32")); - private byte[] bin; - DcaOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getDcaCn( ) { - - if( null == dca) { return null; } - if( "31".equals(Util.bytes2HexString(this.dca))) { - return "3DES(默认)"; - } - if( "32".equals(Util.bytes2HexString(this.dca))) { - return "SM4"; - } - return null; - } - - - public Integer getDcaOptionIndex( ) { - - if( null == dca) { return null; } - if( "31".equals(Util.bytes2HexString(this.dca))) { - return 0; - } - if( "32".equals(Util.bytes2HexString(this.dca))) { - return 1; - } - return null; - } - - - public byte[] getBusinessKeyAsBin( ) { - - return this.businessKey; - } - - - public String getBusinessKeyAsStr( ) { - - if( null == this.businessKey) return null; - return Arrays.toString(this.businessKey); - } - - - public String getBusinessKeyAsHex( ) { - - if( null == this.businessKey) return null; - return Util.bytes2HexString(businessKey); - } - - - public Data setBusinessKey( byte[] bytes ) { - - this.businessKey = bytes; - return this; - } - - - public byte[] getMaxLengthAsBin( ) { - - return this.maxLength; - } - - - public String getMaxLengthAsStr( ) { - - if( null == this.maxLength) return null; - return Arrays.toString(this.maxLength); - } - - - public String getMaxLengthAsHex( ) { - - if( null == this.maxLength) return null; - return Util.bytes2HexString(maxLength); - } - - - public Data setMaxLength( byte[] bytes ) { - - this.maxLength = bytes; - return this; - } - - - public byte[] getSourcePinBlockAsBin( ) { - - return this.sourcePinBlock; - } - - - public String getSourcePinBlockAsStr( ) { - - if( null == this.sourcePinBlock) return null; - return Arrays.toString(this.sourcePinBlock); - } - - - public String getSourcePinBlockAsHex( ) { - - if( null == this.sourcePinBlock) return null; - return Util.bytes2HexString(sourcePinBlock); - } - - - public Data setSourcePinBlock( byte[] bytes ) { - - this.sourcePinBlock = bytes; - return this; - } - - - public byte[] getSourcePinBlockFormatAsBin( ) { - - return this.sourcePinBlockFormat; - } - - - public String getSourcePinBlockFormatAsStr( ) { - - if( null == this.sourcePinBlockFormat) return null; - return Arrays.toString(this.sourcePinBlockFormat); - } - - - public String getSourcePinBlockFormatAsHex( ) { - - if( null == this.sourcePinBlockFormat) return null; - return Util.bytes2HexString(sourcePinBlockFormat); - } - - - public Data setSourcePinBlockFormat( byte[] bytes ) { - - this.sourcePinBlockFormat = bytes; - return this; - } - - - public byte[] getPurposePinBlockFormatAsBin( ) { - - return this.purposePinBlockFormat; - } - - - public String getPurposePinBlockFormatAsStr( ) { - - if( null == this.purposePinBlockFormat) return null; - return Arrays.toString(this.purposePinBlockFormat); - } - - - public String getPurposePinBlockFormatAsHex( ) { - - if( null == this.purposePinBlockFormat) return null; - return Util.bytes2HexString(purposePinBlockFormat); - } - - - public Data setPurposePinBlockFormat( byte[] bytes ) { - - this.purposePinBlockFormat = bytes; - return this; - } - - - public byte[] getAccountAsBin( ) { - - return this.account; - } - - - public String getAccountAsStr( ) { - - if( null == this.account) return null; - return Arrays.toString(this.account); - } - - - public String getAccountAsHex( ) { - - if( null == this.account) return null; - return Util.bytes2HexString(account); - } - - - public Data setAccount( byte[] bytes ) { - - this.account = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != sourceZpk ){ - soup.put("sourceZpk", this.sourceZpk); - } - - if( null != purposeZpk ){ - soup.put("purposeZpk", this.purposeZpk); - } - - if( null != algorithmKey ){ - soup.put("algorithmKey", this.algorithmKey); - } - - if( null != sca ){ - soup.put("sca", this.sca); - soup.put("sca$option", getScaOptionIndex()); - } - - if( null != dca ){ - soup.put("dca", this.dca); - soup.put("dca$option", getDcaOptionIndex()); - } - - if( null != businessKey ){ - soup.put("businessKey", this.businessKey); - } - - soup.put("maxLength", Util.hexString2Bytes("3132")); - if( null != maxLength ){ - soup.put("maxLength", this.maxLength); - } - - if( null != sourcePinBlock ){ - soup.put("sourcePinBlock", this.sourcePinBlock); - } - - if( null != sourcePinBlockFormat ){ - soup.put("sourcePinBlockFormat", this.sourcePinBlockFormat); - } - - if( null != purposePinBlockFormat ){ - soup.put("purposePinBlockFormat", this.purposePinBlockFormat); - } - - if( null != account ){ - soup.put("account", this.account); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("sourceZpk") ){ - this.sourceZpk = ((PacketSection) soup.get("sourceZpk")).getBytes(); - } - - if( soup.containsKey("purposeZpk") ){ - this.purposeZpk = ((PacketSection) soup.get("purposeZpk")).getBytes(); - } - - if( soup.containsKey("algorithmKey") ){ - this.algorithmKey = ((PacketSection) soup.get("algorithmKey")).getBytes(); - } - - if( soup.containsKey("sca") ){ - this.sca = ((PacketSection) soup.get("sca")).getBytes(); - } - - if( soup.containsKey("dca") ){ - this.dca = ((PacketSection) soup.get("dca")).getBytes(); - } - - if( soup.containsKey("businessKey") ){ - this.businessKey = ((PacketSection) soup.get("businessKey")).getBytes(); - } - - this.maxLength = Util.hexString2Bytes("3132"); - if( soup.containsKey("maxLength") ){ - this.maxLength = ((PacketSection) soup.get("maxLength")).getBytes(); - } - - if( soup.containsKey("sourcePinBlock") ){ - this.sourcePinBlock = ((PacketSection) soup.get("sourcePinBlock")).getBytes(); - } - - if( soup.containsKey("sourcePinBlockFormat") ){ - this.sourcePinBlockFormat = ((PacketSection) soup.get("sourcePinBlockFormat")).getBytes(); - } - - if( soup.containsKey("purposePinBlockFormat") ){ - this.purposePinBlockFormat = ((PacketSection) soup.get("purposePinBlockFormat")).getBytes(); - } - - if( soup.containsKey("account") ){ - this.account = ((PacketSection) soup.get("account")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4343")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4343"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] pinLen = null; - private byte[] purposePinBlock = null; - private byte[] purposePinBlockFormat = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV源ZPK奇偶校验错(Util.hexString2Bytes("3130")), - OPV目的ZPK奇偶校验错(Util.hexString2Bytes("3131")), - OPV用户存储区中没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV无效的用户存储索引(Util.hexString2Bytes("3231")), - OPV帐号无效(Util.hexString2Bytes("3232")), - OPV无效PIN块格式代码(Util.hexString2Bytes("3233")), - OPVPIN小于4位或大于12位(Util.hexString2Bytes("3234")), - OPV无效的密钥方案(Util.hexString2Bytes("3236")), - OPV数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "源 ZPK 奇偶校验错"; - } - if( "3131".equals(Util.bytes2HexString(this.error))) { - return "目的 ZPK 奇偶校验错"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区中没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效的用户存储索引"; - } - if( "3232".equals(Util.bytes2HexString(this.error))) { - return "帐号无效"; - } - if( "3233".equals(Util.bytes2HexString(this.error))) { - return "无效 PIN 块格式代码"; - } - if( "3234".equals(Util.bytes2HexString(this.error))) { - return "PIN 小于 4 位或大于 12 位。"; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return "无效的密钥方案"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3131".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3232".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3233".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3234".equals(Util.bytes2HexString(this.error))) { - return 9; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return 10; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 11; - } - return null; - } - - - public byte[] getPinLenAsBin( ) { - - return this.pinLen; - } - - - public String getPinLenAsStr( ) { - - if( null == this.pinLen) return null; - return Arrays.toString(this.pinLen); - } - - - public String getPinLenAsHex( ) { - - if( null == this.pinLen) return null; - return Util.bytes2HexString(pinLen); - } - - - public Data setPinLen( byte[] bytes ) { - - this.pinLen = bytes; - return this; - } - - - public byte[] getPurposePinBlockAsBin( ) { - - return this.purposePinBlock; - } - - - public String getPurposePinBlockAsStr( ) { - - if( null == this.purposePinBlock) return null; - return Arrays.toString(this.purposePinBlock); - } - - - public String getPurposePinBlockAsHex( ) { - - if( null == this.purposePinBlock) return null; - return Util.bytes2HexString(purposePinBlock); - } - - - public Data setPurposePinBlock( byte[] bytes ) { - - this.purposePinBlock = bytes; - return this; - } - - - public byte[] getPurposePinBlockFormatAsBin( ) { - - return this.purposePinBlockFormat; - } - - - public String getPurposePinBlockFormatAsStr( ) { - - if( null == this.purposePinBlockFormat) return null; - return Arrays.toString(this.purposePinBlockFormat); - } - - - public String getPurposePinBlockFormatAsHex( ) { - - if( null == this.purposePinBlockFormat) return null; - return Util.bytes2HexString(purposePinBlockFormat); - } - - - public Data setPurposePinBlockFormat( byte[] bytes ) { - - this.purposePinBlockFormat = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != pinLen ){ - soup.put("pinLen", this.pinLen); - } - - if( null != purposePinBlock ){ - soup.put("purposePinBlock", this.purposePinBlock); - } - - if( null != purposePinBlockFormat ){ - soup.put("purposePinBlockFormat", this.purposePinBlockFormat); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("pinLen") ){ - this.pinLen = ((PacketSection) soup.get("pinLen")).getBytes(); - } - - if( soup.containsKey("purposePinBlock") ){ - this.purposePinBlock = ((PacketSection) soup.get("purposePinBlock")).getBytes(); - } - - if( soup.containsKey("purposePinBlockFormat") ){ - this.purposePinBlockFormat = ((PacketSection) soup.get("purposePinBlockFormat")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4344")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4344"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTODE.java b/src/main/java/racal/sunyard/main/dto/DTODE.java deleted file mode 100644 index 9e57552..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTODE.java +++ /dev/null @@ -1,855 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTODE { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] pvk = null; - private byte[] pin = null; - private byte[] pinLen = null; - private byte[] account = null; - private byte[] turn = null; - private byte[] pinCheck = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getPvkAsBin( ) { - - return this.pvk; - } - - - public String getPvkAsStr( ) { - - if( null == this.pvk) return null; - return Arrays.toString(this.pvk); - } - - - public String getPvkAsHex( ) { - - if( null == this.pvk) return null; - return Util.bytes2HexString(pvk); - } - - - public Data setPvk( byte[] bytes ) { - - this.pvk = bytes; - return this; - } - - - public byte[] getPinAsBin( ) { - - return this.pin; - } - - - public String getPinAsStr( ) { - - if( null == this.pin) return null; - return Arrays.toString(this.pin); - } - - - public String getPinAsHex( ) { - - if( null == this.pin) return null; - return Util.bytes2HexString(pin); - } - - - public Data setPin( byte[] bytes ) { - - this.pin = bytes; - return this; - } - - - public byte[] getPinLenAsBin( ) { - - return this.pinLen; - } - - - public String getPinLenAsStr( ) { - - if( null == this.pinLen) return null; - return Arrays.toString(this.pinLen); - } - - - public String getPinLenAsHex( ) { - - if( null == this.pinLen) return null; - return Util.bytes2HexString(pinLen); - } - - - public Data setPinLen( byte[] bytes ) { - - this.pinLen = bytes; - return this; - } - - - public byte[] getAccountAsBin( ) { - - return this.account; - } - - - public String getAccountAsStr( ) { - - if( null == this.account) return null; - return Arrays.toString(this.account); - } - - - public String getAccountAsHex( ) { - - if( null == this.account) return null; - return Util.bytes2HexString(account); - } - - - public Data setAccount( byte[] bytes ) { - - this.account = bytes; - return this; - } - - - public byte[] getTurnAsBin( ) { - - return this.turn; - } - - - public String getTurnAsStr( ) { - - if( null == this.turn) return null; - return Arrays.toString(this.turn); - } - - - public String getTurnAsHex( ) { - - if( null == this.turn) return null; - return Util.bytes2HexString(turn); - } - - - public Data setTurn( byte[] bytes ) { - - this.turn = bytes; - return this; - } - - - public byte[] getPinCheckAsBin( ) { - - return this.pinCheck; - } - - - public String getPinCheckAsStr( ) { - - if( null == this.pinCheck) return null; - return Arrays.toString(this.pinCheck); - } - - - public String getPinCheckAsHex( ) { - - if( null == this.pinCheck) return null; - return Util.bytes2HexString(pinCheck); - } - - - public Data setPinCheck( byte[] bytes ) { - - this.pinCheck = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != pvk ){ - soup.put("pvk", this.pvk); - } - - if( null != pin ){ - soup.put("pin", this.pin); - } - - if( null != pinLen ){ - soup.put("pinLen", this.pinLen); - } - - if( null != account ){ - soup.put("account", this.account); - } - - if( null != turn ){ - soup.put("turn", this.turn); - } - - if( null != pinCheck ){ - soup.put("pinCheck", this.pinCheck); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("pvk") ){ - this.pvk = ((PacketSection) soup.get("pvk")).getBytes(); - } - - if( soup.containsKey("pin") ){ - this.pin = ((PacketSection) soup.get("pin")).getBytes(); - } - - if( soup.containsKey("pinLen") ){ - this.pinLen = ((PacketSection) soup.get("pinLen")).getBytes(); - } - - if( soup.containsKey("account") ){ - this.account = ((PacketSection) soup.get("account")).getBytes(); - } - - if( soup.containsKey("turn") ){ - this.turn = ((PacketSection) soup.get("turn")).getBytes(); - } - - if( soup.containsKey("pinCheck") ){ - this.pinCheck = ((PacketSection) soup.get("pinCheck")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4445")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4445"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] offset = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV源ZPK奇偶校验错(Util.hexString2Bytes("3130")), - OPV目的ZPK奇偶校验错(Util.hexString2Bytes("3131")), - OPV用户存储区中没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误报告给管理员(Util.hexString2Bytes("3133")), - OPV加密的PIN错误(Util.hexString2Bytes("3134")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV无效的用户存储索引(Util.hexString2Bytes("3231")), - OPV帐号无效(Util.hexString2Bytes("3232")), - OPV无效PIN块格式代码(Util.hexString2Bytes("3233")), - OPVPIN小于4位或大于12位(Util.hexString2Bytes("3234")), - OPV无效的密钥方案(Util.hexString2Bytes("3236")), - OPV数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "源ZPK奇偶校验错"; - } - if( "3131".equals(Util.bytes2HexString(this.error))) { - return "目的ZPK奇偶校验错"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区中没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK错误;报告给管理员"; - } - if( "3134".equals(Util.bytes2HexString(this.error))) { - return "加密的 PIN 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效的用户存储索引"; - } - if( "3232".equals(Util.bytes2HexString(this.error))) { - return "帐号无效"; - } - if( "3233".equals(Util.bytes2HexString(this.error))) { - return "无效PIN块格式代码"; - } - if( "3234".equals(Util.bytes2HexString(this.error))) { - return "PIN小于4位或大于12位"; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return "无效的密钥方案"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3131".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3134".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3232".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3233".equals(Util.bytes2HexString(this.error))) { - return 9; - } - if( "3234".equals(Util.bytes2HexString(this.error))) { - return 10; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return 11; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 12; - } - return null; - } - - - public byte[] getOffsetAsBin( ) { - - return this.offset; - } - - - public String getOffsetAsStr( ) { - - if( null == this.offset) return null; - return Arrays.toString(this.offset); - } - - - public String getOffsetAsHex( ) { - - if( null == this.offset) return null; - return Util.bytes2HexString(offset); - } - - - public Data setOffset( byte[] bytes ) { - - this.offset = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != offset ){ - soup.put("offset", this.offset); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("offset") ){ - this.offset = ((PacketSection) soup.get("offset")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4446")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4446"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOE0.java b/src/main/java/racal/sunyard/main/dto/DTOE0.java deleted file mode 100644 index d0df5a3..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOE0.java +++ /dev/null @@ -1,1640 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOE0 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] packSn = null; - private byte[] alg = null; - private byte[] roundModel = null; - private byte[] keyType = null; - private byte[] key = null; - private byte[] inType = null; - private byte[] outType = null; - private byte[] fullMode = null; - private byte[] fullChar = null; - private byte[] fullType = null; - private byte[] iv = null; - private byte[] msgLen = null; - private byte[] msg = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getPackSnAsBin( ) { - - return this.packSn; - } - - - public String getPackSnAsStr( ) { - - if( null == this.packSn) return null; - return Arrays.toString(this.packSn); - } - - - public String getPackSnAsHex( ) { - - if( null == this.packSn) return null; - return Util.bytes2HexString(packSn); - } - - - public Data setPackSn( byte[] bytes ) { - - this.packSn = bytes; - return this; - } -public enum PackSnOptions { - - OPV仅一块(Util.hexString2Bytes("30")), - OPV第一块(Util.hexString2Bytes("31")), - OPV中间块(Util.hexString2Bytes("32")), - OPV最后块(Util.hexString2Bytes("33")); - private byte[] bin; - PackSnOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getPackSnCn( ) { - - if( null == packSn) { return null; } - if( "30".equals(Util.bytes2HexString(this.packSn))) { - return "仅一块"; - } - if( "31".equals(Util.bytes2HexString(this.packSn))) { - return "第一块"; - } - if( "32".equals(Util.bytes2HexString(this.packSn))) { - return "中间块"; - } - if( "33".equals(Util.bytes2HexString(this.packSn))) { - return "最后块"; - } - return null; - } - - - public Integer getPackSnOptionIndex( ) { - - if( null == packSn) { return null; } - if( "30".equals(Util.bytes2HexString(this.packSn))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.packSn))) { - return 1; - } - if( "32".equals(Util.bytes2HexString(this.packSn))) { - return 2; - } - if( "33".equals(Util.bytes2HexString(this.packSn))) { - return 3; - } - return null; - } - - - public byte[] getAlgAsBin( ) { - - return this.alg; - } - - - public String getAlgAsStr( ) { - - if( null == this.alg) return null; - return Arrays.toString(this.alg); - } - - - public String getAlgAsHex( ) { - - if( null == this.alg) return null; - return Util.bytes2HexString(alg); - } - - - public Data setAlg( byte[] bytes ) { - - this.alg = bytes; - return this; - } -public enum AlgOptions { - - OPVDES加密(Util.hexString2Bytes("30")), - OPVDES解密(Util.hexString2Bytes("31")), - OPVAES加密(Util.hexString2Bytes("32")), - OPVAES解密(Util.hexString2Bytes("33")), - OPVSSF33加密(Util.hexString2Bytes("34")), - OPVSSF33解密(Util.hexString2Bytes("35")), - OPVSM1加密(Util.hexString2Bytes("36")), - OPVSM1解密(Util.hexString2Bytes("37")), - OPVSM4加密(Util.hexString2Bytes("38")), - OPVSM4解密(Util.hexString2Bytes("39")), - OPVIDEA加密(Util.hexString2Bytes("41")), - OPVIDEA解密(Util.hexString2Bytes("42")), - OPVAES256加密(Util.hexString2Bytes("43")), - OPVAES256解密(Util.hexString2Bytes("44")); - private byte[] bin; - AlgOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getAlgCn( ) { - - if( null == alg) { return null; } - if( "30".equals(Util.bytes2HexString(this.alg))) { - return "DES加密"; - } - if( "31".equals(Util.bytes2HexString(this.alg))) { - return "DES解密"; - } - if( "32".equals(Util.bytes2HexString(this.alg))) { - return "AES加密"; - } - if( "33".equals(Util.bytes2HexString(this.alg))) { - return "AES解密"; - } - if( "34".equals(Util.bytes2HexString(this.alg))) { - return "SSF33 加密"; - } - if( "35".equals(Util.bytes2HexString(this.alg))) { - return "SSF33 解密"; - } - if( "36".equals(Util.bytes2HexString(this.alg))) { - return "SM1加密"; - } - if( "37".equals(Util.bytes2HexString(this.alg))) { - return "SM1解密"; - } - if( "38".equals(Util.bytes2HexString(this.alg))) { - return "SM4加密"; - } - if( "39".equals(Util.bytes2HexString(this.alg))) { - return "SM4解密"; - } - if( "41".equals(Util.bytes2HexString(this.alg))) { - return "IDEA 加密"; - } - if( "42".equals(Util.bytes2HexString(this.alg))) { - return "IDEA 解密"; - } - if( "43".equals(Util.bytes2HexString(this.alg))) { - return "AES256 加密"; - } - if( "44".equals(Util.bytes2HexString(this.alg))) { - return "AES256 解密"; - } - return null; - } - - - public Integer getAlgOptionIndex( ) { - - if( null == alg) { return null; } - if( "30".equals(Util.bytes2HexString(this.alg))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.alg))) { - return 1; - } - if( "32".equals(Util.bytes2HexString(this.alg))) { - return 2; - } - if( "33".equals(Util.bytes2HexString(this.alg))) { - return 3; - } - if( "34".equals(Util.bytes2HexString(this.alg))) { - return 4; - } - if( "35".equals(Util.bytes2HexString(this.alg))) { - return 5; - } - if( "36".equals(Util.bytes2HexString(this.alg))) { - return 6; - } - if( "37".equals(Util.bytes2HexString(this.alg))) { - return 7; - } - if( "38".equals(Util.bytes2HexString(this.alg))) { - return 8; - } - if( "39".equals(Util.bytes2HexString(this.alg))) { - return 9; - } - if( "41".equals(Util.bytes2HexString(this.alg))) { - return 10; - } - if( "42".equals(Util.bytes2HexString(this.alg))) { - return 11; - } - if( "43".equals(Util.bytes2HexString(this.alg))) { - return 12; - } - if( "44".equals(Util.bytes2HexString(this.alg))) { - return 13; - } - return null; - } - - - public byte[] getRoundModelAsBin( ) { - - return this.roundModel; - } - - - public String getRoundModelAsStr( ) { - - if( null == this.roundModel) return null; - return Arrays.toString(this.roundModel); - } - - - public String getRoundModelAsHex( ) { - - if( null == this.roundModel) return null; - return Util.bytes2HexString(roundModel); - } - - - public Data setRoundModel( byte[] bytes ) { - - this.roundModel = bytes; - return this; - } -public enum RoundModelOptions { - - OPVECB(Util.hexString2Bytes("31")), - OPVCBC(Util.hexString2Bytes("32")), - OPVCFB(Util.hexString2Bytes("33")), - OPVOFB(Util.hexString2Bytes("34")); - private byte[] bin; - RoundModelOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getRoundModelCn( ) { - - if( null == roundModel) { return null; } - if( "31".equals(Util.bytes2HexString(this.roundModel))) { - return "ECB"; - } - if( "32".equals(Util.bytes2HexString(this.roundModel))) { - return "CBC"; - } - if( "33".equals(Util.bytes2HexString(this.roundModel))) { - return "CFB"; - } - if( "34".equals(Util.bytes2HexString(this.roundModel))) { - return "OFB"; - } - return null; - } - - - public Integer getRoundModelOptionIndex( ) { - - if( null == roundModel) { return null; } - if( "31".equals(Util.bytes2HexString(this.roundModel))) { - return 0; - } - if( "32".equals(Util.bytes2HexString(this.roundModel))) { - return 1; - } - if( "33".equals(Util.bytes2HexString(this.roundModel))) { - return 2; - } - if( "34".equals(Util.bytes2HexString(this.roundModel))) { - return 3; - } - return null; - } - - - public byte[] getKeyTypeAsBin( ) { - - return this.keyType; - } - - - public String getKeyTypeAsStr( ) { - - if( null == this.keyType) return null; - return Arrays.toString(this.keyType); - } - - - public String getKeyTypeAsHex( ) { - - if( null == this.keyType) return null; - return Util.bytes2HexString(keyType); - } - - - public Data setKeyType( byte[] bytes ) { - - this.keyType = bytes; - return this; - } -public enum KeyTypeOptions { - - OPVZEK(Util.hexString2Bytes("30")), - OPVTEK(Util.hexString2Bytes("31")); - private byte[] bin; - KeyTypeOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getKeyTypeCn( ) { - - if( null == keyType) { return null; } - if( "30".equals(Util.bytes2HexString(this.keyType))) { - return "ZEK"; - } - if( "31".equals(Util.bytes2HexString(this.keyType))) { - return "TEK"; - } - return null; - } - - - public Integer getKeyTypeOptionIndex( ) { - - if( null == keyType) { return null; } - if( "30".equals(Util.bytes2HexString(this.keyType))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.keyType))) { - return 1; - } - return null; - } - - - public byte[] getKeyAsBin( ) { - - return this.key; - } - - - public String getKeyAsStr( ) { - - if( null == this.key) return null; - return Arrays.toString(this.key); - } - - - public String getKeyAsHex( ) { - - if( null == this.key) return null; - return Util.bytes2HexString(key); - } - - - public Data setKey( byte[] bytes ) { - - this.key = bytes; - return this; - } - - - public byte[] getInTypeAsBin( ) { - - return this.inType; - } - - - public String getInTypeAsStr( ) { - - if( null == this.inType) return null; - return Arrays.toString(this.inType); - } - - - public String getInTypeAsHex( ) { - - if( null == this.inType) return null; - return Util.bytes2HexString(inType); - } - - - public Data setInType( byte[] bytes ) { - - this.inType = bytes; - return this; - } -public enum InTypeOptions { - - OPV二进制(Util.hexString2Bytes("30")), - OPV扩展十六进制(Util.hexString2Bytes("31")); - private byte[] bin; - InTypeOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getInTypeCn( ) { - - if( null == inType) { return null; } - if( "30".equals(Util.bytes2HexString(this.inType))) { - return "二进制"; - } - if( "31".equals(Util.bytes2HexString(this.inType))) { - return "扩展十六进制"; - } - return null; - } - - - public Integer getInTypeOptionIndex( ) { - - if( null == inType) { return null; } - if( "30".equals(Util.bytes2HexString(this.inType))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.inType))) { - return 1; - } - return null; - } - - - public byte[] getOutTypeAsBin( ) { - - return this.outType; - } - - - public String getOutTypeAsStr( ) { - - if( null == this.outType) return null; - return Arrays.toString(this.outType); - } - - - public String getOutTypeAsHex( ) { - - if( null == this.outType) return null; - return Util.bytes2HexString(outType); - } - - - public Data setOutType( byte[] bytes ) { - - this.outType = bytes; - return this; - } -public enum OutTypeOptions { - - OPV二进制(Util.hexString2Bytes("30")), - OPV扩展十六进制(Util.hexString2Bytes("31")); - private byte[] bin; - OutTypeOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getOutTypeCn( ) { - - if( null == outType) { return null; } - if( "30".equals(Util.bytes2HexString(this.outType))) { - return "二进制"; - } - if( "31".equals(Util.bytes2HexString(this.outType))) { - return "扩展十六进制"; - } - return null; - } - - - public Integer getOutTypeOptionIndex( ) { - - if( null == outType) { return null; } - if( "30".equals(Util.bytes2HexString(this.outType))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.outType))) { - return 1; - } - return null; - } - - - public byte[] getFullModeAsBin( ) { - - return this.fullMode; - } - - - public String getFullModeAsStr( ) { - - if( null == this.fullMode) return null; - return Arrays.toString(this.fullMode); - } - - - public String getFullModeAsHex( ) { - - if( null == this.fullMode) return null; - return Util.bytes2HexString(fullMode); - } - - - public Data setFullMode( byte[] bytes ) { - - this.fullMode = bytes; - return this; - } -public enum FullModeOptions { - - OPV饥饿模式(Util.hexString2Bytes("30")), - OPV贪婪模式(Util.hexString2Bytes("31")); - private byte[] bin; - FullModeOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getFullModeCn( ) { - - if( null == fullMode) { return null; } - if( "30".equals(Util.bytes2HexString(this.fullMode))) { - return "饥饿模式"; - } - if( "31".equals(Util.bytes2HexString(this.fullMode))) { - return "贪婪模式"; - } - return null; - } - - - public Integer getFullModeOptionIndex( ) { - - if( null == fullMode) { return null; } - if( "30".equals(Util.bytes2HexString(this.fullMode))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.fullMode))) { - return 1; - } - return null; - } - - - public byte[] getFullCharAsBin( ) { - - return this.fullChar; - } - - - public String getFullCharAsStr( ) { - - if( null == this.fullChar) return null; - return Arrays.toString(this.fullChar); - } - - - public String getFullCharAsHex( ) { - - if( null == this.fullChar) return null; - return Util.bytes2HexString(fullChar); - } - - - public Data setFullChar( byte[] bytes ) { - - this.fullChar = bytes; - return this; - } -public enum FullCharOptions { - - OPV0000(Util.hexString2Bytes("30303030")), - OPV8000(Util.hexString2Bytes("38303030")), - OPV7FFF(Util.hexString2Bytes("37464646")); - private byte[] bin; - FullCharOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getFullCharCn( ) { - - if( null == fullChar) { return null; } - if( "30303030".equals(Util.bytes2HexString(this.fullChar))) { - return "0000"; - } - if( "38303030".equals(Util.bytes2HexString(this.fullChar))) { - return "8000"; - } - if( "37464646".equals(Util.bytes2HexString(this.fullChar))) { - return "7FFF"; - } - return null; - } - - - public Integer getFullCharOptionIndex( ) { - - if( null == fullChar) { return null; } - if( "30303030".equals(Util.bytes2HexString(this.fullChar))) { - return 0; - } - if( "38303030".equals(Util.bytes2HexString(this.fullChar))) { - return 1; - } - if( "37464646".equals(Util.bytes2HexString(this.fullChar))) { - return 2; - } - return null; - } - - - public byte[] getFullTypeAsBin( ) { - - return this.fullType; - } - - - public String getFullTypeAsStr( ) { - - if( null == this.fullType) return null; - return Arrays.toString(this.fullType); - } - - - public String getFullTypeAsHex( ) { - - if( null == this.fullType) return null; - return Util.bytes2HexString(fullType); - } - - - public Data setFullType( byte[] bytes ) { - - this.fullType = bytes; - return this; - } -public enum FullTypeOptions { - - OPV不计尾(Util.hexString2Bytes("30")), - OPV计尾(Util.hexString2Bytes("31")), - OPVpkcs(Util.hexString2Bytes("32")); - private byte[] bin; - FullTypeOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getFullTypeCn( ) { - - if( null == fullType) { return null; } - if( "30".equals(Util.bytes2HexString(this.fullType))) { - return "不计尾"; - } - if( "31".equals(Util.bytes2HexString(this.fullType))) { - return "计尾"; - } - if( "32".equals(Util.bytes2HexString(this.fullType))) { - return "pkcs"; - } - return null; - } - - - public Integer getFullTypeOptionIndex( ) { - - if( null == fullType) { return null; } - if( "30".equals(Util.bytes2HexString(this.fullType))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.fullType))) { - return 1; - } - if( "32".equals(Util.bytes2HexString(this.fullType))) { - return 2; - } - return null; - } - - - public byte[] getIvAsBin( ) { - - return this.iv; - } - - - public String getIvAsStr( ) { - - if( null == this.iv) return null; - return Arrays.toString(this.iv); - } - - - public String getIvAsHex( ) { - - if( null == this.iv) return null; - return Util.bytes2HexString(iv); - } - - - public Data setIv( byte[] bytes ) { - - this.iv = bytes; - return this; - } - - - public byte[] getMsgLenAsBin( ) { - - return this.msgLen; - } - - - public String getMsgLenAsStr( ) { - - if( null == this.msgLen) return null; - return Arrays.toString(this.msgLen); - } - - - public String getMsgLenAsHex( ) { - - if( null == this.msgLen) return null; - return Util.bytes2HexString(msgLen); - } - - - public Data setMsgLen( byte[] bytes ) { - - this.msgLen = bytes; - return this; - } - - - public byte[] getMsgAsBin( ) { - - return this.msg; - } - - - public String getMsgAsStr( ) { - - if( null == this.msg) return null; - return Arrays.toString(this.msg); - } - - - public String getMsgAsHex( ) { - - if( null == this.msg) return null; - return Util.bytes2HexString(msg); - } - - - public Data setMsg( byte[] bytes ) { - - this.msg = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != packSn ){ - soup.put("packSn", this.packSn); - soup.put("packSn$option", getPackSnOptionIndex()); - } - - if( null != alg ){ - soup.put("alg", this.alg); - soup.put("alg$option", getAlgOptionIndex()); - } - - if( null != roundModel ){ - soup.put("roundModel", this.roundModel); - soup.put("roundModel$option", getRoundModelOptionIndex()); - } - - if( null != keyType ){ - soup.put("keyType", this.keyType); - soup.put("keyType$option", getKeyTypeOptionIndex()); - } - - if( null != key ){ - soup.put("key", this.key); - } - - if( null != inType ){ - soup.put("inType", this.inType); - soup.put("inType$option", getInTypeOptionIndex()); - } - - if( null != outType ){ - soup.put("outType", this.outType); - soup.put("outType$option", getOutTypeOptionIndex()); - } - - if( null != fullMode ){ - soup.put("fullMode", this.fullMode); - soup.put("fullMode$option", getFullModeOptionIndex()); - } - - if( null != fullChar ){ - soup.put("fullChar", this.fullChar); - soup.put("fullChar$option", getFullCharOptionIndex()); - } - - if( null != fullType ){ - soup.put("fullType", this.fullType); - soup.put("fullType$option", getFullTypeOptionIndex()); - } - - if( null != iv ){ - soup.put("iv", this.iv); - } - - if( null != msgLen ){ - soup.put("msgLen", this.msgLen); - } - - if( null != msg ){ - soup.put("msg", this.msg); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("packSn") ){ - this.packSn = ((PacketSection) soup.get("packSn")).getBytes(); - } - - if( soup.containsKey("alg") ){ - this.alg = ((PacketSection) soup.get("alg")).getBytes(); - } - - if( soup.containsKey("roundModel") ){ - this.roundModel = ((PacketSection) soup.get("roundModel")).getBytes(); - } - - if( soup.containsKey("keyType") ){ - this.keyType = ((PacketSection) soup.get("keyType")).getBytes(); - } - - if( soup.containsKey("key") ){ - this.key = ((PacketSection) soup.get("key")).getBytes(); - } - - if( soup.containsKey("inType") ){ - this.inType = ((PacketSection) soup.get("inType")).getBytes(); - } - - if( soup.containsKey("outType") ){ - this.outType = ((PacketSection) soup.get("outType")).getBytes(); - } - - if( soup.containsKey("fullMode") ){ - this.fullMode = ((PacketSection) soup.get("fullMode")).getBytes(); - } - - if( soup.containsKey("fullChar") ){ - this.fullChar = ((PacketSection) soup.get("fullChar")).getBytes(); - } - - if( soup.containsKey("fullType") ){ - this.fullType = ((PacketSection) soup.get("fullType")).getBytes(); - } - - if( soup.containsKey("iv") ){ - this.iv = ((PacketSection) soup.get("iv")).getBytes(); - } - - if( soup.containsKey("msgLen") ){ - this.msgLen = ((PacketSection) soup.get("msgLen")).getBytes(); - } - - if( soup.containsKey("msg") ){ - this.msg = ((PacketSection) soup.get("msg")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4530")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4530"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] outType = null; - private byte[] msgLen = null; - private byte[] msg = null; - private byte[] iv = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV模式标志错(Util.hexString2Bytes("3034")), - OPV未定义的方案ID(Util.hexString2Bytes("3035")), - OPV根密钥奇偶校验错(Util.hexString2Bytes("3130")), - OPV保护密钥奇偶校验错(Util.hexString2Bytes("3131")), - OPV用户存储区没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV离散次数错(Util.hexString2Bytes("3334")), - OPV密钥类型错(Util.hexString2Bytes("3238")), - OPV保护密钥类型错(Util.hexString2Bytes("3530")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return "模式标志错"; - } - if( "3035".equals(Util.bytes2HexString(this.error))) { - return "未定义的方案 ID"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "根密钥奇偶校验错"; - } - if( "3131".equals(Util.bytes2HexString(this.error))) { - return "保护密钥奇偶校验错"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3334".equals(Util.bytes2HexString(this.error))) { - return "离散次数错"; - } - if( "3238".equals(Util.bytes2HexString(this.error))) { - return "密钥类型错"; - } - if( "3530".equals(Util.bytes2HexString(this.error))) { - return "保护密钥类型错"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3035".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3131".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3334".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3238".equals(Util.bytes2HexString(this.error))) { - return 9; - } - if( "3530".equals(Util.bytes2HexString(this.error))) { - return 10; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 11; - } - return null; - } - - - public byte[] getOutTypeAsBin( ) { - - return this.outType; - } - - - public String getOutTypeAsStr( ) { - - if( null == this.outType) return null; - return Arrays.toString(this.outType); - } - - - public String getOutTypeAsHex( ) { - - if( null == this.outType) return null; - return Util.bytes2HexString(outType); - } - - - public Data setOutType( byte[] bytes ) { - - this.outType = bytes; - return this; - } -public enum OutTypeOptions { - - OPV二进制(Util.hexString2Bytes("30")), - OPV扩展十六进制(Util.hexString2Bytes("31")); - private byte[] bin; - OutTypeOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getOutTypeCn( ) { - - if( null == outType) { return null; } - if( "30".equals(Util.bytes2HexString(this.outType))) { - return "二进制"; - } - if( "31".equals(Util.bytes2HexString(this.outType))) { - return "扩展十六进制"; - } - return null; - } - - - public Integer getOutTypeOptionIndex( ) { - - if( null == outType) { return null; } - if( "30".equals(Util.bytes2HexString(this.outType))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.outType))) { - return 1; - } - return null; - } - - - public byte[] getMsgLenAsBin( ) { - - return this.msgLen; - } - - - public String getMsgLenAsStr( ) { - - if( null == this.msgLen) return null; - return Arrays.toString(this.msgLen); - } - - - public String getMsgLenAsHex( ) { - - if( null == this.msgLen) return null; - return Util.bytes2HexString(msgLen); - } - - - public Data setMsgLen( byte[] bytes ) { - - this.msgLen = bytes; - return this; - } - - - public byte[] getMsgAsBin( ) { - - return this.msg; - } - - - public String getMsgAsStr( ) { - - if( null == this.msg) return null; - return Arrays.toString(this.msg); - } - - - public String getMsgAsHex( ) { - - if( null == this.msg) return null; - return Util.bytes2HexString(msg); - } - - - public Data setMsg( byte[] bytes ) { - - this.msg = bytes; - return this; - } - - - public byte[] getIvAsBin( ) { - - return this.iv; - } - - - public String getIvAsStr( ) { - - if( null == this.iv) return null; - return Arrays.toString(this.iv); - } - - - public String getIvAsHex( ) { - - if( null == this.iv) return null; - return Util.bytes2HexString(iv); - } - - - public Data setIv( byte[] bytes ) { - - this.iv = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != outType ){ - soup.put("outType", this.outType); - soup.put("outType$option", getOutTypeOptionIndex()); - } - - if( null != msgLen ){ - soup.put("msgLen", this.msgLen); - } - - if( null != msg ){ - soup.put("msg", this.msg); - } - - if( null != iv ){ - soup.put("iv", this.iv); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("outType") ){ - this.outType = ((PacketSection) soup.get("outType")).getBytes(); - } - - if( soup.containsKey("msgLen") ){ - this.msgLen = ((PacketSection) soup.get("msgLen")).getBytes(); - } - - if( soup.containsKey("msg") ){ - this.msg = ((PacketSection) soup.get("msg")).getBytes(); - } - - if( soup.containsKey("iv") ){ - this.iv = ((PacketSection) soup.get("iv")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4531")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4531"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOE1.java b/src/main/java/racal/sunyard/main/dto/DTOE1.java deleted file mode 100644 index 84e0171..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOE1.java +++ /dev/null @@ -1,1640 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOE1 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] packSn = null; - private byte[] alg = null; - private byte[] roundModel = null; - private byte[] keyType = null; - private byte[] key = null; - private byte[] inType = null; - private byte[] outType = null; - private byte[] fullMode = null; - private byte[] fullChar = null; - private byte[] fullType = null; - private byte[] iv = null; - private byte[] msgLen = null; - private byte[] msg = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getPackSnAsBin( ) { - - return this.packSn; - } - - - public String getPackSnAsStr( ) { - - if( null == this.packSn) return null; - return Arrays.toString(this.packSn); - } - - - public String getPackSnAsHex( ) { - - if( null == this.packSn) return null; - return Util.bytes2HexString(packSn); - } - - - public Data setPackSn( byte[] bytes ) { - - this.packSn = bytes; - return this; - } -public enum PackSnOptions { - - OPV仅一块(Util.hexString2Bytes("30")), - OPV第一块(Util.hexString2Bytes("31")), - OPV中间块(Util.hexString2Bytes("32")), - OPV最后块(Util.hexString2Bytes("33")); - private byte[] bin; - PackSnOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getPackSnCn( ) { - - if( null == packSn) { return null; } - if( "30".equals(Util.bytes2HexString(this.packSn))) { - return "仅一块"; - } - if( "31".equals(Util.bytes2HexString(this.packSn))) { - return "第一块"; - } - if( "32".equals(Util.bytes2HexString(this.packSn))) { - return "中间块"; - } - if( "33".equals(Util.bytes2HexString(this.packSn))) { - return "最后块"; - } - return null; - } - - - public Integer getPackSnOptionIndex( ) { - - if( null == packSn) { return null; } - if( "30".equals(Util.bytes2HexString(this.packSn))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.packSn))) { - return 1; - } - if( "32".equals(Util.bytes2HexString(this.packSn))) { - return 2; - } - if( "33".equals(Util.bytes2HexString(this.packSn))) { - return 3; - } - return null; - } - - - public byte[] getAlgAsBin( ) { - - return this.alg; - } - - - public String getAlgAsStr( ) { - - if( null == this.alg) return null; - return Arrays.toString(this.alg); - } - - - public String getAlgAsHex( ) { - - if( null == this.alg) return null; - return Util.bytes2HexString(alg); - } - - - public Data setAlg( byte[] bytes ) { - - this.alg = bytes; - return this; - } -public enum AlgOptions { - - OPVDES加密(Util.hexString2Bytes("30")), - OPVDES解密(Util.hexString2Bytes("31")), - OPVAES加密(Util.hexString2Bytes("32")), - OPVAES解密(Util.hexString2Bytes("33")), - OPVSSF33加密(Util.hexString2Bytes("34")), - OPVSSF33解密(Util.hexString2Bytes("35")), - OPVSM1加密(Util.hexString2Bytes("36")), - OPVSM1解密(Util.hexString2Bytes("37")), - OPVSM4加密(Util.hexString2Bytes("38")), - OPVSM4解密(Util.hexString2Bytes("39")), - OPVIDEA加密(Util.hexString2Bytes("41")), - OPVIDEA解密(Util.hexString2Bytes("42")), - OPVAES256加密(Util.hexString2Bytes("43")), - OPVAES256解密(Util.hexString2Bytes("44")); - private byte[] bin; - AlgOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getAlgCn( ) { - - if( null == alg) { return null; } - if( "30".equals(Util.bytes2HexString(this.alg))) { - return "DES加密"; - } - if( "31".equals(Util.bytes2HexString(this.alg))) { - return "DES解密"; - } - if( "32".equals(Util.bytes2HexString(this.alg))) { - return "AES加密"; - } - if( "33".equals(Util.bytes2HexString(this.alg))) { - return "AES解密"; - } - if( "34".equals(Util.bytes2HexString(this.alg))) { - return "SSF33 加密"; - } - if( "35".equals(Util.bytes2HexString(this.alg))) { - return "SSF33 解密"; - } - if( "36".equals(Util.bytes2HexString(this.alg))) { - return "SM1加密"; - } - if( "37".equals(Util.bytes2HexString(this.alg))) { - return "SM1解密"; - } - if( "38".equals(Util.bytes2HexString(this.alg))) { - return "SM4加密"; - } - if( "39".equals(Util.bytes2HexString(this.alg))) { - return "SM4解密"; - } - if( "41".equals(Util.bytes2HexString(this.alg))) { - return "IDEA 加密"; - } - if( "42".equals(Util.bytes2HexString(this.alg))) { - return "IDEA 解密"; - } - if( "43".equals(Util.bytes2HexString(this.alg))) { - return "AES256 加密"; - } - if( "44".equals(Util.bytes2HexString(this.alg))) { - return "AES256 解密"; - } - return null; - } - - - public Integer getAlgOptionIndex( ) { - - if( null == alg) { return null; } - if( "30".equals(Util.bytes2HexString(this.alg))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.alg))) { - return 1; - } - if( "32".equals(Util.bytes2HexString(this.alg))) { - return 2; - } - if( "33".equals(Util.bytes2HexString(this.alg))) { - return 3; - } - if( "34".equals(Util.bytes2HexString(this.alg))) { - return 4; - } - if( "35".equals(Util.bytes2HexString(this.alg))) { - return 5; - } - if( "36".equals(Util.bytes2HexString(this.alg))) { - return 6; - } - if( "37".equals(Util.bytes2HexString(this.alg))) { - return 7; - } - if( "38".equals(Util.bytes2HexString(this.alg))) { - return 8; - } - if( "39".equals(Util.bytes2HexString(this.alg))) { - return 9; - } - if( "41".equals(Util.bytes2HexString(this.alg))) { - return 10; - } - if( "42".equals(Util.bytes2HexString(this.alg))) { - return 11; - } - if( "43".equals(Util.bytes2HexString(this.alg))) { - return 12; - } - if( "44".equals(Util.bytes2HexString(this.alg))) { - return 13; - } - return null; - } - - - public byte[] getRoundModelAsBin( ) { - - return this.roundModel; - } - - - public String getRoundModelAsStr( ) { - - if( null == this.roundModel) return null; - return Arrays.toString(this.roundModel); - } - - - public String getRoundModelAsHex( ) { - - if( null == this.roundModel) return null; - return Util.bytes2HexString(roundModel); - } - - - public Data setRoundModel( byte[] bytes ) { - - this.roundModel = bytes; - return this; - } -public enum RoundModelOptions { - - OPVECB(Util.hexString2Bytes("31")), - OPVCBC(Util.hexString2Bytes("32")), - OPVCFB(Util.hexString2Bytes("33")), - OPVOFB(Util.hexString2Bytes("34")); - private byte[] bin; - RoundModelOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getRoundModelCn( ) { - - if( null == roundModel) { return null; } - if( "31".equals(Util.bytes2HexString(this.roundModel))) { - return "ECB"; - } - if( "32".equals(Util.bytes2HexString(this.roundModel))) { - return "CBC"; - } - if( "33".equals(Util.bytes2HexString(this.roundModel))) { - return "CFB"; - } - if( "34".equals(Util.bytes2HexString(this.roundModel))) { - return "OFB"; - } - return null; - } - - - public Integer getRoundModelOptionIndex( ) { - - if( null == roundModel) { return null; } - if( "31".equals(Util.bytes2HexString(this.roundModel))) { - return 0; - } - if( "32".equals(Util.bytes2HexString(this.roundModel))) { - return 1; - } - if( "33".equals(Util.bytes2HexString(this.roundModel))) { - return 2; - } - if( "34".equals(Util.bytes2HexString(this.roundModel))) { - return 3; - } - return null; - } - - - public byte[] getKeyTypeAsBin( ) { - - return this.keyType; - } - - - public String getKeyTypeAsStr( ) { - - if( null == this.keyType) return null; - return Arrays.toString(this.keyType); - } - - - public String getKeyTypeAsHex( ) { - - if( null == this.keyType) return null; - return Util.bytes2HexString(keyType); - } - - - public Data setKeyType( byte[] bytes ) { - - this.keyType = bytes; - return this; - } -public enum KeyTypeOptions { - - OPVZEK(Util.hexString2Bytes("30")), - OPVTEK(Util.hexString2Bytes("31")); - private byte[] bin; - KeyTypeOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getKeyTypeCn( ) { - - if( null == keyType) { return null; } - if( "30".equals(Util.bytes2HexString(this.keyType))) { - return "ZEK"; - } - if( "31".equals(Util.bytes2HexString(this.keyType))) { - return "TEK"; - } - return null; - } - - - public Integer getKeyTypeOptionIndex( ) { - - if( null == keyType) { return null; } - if( "30".equals(Util.bytes2HexString(this.keyType))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.keyType))) { - return 1; - } - return null; - } - - - public byte[] getKeyAsBin( ) { - - return this.key; - } - - - public String getKeyAsStr( ) { - - if( null == this.key) return null; - return Arrays.toString(this.key); - } - - - public String getKeyAsHex( ) { - - if( null == this.key) return null; - return Util.bytes2HexString(key); - } - - - public Data setKey( byte[] bytes ) { - - this.key = bytes; - return this; - } - - - public byte[] getInTypeAsBin( ) { - - return this.inType; - } - - - public String getInTypeAsStr( ) { - - if( null == this.inType) return null; - return Arrays.toString(this.inType); - } - - - public String getInTypeAsHex( ) { - - if( null == this.inType) return null; - return Util.bytes2HexString(inType); - } - - - public Data setInType( byte[] bytes ) { - - this.inType = bytes; - return this; - } -public enum InTypeOptions { - - OPV二进制(Util.hexString2Bytes("30")), - OPV扩展十六进制(Util.hexString2Bytes("31")); - private byte[] bin; - InTypeOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getInTypeCn( ) { - - if( null == inType) { return null; } - if( "30".equals(Util.bytes2HexString(this.inType))) { - return "二进制"; - } - if( "31".equals(Util.bytes2HexString(this.inType))) { - return "扩展十六进制"; - } - return null; - } - - - public Integer getInTypeOptionIndex( ) { - - if( null == inType) { return null; } - if( "30".equals(Util.bytes2HexString(this.inType))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.inType))) { - return 1; - } - return null; - } - - - public byte[] getOutTypeAsBin( ) { - - return this.outType; - } - - - public String getOutTypeAsStr( ) { - - if( null == this.outType) return null; - return Arrays.toString(this.outType); - } - - - public String getOutTypeAsHex( ) { - - if( null == this.outType) return null; - return Util.bytes2HexString(outType); - } - - - public Data setOutType( byte[] bytes ) { - - this.outType = bytes; - return this; - } -public enum OutTypeOptions { - - OPV二进制(Util.hexString2Bytes("30")), - OPV扩展十六进制(Util.hexString2Bytes("31")); - private byte[] bin; - OutTypeOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getOutTypeCn( ) { - - if( null == outType) { return null; } - if( "30".equals(Util.bytes2HexString(this.outType))) { - return "二进制"; - } - if( "31".equals(Util.bytes2HexString(this.outType))) { - return "扩展十六进制"; - } - return null; - } - - - public Integer getOutTypeOptionIndex( ) { - - if( null == outType) { return null; } - if( "30".equals(Util.bytes2HexString(this.outType))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.outType))) { - return 1; - } - return null; - } - - - public byte[] getFullModeAsBin( ) { - - return this.fullMode; - } - - - public String getFullModeAsStr( ) { - - if( null == this.fullMode) return null; - return Arrays.toString(this.fullMode); - } - - - public String getFullModeAsHex( ) { - - if( null == this.fullMode) return null; - return Util.bytes2HexString(fullMode); - } - - - public Data setFullMode( byte[] bytes ) { - - this.fullMode = bytes; - return this; - } -public enum FullModeOptions { - - OPV饥饿模式(Util.hexString2Bytes("30")), - OPV贪婪模式(Util.hexString2Bytes("31")); - private byte[] bin; - FullModeOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getFullModeCn( ) { - - if( null == fullMode) { return null; } - if( "30".equals(Util.bytes2HexString(this.fullMode))) { - return "饥饿模式"; - } - if( "31".equals(Util.bytes2HexString(this.fullMode))) { - return "贪婪模式"; - } - return null; - } - - - public Integer getFullModeOptionIndex( ) { - - if( null == fullMode) { return null; } - if( "30".equals(Util.bytes2HexString(this.fullMode))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.fullMode))) { - return 1; - } - return null; - } - - - public byte[] getFullCharAsBin( ) { - - return this.fullChar; - } - - - public String getFullCharAsStr( ) { - - if( null == this.fullChar) return null; - return Arrays.toString(this.fullChar); - } - - - public String getFullCharAsHex( ) { - - if( null == this.fullChar) return null; - return Util.bytes2HexString(fullChar); - } - - - public Data setFullChar( byte[] bytes ) { - - this.fullChar = bytes; - return this; - } -public enum FullCharOptions { - - OPV0000(Util.hexString2Bytes("30303030")), - OPV8000(Util.hexString2Bytes("38303030")), - OPV7FFF(Util.hexString2Bytes("37464646")); - private byte[] bin; - FullCharOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getFullCharCn( ) { - - if( null == fullChar) { return null; } - if( "30303030".equals(Util.bytes2HexString(this.fullChar))) { - return "0000"; - } - if( "38303030".equals(Util.bytes2HexString(this.fullChar))) { - return "8000"; - } - if( "37464646".equals(Util.bytes2HexString(this.fullChar))) { - return "7FFF"; - } - return null; - } - - - public Integer getFullCharOptionIndex( ) { - - if( null == fullChar) { return null; } - if( "30303030".equals(Util.bytes2HexString(this.fullChar))) { - return 0; - } - if( "38303030".equals(Util.bytes2HexString(this.fullChar))) { - return 1; - } - if( "37464646".equals(Util.bytes2HexString(this.fullChar))) { - return 2; - } - return null; - } - - - public byte[] getFullTypeAsBin( ) { - - return this.fullType; - } - - - public String getFullTypeAsStr( ) { - - if( null == this.fullType) return null; - return Arrays.toString(this.fullType); - } - - - public String getFullTypeAsHex( ) { - - if( null == this.fullType) return null; - return Util.bytes2HexString(fullType); - } - - - public Data setFullType( byte[] bytes ) { - - this.fullType = bytes; - return this; - } -public enum FullTypeOptions { - - OPV不计尾(Util.hexString2Bytes("30")), - OPV计尾(Util.hexString2Bytes("31")), - OPVpkcs(Util.hexString2Bytes("32")); - private byte[] bin; - FullTypeOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getFullTypeCn( ) { - - if( null == fullType) { return null; } - if( "30".equals(Util.bytes2HexString(this.fullType))) { - return "不计尾"; - } - if( "31".equals(Util.bytes2HexString(this.fullType))) { - return "计尾"; - } - if( "32".equals(Util.bytes2HexString(this.fullType))) { - return "pkcs"; - } - return null; - } - - - public Integer getFullTypeOptionIndex( ) { - - if( null == fullType) { return null; } - if( "30".equals(Util.bytes2HexString(this.fullType))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.fullType))) { - return 1; - } - if( "32".equals(Util.bytes2HexString(this.fullType))) { - return 2; - } - return null; - } - - - public byte[] getIvAsBin( ) { - - return this.iv; - } - - - public String getIvAsStr( ) { - - if( null == this.iv) return null; - return Arrays.toString(this.iv); - } - - - public String getIvAsHex( ) { - - if( null == this.iv) return null; - return Util.bytes2HexString(iv); - } - - - public Data setIv( byte[] bytes ) { - - this.iv = bytes; - return this; - } - - - public byte[] getMsgLenAsBin( ) { - - return this.msgLen; - } - - - public String getMsgLenAsStr( ) { - - if( null == this.msgLen) return null; - return Arrays.toString(this.msgLen); - } - - - public String getMsgLenAsHex( ) { - - if( null == this.msgLen) return null; - return Util.bytes2HexString(msgLen); - } - - - public Data setMsgLen( byte[] bytes ) { - - this.msgLen = bytes; - return this; - } - - - public byte[] getMsgAsBin( ) { - - return this.msg; - } - - - public String getMsgAsStr( ) { - - if( null == this.msg) return null; - return Arrays.toString(this.msg); - } - - - public String getMsgAsHex( ) { - - if( null == this.msg) return null; - return Util.bytes2HexString(msg); - } - - - public Data setMsg( byte[] bytes ) { - - this.msg = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != packSn ){ - soup.put("packSn", this.packSn); - soup.put("packSn$option", getPackSnOptionIndex()); - } - - if( null != alg ){ - soup.put("alg", this.alg); - soup.put("alg$option", getAlgOptionIndex()); - } - - if( null != roundModel ){ - soup.put("roundModel", this.roundModel); - soup.put("roundModel$option", getRoundModelOptionIndex()); - } - - if( null != keyType ){ - soup.put("keyType", this.keyType); - soup.put("keyType$option", getKeyTypeOptionIndex()); - } - - if( null != key ){ - soup.put("key", this.key); - } - - if( null != inType ){ - soup.put("inType", this.inType); - soup.put("inType$option", getInTypeOptionIndex()); - } - - if( null != outType ){ - soup.put("outType", this.outType); - soup.put("outType$option", getOutTypeOptionIndex()); - } - - if( null != fullMode ){ - soup.put("fullMode", this.fullMode); - soup.put("fullMode$option", getFullModeOptionIndex()); - } - - if( null != fullChar ){ - soup.put("fullChar", this.fullChar); - soup.put("fullChar$option", getFullCharOptionIndex()); - } - - if( null != fullType ){ - soup.put("fullType", this.fullType); - soup.put("fullType$option", getFullTypeOptionIndex()); - } - - if( null != iv ){ - soup.put("iv", this.iv); - } - - if( null != msgLen ){ - soup.put("msgLen", this.msgLen); - } - - if( null != msg ){ - soup.put("msg", this.msg); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("packSn") ){ - this.packSn = ((PacketSection) soup.get("packSn")).getBytes(); - } - - if( soup.containsKey("alg") ){ - this.alg = ((PacketSection) soup.get("alg")).getBytes(); - } - - if( soup.containsKey("roundModel") ){ - this.roundModel = ((PacketSection) soup.get("roundModel")).getBytes(); - } - - if( soup.containsKey("keyType") ){ - this.keyType = ((PacketSection) soup.get("keyType")).getBytes(); - } - - if( soup.containsKey("key") ){ - this.key = ((PacketSection) soup.get("key")).getBytes(); - } - - if( soup.containsKey("inType") ){ - this.inType = ((PacketSection) soup.get("inType")).getBytes(); - } - - if( soup.containsKey("outType") ){ - this.outType = ((PacketSection) soup.get("outType")).getBytes(); - } - - if( soup.containsKey("fullMode") ){ - this.fullMode = ((PacketSection) soup.get("fullMode")).getBytes(); - } - - if( soup.containsKey("fullChar") ){ - this.fullChar = ((PacketSection) soup.get("fullChar")).getBytes(); - } - - if( soup.containsKey("fullType") ){ - this.fullType = ((PacketSection) soup.get("fullType")).getBytes(); - } - - if( soup.containsKey("iv") ){ - this.iv = ((PacketSection) soup.get("iv")).getBytes(); - } - - if( soup.containsKey("msgLen") ){ - this.msgLen = ((PacketSection) soup.get("msgLen")).getBytes(); - } - - if( soup.containsKey("msg") ){ - this.msg = ((PacketSection) soup.get("msg")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4531")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4531"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] outType = null; - private byte[] msgLen = null; - private byte[] msg = null; - private byte[] iv = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV模式标志错(Util.hexString2Bytes("3034")), - OPV未定义的方案ID(Util.hexString2Bytes("3035")), - OPV根密钥奇偶校验错(Util.hexString2Bytes("3130")), - OPV保护密钥奇偶校验错(Util.hexString2Bytes("3131")), - OPV用户存储区没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV离散次数错(Util.hexString2Bytes("3334")), - OPV密钥类型错(Util.hexString2Bytes("3238")), - OPV保护密钥类型错(Util.hexString2Bytes("3530")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return "模式标志错"; - } - if( "3035".equals(Util.bytes2HexString(this.error))) { - return "未定义的方案 ID"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "根密钥奇偶校验错"; - } - if( "3131".equals(Util.bytes2HexString(this.error))) { - return "保护密钥奇偶校验错"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3334".equals(Util.bytes2HexString(this.error))) { - return "离散次数错"; - } - if( "3238".equals(Util.bytes2HexString(this.error))) { - return "密钥类型错"; - } - if( "3530".equals(Util.bytes2HexString(this.error))) { - return "保护密钥类型错"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3035".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3131".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3334".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3238".equals(Util.bytes2HexString(this.error))) { - return 9; - } - if( "3530".equals(Util.bytes2HexString(this.error))) { - return 10; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 11; - } - return null; - } - - - public byte[] getOutTypeAsBin( ) { - - return this.outType; - } - - - public String getOutTypeAsStr( ) { - - if( null == this.outType) return null; - return Arrays.toString(this.outType); - } - - - public String getOutTypeAsHex( ) { - - if( null == this.outType) return null; - return Util.bytes2HexString(outType); - } - - - public Data setOutType( byte[] bytes ) { - - this.outType = bytes; - return this; - } -public enum OutTypeOptions { - - OPV二进制(Util.hexString2Bytes("30")), - OPV扩展十六进制(Util.hexString2Bytes("31")); - private byte[] bin; - OutTypeOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getOutTypeCn( ) { - - if( null == outType) { return null; } - if( "30".equals(Util.bytes2HexString(this.outType))) { - return "二进制"; - } - if( "31".equals(Util.bytes2HexString(this.outType))) { - return "扩展十六进制"; - } - return null; - } - - - public Integer getOutTypeOptionIndex( ) { - - if( null == outType) { return null; } - if( "30".equals(Util.bytes2HexString(this.outType))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.outType))) { - return 1; - } - return null; - } - - - public byte[] getMsgLenAsBin( ) { - - return this.msgLen; - } - - - public String getMsgLenAsStr( ) { - - if( null == this.msgLen) return null; - return Arrays.toString(this.msgLen); - } - - - public String getMsgLenAsHex( ) { - - if( null == this.msgLen) return null; - return Util.bytes2HexString(msgLen); - } - - - public Data setMsgLen( byte[] bytes ) { - - this.msgLen = bytes; - return this; - } - - - public byte[] getMsgAsBin( ) { - - return this.msg; - } - - - public String getMsgAsStr( ) { - - if( null == this.msg) return null; - return Arrays.toString(this.msg); - } - - - public String getMsgAsHex( ) { - - if( null == this.msg) return null; - return Util.bytes2HexString(msg); - } - - - public Data setMsg( byte[] bytes ) { - - this.msg = bytes; - return this; - } - - - public byte[] getIvAsBin( ) { - - return this.iv; - } - - - public String getIvAsStr( ) { - - if( null == this.iv) return null; - return Arrays.toString(this.iv); - } - - - public String getIvAsHex( ) { - - if( null == this.iv) return null; - return Util.bytes2HexString(iv); - } - - - public Data setIv( byte[] bytes ) { - - this.iv = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != outType ){ - soup.put("outType", this.outType); - soup.put("outType$option", getOutTypeOptionIndex()); - } - - if( null != msgLen ){ - soup.put("msgLen", this.msgLen); - } - - if( null != msg ){ - soup.put("msg", this.msg); - } - - if( null != iv ){ - soup.put("iv", this.iv); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("outType") ){ - this.outType = ((PacketSection) soup.get("outType")).getBytes(); - } - - if( soup.containsKey("msgLen") ){ - this.msgLen = ((PacketSection) soup.get("msgLen")).getBytes(); - } - - if( soup.containsKey("msg") ){ - this.msg = ((PacketSection) soup.get("msg")).getBytes(); - } - - if( soup.containsKey("iv") ){ - this.iv = ((PacketSection) soup.get("iv")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4532")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4532"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOE2.java b/src/main/java/racal/sunyard/main/dto/DTOE2.java deleted file mode 100644 index 085bd2b..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOE2.java +++ /dev/null @@ -1,1019 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOE2 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] algorithmId = null; - private byte[] keyLength = null; - private byte[] flag = null; - private byte[] index = null; - private byte[] startTime = null; - private byte[] endTime = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getAlgorithmIdAsBin( ) { - - return this.algorithmId; - } - - - public String getAlgorithmIdAsStr( ) { - - if( null == this.algorithmId) return null; - return Arrays.toString(this.algorithmId); - } - - - public String getAlgorithmIdAsHex( ) { - - if( null == this.algorithmId) return null; - return Util.bytes2HexString(algorithmId); - } - - - public Data setAlgorithmId( byte[] bytes ) { - - this.algorithmId = bytes; - return this; - } -public enum AlgorithmIdOptions { - - OPVRSA(Util.hexString2Bytes("30")), - OPVSM2(Util.hexString2Bytes("31")); - private byte[] bin; - AlgorithmIdOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getAlgorithmIdCn( ) { - - if( null == algorithmId) { return null; } - if( "30".equals(Util.bytes2HexString(this.algorithmId))) { - return "RSA"; - } - if( "31".equals(Util.bytes2HexString(this.algorithmId))) { - return "SM2"; - } - return null; - } - - - public Integer getAlgorithmIdOptionIndex( ) { - - if( null == algorithmId) { return null; } - if( "30".equals(Util.bytes2HexString(this.algorithmId))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.algorithmId))) { - return 1; - } - return null; - } - - - public byte[] getKeyLengthAsBin( ) { - - return this.keyLength; - } - - - public String getKeyLengthAsStr( ) { - - if( null == this.keyLength) return null; - return Arrays.toString(this.keyLength); - } - - - public String getKeyLengthAsHex( ) { - - if( null == this.keyLength) return null; - return Util.bytes2HexString(keyLength); - } - - - public Data setKeyLength( byte[] bytes ) { - - this.keyLength = bytes; - return this; - } - - - public byte[] getFlagAsBin( ) { - - return this.flag; - } - - - public String getFlagAsStr( ) { - - if( null == this.flag) return null; - return Arrays.toString(this.flag); - } - - - public String getFlagAsHex( ) { - - if( null == this.flag) return null; - return Util.bytes2HexString(flag); - } - - - public Data setFlag( byte[] bytes ) { - - this.flag = bytes; - return this; - } - - - public byte[] getIndexAsBin( ) { - - return this.index; - } - - - public String getIndexAsStr( ) { - - if( null == this.index) return null; - return Arrays.toString(this.index); - } - - - public String getIndexAsHex( ) { - - if( null == this.index) return null; - return Util.bytes2HexString(index); - } - - - public Data setIndex( byte[] bytes ) { - - this.index = bytes; - return this; - } - - - public byte[] getStartTimeAsBin( ) { - - return this.startTime; - } - - - public String getStartTimeAsStr( ) { - - if( null == this.startTime) return null; - return Arrays.toString(this.startTime); - } - - - public String getStartTimeAsHex( ) { - - if( null == this.startTime) return null; - return Util.bytes2HexString(startTime); - } - - - public Data setStartTime( byte[] bytes ) { - - this.startTime = bytes; - return this; - } - - - public byte[] getEndTimeAsBin( ) { - - return this.endTime; - } - - - public String getEndTimeAsStr( ) { - - if( null == this.endTime) return null; - return Arrays.toString(this.endTime); - } - - - public String getEndTimeAsHex( ) { - - if( null == this.endTime) return null; - return Util.bytes2HexString(endTime); - } - - - public Data setEndTime( byte[] bytes ) { - - this.endTime = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != algorithmId ){ - soup.put("algorithmId", this.algorithmId); - soup.put("algorithmId$option", getAlgorithmIdOptionIndex()); - } - - if( null != keyLength ){ - soup.put("keyLength", this.keyLength); - } - - if( null != flag ){ - soup.put("flag", this.flag); - } - - if( null != index ){ - soup.put("index", this.index); - } - - if( null != startTime ){ - soup.put("startTime", this.startTime); - } - - if( null != endTime ){ - soup.put("endTime", this.endTime); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("algorithmId") ){ - this.algorithmId = ((PacketSection) soup.get("algorithmId")).getBytes(); - } - - if( soup.containsKey("keyLength") ){ - this.keyLength = ((PacketSection) soup.get("keyLength")).getBytes(); - } - - if( soup.containsKey("flag") ){ - this.flag = ((PacketSection) soup.get("flag")).getBytes(); - } - - if( soup.containsKey("index") ){ - this.index = ((PacketSection) soup.get("index")).getBytes(); - } - - if( soup.containsKey("startTime") ){ - this.startTime = ((PacketSection) soup.get("startTime")).getBytes(); - } - - if( soup.containsKey("endTime") ){ - this.endTime = ((PacketSection) soup.get("endTime")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4532")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4532"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] privateKeyLength = null; - private byte[] privateKey = null; - private byte[] publicKeyLength = null; - private byte[] publicKey = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV无效的哈希标识(Util.hexString2Bytes("3035")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVDSP错误(Util.hexString2Bytes("3437")), - OPV数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3035".equals(Util.bytes2HexString(this.error))) { - return "无效的哈希标识"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return "DSP 错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3035".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 4; - } - return null; - } - - - public byte[] getPrivateKeyLengthAsBin( ) { - - return this.privateKeyLength; - } - - - public String getPrivateKeyLengthAsStr( ) { - - if( null == this.privateKeyLength) return null; - return Arrays.toString(this.privateKeyLength); - } - - - public String getPrivateKeyLengthAsHex( ) { - - if( null == this.privateKeyLength) return null; - return Util.bytes2HexString(privateKeyLength); - } - - - public Data setPrivateKeyLength( byte[] bytes ) { - - this.privateKeyLength = bytes; - return this; - } - - - public byte[] getPrivateKeyAsBin( ) { - - return this.privateKey; - } - - - public String getPrivateKeyAsStr( ) { - - if( null == this.privateKey) return null; - return Arrays.toString(this.privateKey); - } - - - public String getPrivateKeyAsHex( ) { - - if( null == this.privateKey) return null; - return Util.bytes2HexString(privateKey); - } - - - public Data setPrivateKey( byte[] bytes ) { - - this.privateKey = bytes; - return this; - } - - - public byte[] getPublicKeyLengthAsBin( ) { - - return this.publicKeyLength; - } - - - public String getPublicKeyLengthAsStr( ) { - - if( null == this.publicKeyLength) return null; - return Arrays.toString(this.publicKeyLength); - } - - - public String getPublicKeyLengthAsHex( ) { - - if( null == this.publicKeyLength) return null; - return Util.bytes2HexString(publicKeyLength); - } - - - public Data setPublicKeyLength( byte[] bytes ) { - - this.publicKeyLength = bytes; - return this; - } - - - public byte[] getPublicKeyAsBin( ) { - - return this.publicKey; - } - - - public String getPublicKeyAsStr( ) { - - if( null == this.publicKey) return null; - return Arrays.toString(this.publicKey); - } - - - public String getPublicKeyAsHex( ) { - - if( null == this.publicKey) return null; - return Util.bytes2HexString(publicKey); - } - - - public Data setPublicKey( byte[] bytes ) { - - this.publicKey = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != privateKeyLength ){ - soup.put("privateKeyLength", this.privateKeyLength); - } - - if( null != privateKey ){ - soup.put("privateKey", this.privateKey); - } - - if( null != publicKeyLength ){ - soup.put("publicKeyLength", this.publicKeyLength); - } - - if( null != publicKey ){ - soup.put("publicKey", this.publicKey); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("privateKeyLength") ){ - this.privateKeyLength = ((PacketSection) soup.get("privateKeyLength")).getBytes(); - } - - if( soup.containsKey("privateKey") ){ - this.privateKey = ((PacketSection) soup.get("privateKey")).getBytes(); - } - - if( soup.containsKey("publicKeyLength") ){ - this.publicKeyLength = ((PacketSection) soup.get("publicKeyLength")).getBytes(); - } - - if( soup.containsKey("publicKey") ){ - this.publicKey = ((PacketSection) soup.get("publicKey")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4533")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4533"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOE4.java b/src/main/java/racal/sunyard/main/dto/DTOE4.java deleted file mode 100644 index 3c0afc8..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOE4.java +++ /dev/null @@ -1,952 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOE4 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] nid = null; - private byte[] flg = null; - private byte[] index = null; - private byte[] startTime = null; - private byte[] endTime = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getNidAsBin( ) { - - return this.nid; - } - - - public String getNidAsStr( ) { - - if( null == this.nid) return null; - return Arrays.toString(this.nid); - } - - - public String getNidAsHex( ) { - - if( null == this.nid) return null; - return Util.bytes2HexString(nid); - } - - - public Data setNid( byte[] bytes ) { - - this.nid = bytes; - return this; - } - - - public byte[] getFlgAsBin( ) { - - return this.flg; - } - - - public String getFlgAsStr( ) { - - if( null == this.flg) return null; - return Arrays.toString(this.flg); - } - - - public String getFlgAsHex( ) { - - if( null == this.flg) return null; - return Util.bytes2HexString(flg); - } - - - public Data setFlg( byte[] bytes ) { - - this.flg = bytes; - return this; - } - - - public byte[] getIndexAsBin( ) { - - return this.index; - } - - - public String getIndexAsStr( ) { - - if( null == this.index) return null; - return Arrays.toString(this.index); - } - - - public String getIndexAsHex( ) { - - if( null == this.index) return null; - return Util.bytes2HexString(index); - } - - - public Data setIndex( byte[] bytes ) { - - this.index = bytes; - return this; - } - - - public byte[] getStartTimeAsBin( ) { - - return this.startTime; - } - - - public String getStartTimeAsStr( ) { - - if( null == this.startTime) return null; - return Arrays.toString(this.startTime); - } - - - public String getStartTimeAsHex( ) { - - if( null == this.startTime) return null; - return Util.bytes2HexString(startTime); - } - - - public Data setStartTime( byte[] bytes ) { - - this.startTime = bytes; - return this; - } - - - public byte[] getEndTimeAsBin( ) { - - return this.endTime; - } - - - public String getEndTimeAsStr( ) { - - if( null == this.endTime) return null; - return Arrays.toString(this.endTime); - } - - - public String getEndTimeAsHex( ) { - - if( null == this.endTime) return null; - return Util.bytes2HexString(endTime); - } - - - public Data setEndTime( byte[] bytes ) { - - this.endTime = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != nid ){ - soup.put("nid", this.nid); - } - - if( null != flg ){ - soup.put("flg", this.flg); - } - - if( null != index ){ - soup.put("index", this.index); - } - - if( null != startTime ){ - soup.put("startTime", this.startTime); - } - - if( null != endTime ){ - soup.put("endTime", this.endTime); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("nid") ){ - this.nid = ((PacketSection) soup.get("nid")).getBytes(); - } - - if( soup.containsKey("flg") ){ - this.flg = ((PacketSection) soup.get("flg")).getBytes(); - } - - if( soup.containsKey("index") ){ - this.index = ((PacketSection) soup.get("index")).getBytes(); - } - - if( soup.containsKey("startTime") ){ - this.startTime = ((PacketSection) soup.get("startTime")).getBytes(); - } - - if( soup.containsKey("endTime") ){ - this.endTime = ((PacketSection) soup.get("endTime")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4534")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4534"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] privateKeyLength = null; - private byte[] privateKey = null; - private byte[] publicKeyLength = null; - private byte[] publicKey = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV无效的哈希标识(Util.hexString2Bytes("3035")), - OPV生成密钥错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVDSP错误(Util.hexString2Bytes("3437")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3035".equals(Util.bytes2HexString(this.error))) { - return "无效的哈希标识"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "生成密钥错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return "DSP 错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3035".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 5; - } - return null; - } - - - public byte[] getPrivateKeyLengthAsBin( ) { - - return this.privateKeyLength; - } - - - public String getPrivateKeyLengthAsStr( ) { - - if( null == this.privateKeyLength) return null; - return Arrays.toString(this.privateKeyLength); - } - - - public String getPrivateKeyLengthAsHex( ) { - - if( null == this.privateKeyLength) return null; - return Util.bytes2HexString(privateKeyLength); - } - - - public Data setPrivateKeyLength( byte[] bytes ) { - - this.privateKeyLength = bytes; - return this; - } - - - public byte[] getPrivateKeyAsBin( ) { - - return this.privateKey; - } - - - public String getPrivateKeyAsStr( ) { - - if( null == this.privateKey) return null; - return Arrays.toString(this.privateKey); - } - - - public String getPrivateKeyAsHex( ) { - - if( null == this.privateKey) return null; - return Util.bytes2HexString(privateKey); - } - - - public Data setPrivateKey( byte[] bytes ) { - - this.privateKey = bytes; - return this; - } - - - public byte[] getPublicKeyLengthAsBin( ) { - - return this.publicKeyLength; - } - - - public String getPublicKeyLengthAsStr( ) { - - if( null == this.publicKeyLength) return null; - return Arrays.toString(this.publicKeyLength); - } - - - public String getPublicKeyLengthAsHex( ) { - - if( null == this.publicKeyLength) return null; - return Util.bytes2HexString(publicKeyLength); - } - - - public Data setPublicKeyLength( byte[] bytes ) { - - this.publicKeyLength = bytes; - return this; - } - - - public byte[] getPublicKeyAsBin( ) { - - return this.publicKey; - } - - - public String getPublicKeyAsStr( ) { - - if( null == this.publicKey) return null; - return Arrays.toString(this.publicKey); - } - - - public String getPublicKeyAsHex( ) { - - if( null == this.publicKey) return null; - return Util.bytes2HexString(publicKey); - } - - - public Data setPublicKey( byte[] bytes ) { - - this.publicKey = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != privateKeyLength ){ - soup.put("privateKeyLength", this.privateKeyLength); - } - - if( null != privateKey ){ - soup.put("privateKey", this.privateKey); - } - - if( null != publicKeyLength ){ - soup.put("publicKeyLength", this.publicKeyLength); - } - - if( null != publicKey ){ - soup.put("publicKey", this.publicKey); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("privateKeyLength") ){ - this.privateKeyLength = ((PacketSection) soup.get("privateKeyLength")).getBytes(); - } - - if( soup.containsKey("privateKey") ){ - this.privateKey = ((PacketSection) soup.get("privateKey")).getBytes(); - } - - if( soup.containsKey("publicKeyLength") ){ - this.publicKeyLength = ((PacketSection) soup.get("publicKeyLength")).getBytes(); - } - - if( soup.containsKey("publicKey") ){ - this.publicKey = ((PacketSection) soup.get("publicKey")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4535")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4535"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOFA.java b/src/main/java/racal/sunyard/main/dto/DTOFA.java deleted file mode 100644 index 65921e4..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOFA.java +++ /dev/null @@ -1,1016 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOFA { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] zmk = null; - private byte[] zpk = null; - private byte[] businessKey = null; - private byte[] separator = null; - private byte[] zmkSolution = null; - private byte[] lmkSolution = null; - private byte[] keyCheckType = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getZmkAsBin( ) { - - return this.zmk; - } - - - public String getZmkAsStr( ) { - - if( null == this.zmk) return null; - return Arrays.toString(this.zmk); - } - - - public String getZmkAsHex( ) { - - if( null == this.zmk) return null; - return Util.bytes2HexString(zmk); - } - - - public Data setZmk( byte[] bytes ) { - - this.zmk = bytes; - return this; - } - - - public byte[] getZpkAsBin( ) { - - return this.zpk; - } - - - public String getZpkAsStr( ) { - - if( null == this.zpk) return null; - return Arrays.toString(this.zpk); - } - - - public String getZpkAsHex( ) { - - if( null == this.zpk) return null; - return Util.bytes2HexString(zpk); - } - - - public Data setZpk( byte[] bytes ) { - - this.zpk = bytes; - return this; - } - - - public byte[] getBusinessKeyAsBin( ) { - - return this.businessKey; - } - - - public String getBusinessKeyAsStr( ) { - - if( null == this.businessKey) return null; - return Arrays.toString(this.businessKey); - } - - - public String getBusinessKeyAsHex( ) { - - if( null == this.businessKey) return null; - return Util.bytes2HexString(businessKey); - } - - - public Data setBusinessKey( byte[] bytes ) { - - this.businessKey = bytes; - return this; - } - - - public byte[] getSeparatorAsBin( ) { - - return this.separator; - } - - - public String getSeparatorAsStr( ) { - - if( null == this.separator) return null; - return Arrays.toString(this.separator); - } - - - public String getSeparatorAsHex( ) { - - if( null == this.separator) return null; - return Util.bytes2HexString(separator); - } - - - public Data setSeparator( byte[] bytes ) { - - this.separator = bytes; - return this; - } - - - public byte[] getZmkSolutionAsBin( ) { - - return this.zmkSolution; - } - - - public String getZmkSolutionAsStr( ) { - - if( null == this.zmkSolution) return null; - return Arrays.toString(this.zmkSolution); - } - - - public String getZmkSolutionAsHex( ) { - - if( null == this.zmkSolution) return null; - return Util.bytes2HexString(zmkSolution); - } - - - public Data setZmkSolution( byte[] bytes ) { - - this.zmkSolution = bytes; - return this; - } - - - public byte[] getLmkSolutionAsBin( ) { - - return this.lmkSolution; - } - - - public String getLmkSolutionAsStr( ) { - - if( null == this.lmkSolution) return null; - return Arrays.toString(this.lmkSolution); - } - - - public String getLmkSolutionAsHex( ) { - - if( null == this.lmkSolution) return null; - return Util.bytes2HexString(lmkSolution); - } - - - public Data setLmkSolution( byte[] bytes ) { - - this.lmkSolution = bytes; - return this; - } - - - public byte[] getKeyCheckTypeAsBin( ) { - - return this.keyCheckType; - } - - - public String getKeyCheckTypeAsStr( ) { - - if( null == this.keyCheckType) return null; - return Arrays.toString(this.keyCheckType); - } - - - public String getKeyCheckTypeAsHex( ) { - - if( null == this.keyCheckType) return null; - return Util.bytes2HexString(keyCheckType); - } - - - public Data setKeyCheckType( byte[] bytes ) { - - this.keyCheckType = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != zmk ){ - soup.put("zmk", this.zmk); - } - - if( null != zpk ){ - soup.put("zpk", this.zpk); - } - - if( null != businessKey ){ - soup.put("businessKey", this.businessKey); - } - - if( null != separator ){ - soup.put("separator", this.separator); - } - - if( null != zmkSolution ){ - soup.put("zmkSolution", this.zmkSolution); - } - - if( null != lmkSolution ){ - soup.put("lmkSolution", this.lmkSolution); - } - - if( null != keyCheckType ){ - soup.put("keyCheckType", this.keyCheckType); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("zmk") ){ - this.zmk = ((PacketSection) soup.get("zmk")).getBytes(); - } - - if( soup.containsKey("zpk") ){ - this.zpk = ((PacketSection) soup.get("zpk")).getBytes(); - } - - if( soup.containsKey("businessKey") ){ - this.businessKey = ((PacketSection) soup.get("businessKey")).getBytes(); - } - - if( soup.containsKey("separator") ){ - this.separator = ((PacketSection) soup.get("separator")).getBytes(); - } - - if( soup.containsKey("zmkSolution") ){ - this.zmkSolution = ((PacketSection) soup.get("zmkSolution")).getBytes(); - } - - if( soup.containsKey("lmkSolution") ){ - this.lmkSolution = ((PacketSection) soup.get("lmkSolution")).getBytes(); - } - - if( soup.containsKey("keyCheckType") ){ - this.keyCheckType = ((PacketSection) soup.get("keyCheckType")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4641")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4641"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] zpkHead = null; - private byte[] zpk = null; - private byte[] keyCheck = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV密钥奇偶校验错仅仅是报告错误并不影响结果(Util.hexString2Bytes("3031")), - OPVZMK奇偶校验错(Util.hexString2Bytes("3130")), - OPV全0的ZPK为偶校验终止运行(Util.hexString2Bytes("3131")), - OPV用户存储区中没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV无效用户存储区索引(Util.hexString2Bytes("3231")), - OPV无效的密钥方案(Util.hexString2Bytes("3236")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3031".equals(Util.bytes2HexString(this.error))) { - return "密钥奇偶校验错,仅仅是报告错误,并不影响结果"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "ZMK 奇偶校验错"; - } - if( "3131".equals(Util.bytes2HexString(this.error))) { - return "全 0 的 ZPK 为偶校验(终止运行)"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区中没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效用户存储区索引"; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return "无效的密钥方案"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3031".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3131".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 9; - } - return null; - } - - - public byte[] getZpkHeadAsBin( ) { - - return this.zpkHead; - } - - - public String getZpkHeadAsStr( ) { - - if( null == this.zpkHead) return null; - return Arrays.toString(this.zpkHead); - } - - - public String getZpkHeadAsHex( ) { - - if( null == this.zpkHead) return null; - return Util.bytes2HexString(zpkHead); - } - - - public Data setZpkHead( byte[] bytes ) { - - this.zpkHead = bytes; - return this; - } - - - public byte[] getZpkAsBin( ) { - - return this.zpk; - } - - - public String getZpkAsStr( ) { - - if( null == this.zpk) return null; - return Arrays.toString(this.zpk); - } - - - public String getZpkAsHex( ) { - - if( null == this.zpk) return null; - return Util.bytes2HexString(zpk); - } - - - public Data setZpk( byte[] bytes ) { - - this.zpk = bytes; - return this; - } - - - public byte[] getKeyCheckAsBin( ) { - - return this.keyCheck; - } - - - public String getKeyCheckAsStr( ) { - - if( null == this.keyCheck) return null; - return Arrays.toString(this.keyCheck); - } - - - public String getKeyCheckAsHex( ) { - - if( null == this.keyCheck) return null; - return Util.bytes2HexString(keyCheck); - } - - - public Data setKeyCheck( byte[] bytes ) { - - this.keyCheck = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != zpkHead ){ - soup.put("zpkHead", this.zpkHead); - } - - if( null != zpk ){ - soup.put("zpk", this.zpk); - } - - if( null != keyCheck ){ - soup.put("keyCheck", this.keyCheck); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("zpkHead") ){ - this.zpkHead = ((PacketSection) soup.get("zpkHead")).getBytes(); - } - - if( soup.containsKey("zpk") ){ - this.zpk = ((PacketSection) soup.get("zpk")).getBytes(); - } - - if( soup.containsKey("keyCheck") ){ - this.keyCheck = ((PacketSection) soup.get("keyCheck")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4642")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4642"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOFC.java b/src/main/java/racal/sunyard/main/dto/DTOFC.java deleted file mode 100644 index b339443..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOFC.java +++ /dev/null @@ -1,1002 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOFC { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] zmk = null; - private byte[] tmk = null; - private byte[] businessKey = null; - private byte[] separator = null; - private byte[] zmkSolution = null; - private byte[] lmkSolution = null; - private byte[] keyCheckType = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getZmkAsBin( ) { - - return this.zmk; - } - - - public String getZmkAsStr( ) { - - if( null == this.zmk) return null; - return Arrays.toString(this.zmk); - } - - - public String getZmkAsHex( ) { - - if( null == this.zmk) return null; - return Util.bytes2HexString(zmk); - } - - - public Data setZmk( byte[] bytes ) { - - this.zmk = bytes; - return this; - } - - - public byte[] getTmkAsBin( ) { - - return this.tmk; - } - - - public String getTmkAsStr( ) { - - if( null == this.tmk) return null; - return Arrays.toString(this.tmk); - } - - - public String getTmkAsHex( ) { - - if( null == this.tmk) return null; - return Util.bytes2HexString(tmk); - } - - - public Data setTmk( byte[] bytes ) { - - this.tmk = bytes; - return this; - } - - - public byte[] getBusinessKeyAsBin( ) { - - return this.businessKey; - } - - - public String getBusinessKeyAsStr( ) { - - if( null == this.businessKey) return null; - return Arrays.toString(this.businessKey); - } - - - public String getBusinessKeyAsHex( ) { - - if( null == this.businessKey) return null; - return Util.bytes2HexString(businessKey); - } - - - public Data setBusinessKey( byte[] bytes ) { - - this.businessKey = bytes; - return this; - } - - - public byte[] getSeparatorAsBin( ) { - - return this.separator; - } - - - public String getSeparatorAsStr( ) { - - if( null == this.separator) return null; - return Arrays.toString(this.separator); - } - - - public String getSeparatorAsHex( ) { - - if( null == this.separator) return null; - return Util.bytes2HexString(separator); - } - - - public Data setSeparator( byte[] bytes ) { - - this.separator = bytes; - return this; - } - - - public byte[] getZmkSolutionAsBin( ) { - - return this.zmkSolution; - } - - - public String getZmkSolutionAsStr( ) { - - if( null == this.zmkSolution) return null; - return Arrays.toString(this.zmkSolution); - } - - - public String getZmkSolutionAsHex( ) { - - if( null == this.zmkSolution) return null; - return Util.bytes2HexString(zmkSolution); - } - - - public Data setZmkSolution( byte[] bytes ) { - - this.zmkSolution = bytes; - return this; - } - - - public byte[] getLmkSolutionAsBin( ) { - - return this.lmkSolution; - } - - - public String getLmkSolutionAsStr( ) { - - if( null == this.lmkSolution) return null; - return Arrays.toString(this.lmkSolution); - } - - - public String getLmkSolutionAsHex( ) { - - if( null == this.lmkSolution) return null; - return Util.bytes2HexString(lmkSolution); - } - - - public Data setLmkSolution( byte[] bytes ) { - - this.lmkSolution = bytes; - return this; - } - - - public byte[] getKeyCheckTypeAsBin( ) { - - return this.keyCheckType; - } - - - public String getKeyCheckTypeAsStr( ) { - - if( null == this.keyCheckType) return null; - return Arrays.toString(this.keyCheckType); - } - - - public String getKeyCheckTypeAsHex( ) { - - if( null == this.keyCheckType) return null; - return Util.bytes2HexString(keyCheckType); - } - - - public Data setKeyCheckType( byte[] bytes ) { - - this.keyCheckType = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != zmk ){ - soup.put("zmk", this.zmk); - } - - if( null != tmk ){ - soup.put("tmk", this.tmk); - } - - if( null != businessKey ){ - soup.put("businessKey", this.businessKey); - } - - if( null != separator ){ - soup.put("separator", this.separator); - } - - if( null != zmkSolution ){ - soup.put("zmkSolution", this.zmkSolution); - } - - if( null != lmkSolution ){ - soup.put("lmkSolution", this.lmkSolution); - } - - if( null != keyCheckType ){ - soup.put("keyCheckType", this.keyCheckType); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("zmk") ){ - this.zmk = ((PacketSection) soup.get("zmk")).getBytes(); - } - - if( soup.containsKey("tmk") ){ - this.tmk = ((PacketSection) soup.get("tmk")).getBytes(); - } - - if( soup.containsKey("businessKey") ){ - this.businessKey = ((PacketSection) soup.get("businessKey")).getBytes(); - } - - if( soup.containsKey("separator") ){ - this.separator = ((PacketSection) soup.get("separator")).getBytes(); - } - - if( soup.containsKey("zmkSolution") ){ - this.zmkSolution = ((PacketSection) soup.get("zmkSolution")).getBytes(); - } - - if( soup.containsKey("lmkSolution") ){ - this.lmkSolution = ((PacketSection) soup.get("lmkSolution")).getBytes(); - } - - if( soup.containsKey("keyCheckType") ){ - this.keyCheckType = ((PacketSection) soup.get("keyCheckType")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4643")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4643"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] tmkHead = null; - private byte[] tmkKey = null; - private byte[] keyCheck = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPVZMK奇偶校验错(Util.hexString2Bytes("3130")), - OPVTMKTPK或PVK奇偶校验错(Util.hexString2Bytes("3131")), - OPV用户存储区中没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV不在授权状态(Util.hexString2Bytes("3137")), - OPV无效用户存储区索引(Util.hexString2Bytes("3231")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "ZMK 奇偶校验错"; - } - if( "3131".equals(Util.bytes2HexString(this.error))) { - return "TMK、 TPK 或 PVK 奇偶校验错"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区中没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3137".equals(Util.bytes2HexString(this.error))) { - return "不在授权状态"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效用户存储区索引"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3131".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3137".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 7; - } - return null; - } - - - public byte[] getTmkHeadAsBin( ) { - - return this.tmkHead; - } - - - public String getTmkHeadAsStr( ) { - - if( null == this.tmkHead) return null; - return Arrays.toString(this.tmkHead); - } - - - public String getTmkHeadAsHex( ) { - - if( null == this.tmkHead) return null; - return Util.bytes2HexString(tmkHead); - } - - - public Data setTmkHead( byte[] bytes ) { - - this.tmkHead = bytes; - return this; - } - - - public byte[] getTmkKeyAsBin( ) { - - return this.tmkKey; - } - - - public String getTmkKeyAsStr( ) { - - if( null == this.tmkKey) return null; - return Arrays.toString(this.tmkKey); - } - - - public String getTmkKeyAsHex( ) { - - if( null == this.tmkKey) return null; - return Util.bytes2HexString(tmkKey); - } - - - public Data setTmkKey( byte[] bytes ) { - - this.tmkKey = bytes; - return this; - } - - - public byte[] getKeyCheckAsBin( ) { - - return this.keyCheck; - } - - - public String getKeyCheckAsStr( ) { - - if( null == this.keyCheck) return null; - return Arrays.toString(this.keyCheck); - } - - - public String getKeyCheckAsHex( ) { - - if( null == this.keyCheck) return null; - return Util.bytes2HexString(keyCheck); - } - - - public Data setKeyCheck( byte[] bytes ) { - - this.keyCheck = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != tmkHead ){ - soup.put("tmkHead", this.tmkHead); - } - - if( null != tmkKey ){ - soup.put("tmkKey", this.tmkKey); - } - - if( null != keyCheck ){ - soup.put("keyCheck", this.keyCheck); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("tmkHead") ){ - this.tmkHead = ((PacketSection) soup.get("tmkHead")).getBytes(); - } - - if( soup.containsKey("tmkKey") ){ - this.tmkKey = ((PacketSection) soup.get("tmkKey")).getBytes(); - } - - if( soup.containsKey("keyCheck") ){ - this.keyCheck = ((PacketSection) soup.get("keyCheck")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4644")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4644"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOFE.java b/src/main/java/racal/sunyard/main/dto/DTOFE.java deleted file mode 100644 index fe8eaeb..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOFE.java +++ /dev/null @@ -1,1009 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOFE { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] zmk = null; - private byte[] tmk = null; - private byte[] businessKey = null; - private byte[] separator = null; - private byte[] zmkSolution = null; - private byte[] lmkSolution = null; - private byte[] keyCheckType = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getZmkAsBin( ) { - - return this.zmk; - } - - - public String getZmkAsStr( ) { - - if( null == this.zmk) return null; - return Arrays.toString(this.zmk); - } - - - public String getZmkAsHex( ) { - - if( null == this.zmk) return null; - return Util.bytes2HexString(zmk); - } - - - public Data setZmk( byte[] bytes ) { - - this.zmk = bytes; - return this; - } - - - public byte[] getTmkAsBin( ) { - - return this.tmk; - } - - - public String getTmkAsStr( ) { - - if( null == this.tmk) return null; - return Arrays.toString(this.tmk); - } - - - public String getTmkAsHex( ) { - - if( null == this.tmk) return null; - return Util.bytes2HexString(tmk); - } - - - public Data setTmk( byte[] bytes ) { - - this.tmk = bytes; - return this; - } - - - public byte[] getBusinessKeyAsBin( ) { - - return this.businessKey; - } - - - public String getBusinessKeyAsStr( ) { - - if( null == this.businessKey) return null; - return Arrays.toString(this.businessKey); - } - - - public String getBusinessKeyAsHex( ) { - - if( null == this.businessKey) return null; - return Util.bytes2HexString(businessKey); - } - - - public Data setBusinessKey( byte[] bytes ) { - - this.businessKey = bytes; - return this; - } - - - public byte[] getSeparatorAsBin( ) { - - return this.separator; - } - - - public String getSeparatorAsStr( ) { - - if( null == this.separator) return null; - return Arrays.toString(this.separator); - } - - - public String getSeparatorAsHex( ) { - - if( null == this.separator) return null; - return Util.bytes2HexString(separator); - } - - - public Data setSeparator( byte[] bytes ) { - - this.separator = bytes; - return this; - } - - - public byte[] getZmkSolutionAsBin( ) { - - return this.zmkSolution; - } - - - public String getZmkSolutionAsStr( ) { - - if( null == this.zmkSolution) return null; - return Arrays.toString(this.zmkSolution); - } - - - public String getZmkSolutionAsHex( ) { - - if( null == this.zmkSolution) return null; - return Util.bytes2HexString(zmkSolution); - } - - - public Data setZmkSolution( byte[] bytes ) { - - this.zmkSolution = bytes; - return this; - } - - - public byte[] getLmkSolutionAsBin( ) { - - return this.lmkSolution; - } - - - public String getLmkSolutionAsStr( ) { - - if( null == this.lmkSolution) return null; - return Arrays.toString(this.lmkSolution); - } - - - public String getLmkSolutionAsHex( ) { - - if( null == this.lmkSolution) return null; - return Util.bytes2HexString(lmkSolution); - } - - - public Data setLmkSolution( byte[] bytes ) { - - this.lmkSolution = bytes; - return this; - } - - - public byte[] getKeyCheckTypeAsBin( ) { - - return this.keyCheckType; - } - - - public String getKeyCheckTypeAsStr( ) { - - if( null == this.keyCheckType) return null; - return Arrays.toString(this.keyCheckType); - } - - - public String getKeyCheckTypeAsHex( ) { - - if( null == this.keyCheckType) return null; - return Util.bytes2HexString(keyCheckType); - } - - - public Data setKeyCheckType( byte[] bytes ) { - - this.keyCheckType = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != zmk ){ - soup.put("zmk", this.zmk); - } - - if( null != tmk ){ - soup.put("tmk", this.tmk); - } - - if( null != businessKey ){ - soup.put("businessKey", this.businessKey); - } - - if( null != separator ){ - soup.put("separator", this.separator); - } - - if( null != zmkSolution ){ - soup.put("zmkSolution", this.zmkSolution); - } - - if( null != lmkSolution ){ - soup.put("lmkSolution", this.lmkSolution); - } - - if( null != keyCheckType ){ - soup.put("keyCheckType", this.keyCheckType); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("zmk") ){ - this.zmk = ((PacketSection) soup.get("zmk")).getBytes(); - } - - if( soup.containsKey("tmk") ){ - this.tmk = ((PacketSection) soup.get("tmk")).getBytes(); - } - - if( soup.containsKey("businessKey") ){ - this.businessKey = ((PacketSection) soup.get("businessKey")).getBytes(); - } - - if( soup.containsKey("separator") ){ - this.separator = ((PacketSection) soup.get("separator")).getBytes(); - } - - if( soup.containsKey("zmkSolution") ){ - this.zmkSolution = ((PacketSection) soup.get("zmkSolution")).getBytes(); - } - - if( soup.containsKey("lmkSolution") ){ - this.lmkSolution = ((PacketSection) soup.get("lmkSolution")).getBytes(); - } - - if( soup.containsKey("keyCheckType") ){ - this.keyCheckType = ((PacketSection) soup.get("keyCheckType")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4645")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4645"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] tmkHead = null; - private byte[] tmkKey = null; - private byte[] keyCheck = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPVZMK奇偶校验错(Util.hexString2Bytes("3130")), - OPVTMKTPK或PVK奇偶校验错(Util.hexString2Bytes("3131")), - OPV用户存储区中没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV不在授权状态(Util.hexString2Bytes("3137")), - OPV无效用户存储区索引(Util.hexString2Bytes("3231")), - OPV数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "ZMK 奇偶校验错"; - } - if( "3131".equals(Util.bytes2HexString(this.error))) { - return "TMK、 TPK 或 PVK 奇偶校验错"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区中没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3137".equals(Util.bytes2HexString(this.error))) { - return "不在授权状态"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效用户存储区索引"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3131".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3137".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 8; - } - return null; - } - - - public byte[] getTmkHeadAsBin( ) { - - return this.tmkHead; - } - - - public String getTmkHeadAsStr( ) { - - if( null == this.tmkHead) return null; - return Arrays.toString(this.tmkHead); - } - - - public String getTmkHeadAsHex( ) { - - if( null == this.tmkHead) return null; - return Util.bytes2HexString(tmkHead); - } - - - public Data setTmkHead( byte[] bytes ) { - - this.tmkHead = bytes; - return this; - } - - - public byte[] getTmkKeyAsBin( ) { - - return this.tmkKey; - } - - - public String getTmkKeyAsStr( ) { - - if( null == this.tmkKey) return null; - return Arrays.toString(this.tmkKey); - } - - - public String getTmkKeyAsHex( ) { - - if( null == this.tmkKey) return null; - return Util.bytes2HexString(tmkKey); - } - - - public Data setTmkKey( byte[] bytes ) { - - this.tmkKey = bytes; - return this; - } - - - public byte[] getKeyCheckAsBin( ) { - - return this.keyCheck; - } - - - public String getKeyCheckAsStr( ) { - - if( null == this.keyCheck) return null; - return Arrays.toString(this.keyCheck); - } - - - public String getKeyCheckAsHex( ) { - - if( null == this.keyCheck) return null; - return Util.bytes2HexString(keyCheck); - } - - - public Data setKeyCheck( byte[] bytes ) { - - this.keyCheck = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != tmkHead ){ - soup.put("tmkHead", this.tmkHead); - } - - if( null != tmkKey ){ - soup.put("tmkKey", this.tmkKey); - } - - if( null != keyCheck ){ - soup.put("keyCheck", this.keyCheck); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("tmkHead") ){ - this.tmkHead = ((PacketSection) soup.get("tmkHead")).getBytes(); - } - - if( soup.containsKey("tmkKey") ){ - this.tmkKey = ((PacketSection) soup.get("tmkKey")).getBytes(); - } - - if( soup.containsKey("keyCheck") ){ - this.keyCheck = ((PacketSection) soup.get("keyCheck")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4646")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4646"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOFI.java b/src/main/java/racal/sunyard/main/dto/DTOFI.java deleted file mode 100644 index 1716741..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOFI.java +++ /dev/null @@ -1,1249 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOFI { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] key = null; - private byte[] zmk = null; - private byte[] businessKey = null; - private byte[] separator = null; - private byte[] zmkSolution = null; - private byte[] lmkSolution = null; - private byte[] keyCheckType = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getKeyAsBin( ) { - - return this.key; - } - - - public String getKeyAsStr( ) { - - if( null == this.key) return null; - return Arrays.toString(this.key); - } - - - public String getKeyAsHex( ) { - - if( null == this.key) return null; - return Util.bytes2HexString(key); - } - - - public Data setKey( byte[] bytes ) { - - this.key = bytes; - return this; - } -public enum KeyOptions { - - OPVZEK(Util.hexString2Bytes("30")), - OPVZAK(Util.hexString2Bytes("31")); - private byte[] bin; - KeyOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getKeyCn( ) { - - if( null == key) { return null; } - if( "30".equals(Util.bytes2HexString(this.key))) { - return "ZEK"; - } - if( "31".equals(Util.bytes2HexString(this.key))) { - return "ZAK"; - } - return null; - } - - - public Integer getKeyOptionIndex( ) { - - if( null == key) { return null; } - if( "30".equals(Util.bytes2HexString(this.key))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.key))) { - return 1; - } - return null; - } - - - public byte[] getZmkAsBin( ) { - - return this.zmk; - } - - - public String getZmkAsStr( ) { - - if( null == this.zmk) return null; - return Arrays.toString(this.zmk); - } - - - public String getZmkAsHex( ) { - - if( null == this.zmk) return null; - return Util.bytes2HexString(zmk); - } - - - public Data setZmk( byte[] bytes ) { - - this.zmk = bytes; - return this; - } - - - public byte[] getBusinessKeyAsBin( ) { - - return this.businessKey; - } - - - public String getBusinessKeyAsStr( ) { - - if( null == this.businessKey) return null; - return Arrays.toString(this.businessKey); - } - - - public String getBusinessKeyAsHex( ) { - - if( null == this.businessKey) return null; - return Util.bytes2HexString(businessKey); - } - - - public Data setBusinessKey( byte[] bytes ) { - - this.businessKey = bytes; - return this; - } - - - public byte[] getSeparatorAsBin( ) { - - return this.separator; - } - - - public String getSeparatorAsStr( ) { - - if( null == this.separator) return null; - return Arrays.toString(this.separator); - } - - - public String getSeparatorAsHex( ) { - - if( null == this.separator) return null; - return Util.bytes2HexString(separator); - } - - - public Data setSeparator( byte[] bytes ) { - - this.separator = bytes; - return this; - } - - - public byte[] getZmkSolutionAsBin( ) { - - return this.zmkSolution; - } - - - public String getZmkSolutionAsStr( ) { - - if( null == this.zmkSolution) return null; - return Arrays.toString(this.zmkSolution); - } - - - public String getZmkSolutionAsHex( ) { - - if( null == this.zmkSolution) return null; - return Util.bytes2HexString(zmkSolution); - } - - - public Data setZmkSolution( byte[] bytes ) { - - this.zmkSolution = bytes; - return this; - } - - - public byte[] getLmkSolutionAsBin( ) { - - return this.lmkSolution; - } - - - public String getLmkSolutionAsStr( ) { - - if( null == this.lmkSolution) return null; - return Arrays.toString(this.lmkSolution); - } - - - public String getLmkSolutionAsHex( ) { - - if( null == this.lmkSolution) return null; - return Util.bytes2HexString(lmkSolution); - } - - - public Data setLmkSolution( byte[] bytes ) { - - this.lmkSolution = bytes; - return this; - } - - - public byte[] getKeyCheckTypeAsBin( ) { - - return this.keyCheckType; - } - - - public String getKeyCheckTypeAsStr( ) { - - if( null == this.keyCheckType) return null; - return Arrays.toString(this.keyCheckType); - } - - - public String getKeyCheckTypeAsHex( ) { - - if( null == this.keyCheckType) return null; - return Util.bytes2HexString(keyCheckType); - } - - - public Data setKeyCheckType( byte[] bytes ) { - - this.keyCheckType = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != key ){ - soup.put("key", this.key); - soup.put("key$option", getKeyOptionIndex()); - } - - if( null != zmk ){ - soup.put("zmk", this.zmk); - } - - if( null != businessKey ){ - soup.put("businessKey", this.businessKey); - } - - if( null != separator ){ - soup.put("separator", this.separator); - } - - if( null != zmkSolution ){ - soup.put("zmkSolution", this.zmkSolution); - } - - if( null != lmkSolution ){ - soup.put("lmkSolution", this.lmkSolution); - } - - if( null != keyCheckType ){ - soup.put("keyCheckType", this.keyCheckType); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("key") ){ - this.key = ((PacketSection) soup.get("key")).getBytes(); - } - - if( soup.containsKey("zmk") ){ - this.zmk = ((PacketSection) soup.get("zmk")).getBytes(); - } - - if( soup.containsKey("businessKey") ){ - this.businessKey = ((PacketSection) soup.get("businessKey")).getBytes(); - } - - if( soup.containsKey("separator") ){ - this.separator = ((PacketSection) soup.get("separator")).getBytes(); - } - - if( soup.containsKey("zmkSolution") ){ - this.zmkSolution = ((PacketSection) soup.get("zmkSolution")).getBytes(); - } - - if( soup.containsKey("lmkSolution") ){ - this.lmkSolution = ((PacketSection) soup.get("lmkSolution")).getBytes(); - } - - if( soup.containsKey("keyCheckType") ){ - this.keyCheckType = ((PacketSection) soup.get("keyCheckType")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4649")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4649"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] zekZmkHead = null; - private byte[] zekZmk = null; - private byte[] zekLmkHead = null; - private byte[] zekLmk = null; - private byte[] zakZmkHead = null; - private byte[] zakZmk = null; - private byte[] zakLmkHead = null; - private byte[] zakLmk = null; - private byte[] keyCheck = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV第一个成份奇偶校验错(Util.hexString2Bytes("3130")), - OPV用户存储区中没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV无效用户存储区索引(Util.hexString2Bytes("3231")), - OPV数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "第一个成份奇偶校验错"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区中没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效用户存储区索引"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 6; - } - return null; - } - - - public byte[] getZekZmkHeadAsBin( ) { - - return this.zekZmkHead; - } - - - public String getZekZmkHeadAsStr( ) { - - if( null == this.zekZmkHead) return null; - return Arrays.toString(this.zekZmkHead); - } - - - public String getZekZmkHeadAsHex( ) { - - if( null == this.zekZmkHead) return null; - return Util.bytes2HexString(zekZmkHead); - } - - - public Data setZekZmkHead( byte[] bytes ) { - - this.zekZmkHead = bytes; - return this; - } - - - public byte[] getZekZmkAsBin( ) { - - return this.zekZmk; - } - - - public String getZekZmkAsStr( ) { - - if( null == this.zekZmk) return null; - return Arrays.toString(this.zekZmk); - } - - - public String getZekZmkAsHex( ) { - - if( null == this.zekZmk) return null; - return Util.bytes2HexString(zekZmk); - } - - - public Data setZekZmk( byte[] bytes ) { - - this.zekZmk = bytes; - return this; - } - - - public byte[] getZekLmkHeadAsBin( ) { - - return this.zekLmkHead; - } - - - public String getZekLmkHeadAsStr( ) { - - if( null == this.zekLmkHead) return null; - return Arrays.toString(this.zekLmkHead); - } - - - public String getZekLmkHeadAsHex( ) { - - if( null == this.zekLmkHead) return null; - return Util.bytes2HexString(zekLmkHead); - } - - - public Data setZekLmkHead( byte[] bytes ) { - - this.zekLmkHead = bytes; - return this; - } - - - public byte[] getZekLmkAsBin( ) { - - return this.zekLmk; - } - - - public String getZekLmkAsStr( ) { - - if( null == this.zekLmk) return null; - return Arrays.toString(this.zekLmk); - } - - - public String getZekLmkAsHex( ) { - - if( null == this.zekLmk) return null; - return Util.bytes2HexString(zekLmk); - } - - - public Data setZekLmk( byte[] bytes ) { - - this.zekLmk = bytes; - return this; - } - - - public byte[] getZakZmkHeadAsBin( ) { - - return this.zakZmkHead; - } - - - public String getZakZmkHeadAsStr( ) { - - if( null == this.zakZmkHead) return null; - return Arrays.toString(this.zakZmkHead); - } - - - public String getZakZmkHeadAsHex( ) { - - if( null == this.zakZmkHead) return null; - return Util.bytes2HexString(zakZmkHead); - } - - - public Data setZakZmkHead( byte[] bytes ) { - - this.zakZmkHead = bytes; - return this; - } - - - public byte[] getZakZmkAsBin( ) { - - return this.zakZmk; - } - - - public String getZakZmkAsStr( ) { - - if( null == this.zakZmk) return null; - return Arrays.toString(this.zakZmk); - } - - - public String getZakZmkAsHex( ) { - - if( null == this.zakZmk) return null; - return Util.bytes2HexString(zakZmk); - } - - - public Data setZakZmk( byte[] bytes ) { - - this.zakZmk = bytes; - return this; - } - - - public byte[] getZakLmkHeadAsBin( ) { - - return this.zakLmkHead; - } - - - public String getZakLmkHeadAsStr( ) { - - if( null == this.zakLmkHead) return null; - return Arrays.toString(this.zakLmkHead); - } - - - public String getZakLmkHeadAsHex( ) { - - if( null == this.zakLmkHead) return null; - return Util.bytes2HexString(zakLmkHead); - } - - - public Data setZakLmkHead( byte[] bytes ) { - - this.zakLmkHead = bytes; - return this; - } - - - public byte[] getZakLmkAsBin( ) { - - return this.zakLmk; - } - - - public String getZakLmkAsStr( ) { - - if( null == this.zakLmk) return null; - return Arrays.toString(this.zakLmk); - } - - - public String getZakLmkAsHex( ) { - - if( null == this.zakLmk) return null; - return Util.bytes2HexString(zakLmk); - } - - - public Data setZakLmk( byte[] bytes ) { - - this.zakLmk = bytes; - return this; - } - - - public byte[] getKeyCheckAsBin( ) { - - return this.keyCheck; - } - - - public String getKeyCheckAsStr( ) { - - if( null == this.keyCheck) return null; - return Arrays.toString(this.keyCheck); - } - - - public String getKeyCheckAsHex( ) { - - if( null == this.keyCheck) return null; - return Util.bytes2HexString(keyCheck); - } - - - public Data setKeyCheck( byte[] bytes ) { - - this.keyCheck = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != zekZmkHead ){ - soup.put("zekZmkHead", this.zekZmkHead); - } - - if( null != zekZmk ){ - soup.put("zekZmk", this.zekZmk); - } - - if( null != zekLmkHead ){ - soup.put("zekLmkHead", this.zekLmkHead); - } - - if( null != zekLmk ){ - soup.put("zekLmk", this.zekLmk); - } - - if( null != zakZmkHead ){ - soup.put("zakZmkHead", this.zakZmkHead); - } - - if( null != zakZmk ){ - soup.put("zakZmk", this.zakZmk); - } - - if( null != zakLmkHead ){ - soup.put("zakLmkHead", this.zakLmkHead); - } - - if( null != zakLmk ){ - soup.put("zakLmk", this.zakLmk); - } - - if( null != keyCheck ){ - soup.put("keyCheck", this.keyCheck); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("zekZmkHead") ){ - this.zekZmkHead = ((PacketSection) soup.get("zekZmkHead")).getBytes(); - } - - if( soup.containsKey("zekZmk") ){ - this.zekZmk = ((PacketSection) soup.get("zekZmk")).getBytes(); - } - - if( soup.containsKey("zekLmkHead") ){ - this.zekLmkHead = ((PacketSection) soup.get("zekLmkHead")).getBytes(); - } - - if( soup.containsKey("zekLmk") ){ - this.zekLmk = ((PacketSection) soup.get("zekLmk")).getBytes(); - } - - if( soup.containsKey("zakZmkHead") ){ - this.zakZmkHead = ((PacketSection) soup.get("zakZmkHead")).getBytes(); - } - - if( soup.containsKey("zakZmk") ){ - this.zakZmk = ((PacketSection) soup.get("zakZmk")).getBytes(); - } - - if( soup.containsKey("zakLmkHead") ){ - this.zakLmkHead = ((PacketSection) soup.get("zakLmkHead")).getBytes(); - } - - if( soup.containsKey("zakLmk") ){ - this.zakLmk = ((PacketSection) soup.get("zakLmk")).getBytes(); - } - - if( soup.containsKey("keyCheck") ){ - this.keyCheck = ((PacketSection) soup.get("keyCheck")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("464A")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("464A"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOFK.java b/src/main/java/racal/sunyard/main/dto/DTOFK.java deleted file mode 100644 index 366620c..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOFK.java +++ /dev/null @@ -1,1148 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOFK { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] key = null; - private byte[] zmk = null; - private byte[] zekOrzak = null; - private byte[] businessKey = null; - private byte[] separator = null; - private byte[] zmkSolution = null; - private byte[] lmkSolution = null; - private byte[] keyCheckType = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getKeyAsBin( ) { - - return this.key; - } - - - public String getKeyAsStr( ) { - - if( null == this.key) return null; - return Arrays.toString(this.key); - } - - - public String getKeyAsHex( ) { - - if( null == this.key) return null; - return Util.bytes2HexString(key); - } - - - public Data setKey( byte[] bytes ) { - - this.key = bytes; - return this; - } -public enum KeyOptions { - - OPVZEK(Util.hexString2Bytes("30")), - OPVZAK(Util.hexString2Bytes("31")); - private byte[] bin; - KeyOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getKeyCn( ) { - - if( null == key) { return null; } - if( "30".equals(Util.bytes2HexString(this.key))) { - return "ZEK"; - } - if( "31".equals(Util.bytes2HexString(this.key))) { - return "ZAK"; - } - return null; - } - - - public Integer getKeyOptionIndex( ) { - - if( null == key) { return null; } - if( "30".equals(Util.bytes2HexString(this.key))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.key))) { - return 1; - } - return null; - } - - - public byte[] getZmkAsBin( ) { - - return this.zmk; - } - - - public String getZmkAsStr( ) { - - if( null == this.zmk) return null; - return Arrays.toString(this.zmk); - } - - - public String getZmkAsHex( ) { - - if( null == this.zmk) return null; - return Util.bytes2HexString(zmk); - } - - - public Data setZmk( byte[] bytes ) { - - this.zmk = bytes; - return this; - } - - - public byte[] getZekOrzakAsBin( ) { - - return this.zekOrzak; - } - - - public String getZekOrzakAsStr( ) { - - if( null == this.zekOrzak) return null; - return Arrays.toString(this.zekOrzak); - } - - - public String getZekOrzakAsHex( ) { - - if( null == this.zekOrzak) return null; - return Util.bytes2HexString(zekOrzak); - } - - - public Data setZekOrzak( byte[] bytes ) { - - this.zekOrzak = bytes; - return this; - } - - - public byte[] getBusinessKeyAsBin( ) { - - return this.businessKey; - } - - - public String getBusinessKeyAsStr( ) { - - if( null == this.businessKey) return null; - return Arrays.toString(this.businessKey); - } - - - public String getBusinessKeyAsHex( ) { - - if( null == this.businessKey) return null; - return Util.bytes2HexString(businessKey); - } - - - public Data setBusinessKey( byte[] bytes ) { - - this.businessKey = bytes; - return this; - } - - - public byte[] getSeparatorAsBin( ) { - - return this.separator; - } - - - public String getSeparatorAsStr( ) { - - if( null == this.separator) return null; - return Arrays.toString(this.separator); - } - - - public String getSeparatorAsHex( ) { - - if( null == this.separator) return null; - return Util.bytes2HexString(separator); - } - - - public Data setSeparator( byte[] bytes ) { - - this.separator = bytes; - return this; - } - - - public byte[] getZmkSolutionAsBin( ) { - - return this.zmkSolution; - } - - - public String getZmkSolutionAsStr( ) { - - if( null == this.zmkSolution) return null; - return Arrays.toString(this.zmkSolution); - } - - - public String getZmkSolutionAsHex( ) { - - if( null == this.zmkSolution) return null; - return Util.bytes2HexString(zmkSolution); - } - - - public Data setZmkSolution( byte[] bytes ) { - - this.zmkSolution = bytes; - return this; - } - - - public byte[] getLmkSolutionAsBin( ) { - - return this.lmkSolution; - } - - - public String getLmkSolutionAsStr( ) { - - if( null == this.lmkSolution) return null; - return Arrays.toString(this.lmkSolution); - } - - - public String getLmkSolutionAsHex( ) { - - if( null == this.lmkSolution) return null; - return Util.bytes2HexString(lmkSolution); - } - - - public Data setLmkSolution( byte[] bytes ) { - - this.lmkSolution = bytes; - return this; - } - - - public byte[] getKeyCheckTypeAsBin( ) { - - return this.keyCheckType; - } - - - public String getKeyCheckTypeAsStr( ) { - - if( null == this.keyCheckType) return null; - return Arrays.toString(this.keyCheckType); - } - - - public String getKeyCheckTypeAsHex( ) { - - if( null == this.keyCheckType) return null; - return Util.bytes2HexString(keyCheckType); - } - - - public Data setKeyCheckType( byte[] bytes ) { - - this.keyCheckType = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != key ){ - soup.put("key", this.key); - soup.put("key$option", getKeyOptionIndex()); - } - - if( null != zmk ){ - soup.put("zmk", this.zmk); - } - - if( null != zekOrzak ){ - soup.put("zekOrzak", this.zekOrzak); - } - - if( null != businessKey ){ - soup.put("businessKey", this.businessKey); - } - - if( null != separator ){ - soup.put("separator", this.separator); - } - - if( null != zmkSolution ){ - soup.put("zmkSolution", this.zmkSolution); - } - - if( null != lmkSolution ){ - soup.put("lmkSolution", this.lmkSolution); - } - - if( null != keyCheckType ){ - soup.put("keyCheckType", this.keyCheckType); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("key") ){ - this.key = ((PacketSection) soup.get("key")).getBytes(); - } - - if( soup.containsKey("zmk") ){ - this.zmk = ((PacketSection) soup.get("zmk")).getBytes(); - } - - if( soup.containsKey("zekOrzak") ){ - this.zekOrzak = ((PacketSection) soup.get("zekOrzak")).getBytes(); - } - - if( soup.containsKey("businessKey") ){ - this.businessKey = ((PacketSection) soup.get("businessKey")).getBytes(); - } - - if( soup.containsKey("separator") ){ - this.separator = ((PacketSection) soup.get("separator")).getBytes(); - } - - if( soup.containsKey("zmkSolution") ){ - this.zmkSolution = ((PacketSection) soup.get("zmkSolution")).getBytes(); - } - - if( soup.containsKey("lmkSolution") ){ - this.lmkSolution = ((PacketSection) soup.get("lmkSolution")).getBytes(); - } - - if( soup.containsKey("keyCheckType") ){ - this.keyCheckType = ((PacketSection) soup.get("keyCheckType")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("464B")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("464B"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] zekLmkHead = null; - private byte[] zekLmk = null; - private byte[] zakLmkHead = null; - private byte[] zakLmk = null; - private byte[] keyCheck = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV第一个成份奇偶校验错(Util.hexString2Bytes("3130")), - OPV用户存储区中没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV无效用户存储区索引(Util.hexString2Bytes("3231")), - OPV密钥方案错误(Util.hexString2Bytes("3236")), - OPV数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "第一个成份奇偶校验错"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区中没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效用户存储区索引"; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return "密钥方案错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 7; - } - return null; - } - - - public byte[] getZekLmkHeadAsBin( ) { - - return this.zekLmkHead; - } - - - public String getZekLmkHeadAsStr( ) { - - if( null == this.zekLmkHead) return null; - return Arrays.toString(this.zekLmkHead); - } - - - public String getZekLmkHeadAsHex( ) { - - if( null == this.zekLmkHead) return null; - return Util.bytes2HexString(zekLmkHead); - } - - - public Data setZekLmkHead( byte[] bytes ) { - - this.zekLmkHead = bytes; - return this; - } - - - public byte[] getZekLmkAsBin( ) { - - return this.zekLmk; - } - - - public String getZekLmkAsStr( ) { - - if( null == this.zekLmk) return null; - return Arrays.toString(this.zekLmk); - } - - - public String getZekLmkAsHex( ) { - - if( null == this.zekLmk) return null; - return Util.bytes2HexString(zekLmk); - } - - - public Data setZekLmk( byte[] bytes ) { - - this.zekLmk = bytes; - return this; - } - - - public byte[] getZakLmkHeadAsBin( ) { - - return this.zakLmkHead; - } - - - public String getZakLmkHeadAsStr( ) { - - if( null == this.zakLmkHead) return null; - return Arrays.toString(this.zakLmkHead); - } - - - public String getZakLmkHeadAsHex( ) { - - if( null == this.zakLmkHead) return null; - return Util.bytes2HexString(zakLmkHead); - } - - - public Data setZakLmkHead( byte[] bytes ) { - - this.zakLmkHead = bytes; - return this; - } - - - public byte[] getZakLmkAsBin( ) { - - return this.zakLmk; - } - - - public String getZakLmkAsStr( ) { - - if( null == this.zakLmk) return null; - return Arrays.toString(this.zakLmk); - } - - - public String getZakLmkAsHex( ) { - - if( null == this.zakLmk) return null; - return Util.bytes2HexString(zakLmk); - } - - - public Data setZakLmk( byte[] bytes ) { - - this.zakLmk = bytes; - return this; - } - - - public byte[] getKeyCheckAsBin( ) { - - return this.keyCheck; - } - - - public String getKeyCheckAsStr( ) { - - if( null == this.keyCheck) return null; - return Arrays.toString(this.keyCheck); - } - - - public String getKeyCheckAsHex( ) { - - if( null == this.keyCheck) return null; - return Util.bytes2HexString(keyCheck); - } - - - public Data setKeyCheck( byte[] bytes ) { - - this.keyCheck = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != zekLmkHead ){ - soup.put("zekLmkHead", this.zekLmkHead); - } - - if( null != zekLmk ){ - soup.put("zekLmk", this.zekLmk); - } - - if( null != zakLmkHead ){ - soup.put("zakLmkHead", this.zakLmkHead); - } - - if( null != zakLmk ){ - soup.put("zakLmk", this.zakLmk); - } - - if( null != keyCheck ){ - soup.put("keyCheck", this.keyCheck); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("zekLmkHead") ){ - this.zekLmkHead = ((PacketSection) soup.get("zekLmkHead")).getBytes(); - } - - if( soup.containsKey("zekLmk") ){ - this.zekLmk = ((PacketSection) soup.get("zekLmk")).getBytes(); - } - - if( soup.containsKey("zakLmkHead") ){ - this.zakLmkHead = ((PacketSection) soup.get("zakLmkHead")).getBytes(); - } - - if( soup.containsKey("zakLmk") ){ - this.zakLmk = ((PacketSection) soup.get("zakLmk")).getBytes(); - } - - if( soup.containsKey("keyCheck") ){ - this.keyCheck = ((PacketSection) soup.get("keyCheck")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("464C")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("464C"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOFM.java b/src/main/java/racal/sunyard/main/dto/DTOFM.java deleted file mode 100644 index ccc8f99..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOFM.java +++ /dev/null @@ -1,1148 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOFM { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] key = null; - private byte[] zmk = null; - private byte[] zekOrzak = null; - private byte[] businessKey = null; - private byte[] separator = null; - private byte[] zmkSolution = null; - private byte[] lmkSolution = null; - private byte[] keyCheckType = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getKeyAsBin( ) { - - return this.key; - } - - - public String getKeyAsStr( ) { - - if( null == this.key) return null; - return Arrays.toString(this.key); - } - - - public String getKeyAsHex( ) { - - if( null == this.key) return null; - return Util.bytes2HexString(key); - } - - - public Data setKey( byte[] bytes ) { - - this.key = bytes; - return this; - } -public enum KeyOptions { - - OPVZEK(Util.hexString2Bytes("30")), - OPVZAK(Util.hexString2Bytes("31")); - private byte[] bin; - KeyOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getKeyCn( ) { - - if( null == key) { return null; } - if( "30".equals(Util.bytes2HexString(this.key))) { - return "ZEK"; - } - if( "31".equals(Util.bytes2HexString(this.key))) { - return "ZAK"; - } - return null; - } - - - public Integer getKeyOptionIndex( ) { - - if( null == key) { return null; } - if( "30".equals(Util.bytes2HexString(this.key))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.key))) { - return 1; - } - return null; - } - - - public byte[] getZmkAsBin( ) { - - return this.zmk; - } - - - public String getZmkAsStr( ) { - - if( null == this.zmk) return null; - return Arrays.toString(this.zmk); - } - - - public String getZmkAsHex( ) { - - if( null == this.zmk) return null; - return Util.bytes2HexString(zmk); - } - - - public Data setZmk( byte[] bytes ) { - - this.zmk = bytes; - return this; - } - - - public byte[] getZekOrzakAsBin( ) { - - return this.zekOrzak; - } - - - public String getZekOrzakAsStr( ) { - - if( null == this.zekOrzak) return null; - return Arrays.toString(this.zekOrzak); - } - - - public String getZekOrzakAsHex( ) { - - if( null == this.zekOrzak) return null; - return Util.bytes2HexString(zekOrzak); - } - - - public Data setZekOrzak( byte[] bytes ) { - - this.zekOrzak = bytes; - return this; - } - - - public byte[] getBusinessKeyAsBin( ) { - - return this.businessKey; - } - - - public String getBusinessKeyAsStr( ) { - - if( null == this.businessKey) return null; - return Arrays.toString(this.businessKey); - } - - - public String getBusinessKeyAsHex( ) { - - if( null == this.businessKey) return null; - return Util.bytes2HexString(businessKey); - } - - - public Data setBusinessKey( byte[] bytes ) { - - this.businessKey = bytes; - return this; - } - - - public byte[] getSeparatorAsBin( ) { - - return this.separator; - } - - - public String getSeparatorAsStr( ) { - - if( null == this.separator) return null; - return Arrays.toString(this.separator); - } - - - public String getSeparatorAsHex( ) { - - if( null == this.separator) return null; - return Util.bytes2HexString(separator); - } - - - public Data setSeparator( byte[] bytes ) { - - this.separator = bytes; - return this; - } - - - public byte[] getZmkSolutionAsBin( ) { - - return this.zmkSolution; - } - - - public String getZmkSolutionAsStr( ) { - - if( null == this.zmkSolution) return null; - return Arrays.toString(this.zmkSolution); - } - - - public String getZmkSolutionAsHex( ) { - - if( null == this.zmkSolution) return null; - return Util.bytes2HexString(zmkSolution); - } - - - public Data setZmkSolution( byte[] bytes ) { - - this.zmkSolution = bytes; - return this; - } - - - public byte[] getLmkSolutionAsBin( ) { - - return this.lmkSolution; - } - - - public String getLmkSolutionAsStr( ) { - - if( null == this.lmkSolution) return null; - return Arrays.toString(this.lmkSolution); - } - - - public String getLmkSolutionAsHex( ) { - - if( null == this.lmkSolution) return null; - return Util.bytes2HexString(lmkSolution); - } - - - public Data setLmkSolution( byte[] bytes ) { - - this.lmkSolution = bytes; - return this; - } - - - public byte[] getKeyCheckTypeAsBin( ) { - - return this.keyCheckType; - } - - - public String getKeyCheckTypeAsStr( ) { - - if( null == this.keyCheckType) return null; - return Arrays.toString(this.keyCheckType); - } - - - public String getKeyCheckTypeAsHex( ) { - - if( null == this.keyCheckType) return null; - return Util.bytes2HexString(keyCheckType); - } - - - public Data setKeyCheckType( byte[] bytes ) { - - this.keyCheckType = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != key ){ - soup.put("key", this.key); - soup.put("key$option", getKeyOptionIndex()); - } - - if( null != zmk ){ - soup.put("zmk", this.zmk); - } - - if( null != zekOrzak ){ - soup.put("zekOrzak", this.zekOrzak); - } - - if( null != businessKey ){ - soup.put("businessKey", this.businessKey); - } - - if( null != separator ){ - soup.put("separator", this.separator); - } - - if( null != zmkSolution ){ - soup.put("zmkSolution", this.zmkSolution); - } - - if( null != lmkSolution ){ - soup.put("lmkSolution", this.lmkSolution); - } - - if( null != keyCheckType ){ - soup.put("keyCheckType", this.keyCheckType); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("key") ){ - this.key = ((PacketSection) soup.get("key")).getBytes(); - } - - if( soup.containsKey("zmk") ){ - this.zmk = ((PacketSection) soup.get("zmk")).getBytes(); - } - - if( soup.containsKey("zekOrzak") ){ - this.zekOrzak = ((PacketSection) soup.get("zekOrzak")).getBytes(); - } - - if( soup.containsKey("businessKey") ){ - this.businessKey = ((PacketSection) soup.get("businessKey")).getBytes(); - } - - if( soup.containsKey("separator") ){ - this.separator = ((PacketSection) soup.get("separator")).getBytes(); - } - - if( soup.containsKey("zmkSolution") ){ - this.zmkSolution = ((PacketSection) soup.get("zmkSolution")).getBytes(); - } - - if( soup.containsKey("lmkSolution") ){ - this.lmkSolution = ((PacketSection) soup.get("lmkSolution")).getBytes(); - } - - if( soup.containsKey("keyCheckType") ){ - this.keyCheckType = ((PacketSection) soup.get("keyCheckType")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("464D")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("464D"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] zekZmkHead = null; - private byte[] zekZmk = null; - private byte[] zakZmkHead = null; - private byte[] zakZmk = null; - private byte[] keyCheck = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV第一个成份奇偶校验错(Util.hexString2Bytes("3130")), - OPV第二或第三个成份奇偶校验错(Util.hexString2Bytes("3131")), - OPV用户存储区中没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV无效用户存储区索引(Util.hexString2Bytes("3231")), - OPV数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "第一个成份奇偶校验错"; - } - if( "3131".equals(Util.bytes2HexString(this.error))) { - return "第二或第三个成份奇偶校验错"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区中没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效用户存储区索引"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3131".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 7; - } - return null; - } - - - public byte[] getZekZmkHeadAsBin( ) { - - return this.zekZmkHead; - } - - - public String getZekZmkHeadAsStr( ) { - - if( null == this.zekZmkHead) return null; - return Arrays.toString(this.zekZmkHead); - } - - - public String getZekZmkHeadAsHex( ) { - - if( null == this.zekZmkHead) return null; - return Util.bytes2HexString(zekZmkHead); - } - - - public Data setZekZmkHead( byte[] bytes ) { - - this.zekZmkHead = bytes; - return this; - } - - - public byte[] getZekZmkAsBin( ) { - - return this.zekZmk; - } - - - public String getZekZmkAsStr( ) { - - if( null == this.zekZmk) return null; - return Arrays.toString(this.zekZmk); - } - - - public String getZekZmkAsHex( ) { - - if( null == this.zekZmk) return null; - return Util.bytes2HexString(zekZmk); - } - - - public Data setZekZmk( byte[] bytes ) { - - this.zekZmk = bytes; - return this; - } - - - public byte[] getZakZmkHeadAsBin( ) { - - return this.zakZmkHead; - } - - - public String getZakZmkHeadAsStr( ) { - - if( null == this.zakZmkHead) return null; - return Arrays.toString(this.zakZmkHead); - } - - - public String getZakZmkHeadAsHex( ) { - - if( null == this.zakZmkHead) return null; - return Util.bytes2HexString(zakZmkHead); - } - - - public Data setZakZmkHead( byte[] bytes ) { - - this.zakZmkHead = bytes; - return this; - } - - - public byte[] getZakZmkAsBin( ) { - - return this.zakZmk; - } - - - public String getZakZmkAsStr( ) { - - if( null == this.zakZmk) return null; - return Arrays.toString(this.zakZmk); - } - - - public String getZakZmkAsHex( ) { - - if( null == this.zakZmk) return null; - return Util.bytes2HexString(zakZmk); - } - - - public Data setZakZmk( byte[] bytes ) { - - this.zakZmk = bytes; - return this; - } - - - public byte[] getKeyCheckAsBin( ) { - - return this.keyCheck; - } - - - public String getKeyCheckAsStr( ) { - - if( null == this.keyCheck) return null; - return Arrays.toString(this.keyCheck); - } - - - public String getKeyCheckAsHex( ) { - - if( null == this.keyCheck) return null; - return Util.bytes2HexString(keyCheck); - } - - - public Data setKeyCheck( byte[] bytes ) { - - this.keyCheck = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != zekZmkHead ){ - soup.put("zekZmkHead", this.zekZmkHead); - } - - if( null != zekZmk ){ - soup.put("zekZmk", this.zekZmk); - } - - if( null != zakZmkHead ){ - soup.put("zakZmkHead", this.zakZmkHead); - } - - if( null != zakZmk ){ - soup.put("zakZmk", this.zakZmk); - } - - if( null != keyCheck ){ - soup.put("keyCheck", this.keyCheck); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("zekZmkHead") ){ - this.zekZmkHead = ((PacketSection) soup.get("zekZmkHead")).getBytes(); - } - - if( soup.containsKey("zekZmk") ){ - this.zekZmk = ((PacketSection) soup.get("zekZmk")).getBytes(); - } - - if( soup.containsKey("zakZmkHead") ){ - this.zakZmkHead = ((PacketSection) soup.get("zakZmkHead")).getBytes(); - } - - if( soup.containsKey("zakZmk") ){ - this.zakZmk = ((PacketSection) soup.get("zakZmk")).getBytes(); - } - - if( soup.containsKey("keyCheck") ){ - this.keyCheck = ((PacketSection) soup.get("keyCheck")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("464E")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("464E"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOGC.java b/src/main/java/racal/sunyard/main/dto/DTOGC.java deleted file mode 100644 index ab6df8d..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOGC.java +++ /dev/null @@ -1,1016 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOGC { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] zmk = null; - private byte[] zpk = null; - private byte[] businessKey = null; - private byte[] separator = null; - private byte[] zmkSolution = null; - private byte[] lmkSolution = null; - private byte[] keyCheckType = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getZmkAsBin( ) { - - return this.zmk; - } - - - public String getZmkAsStr( ) { - - if( null == this.zmk) return null; - return Arrays.toString(this.zmk); - } - - - public String getZmkAsHex( ) { - - if( null == this.zmk) return null; - return Util.bytes2HexString(zmk); - } - - - public Data setZmk( byte[] bytes ) { - - this.zmk = bytes; - return this; - } - - - public byte[] getZpkAsBin( ) { - - return this.zpk; - } - - - public String getZpkAsStr( ) { - - if( null == this.zpk) return null; - return Arrays.toString(this.zpk); - } - - - public String getZpkAsHex( ) { - - if( null == this.zpk) return null; - return Util.bytes2HexString(zpk); - } - - - public Data setZpk( byte[] bytes ) { - - this.zpk = bytes; - return this; - } - - - public byte[] getBusinessKeyAsBin( ) { - - return this.businessKey; - } - - - public String getBusinessKeyAsStr( ) { - - if( null == this.businessKey) return null; - return Arrays.toString(this.businessKey); - } - - - public String getBusinessKeyAsHex( ) { - - if( null == this.businessKey) return null; - return Util.bytes2HexString(businessKey); - } - - - public Data setBusinessKey( byte[] bytes ) { - - this.businessKey = bytes; - return this; - } - - - public byte[] getSeparatorAsBin( ) { - - return this.separator; - } - - - public String getSeparatorAsStr( ) { - - if( null == this.separator) return null; - return Arrays.toString(this.separator); - } - - - public String getSeparatorAsHex( ) { - - if( null == this.separator) return null; - return Util.bytes2HexString(separator); - } - - - public Data setSeparator( byte[] bytes ) { - - this.separator = bytes; - return this; - } - - - public byte[] getZmkSolutionAsBin( ) { - - return this.zmkSolution; - } - - - public String getZmkSolutionAsStr( ) { - - if( null == this.zmkSolution) return null; - return Arrays.toString(this.zmkSolution); - } - - - public String getZmkSolutionAsHex( ) { - - if( null == this.zmkSolution) return null; - return Util.bytes2HexString(zmkSolution); - } - - - public Data setZmkSolution( byte[] bytes ) { - - this.zmkSolution = bytes; - return this; - } - - - public byte[] getLmkSolutionAsBin( ) { - - return this.lmkSolution; - } - - - public String getLmkSolutionAsStr( ) { - - if( null == this.lmkSolution) return null; - return Arrays.toString(this.lmkSolution); - } - - - public String getLmkSolutionAsHex( ) { - - if( null == this.lmkSolution) return null; - return Util.bytes2HexString(lmkSolution); - } - - - public Data setLmkSolution( byte[] bytes ) { - - this.lmkSolution = bytes; - return this; - } - - - public byte[] getKeyCheckTypeAsBin( ) { - - return this.keyCheckType; - } - - - public String getKeyCheckTypeAsStr( ) { - - if( null == this.keyCheckType) return null; - return Arrays.toString(this.keyCheckType); - } - - - public String getKeyCheckTypeAsHex( ) { - - if( null == this.keyCheckType) return null; - return Util.bytes2HexString(keyCheckType); - } - - - public Data setKeyCheckType( byte[] bytes ) { - - this.keyCheckType = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != zmk ){ - soup.put("zmk", this.zmk); - } - - if( null != zpk ){ - soup.put("zpk", this.zpk); - } - - if( null != businessKey ){ - soup.put("businessKey", this.businessKey); - } - - if( null != separator ){ - soup.put("separator", this.separator); - } - - if( null != zmkSolution ){ - soup.put("zmkSolution", this.zmkSolution); - } - - if( null != lmkSolution ){ - soup.put("lmkSolution", this.lmkSolution); - } - - if( null != keyCheckType ){ - soup.put("keyCheckType", this.keyCheckType); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("zmk") ){ - this.zmk = ((PacketSection) soup.get("zmk")).getBytes(); - } - - if( soup.containsKey("zpk") ){ - this.zpk = ((PacketSection) soup.get("zpk")).getBytes(); - } - - if( soup.containsKey("businessKey") ){ - this.businessKey = ((PacketSection) soup.get("businessKey")).getBytes(); - } - - if( soup.containsKey("separator") ){ - this.separator = ((PacketSection) soup.get("separator")).getBytes(); - } - - if( soup.containsKey("zmkSolution") ){ - this.zmkSolution = ((PacketSection) soup.get("zmkSolution")).getBytes(); - } - - if( soup.containsKey("lmkSolution") ){ - this.lmkSolution = ((PacketSection) soup.get("lmkSolution")).getBytes(); - } - - if( soup.containsKey("keyCheckType") ){ - this.keyCheckType = ((PacketSection) soup.get("keyCheckType")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4743")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4743"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] zpkHead = null; - private byte[] zpk = null; - private byte[] keyCheck = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV密钥奇偶校验错仅仅是报告错误并不影响结果(Util.hexString2Bytes("3031")), - OPVZMK奇偶校验错(Util.hexString2Bytes("3130")), - OPV全0的ZPK为偶校验终止运行(Util.hexString2Bytes("3131")), - OPV用户存储区中没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV无效用户存储区索引(Util.hexString2Bytes("3231")), - OPV无效的密钥方案(Util.hexString2Bytes("3236")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3031".equals(Util.bytes2HexString(this.error))) { - return "密钥奇偶校验错,仅仅是报告错误,并不影响结果"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "ZMK 奇偶校验错"; - } - if( "3131".equals(Util.bytes2HexString(this.error))) { - return "全 0 的 ZPK 为偶校验(终止运行)"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区中没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效用户存储区索引"; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return "无效的密钥方案"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3031".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3131".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 9; - } - return null; - } - - - public byte[] getZpkHeadAsBin( ) { - - return this.zpkHead; - } - - - public String getZpkHeadAsStr( ) { - - if( null == this.zpkHead) return null; - return Arrays.toString(this.zpkHead); - } - - - public String getZpkHeadAsHex( ) { - - if( null == this.zpkHead) return null; - return Util.bytes2HexString(zpkHead); - } - - - public Data setZpkHead( byte[] bytes ) { - - this.zpkHead = bytes; - return this; - } - - - public byte[] getZpkAsBin( ) { - - return this.zpk; - } - - - public String getZpkAsStr( ) { - - if( null == this.zpk) return null; - return Arrays.toString(this.zpk); - } - - - public String getZpkAsHex( ) { - - if( null == this.zpk) return null; - return Util.bytes2HexString(zpk); - } - - - public Data setZpk( byte[] bytes ) { - - this.zpk = bytes; - return this; - } - - - public byte[] getKeyCheckAsBin( ) { - - return this.keyCheck; - } - - - public String getKeyCheckAsStr( ) { - - if( null == this.keyCheck) return null; - return Arrays.toString(this.keyCheck); - } - - - public String getKeyCheckAsHex( ) { - - if( null == this.keyCheck) return null; - return Util.bytes2HexString(keyCheck); - } - - - public Data setKeyCheck( byte[] bytes ) { - - this.keyCheck = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != zpkHead ){ - soup.put("zpkHead", this.zpkHead); - } - - if( null != zpk ){ - soup.put("zpk", this.zpk); - } - - if( null != keyCheck ){ - soup.put("keyCheck", this.keyCheck); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("zpkHead") ){ - this.zpkHead = ((PacketSection) soup.get("zpkHead")).getBytes(); - } - - if( soup.containsKey("zpk") ){ - this.zpk = ((PacketSection) soup.get("zpk")).getBytes(); - } - - if( soup.containsKey("keyCheck") ){ - this.keyCheck = ((PacketSection) soup.get("keyCheck")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4744")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4744"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOGY.java b/src/main/java/racal/sunyard/main/dto/DTOGY.java deleted file mode 100644 index 228b926..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOGY.java +++ /dev/null @@ -1,1023 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOGY { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] num = null; - private byte[] keys = null; - private byte[] flag = null; - private byte[] split = null; - private byte[] zmk = null; - private byte[] lmk = null; - private byte[] kcvType = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getNumAsBin( ) { - - return this.num; - } - - - public String getNumAsStr( ) { - - if( null == this.num) return null; - return Arrays.toString(this.num); - } - - - public String getNumAsHex( ) { - - if( null == this.num) return null; - return Util.bytes2HexString(num); - } - - - public Data setNum( byte[] bytes ) { - - this.num = bytes; - return this; - } - - - public byte[] getKeysAsBin( ) { - - return this.keys; - } - - - public String getKeysAsStr( ) { - - if( null == this.keys) return null; - return Arrays.toString(this.keys); - } - - - public String getKeysAsHex( ) { - - if( null == this.keys) return null; - return Util.bytes2HexString(keys); - } - - - public Data setKeys( byte[] bytes ) { - - this.keys = bytes; - return this; - } - - - public byte[] getFlagAsBin( ) { - - return this.flag; - } - - - public String getFlagAsStr( ) { - - if( null == this.flag) return null; - return Arrays.toString(this.flag); - } - - - public String getFlagAsHex( ) { - - if( null == this.flag) return null; - return Util.bytes2HexString(flag); - } - - - public Data setFlag( byte[] bytes ) { - - this.flag = bytes; - return this; - } - - - public byte[] getSplitAsBin( ) { - - return this.split; - } - - - public String getSplitAsStr( ) { - - if( null == this.split) return null; - return Arrays.toString(this.split); - } - - - public String getSplitAsHex( ) { - - if( null == this.split) return null; - return Util.bytes2HexString(split); - } - - - public Data setSplit( byte[] bytes ) { - - this.split = bytes; - return this; - } - - - public byte[] getZmkAsBin( ) { - - return this.zmk; - } - - - public String getZmkAsStr( ) { - - if( null == this.zmk) return null; - return Arrays.toString(this.zmk); - } - - - public String getZmkAsHex( ) { - - if( null == this.zmk) return null; - return Util.bytes2HexString(zmk); - } - - - public Data setZmk( byte[] bytes ) { - - this.zmk = bytes; - return this; - } - - - public byte[] getLmkAsBin( ) { - - return this.lmk; - } - - - public String getLmkAsStr( ) { - - if( null == this.lmk) return null; - return Arrays.toString(this.lmk); - } - - - public String getLmkAsHex( ) { - - if( null == this.lmk) return null; - return Util.bytes2HexString(lmk); - } - - - public Data setLmk( byte[] bytes ) { - - this.lmk = bytes; - return this; - } - - - public byte[] getKcvTypeAsBin( ) { - - return this.kcvType; - } - - - public String getKcvTypeAsStr( ) { - - if( null == this.kcvType) return null; - return Arrays.toString(this.kcvType); - } - - - public String getKcvTypeAsHex( ) { - - if( null == this.kcvType) return null; - return Util.bytes2HexString(kcvType); - } - - - public Data setKcvType( byte[] bytes ) { - - this.kcvType = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != num ){ - soup.put("num", this.num); - } - - if( null != keys ){ - soup.put("keys", this.keys); - } - - if( null != flag ){ - soup.put("flag", this.flag); - } - - if( null != split ){ - soup.put("split", this.split); - } - - if( null != zmk ){ - soup.put("zmk", this.zmk); - } - - if( null != lmk ){ - soup.put("lmk", this.lmk); - } - - if( null != kcvType ){ - soup.put("kcvType", this.kcvType); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("num") ){ - this.num = ((PacketSection) soup.get("num")).getBytes(); - } - - if( soup.containsKey("keys") ){ - this.keys = ((PacketSection) soup.get("keys")).getBytes(); - } - - if( soup.containsKey("flag") ){ - this.flag = ((PacketSection) soup.get("flag")).getBytes(); - } - - if( soup.containsKey("split") ){ - this.split = ((PacketSection) soup.get("split")).getBytes(); - } - - if( soup.containsKey("zmk") ){ - this.zmk = ((PacketSection) soup.get("zmk")).getBytes(); - } - - if( soup.containsKey("lmk") ){ - this.lmk = ((PacketSection) soup.get("lmk")).getBytes(); - } - - if( soup.containsKey("kcvType") ){ - this.kcvType = ((PacketSection) soup.get("kcvType")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4759")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4759"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] keyHead = null; - private byte[] key = null; - private byte[] kcv = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV密钥奇偶校验错(Util.hexString2Bytes("3031")), - OPVZMK奇偶校验错(Util.hexString2Bytes("3130")), - OPV用户存储区中没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV不在授权状态(Util.hexString2Bytes("3137")), - OPV无效用户存储区索引(Util.hexString2Bytes("3231")), - OPV无效的密钥类型(Util.hexString2Bytes("3238")), - OPV无效的密钥方案(Util.hexString2Bytes("3236")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3031".equals(Util.bytes2HexString(this.error))) { - return "密钥奇偶校验错"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "ZMK 奇偶校验错"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区中没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3137".equals(Util.bytes2HexString(this.error))) { - return "不在授权状态"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效用户存储区索引"; - } - if( "3238".equals(Util.bytes2HexString(this.error))) { - return "无效的密钥类型"; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return "无效的密钥方案"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3031".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3137".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3238".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return 9; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 10; - } - return null; - } - - - public byte[] getKeyHeadAsBin( ) { - - return this.keyHead; - } - - - public String getKeyHeadAsStr( ) { - - if( null == this.keyHead) return null; - return Arrays.toString(this.keyHead); - } - - - public String getKeyHeadAsHex( ) { - - if( null == this.keyHead) return null; - return Util.bytes2HexString(keyHead); - } - - - public Data setKeyHead( byte[] bytes ) { - - this.keyHead = bytes; - return this; - } - - - public byte[] getKeyAsBin( ) { - - return this.key; - } - - - public String getKeyAsStr( ) { - - if( null == this.key) return null; - return Arrays.toString(this.key); - } - - - public String getKeyAsHex( ) { - - if( null == this.key) return null; - return Util.bytes2HexString(key); - } - - - public Data setKey( byte[] bytes ) { - - this.key = bytes; - return this; - } - - - public byte[] getKcvAsBin( ) { - - return this.kcv; - } - - - public String getKcvAsStr( ) { - - if( null == this.kcv) return null; - return Arrays.toString(this.kcv); - } - - - public String getKcvAsHex( ) { - - if( null == this.kcv) return null; - return Util.bytes2HexString(kcv); - } - - - public Data setKcv( byte[] bytes ) { - - this.kcv = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != keyHead ){ - soup.put("keyHead", this.keyHead); - } - - if( null != key ){ - soup.put("key", this.key); - } - - if( null != kcv ){ - soup.put("kcv", this.kcv); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("keyHead") ){ - this.keyHead = ((PacketSection) soup.get("keyHead")).getBytes(); - } - - if( soup.containsKey("key") ){ - this.key = ((PacketSection) soup.get("key")).getBytes(); - } - - if( soup.containsKey("kcv") ){ - this.kcv = ((PacketSection) soup.get("kcv")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("475A")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("475A"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOHA.java b/src/main/java/racal/sunyard/main/dto/DTOHA.java deleted file mode 100644 index 6150096..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOHA.java +++ /dev/null @@ -1,1040 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOHA { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] tmk = null; - private byte[] businessKey = null; - private byte[] separator = null; - private byte[] tmkSolution = null; - private byte[] lmkSolution = null; - private byte[] keyCheckType = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getTmkAsBin( ) { - - return this.tmk; - } - - - public String getTmkAsStr( ) { - - if( null == this.tmk) return null; - return Arrays.toString(this.tmk); - } - - - public String getTmkAsHex( ) { - - if( null == this.tmk) return null; - return Util.bytes2HexString(tmk); - } - - - public Data setTmk( byte[] bytes ) { - - this.tmk = bytes; - return this; - } - - - public byte[] getBusinessKeyAsBin( ) { - - return this.businessKey; - } - - - public String getBusinessKeyAsStr( ) { - - if( null == this.businessKey) return null; - return Arrays.toString(this.businessKey); - } - - - public String getBusinessKeyAsHex( ) { - - if( null == this.businessKey) return null; - return Util.bytes2HexString(businessKey); - } - - - public Data setBusinessKey( byte[] bytes ) { - - this.businessKey = bytes; - return this; - } - - - public byte[] getSeparatorAsBin( ) { - - return this.separator; - } - - - public String getSeparatorAsStr( ) { - - if( null == this.separator) return null; - return Arrays.toString(this.separator); - } - - - public String getSeparatorAsHex( ) { - - if( null == this.separator) return null; - return Util.bytes2HexString(separator); - } - - - public Data setSeparator( byte[] bytes ) { - - this.separator = bytes; - return this; - } - - - public byte[] getTmkSolutionAsBin( ) { - - return this.tmkSolution; - } - - - public String getTmkSolutionAsStr( ) { - - if( null == this.tmkSolution) return null; - return Arrays.toString(this.tmkSolution); - } - - - public String getTmkSolutionAsHex( ) { - - if( null == this.tmkSolution) return null; - return Util.bytes2HexString(tmkSolution); - } - - - public Data setTmkSolution( byte[] bytes ) { - - this.tmkSolution = bytes; - return this; - } - - - public byte[] getLmkSolutionAsBin( ) { - - return this.lmkSolution; - } - - - public String getLmkSolutionAsStr( ) { - - if( null == this.lmkSolution) return null; - return Arrays.toString(this.lmkSolution); - } - - - public String getLmkSolutionAsHex( ) { - - if( null == this.lmkSolution) return null; - return Util.bytes2HexString(lmkSolution); - } - - - public Data setLmkSolution( byte[] bytes ) { - - this.lmkSolution = bytes; - return this; - } - - - public byte[] getKeyCheckTypeAsBin( ) { - - return this.keyCheckType; - } - - - public String getKeyCheckTypeAsStr( ) { - - if( null == this.keyCheckType) return null; - return Arrays.toString(this.keyCheckType); - } - - - public String getKeyCheckTypeAsHex( ) { - - if( null == this.keyCheckType) return null; - return Util.bytes2HexString(keyCheckType); - } - - - public Data setKeyCheckType( byte[] bytes ) { - - this.keyCheckType = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != tmk ){ - soup.put("tmk", this.tmk); - } - - soup.put("businessKey", Util.hexString2Bytes("4E")); - if( null != businessKey ){ - soup.put("businessKey", this.businessKey); - } - - if( null != separator ){ - soup.put("separator", this.separator); - } - - if( null != tmkSolution ){ - soup.put("tmkSolution", this.tmkSolution); - } - - if( null != lmkSolution ){ - soup.put("lmkSolution", this.lmkSolution); - } - - if( null != keyCheckType ){ - soup.put("keyCheckType", this.keyCheckType); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("tmk") ){ - this.tmk = ((PacketSection) soup.get("tmk")).getBytes(); - } - - this.businessKey = Util.hexString2Bytes("4E"); - if( soup.containsKey("businessKey") ){ - this.businessKey = ((PacketSection) soup.get("businessKey")).getBytes(); - } - - if( soup.containsKey("separator") ){ - this.separator = ((PacketSection) soup.get("separator")).getBytes(); - } - - if( soup.containsKey("tmkSolution") ){ - this.tmkSolution = ((PacketSection) soup.get("tmkSolution")).getBytes(); - } - - if( soup.containsKey("lmkSolution") ){ - this.lmkSolution = ((PacketSection) soup.get("lmkSolution")).getBytes(); - } - - if( soup.containsKey("keyCheckType") ){ - this.keyCheckType = ((PacketSection) soup.get("keyCheckType")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4841")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4841"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] takTmkHead = null; - private byte[] takTmk = null; - private byte[] takLmkHead = null; - private byte[] takLmk = null; - private byte[] keyCheck = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV第一个成份奇偶校验错(Util.hexString2Bytes("3130")), - OPV用户存储区中没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV无效用户存储区索引(Util.hexString2Bytes("3231")), - OPV无效的密钥方案(Util.hexString2Bytes("3236")), - OPV数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "第一个成份奇偶校验错"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区中没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效用户存储区索引"; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return "无效的密钥方案"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 7; - } - return null; - } - - - public byte[] getTakTmkHeadAsBin( ) { - - return this.takTmkHead; - } - - - public String getTakTmkHeadAsStr( ) { - - if( null == this.takTmkHead) return null; - return Arrays.toString(this.takTmkHead); - } - - - public String getTakTmkHeadAsHex( ) { - - if( null == this.takTmkHead) return null; - return Util.bytes2HexString(takTmkHead); - } - - - public Data setTakTmkHead( byte[] bytes ) { - - this.takTmkHead = bytes; - return this; - } - - - public byte[] getTakTmkAsBin( ) { - - return this.takTmk; - } - - - public String getTakTmkAsStr( ) { - - if( null == this.takTmk) return null; - return Arrays.toString(this.takTmk); - } - - - public String getTakTmkAsHex( ) { - - if( null == this.takTmk) return null; - return Util.bytes2HexString(takTmk); - } - - - public Data setTakTmk( byte[] bytes ) { - - this.takTmk = bytes; - return this; - } - - - public byte[] getTakLmkHeadAsBin( ) { - - return this.takLmkHead; - } - - - public String getTakLmkHeadAsStr( ) { - - if( null == this.takLmkHead) return null; - return Arrays.toString(this.takLmkHead); - } - - - public String getTakLmkHeadAsHex( ) { - - if( null == this.takLmkHead) return null; - return Util.bytes2HexString(takLmkHead); - } - - - public Data setTakLmkHead( byte[] bytes ) { - - this.takLmkHead = bytes; - return this; - } - - - public byte[] getTakLmkAsBin( ) { - - return this.takLmk; - } - - - public String getTakLmkAsStr( ) { - - if( null == this.takLmk) return null; - return Arrays.toString(this.takLmk); - } - - - public String getTakLmkAsHex( ) { - - if( null == this.takLmk) return null; - return Util.bytes2HexString(takLmk); - } - - - public Data setTakLmk( byte[] bytes ) { - - this.takLmk = bytes; - return this; - } - - - public byte[] getKeyCheckAsBin( ) { - - return this.keyCheck; - } - - - public String getKeyCheckAsStr( ) { - - if( null == this.keyCheck) return null; - return Arrays.toString(this.keyCheck); - } - - - public String getKeyCheckAsHex( ) { - - if( null == this.keyCheck) return null; - return Util.bytes2HexString(keyCheck); - } - - - public Data setKeyCheck( byte[] bytes ) { - - this.keyCheck = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != takTmkHead ){ - soup.put("takTmkHead", this.takTmkHead); - } - - if( null != takTmk ){ - soup.put("takTmk", this.takTmk); - } - - if( null != takLmkHead ){ - soup.put("takLmkHead", this.takLmkHead); - } - - if( null != takLmk ){ - soup.put("takLmk", this.takLmk); - } - - if( null != keyCheck ){ - soup.put("keyCheck", this.keyCheck); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("takTmkHead") ){ - this.takTmkHead = ((PacketSection) soup.get("takTmkHead")).getBytes(); - } - - if( soup.containsKey("takTmk") ){ - this.takTmk = ((PacketSection) soup.get("takTmk")).getBytes(); - } - - if( soup.containsKey("takLmkHead") ){ - this.takLmkHead = ((PacketSection) soup.get("takLmkHead")).getBytes(); - } - - if( soup.containsKey("takLmk") ){ - this.takLmk = ((PacketSection) soup.get("takLmk")).getBytes(); - } - - if( soup.containsKey("keyCheck") ){ - this.keyCheck = ((PacketSection) soup.get("keyCheck")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4842")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4842"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOHC.java b/src/main/java/racal/sunyard/main/dto/DTOHC.java deleted file mode 100644 index 31c13c0..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOHC.java +++ /dev/null @@ -1,1038 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOHC { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] tmk = null; - private byte[] businessKey = null; - private byte[] separator = null; - private byte[] tmkSolution = null; - private byte[] lmkSolution = null; - private byte[] keyCheckType = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getTmkAsBin( ) { - - return this.tmk; - } - - - public String getTmkAsStr( ) { - - if( null == this.tmk) return null; - return Arrays.toString(this.tmk); - } - - - public String getTmkAsHex( ) { - - if( null == this.tmk) return null; - return Util.bytes2HexString(tmk); - } - - - public Data setTmk( byte[] bytes ) { - - this.tmk = bytes; - return this; - } - - - public byte[] getBusinessKeyAsBin( ) { - - return this.businessKey; - } - - - public String getBusinessKeyAsStr( ) { - - if( null == this.businessKey) return null; - return Arrays.toString(this.businessKey); - } - - - public String getBusinessKeyAsHex( ) { - - if( null == this.businessKey) return null; - return Util.bytes2HexString(businessKey); - } - - - public Data setBusinessKey( byte[] bytes ) { - - this.businessKey = bytes; - return this; - } - - - public byte[] getSeparatorAsBin( ) { - - return this.separator; - } - - - public String getSeparatorAsStr( ) { - - if( null == this.separator) return null; - return Arrays.toString(this.separator); - } - - - public String getSeparatorAsHex( ) { - - if( null == this.separator) return null; - return Util.bytes2HexString(separator); - } - - - public Data setSeparator( byte[] bytes ) { - - this.separator = bytes; - return this; - } - - - public byte[] getTmkSolutionAsBin( ) { - - return this.tmkSolution; - } - - - public String getTmkSolutionAsStr( ) { - - if( null == this.tmkSolution) return null; - return Arrays.toString(this.tmkSolution); - } - - - public String getTmkSolutionAsHex( ) { - - if( null == this.tmkSolution) return null; - return Util.bytes2HexString(tmkSolution); - } - - - public Data setTmkSolution( byte[] bytes ) { - - this.tmkSolution = bytes; - return this; - } - - - public byte[] getLmkSolutionAsBin( ) { - - return this.lmkSolution; - } - - - public String getLmkSolutionAsStr( ) { - - if( null == this.lmkSolution) return null; - return Arrays.toString(this.lmkSolution); - } - - - public String getLmkSolutionAsHex( ) { - - if( null == this.lmkSolution) return null; - return Util.bytes2HexString(lmkSolution); - } - - - public Data setLmkSolution( byte[] bytes ) { - - this.lmkSolution = bytes; - return this; - } - - - public byte[] getKeyCheckTypeAsBin( ) { - - return this.keyCheckType; - } - - - public String getKeyCheckTypeAsStr( ) { - - if( null == this.keyCheckType) return null; - return Arrays.toString(this.keyCheckType); - } - - - public String getKeyCheckTypeAsHex( ) { - - if( null == this.keyCheckType) return null; - return Util.bytes2HexString(keyCheckType); - } - - - public Data setKeyCheckType( byte[] bytes ) { - - this.keyCheckType = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != tmk ){ - soup.put("tmk", this.tmk); - } - - if( null != businessKey ){ - soup.put("businessKey", this.businessKey); - } - - if( null != separator ){ - soup.put("separator", this.separator); - } - - if( null != tmkSolution ){ - soup.put("tmkSolution", this.tmkSolution); - } - - if( null != lmkSolution ){ - soup.put("lmkSolution", this.lmkSolution); - } - - if( null != keyCheckType ){ - soup.put("keyCheckType", this.keyCheckType); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("tmk") ){ - this.tmk = ((PacketSection) soup.get("tmk")).getBytes(); - } - - if( soup.containsKey("businessKey") ){ - this.businessKey = ((PacketSection) soup.get("businessKey")).getBytes(); - } - - if( soup.containsKey("separator") ){ - this.separator = ((PacketSection) soup.get("separator")).getBytes(); - } - - if( soup.containsKey("tmkSolution") ){ - this.tmkSolution = ((PacketSection) soup.get("tmkSolution")).getBytes(); - } - - if( soup.containsKey("lmkSolution") ){ - this.lmkSolution = ((PacketSection) soup.get("lmkSolution")).getBytes(); - } - - if( soup.containsKey("keyCheckType") ){ - this.keyCheckType = ((PacketSection) soup.get("keyCheckType")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4843")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4843"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] tmkHead = null; - private byte[] tmkKey = null; - private byte[] lmkHead = null; - private byte[] lmkKey = null; - private byte[] keyCheck = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV第一个成份奇偶校验错(Util.hexString2Bytes("3130")), - OPV用户存储区中没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV无效用户存储区索引(Util.hexString2Bytes("3231")), - OPV无效的密钥方案(Util.hexString2Bytes("3236")), - OPV数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "第一个成份奇偶校验错"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区中没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效用户存储区索引"; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return "无效的密钥方案"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 7; - } - return null; - } - - - public byte[] getTmkHeadAsBin( ) { - - return this.tmkHead; - } - - - public String getTmkHeadAsStr( ) { - - if( null == this.tmkHead) return null; - return Arrays.toString(this.tmkHead); - } - - - public String getTmkHeadAsHex( ) { - - if( null == this.tmkHead) return null; - return Util.bytes2HexString(tmkHead); - } - - - public Data setTmkHead( byte[] bytes ) { - - this.tmkHead = bytes; - return this; - } - - - public byte[] getTmkKeyAsBin( ) { - - return this.tmkKey; - } - - - public String getTmkKeyAsStr( ) { - - if( null == this.tmkKey) return null; - return Arrays.toString(this.tmkKey); - } - - - public String getTmkKeyAsHex( ) { - - if( null == this.tmkKey) return null; - return Util.bytes2HexString(tmkKey); - } - - - public Data setTmkKey( byte[] bytes ) { - - this.tmkKey = bytes; - return this; - } - - - public byte[] getLmkHeadAsBin( ) { - - return this.lmkHead; - } - - - public String getLmkHeadAsStr( ) { - - if( null == this.lmkHead) return null; - return Arrays.toString(this.lmkHead); - } - - - public String getLmkHeadAsHex( ) { - - if( null == this.lmkHead) return null; - return Util.bytes2HexString(lmkHead); - } - - - public Data setLmkHead( byte[] bytes ) { - - this.lmkHead = bytes; - return this; - } - - - public byte[] getLmkKeyAsBin( ) { - - return this.lmkKey; - } - - - public String getLmkKeyAsStr( ) { - - if( null == this.lmkKey) return null; - return Arrays.toString(this.lmkKey); - } - - - public String getLmkKeyAsHex( ) { - - if( null == this.lmkKey) return null; - return Util.bytes2HexString(lmkKey); - } - - - public Data setLmkKey( byte[] bytes ) { - - this.lmkKey = bytes; - return this; - } - - - public byte[] getKeyCheckAsBin( ) { - - return this.keyCheck; - } - - - public String getKeyCheckAsStr( ) { - - if( null == this.keyCheck) return null; - return Arrays.toString(this.keyCheck); - } - - - public String getKeyCheckAsHex( ) { - - if( null == this.keyCheck) return null; - return Util.bytes2HexString(keyCheck); - } - - - public Data setKeyCheck( byte[] bytes ) { - - this.keyCheck = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != tmkHead ){ - soup.put("tmkHead", this.tmkHead); - } - - if( null != tmkKey ){ - soup.put("tmkKey", this.tmkKey); - } - - if( null != lmkHead ){ - soup.put("lmkHead", this.lmkHead); - } - - if( null != lmkKey ){ - soup.put("lmkKey", this.lmkKey); - } - - if( null != keyCheck ){ - soup.put("keyCheck", this.keyCheck); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("tmkHead") ){ - this.tmkHead = ((PacketSection) soup.get("tmkHead")).getBytes(); - } - - if( soup.containsKey("tmkKey") ){ - this.tmkKey = ((PacketSection) soup.get("tmkKey")).getBytes(); - } - - if( soup.containsKey("lmkHead") ){ - this.lmkHead = ((PacketSection) soup.get("lmkHead")).getBytes(); - } - - if( soup.containsKey("lmkKey") ){ - this.lmkKey = ((PacketSection) soup.get("lmkKey")).getBytes(); - } - - if( soup.containsKey("keyCheck") ){ - this.keyCheck = ((PacketSection) soup.get("keyCheck")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4844")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4844"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOHI.java b/src/main/java/racal/sunyard/main/dto/DTOHI.java deleted file mode 100644 index e3d5849..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOHI.java +++ /dev/null @@ -1,708 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOHI { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4849")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4849"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] cpu = null; - private byte[] mem = null; - private byte[] disk = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV系统调用错误(Util.hexString2Bytes("3733")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3733".equals(Util.bytes2HexString(this.error))) { - return "系统调用错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3733".equals(Util.bytes2HexString(this.error))) { - return 1; - } - return null; - } - - - public byte[] getCpuAsBin( ) { - - return this.cpu; - } - - - public String getCpuAsStr( ) { - - if( null == this.cpu) return null; - return Arrays.toString(this.cpu); - } - - - public String getCpuAsHex( ) { - - if( null == this.cpu) return null; - return Util.bytes2HexString(cpu); - } - - - public Data setCpu( byte[] bytes ) { - - this.cpu = bytes; - return this; - } - - - public byte[] getMemAsBin( ) { - - return this.mem; - } - - - public String getMemAsStr( ) { - - if( null == this.mem) return null; - return Arrays.toString(this.mem); - } - - - public String getMemAsHex( ) { - - if( null == this.mem) return null; - return Util.bytes2HexString(mem); - } - - - public Data setMem( byte[] bytes ) { - - this.mem = bytes; - return this; - } - - - public byte[] getDiskAsBin( ) { - - return this.disk; - } - - - public String getDiskAsStr( ) { - - if( null == this.disk) return null; - return Arrays.toString(this.disk); - } - - - public String getDiskAsHex( ) { - - if( null == this.disk) return null; - return Util.bytes2HexString(disk); - } - - - public Data setDisk( byte[] bytes ) { - - this.disk = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != cpu ){ - soup.put("cpu", this.cpu); - } - - if( null != mem ){ - soup.put("mem", this.mem); - } - - if( null != disk ){ - soup.put("disk", this.disk); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("cpu") ){ - this.cpu = ((PacketSection) soup.get("cpu")).getBytes(); - } - - if( soup.containsKey("mem") ){ - this.mem = ((PacketSection) soup.get("mem")).getBytes(); - } - - if( soup.containsKey("disk") ){ - this.disk = ((PacketSection) soup.get("disk")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("484A")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("484A"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOHV.java b/src/main/java/racal/sunyard/main/dto/DTOHV.java deleted file mode 100644 index 83ac7a3..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOHV.java +++ /dev/null @@ -1,780 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOHV { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] num = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getNumAsBin( ) { - - return this.num; - } - - - public String getNumAsStr( ) { - - if( null == this.num) return null; - return Arrays.toString(this.num); - } - - - public String getNumAsHex( ) { - - if( null == this.num) return null; - return Util.bytes2HexString(num); - } - - - public Data setNum( byte[] bytes ) { - - this.num = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != num ){ - soup.put("num", this.num); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("num") ){ - this.num = ((PacketSection) soup.get("num")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4856")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4856"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] name = null; - private byte[] model = null; - private byte[] equipNo = null; - private byte[] softVersion = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV系统调用错误(Util.hexString2Bytes("3733")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3733".equals(Util.bytes2HexString(this.error))) { - return "系统调用错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3733".equals(Util.bytes2HexString(this.error))) { - return 1; - } - return null; - } - - - public byte[] getNameAsBin( ) { - - return this.name; - } - - - public String getNameAsStr( ) { - - if( null == this.name) return null; - return Arrays.toString(this.name); - } - - - public String getNameAsHex( ) { - - if( null == this.name) return null; - return Util.bytes2HexString(name); - } - - - public Data setName( byte[] bytes ) { - - this.name = bytes; - return this; - } - - - public byte[] getModelAsBin( ) { - - return this.model; - } - - - public String getModelAsStr( ) { - - if( null == this.model) return null; - return Arrays.toString(this.model); - } - - - public String getModelAsHex( ) { - - if( null == this.model) return null; - return Util.bytes2HexString(model); - } - - - public Data setModel( byte[] bytes ) { - - this.model = bytes; - return this; - } - - - public byte[] getEquipNoAsBin( ) { - - return this.equipNo; - } - - - public String getEquipNoAsStr( ) { - - if( null == this.equipNo) return null; - return Arrays.toString(this.equipNo); - } - - - public String getEquipNoAsHex( ) { - - if( null == this.equipNo) return null; - return Util.bytes2HexString(equipNo); - } - - - public Data setEquipNo( byte[] bytes ) { - - this.equipNo = bytes; - return this; - } - - - public byte[] getSoftVersionAsBin( ) { - - return this.softVersion; - } - - - public String getSoftVersionAsStr( ) { - - if( null == this.softVersion) return null; - return Arrays.toString(this.softVersion); - } - - - public String getSoftVersionAsHex( ) { - - if( null == this.softVersion) return null; - return Util.bytes2HexString(softVersion); - } - - - public Data setSoftVersion( byte[] bytes ) { - - this.softVersion = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != name ){ - soup.put("name", this.name); - } - - if( null != model ){ - soup.put("model", this.model); - } - - if( null != equipNo ){ - soup.put("equipNo", this.equipNo); - } - - if( null != softVersion ){ - soup.put("softVersion", this.softVersion); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("name") ){ - this.name = ((PacketSection) soup.get("name")).getBytes(); - } - - if( soup.containsKey("model") ){ - this.model = ((PacketSection) soup.get("model")).getBytes(); - } - - if( soup.containsKey("equipNo") ){ - this.equipNo = ((PacketSection) soup.get("equipNo")).getBytes(); - } - - if( soup.containsKey("softVersion") ){ - this.softVersion = ((PacketSection) soup.get("softVersion")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4857")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4857"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOIA.java b/src/main/java/racal/sunyard/main/dto/DTOIA.java deleted file mode 100644 index a4c2656..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOIA.java +++ /dev/null @@ -1,1031 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOIA { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] zmk = null; - private byte[] businessKey = null; - private byte[] separator = null; - private byte[] zmkSolution = null; - private byte[] lmkSolution = null; - private byte[] keyCheckType = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getZmkAsBin( ) { - - return this.zmk; - } - - - public String getZmkAsStr( ) { - - if( null == this.zmk) return null; - return Arrays.toString(this.zmk); - } - - - public String getZmkAsHex( ) { - - if( null == this.zmk) return null; - return Util.bytes2HexString(zmk); - } - - - public Data setZmk( byte[] bytes ) { - - this.zmk = bytes; - return this; - } - - - public byte[] getBusinessKeyAsBin( ) { - - return this.businessKey; - } - - - public String getBusinessKeyAsStr( ) { - - if( null == this.businessKey) return null; - return Arrays.toString(this.businessKey); - } - - - public String getBusinessKeyAsHex( ) { - - if( null == this.businessKey) return null; - return Util.bytes2HexString(businessKey); - } - - - public Data setBusinessKey( byte[] bytes ) { - - this.businessKey = bytes; - return this; - } - - - public byte[] getSeparatorAsBin( ) { - - return this.separator; - } - - - public String getSeparatorAsStr( ) { - - if( null == this.separator) return null; - return Arrays.toString(this.separator); - } - - - public String getSeparatorAsHex( ) { - - if( null == this.separator) return null; - return Util.bytes2HexString(separator); - } - - - public Data setSeparator( byte[] bytes ) { - - this.separator = bytes; - return this; - } - - - public byte[] getZmkSolutionAsBin( ) { - - return this.zmkSolution; - } - - - public String getZmkSolutionAsStr( ) { - - if( null == this.zmkSolution) return null; - return Arrays.toString(this.zmkSolution); - } - - - public String getZmkSolutionAsHex( ) { - - if( null == this.zmkSolution) return null; - return Util.bytes2HexString(zmkSolution); - } - - - public Data setZmkSolution( byte[] bytes ) { - - this.zmkSolution = bytes; - return this; - } - - - public byte[] getLmkSolutionAsBin( ) { - - return this.lmkSolution; - } - - - public String getLmkSolutionAsStr( ) { - - if( null == this.lmkSolution) return null; - return Arrays.toString(this.lmkSolution); - } - - - public String getLmkSolutionAsHex( ) { - - if( null == this.lmkSolution) return null; - return Util.bytes2HexString(lmkSolution); - } - - - public Data setLmkSolution( byte[] bytes ) { - - this.lmkSolution = bytes; - return this; - } - - - public byte[] getKeyCheckTypeAsBin( ) { - - return this.keyCheckType; - } - - - public String getKeyCheckTypeAsStr( ) { - - if( null == this.keyCheckType) return null; - return Arrays.toString(this.keyCheckType); - } - - - public String getKeyCheckTypeAsHex( ) { - - if( null == this.keyCheckType) return null; - return Util.bytes2HexString(keyCheckType); - } - - - public Data setKeyCheckType( byte[] bytes ) { - - this.keyCheckType = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != zmk ){ - soup.put("zmk", this.zmk); - } - - if( null != businessKey ){ - soup.put("businessKey", this.businessKey); - } - - if( null != separator ){ - soup.put("separator", this.separator); - } - - if( null != zmkSolution ){ - soup.put("zmkSolution", this.zmkSolution); - } - - if( null != lmkSolution ){ - soup.put("lmkSolution", this.lmkSolution); - } - - if( null != keyCheckType ){ - soup.put("keyCheckType", this.keyCheckType); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("zmk") ){ - this.zmk = ((PacketSection) soup.get("zmk")).getBytes(); - } - - if( soup.containsKey("businessKey") ){ - this.businessKey = ((PacketSection) soup.get("businessKey")).getBytes(); - } - - if( soup.containsKey("separator") ){ - this.separator = ((PacketSection) soup.get("separator")).getBytes(); - } - - if( soup.containsKey("zmkSolution") ){ - this.zmkSolution = ((PacketSection) soup.get("zmkSolution")).getBytes(); - } - - if( soup.containsKey("lmkSolution") ){ - this.lmkSolution = ((PacketSection) soup.get("lmkSolution")).getBytes(); - } - - if( soup.containsKey("keyCheckType") ){ - this.keyCheckType = ((PacketSection) soup.get("keyCheckType")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4941")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4941"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] zpkZmkHead = null; - private byte[] zpkZmk = null; - private byte[] zpkLmkHead = null; - private byte[] zpkLmk = null; - private byte[] keyCheck = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPVZMK奇偶校验错(Util.hexString2Bytes("3130")), - OPV用户存储区中没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV无效用户存储区索引(Util.hexString2Bytes("3231")), - OPV数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "ZMK 奇偶校验错"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区中没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效用户存储区索引"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 6; - } - return null; - } - - - public byte[] getZpkZmkHeadAsBin( ) { - - return this.zpkZmkHead; - } - - - public String getZpkZmkHeadAsStr( ) { - - if( null == this.zpkZmkHead) return null; - return Arrays.toString(this.zpkZmkHead); - } - - - public String getZpkZmkHeadAsHex( ) { - - if( null == this.zpkZmkHead) return null; - return Util.bytes2HexString(zpkZmkHead); - } - - - public Data setZpkZmkHead( byte[] bytes ) { - - this.zpkZmkHead = bytes; - return this; - } - - - public byte[] getZpkZmkAsBin( ) { - - return this.zpkZmk; - } - - - public String getZpkZmkAsStr( ) { - - if( null == this.zpkZmk) return null; - return Arrays.toString(this.zpkZmk); - } - - - public String getZpkZmkAsHex( ) { - - if( null == this.zpkZmk) return null; - return Util.bytes2HexString(zpkZmk); - } - - - public Data setZpkZmk( byte[] bytes ) { - - this.zpkZmk = bytes; - return this; - } - - - public byte[] getZpkLmkHeadAsBin( ) { - - return this.zpkLmkHead; - } - - - public String getZpkLmkHeadAsStr( ) { - - if( null == this.zpkLmkHead) return null; - return Arrays.toString(this.zpkLmkHead); - } - - - public String getZpkLmkHeadAsHex( ) { - - if( null == this.zpkLmkHead) return null; - return Util.bytes2HexString(zpkLmkHead); - } - - - public Data setZpkLmkHead( byte[] bytes ) { - - this.zpkLmkHead = bytes; - return this; - } - - - public byte[] getZpkLmkAsBin( ) { - - return this.zpkLmk; - } - - - public String getZpkLmkAsStr( ) { - - if( null == this.zpkLmk) return null; - return Arrays.toString(this.zpkLmk); - } - - - public String getZpkLmkAsHex( ) { - - if( null == this.zpkLmk) return null; - return Util.bytes2HexString(zpkLmk); - } - - - public Data setZpkLmk( byte[] bytes ) { - - this.zpkLmk = bytes; - return this; - } - - - public byte[] getKeyCheckAsBin( ) { - - return this.keyCheck; - } - - - public String getKeyCheckAsStr( ) { - - if( null == this.keyCheck) return null; - return Arrays.toString(this.keyCheck); - } - - - public String getKeyCheckAsHex( ) { - - if( null == this.keyCheck) return null; - return Util.bytes2HexString(keyCheck); - } - - - public Data setKeyCheck( byte[] bytes ) { - - this.keyCheck = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != zpkZmkHead ){ - soup.put("zpkZmkHead", this.zpkZmkHead); - } - - if( null != zpkZmk ){ - soup.put("zpkZmk", this.zpkZmk); - } - - if( null != zpkLmkHead ){ - soup.put("zpkLmkHead", this.zpkLmkHead); - } - - if( null != zpkLmk ){ - soup.put("zpkLmk", this.zpkLmk); - } - - if( null != keyCheck ){ - soup.put("keyCheck", this.keyCheck); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("zpkZmkHead") ){ - this.zpkZmkHead = ((PacketSection) soup.get("zpkZmkHead")).getBytes(); - } - - if( soup.containsKey("zpkZmk") ){ - this.zpkZmk = ((PacketSection) soup.get("zpkZmk")).getBytes(); - } - - if( soup.containsKey("zpkLmkHead") ){ - this.zpkLmkHead = ((PacketSection) soup.get("zpkLmkHead")).getBytes(); - } - - if( soup.containsKey("zpkLmk") ){ - this.zpkLmk = ((PacketSection) soup.get("zpkLmk")).getBytes(); - } - - if( soup.containsKey("keyCheck") ){ - this.keyCheck = ((PacketSection) soup.get("keyCheck")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4942")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4942"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOJA.java b/src/main/java/racal/sunyard/main/dto/DTOJA.java deleted file mode 100644 index 221c066..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOJA.java +++ /dev/null @@ -1,839 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOJA { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] account = null; - private byte[] pinLen = null; - private byte[] algorithmKey = null; - private byte[] encryptionAlg = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getAccountAsBin( ) { - - return this.account; - } - - - public String getAccountAsStr( ) { - - if( null == this.account) return null; - return Arrays.toString(this.account); - } - - - public String getAccountAsHex( ) { - - if( null == this.account) return null; - return Util.bytes2HexString(account); - } - - - public Data setAccount( byte[] bytes ) { - - this.account = bytes; - return this; - } - - - public byte[] getPinLenAsBin( ) { - - return this.pinLen; - } - - - public String getPinLenAsStr( ) { - - if( null == this.pinLen) return null; - return Arrays.toString(this.pinLen); - } - - - public String getPinLenAsHex( ) { - - if( null == this.pinLen) return null; - return Util.bytes2HexString(pinLen); - } - - - public Data setPinLen( byte[] bytes ) { - - this.pinLen = bytes; - return this; - } - - - public byte[] getAlgorithmKeyAsBin( ) { - - return this.algorithmKey; - } - - - public String getAlgorithmKeyAsStr( ) { - - if( null == this.algorithmKey) return null; - return Arrays.toString(this.algorithmKey); - } - - - public String getAlgorithmKeyAsHex( ) { - - if( null == this.algorithmKey) return null; - return Util.bytes2HexString(algorithmKey); - } - - - public Data setAlgorithmKey( byte[] bytes ) { - - this.algorithmKey = bytes; - return this; - } - - - public byte[] getEncryptionAlgAsBin( ) { - - return this.encryptionAlg; - } - - - public String getEncryptionAlgAsStr( ) { - - if( null == this.encryptionAlg) return null; - return Arrays.toString(this.encryptionAlg); - } - - - public String getEncryptionAlgAsHex( ) { - - if( null == this.encryptionAlg) return null; - return Util.bytes2HexString(encryptionAlg); - } - - - public Data setEncryptionAlg( byte[] bytes ) { - - this.encryptionAlg = bytes; - return this; - } -public enum EncryptionAlgOptions { - - OPV3DES默认(Util.hexString2Bytes("30")), - OPVSM4(Util.hexString2Bytes("31")); - private byte[] bin; - EncryptionAlgOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getEncryptionAlgCn( ) { - - if( null == encryptionAlg) { return null; } - if( "30".equals(Util.bytes2HexString(this.encryptionAlg))) { - return "3DES(默认)"; - } - if( "31".equals(Util.bytes2HexString(this.encryptionAlg))) { - return "SM4"; - } - return null; - } - - - public Integer getEncryptionAlgOptionIndex( ) { - - if( null == encryptionAlg) { return null; } - if( "30".equals(Util.bytes2HexString(this.encryptionAlg))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.encryptionAlg))) { - return 1; - } - return null; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != account ){ - soup.put("account", this.account); - } - - if( null != pinLen ){ - soup.put("pinLen", this.pinLen); - } - - if( null != algorithmKey ){ - soup.put("algorithmKey", this.algorithmKey); - } - - if( null != encryptionAlg ){ - soup.put("encryptionAlg", this.encryptionAlg); - soup.put("encryptionAlg$option", getEncryptionAlgOptionIndex()); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("account") ){ - this.account = ((PacketSection) soup.get("account")).getBytes(); - } - - if( soup.containsKey("pinLen") ){ - this.pinLen = ((PacketSection) soup.get("pinLen")).getBytes(); - } - - if( soup.containsKey("algorithmKey") ){ - this.algorithmKey = ((PacketSection) soup.get("algorithmKey")).getBytes(); - } - - if( soup.containsKey("encryptionAlg") ){ - this.encryptionAlg = ((PacketSection) soup.get("encryptionAlg")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4A41")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4A41"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] pinBlock = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV用户存储区没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVPIN长度等于或大于被加密的PIN长度(Util.hexString2Bytes("3234")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3234".equals(Util.bytes2HexString(this.error))) { - return "PIN 长度等于或大于被加密的 PIN 长度。"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3234".equals(Util.bytes2HexString(this.error))) { - return 4; - } - return null; - } - - - public byte[] getPinBlockAsBin( ) { - - return this.pinBlock; - } - - - public String getPinBlockAsStr( ) { - - if( null == this.pinBlock) return null; - return Arrays.toString(this.pinBlock); - } - - - public String getPinBlockAsHex( ) { - - if( null == this.pinBlock) return null; - return Util.bytes2HexString(pinBlock); - } - - - public Data setPinBlock( byte[] bytes ) { - - this.pinBlock = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != pinBlock ){ - soup.put("pinBlock", this.pinBlock); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("pinBlock") ){ - this.pinBlock = ((PacketSection) soup.get("pinBlock")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4A42")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4A42"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOJC.java b/src/main/java/racal/sunyard/main/dto/DTOJC.java deleted file mode 100644 index fd99afe..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOJC.java +++ /dev/null @@ -1,1070 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOJC { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] zpk = null; - private byte[] algorithmKey = null; - private byte[] sca = null; - private byte[] dca = null; - private byte[] businessKey = null; - private byte[] pinBlock = null; - private byte[] pinBlockFormat = null; - private byte[] account = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getZpkAsBin( ) { - - return this.zpk; - } - - - public String getZpkAsStr( ) { - - if( null == this.zpk) return null; - return Arrays.toString(this.zpk); - } - - - public String getZpkAsHex( ) { - - if( null == this.zpk) return null; - return Util.bytes2HexString(zpk); - } - - - public Data setZpk( byte[] bytes ) { - - this.zpk = bytes; - return this; - } - - - public byte[] getAlgorithmKeyAsBin( ) { - - return this.algorithmKey; - } - - - public String getAlgorithmKeyAsStr( ) { - - if( null == this.algorithmKey) return null; - return Arrays.toString(this.algorithmKey); - } - - - public String getAlgorithmKeyAsHex( ) { - - if( null == this.algorithmKey) return null; - return Util.bytes2HexString(algorithmKey); - } - - - public Data setAlgorithmKey( byte[] bytes ) { - - this.algorithmKey = bytes; - return this; - } - - - public byte[] getScaAsBin( ) { - - return this.sca; - } - - - public String getScaAsStr( ) { - - if( null == this.sca) return null; - return Arrays.toString(this.sca); - } - - - public String getScaAsHex( ) { - - if( null == this.sca) return null; - return Util.bytes2HexString(sca); - } - - - public Data setSca( byte[] bytes ) { - - this.sca = bytes; - return this; - } -public enum ScaOptions { - - OPV3DES(Util.hexString2Bytes("31")), - OPVSM4(Util.hexString2Bytes("32")); - private byte[] bin; - ScaOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getScaCn( ) { - - if( null == sca) { return null; } - if( "31".equals(Util.bytes2HexString(this.sca))) { - return "3DES"; - } - if( "32".equals(Util.bytes2HexString(this.sca))) { - return "SM4"; - } - return null; - } - - - public Integer getScaOptionIndex( ) { - - if( null == sca) { return null; } - if( "31".equals(Util.bytes2HexString(this.sca))) { - return 0; - } - if( "32".equals(Util.bytes2HexString(this.sca))) { - return 1; - } - return null; - } - - - public byte[] getDcaAsBin( ) { - - return this.dca; - } - - - public String getDcaAsStr( ) { - - if( null == this.dca) return null; - return Arrays.toString(this.dca); - } - - - public String getDcaAsHex( ) { - - if( null == this.dca) return null; - return Util.bytes2HexString(dca); - } - - - public Data setDca( byte[] bytes ) { - - this.dca = bytes; - return this; - } -public enum DcaOptions { - - OPV3DES(Util.hexString2Bytes("31")), - OPVSM4(Util.hexString2Bytes("32")); - private byte[] bin; - DcaOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getDcaCn( ) { - - if( null == dca) { return null; } - if( "31".equals(Util.bytes2HexString(this.dca))) { - return "3DES"; - } - if( "32".equals(Util.bytes2HexString(this.dca))) { - return "SM4"; - } - return null; - } - - - public Integer getDcaOptionIndex( ) { - - if( null == dca) { return null; } - if( "31".equals(Util.bytes2HexString(this.dca))) { - return 0; - } - if( "32".equals(Util.bytes2HexString(this.dca))) { - return 1; - } - return null; - } - - - public byte[] getBusinessKeyAsBin( ) { - - return this.businessKey; - } - - - public String getBusinessKeyAsStr( ) { - - if( null == this.businessKey) return null; - return Arrays.toString(this.businessKey); - } - - - public String getBusinessKeyAsHex( ) { - - if( null == this.businessKey) return null; - return Util.bytes2HexString(businessKey); - } - - - public Data setBusinessKey( byte[] bytes ) { - - this.businessKey = bytes; - return this; - } - - - public byte[] getPinBlockAsBin( ) { - - return this.pinBlock; - } - - - public String getPinBlockAsStr( ) { - - if( null == this.pinBlock) return null; - return Arrays.toString(this.pinBlock); - } - - - public String getPinBlockAsHex( ) { - - if( null == this.pinBlock) return null; - return Util.bytes2HexString(pinBlock); - } - - - public Data setPinBlock( byte[] bytes ) { - - this.pinBlock = bytes; - return this; - } - - - public byte[] getPinBlockFormatAsBin( ) { - - return this.pinBlockFormat; - } - - - public String getPinBlockFormatAsStr( ) { - - if( null == this.pinBlockFormat) return null; - return Arrays.toString(this.pinBlockFormat); - } - - - public String getPinBlockFormatAsHex( ) { - - if( null == this.pinBlockFormat) return null; - return Util.bytes2HexString(pinBlockFormat); - } - - - public Data setPinBlockFormat( byte[] bytes ) { - - this.pinBlockFormat = bytes; - return this; - } - - - public byte[] getAccountAsBin( ) { - - return this.account; - } - - - public String getAccountAsStr( ) { - - if( null == this.account) return null; - return Arrays.toString(this.account); - } - - - public String getAccountAsHex( ) { - - if( null == this.account) return null; - return Util.bytes2HexString(account); - } - - - public Data setAccount( byte[] bytes ) { - - this.account = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != zpk ){ - soup.put("zpk", this.zpk); - } - - if( null != algorithmKey ){ - soup.put("algorithmKey", this.algorithmKey); - } - - if( null != sca ){ - soup.put("sca", this.sca); - soup.put("sca$option", getScaOptionIndex()); - } - - if( null != dca ){ - soup.put("dca", this.dca); - soup.put("dca$option", getDcaOptionIndex()); - } - - if( null != businessKey ){ - soup.put("businessKey", this.businessKey); - } - - if( null != pinBlock ){ - soup.put("PinBlock", this.pinBlock); - } - - if( null != pinBlockFormat ){ - soup.put("pinBlockFormat", this.pinBlockFormat); - } - - if( null != account ){ - soup.put("account", this.account); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("zpk") ){ - this.zpk = ((PacketSection) soup.get("zpk")).getBytes(); - } - - if( soup.containsKey("algorithmKey") ){ - this.algorithmKey = ((PacketSection) soup.get("algorithmKey")).getBytes(); - } - - if( soup.containsKey("sca") ){ - this.sca = ((PacketSection) soup.get("sca")).getBytes(); - } - - if( soup.containsKey("dca") ){ - this.dca = ((PacketSection) soup.get("dca")).getBytes(); - } - - if( soup.containsKey("businessKey") ){ - this.businessKey = ((PacketSection) soup.get("businessKey")).getBytes(); - } - - if( soup.containsKey("PinBlock") ){ - this.pinBlock = ((PacketSection) soup.get("PinBlock")).getBytes(); - } - - if( soup.containsKey("pinBlockFormat") ){ - this.pinBlockFormat = ((PacketSection) soup.get("pinBlockFormat")).getBytes(); - } - - if( soup.containsKey("account") ){ - this.account = ((PacketSection) soup.get("account")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4A43")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4A43"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] pinBlock = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV源TPK奇偶校验错(Util.hexString2Bytes("3130")), - OPV用户存储区中没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVPIN块错误(Util.hexString2Bytes("3230")), - OPV无效的用户存储索引(Util.hexString2Bytes("3231")), - OPV帐号无效(Util.hexString2Bytes("3232")), - OPV无效PIN块格式代码(Util.hexString2Bytes("3233")), - OPVPIN小于4位或大于12位(Util.hexString2Bytes("3234")), - OPV无效的密钥方案(Util.hexString2Bytes("3236")), - OPV数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "源TPK奇偶校验错"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区中没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3230".equals(Util.bytes2HexString(this.error))) { - return "PIN块错误"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效的用户存储索引"; - } - if( "3232".equals(Util.bytes2HexString(this.error))) { - return "帐号无效"; - } - if( "3233".equals(Util.bytes2HexString(this.error))) { - return "无效 PIN 块格式代码"; - } - if( "3234".equals(Util.bytes2HexString(this.error))) { - return "PIN 小于 4 位或大于 12 位。"; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return "无效的密钥方案"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3230".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3232".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3233".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3234".equals(Util.bytes2HexString(this.error))) { - return 9; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return 10; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 11; - } - return null; - } - - - public byte[] getPinBlockAsBin( ) { - - return this.pinBlock; - } - - - public String getPinBlockAsStr( ) { - - if( null == this.pinBlock) return null; - return Arrays.toString(this.pinBlock); - } - - - public String getPinBlockAsHex( ) { - - if( null == this.pinBlock) return null; - return Util.bytes2HexString(pinBlock); - } - - - public Data setPinBlock( byte[] bytes ) { - - this.pinBlock = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != pinBlock ){ - soup.put("pinBlock", this.pinBlock); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("pinBlock") ){ - this.pinBlock = ((PacketSection) soup.get("pinBlock")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4A44")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4A44"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOJE.java b/src/main/java/racal/sunyard/main/dto/DTOJE.java deleted file mode 100644 index c6c5bc4..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOJE.java +++ /dev/null @@ -1,1070 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOJE { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] zpk = null; - private byte[] algorithmKey = null; - private byte[] sca = null; - private byte[] dca = null; - private byte[] businessKey = null; - private byte[] pinBlock = null; - private byte[] pinBlockFormat = null; - private byte[] account = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getZpkAsBin( ) { - - return this.zpk; - } - - - public String getZpkAsStr( ) { - - if( null == this.zpk) return null; - return Arrays.toString(this.zpk); - } - - - public String getZpkAsHex( ) { - - if( null == this.zpk) return null; - return Util.bytes2HexString(zpk); - } - - - public Data setZpk( byte[] bytes ) { - - this.zpk = bytes; - return this; - } - - - public byte[] getAlgorithmKeyAsBin( ) { - - return this.algorithmKey; - } - - - public String getAlgorithmKeyAsStr( ) { - - if( null == this.algorithmKey) return null; - return Arrays.toString(this.algorithmKey); - } - - - public String getAlgorithmKeyAsHex( ) { - - if( null == this.algorithmKey) return null; - return Util.bytes2HexString(algorithmKey); - } - - - public Data setAlgorithmKey( byte[] bytes ) { - - this.algorithmKey = bytes; - return this; - } - - - public byte[] getScaAsBin( ) { - - return this.sca; - } - - - public String getScaAsStr( ) { - - if( null == this.sca) return null; - return Arrays.toString(this.sca); - } - - - public String getScaAsHex( ) { - - if( null == this.sca) return null; - return Util.bytes2HexString(sca); - } - - - public Data setSca( byte[] bytes ) { - - this.sca = bytes; - return this; - } -public enum ScaOptions { - - OPV3DES(Util.hexString2Bytes("31")), - OPVSM4(Util.hexString2Bytes("32")); - private byte[] bin; - ScaOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getScaCn( ) { - - if( null == sca) { return null; } - if( "31".equals(Util.bytes2HexString(this.sca))) { - return "3DES"; - } - if( "32".equals(Util.bytes2HexString(this.sca))) { - return "SM4"; - } - return null; - } - - - public Integer getScaOptionIndex( ) { - - if( null == sca) { return null; } - if( "31".equals(Util.bytes2HexString(this.sca))) { - return 0; - } - if( "32".equals(Util.bytes2HexString(this.sca))) { - return 1; - } - return null; - } - - - public byte[] getDcaAsBin( ) { - - return this.dca; - } - - - public String getDcaAsStr( ) { - - if( null == this.dca) return null; - return Arrays.toString(this.dca); - } - - - public String getDcaAsHex( ) { - - if( null == this.dca) return null; - return Util.bytes2HexString(dca); - } - - - public Data setDca( byte[] bytes ) { - - this.dca = bytes; - return this; - } -public enum DcaOptions { - - OPV3DES(Util.hexString2Bytes("31")), - OPVSM4(Util.hexString2Bytes("32")); - private byte[] bin; - DcaOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getDcaCn( ) { - - if( null == dca) { return null; } - if( "31".equals(Util.bytes2HexString(this.dca))) { - return "3DES"; - } - if( "32".equals(Util.bytes2HexString(this.dca))) { - return "SM4"; - } - return null; - } - - - public Integer getDcaOptionIndex( ) { - - if( null == dca) { return null; } - if( "31".equals(Util.bytes2HexString(this.dca))) { - return 0; - } - if( "32".equals(Util.bytes2HexString(this.dca))) { - return 1; - } - return null; - } - - - public byte[] getBusinessKeyAsBin( ) { - - return this.businessKey; - } - - - public String getBusinessKeyAsStr( ) { - - if( null == this.businessKey) return null; - return Arrays.toString(this.businessKey); - } - - - public String getBusinessKeyAsHex( ) { - - if( null == this.businessKey) return null; - return Util.bytes2HexString(businessKey); - } - - - public Data setBusinessKey( byte[] bytes ) { - - this.businessKey = bytes; - return this; - } - - - public byte[] getPinBlockAsBin( ) { - - return this.pinBlock; - } - - - public String getPinBlockAsStr( ) { - - if( null == this.pinBlock) return null; - return Arrays.toString(this.pinBlock); - } - - - public String getPinBlockAsHex( ) { - - if( null == this.pinBlock) return null; - return Util.bytes2HexString(pinBlock); - } - - - public Data setPinBlock( byte[] bytes ) { - - this.pinBlock = bytes; - return this; - } - - - public byte[] getPinBlockFormatAsBin( ) { - - return this.pinBlockFormat; - } - - - public String getPinBlockFormatAsStr( ) { - - if( null == this.pinBlockFormat) return null; - return Arrays.toString(this.pinBlockFormat); - } - - - public String getPinBlockFormatAsHex( ) { - - if( null == this.pinBlockFormat) return null; - return Util.bytes2HexString(pinBlockFormat); - } - - - public Data setPinBlockFormat( byte[] bytes ) { - - this.pinBlockFormat = bytes; - return this; - } - - - public byte[] getAccountAsBin( ) { - - return this.account; - } - - - public String getAccountAsStr( ) { - - if( null == this.account) return null; - return Arrays.toString(this.account); - } - - - public String getAccountAsHex( ) { - - if( null == this.account) return null; - return Util.bytes2HexString(account); - } - - - public Data setAccount( byte[] bytes ) { - - this.account = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != zpk ){ - soup.put("zpk", this.zpk); - } - - if( null != algorithmKey ){ - soup.put("algorithmKey", this.algorithmKey); - } - - if( null != sca ){ - soup.put("sca", this.sca); - soup.put("sca$option", getScaOptionIndex()); - } - - if( null != dca ){ - soup.put("dca", this.dca); - soup.put("dca$option", getDcaOptionIndex()); - } - - if( null != businessKey ){ - soup.put("businessKey", this.businessKey); - } - - if( null != pinBlock ){ - soup.put("PinBlock", this.pinBlock); - } - - if( null != pinBlockFormat ){ - soup.put("pinBlockFormat", this.pinBlockFormat); - } - - if( null != account ){ - soup.put("account", this.account); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("zpk") ){ - this.zpk = ((PacketSection) soup.get("zpk")).getBytes(); - } - - if( soup.containsKey("algorithmKey") ){ - this.algorithmKey = ((PacketSection) soup.get("algorithmKey")).getBytes(); - } - - if( soup.containsKey("sca") ){ - this.sca = ((PacketSection) soup.get("sca")).getBytes(); - } - - if( soup.containsKey("dca") ){ - this.dca = ((PacketSection) soup.get("dca")).getBytes(); - } - - if( soup.containsKey("businessKey") ){ - this.businessKey = ((PacketSection) soup.get("businessKey")).getBytes(); - } - - if( soup.containsKey("PinBlock") ){ - this.pinBlock = ((PacketSection) soup.get("PinBlock")).getBytes(); - } - - if( soup.containsKey("pinBlockFormat") ){ - this.pinBlockFormat = ((PacketSection) soup.get("pinBlockFormat")).getBytes(); - } - - if( soup.containsKey("account") ){ - this.account = ((PacketSection) soup.get("account")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4A45")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4A45"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] pinBlock = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV源ZPK奇偶校验错(Util.hexString2Bytes("3130")), - OPV用户存储区中没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVPIN块错误(Util.hexString2Bytes("3230")), - OPV无效的用户存储索引(Util.hexString2Bytes("3231")), - OPV帐号无效(Util.hexString2Bytes("3232")), - OPV无效PIN块格式代码(Util.hexString2Bytes("3233")), - OPVPIN小于4位或大于12位(Util.hexString2Bytes("3234")), - OPV无效的密钥方案(Util.hexString2Bytes("3236")), - OPV数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "源 ZPK 奇偶校验错"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区中没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3230".equals(Util.bytes2HexString(this.error))) { - return "PIN块错误"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效的用户存储索引"; - } - if( "3232".equals(Util.bytes2HexString(this.error))) { - return "帐号无效"; - } - if( "3233".equals(Util.bytes2HexString(this.error))) { - return "无效 PIN 块格式代码"; - } - if( "3234".equals(Util.bytes2HexString(this.error))) { - return "PIN 小于 4 位或大于 12 位。"; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return "无效的密钥方案"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3230".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3232".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3233".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3234".equals(Util.bytes2HexString(this.error))) { - return 9; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return 10; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 11; - } - return null; - } - - - public byte[] getPinBlockAsBin( ) { - - return this.pinBlock; - } - - - public String getPinBlockAsStr( ) { - - if( null == this.pinBlock) return null; - return Arrays.toString(this.pinBlock); - } - - - public String getPinBlockAsHex( ) { - - if( null == this.pinBlock) return null; - return Util.bytes2HexString(pinBlock); - } - - - public Data setPinBlock( byte[] bytes ) { - - this.pinBlock = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != pinBlock ){ - soup.put("pinBlock", this.pinBlock); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("pinBlock") ){ - this.pinBlock = ((PacketSection) soup.get("pinBlock")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4A46")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4A46"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOJG.java b/src/main/java/racal/sunyard/main/dto/DTOJG.java deleted file mode 100644 index 7990c30..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOJG.java +++ /dev/null @@ -1,1070 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOJG { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] zpk = null; - private byte[] algorithmKey = null; - private byte[] sca = null; - private byte[] dca = null; - private byte[] businessKey = null; - private byte[] pinBlock = null; - private byte[] pinBlockFormat = null; - private byte[] account = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getZpkAsBin( ) { - - return this.zpk; - } - - - public String getZpkAsStr( ) { - - if( null == this.zpk) return null; - return Arrays.toString(this.zpk); - } - - - public String getZpkAsHex( ) { - - if( null == this.zpk) return null; - return Util.bytes2HexString(zpk); - } - - - public Data setZpk( byte[] bytes ) { - - this.zpk = bytes; - return this; - } - - - public byte[] getAlgorithmKeyAsBin( ) { - - return this.algorithmKey; - } - - - public String getAlgorithmKeyAsStr( ) { - - if( null == this.algorithmKey) return null; - return Arrays.toString(this.algorithmKey); - } - - - public String getAlgorithmKeyAsHex( ) { - - if( null == this.algorithmKey) return null; - return Util.bytes2HexString(algorithmKey); - } - - - public Data setAlgorithmKey( byte[] bytes ) { - - this.algorithmKey = bytes; - return this; - } - - - public byte[] getScaAsBin( ) { - - return this.sca; - } - - - public String getScaAsStr( ) { - - if( null == this.sca) return null; - return Arrays.toString(this.sca); - } - - - public String getScaAsHex( ) { - - if( null == this.sca) return null; - return Util.bytes2HexString(sca); - } - - - public Data setSca( byte[] bytes ) { - - this.sca = bytes; - return this; - } -public enum ScaOptions { - - OPV3DES(Util.hexString2Bytes("31")), - OPVSM4(Util.hexString2Bytes("32")); - private byte[] bin; - ScaOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getScaCn( ) { - - if( null == sca) { return null; } - if( "31".equals(Util.bytes2HexString(this.sca))) { - return "3DES"; - } - if( "32".equals(Util.bytes2HexString(this.sca))) { - return "SM4"; - } - return null; - } - - - public Integer getScaOptionIndex( ) { - - if( null == sca) { return null; } - if( "31".equals(Util.bytes2HexString(this.sca))) { - return 0; - } - if( "32".equals(Util.bytes2HexString(this.sca))) { - return 1; - } - return null; - } - - - public byte[] getDcaAsBin( ) { - - return this.dca; - } - - - public String getDcaAsStr( ) { - - if( null == this.dca) return null; - return Arrays.toString(this.dca); - } - - - public String getDcaAsHex( ) { - - if( null == this.dca) return null; - return Util.bytes2HexString(dca); - } - - - public Data setDca( byte[] bytes ) { - - this.dca = bytes; - return this; - } -public enum DcaOptions { - - OPV3DES(Util.hexString2Bytes("31")), - OPVSM4(Util.hexString2Bytes("32")); - private byte[] bin; - DcaOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getDcaCn( ) { - - if( null == dca) { return null; } - if( "31".equals(Util.bytes2HexString(this.dca))) { - return "3DES"; - } - if( "32".equals(Util.bytes2HexString(this.dca))) { - return "SM4"; - } - return null; - } - - - public Integer getDcaOptionIndex( ) { - - if( null == dca) { return null; } - if( "31".equals(Util.bytes2HexString(this.dca))) { - return 0; - } - if( "32".equals(Util.bytes2HexString(this.dca))) { - return 1; - } - return null; - } - - - public byte[] getBusinessKeyAsBin( ) { - - return this.businessKey; - } - - - public String getBusinessKeyAsStr( ) { - - if( null == this.businessKey) return null; - return Arrays.toString(this.businessKey); - } - - - public String getBusinessKeyAsHex( ) { - - if( null == this.businessKey) return null; - return Util.bytes2HexString(businessKey); - } - - - public Data setBusinessKey( byte[] bytes ) { - - this.businessKey = bytes; - return this; - } - - - public byte[] getPinBlockAsBin( ) { - - return this.pinBlock; - } - - - public String getPinBlockAsStr( ) { - - if( null == this.pinBlock) return null; - return Arrays.toString(this.pinBlock); - } - - - public String getPinBlockAsHex( ) { - - if( null == this.pinBlock) return null; - return Util.bytes2HexString(pinBlock); - } - - - public Data setPinBlock( byte[] bytes ) { - - this.pinBlock = bytes; - return this; - } - - - public byte[] getPinBlockFormatAsBin( ) { - - return this.pinBlockFormat; - } - - - public String getPinBlockFormatAsStr( ) { - - if( null == this.pinBlockFormat) return null; - return Arrays.toString(this.pinBlockFormat); - } - - - public String getPinBlockFormatAsHex( ) { - - if( null == this.pinBlockFormat) return null; - return Util.bytes2HexString(pinBlockFormat); - } - - - public Data setPinBlockFormat( byte[] bytes ) { - - this.pinBlockFormat = bytes; - return this; - } - - - public byte[] getAccountAsBin( ) { - - return this.account; - } - - - public String getAccountAsStr( ) { - - if( null == this.account) return null; - return Arrays.toString(this.account); - } - - - public String getAccountAsHex( ) { - - if( null == this.account) return null; - return Util.bytes2HexString(account); - } - - - public Data setAccount( byte[] bytes ) { - - this.account = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != zpk ){ - soup.put("zpk", this.zpk); - } - - if( null != algorithmKey ){ - soup.put("algorithmKey", this.algorithmKey); - } - - if( null != sca ){ - soup.put("sca", this.sca); - soup.put("sca$option", getScaOptionIndex()); - } - - if( null != dca ){ - soup.put("dca", this.dca); - soup.put("dca$option", getDcaOptionIndex()); - } - - if( null != businessKey ){ - soup.put("businessKey", this.businessKey); - } - - if( null != pinBlock ){ - soup.put("PinBlock", this.pinBlock); - } - - if( null != pinBlockFormat ){ - soup.put("pinBlockFormat", this.pinBlockFormat); - } - - if( null != account ){ - soup.put("account", this.account); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("zpk") ){ - this.zpk = ((PacketSection) soup.get("zpk")).getBytes(); - } - - if( soup.containsKey("algorithmKey") ){ - this.algorithmKey = ((PacketSection) soup.get("algorithmKey")).getBytes(); - } - - if( soup.containsKey("sca") ){ - this.sca = ((PacketSection) soup.get("sca")).getBytes(); - } - - if( soup.containsKey("dca") ){ - this.dca = ((PacketSection) soup.get("dca")).getBytes(); - } - - if( soup.containsKey("businessKey") ){ - this.businessKey = ((PacketSection) soup.get("businessKey")).getBytes(); - } - - if( soup.containsKey("PinBlock") ){ - this.pinBlock = ((PacketSection) soup.get("PinBlock")).getBytes(); - } - - if( soup.containsKey("pinBlockFormat") ){ - this.pinBlockFormat = ((PacketSection) soup.get("pinBlockFormat")).getBytes(); - } - - if( soup.containsKey("account") ){ - this.account = ((PacketSection) soup.get("account")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4A47")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4A47"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] pinBlock = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPVZPK奇偶校验错(Util.hexString2Bytes("3131")), - OPV用户存储区中没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV来自主机的PIN错误(Util.hexString2Bytes("3134")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVPIN块错误(Util.hexString2Bytes("3230")), - OPV无效的用户存储索引(Util.hexString2Bytes("3231")), - OPV无效PIN块格式代码(Util.hexString2Bytes("3233")), - OPVPIN小于4位或大于12位(Util.hexString2Bytes("3234")), - OPV无效的密钥方案(Util.hexString2Bytes("3236")), - OPV数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3131".equals(Util.bytes2HexString(this.error))) { - return "ZPK 奇偶校验错"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区中没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3134".equals(Util.bytes2HexString(this.error))) { - return "来自主机的PIN错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3230".equals(Util.bytes2HexString(this.error))) { - return "PIN块错误"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效的用户存储索引"; - } - if( "3233".equals(Util.bytes2HexString(this.error))) { - return "无效 PIN 块格式代码"; - } - if( "3234".equals(Util.bytes2HexString(this.error))) { - return "PIN 小于 4 位或大于 12 位。"; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return "无效的密钥方案"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3131".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3134".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3230".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3233".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3234".equals(Util.bytes2HexString(this.error))) { - return 9; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return 10; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 11; - } - return null; - } - - - public byte[] getPinBlockAsBin( ) { - - return this.pinBlock; - } - - - public String getPinBlockAsStr( ) { - - if( null == this.pinBlock) return null; - return Arrays.toString(this.pinBlock); - } - - - public String getPinBlockAsHex( ) { - - if( null == this.pinBlock) return null; - return Util.bytes2HexString(pinBlock); - } - - - public Data setPinBlock( byte[] bytes ) { - - this.pinBlock = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != pinBlock ){ - soup.put("pinBlock", this.pinBlock); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("pinBlock") ){ - this.pinBlock = ((PacketSection) soup.get("pinBlock")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4A48")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4A48"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOLB.java b/src/main/java/racal/sunyard/main/dto/DTOLB.java deleted file mode 100644 index 9c767bf..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOLB.java +++ /dev/null @@ -1,923 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOLB { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] indexFlag = null; - private byte[] index = null; - private byte[] key = null; - private byte[] checkFlag = null; - private byte[] checkValue = null; - private byte[] startTime = null; - private byte[] endTime = null; - private byte[] businessKey = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getIndexFlagAsBin( ) { - - return this.indexFlag; - } - - - public String getIndexFlagAsStr( ) { - - if( null == this.indexFlag) return null; - return Arrays.toString(this.indexFlag); - } - - - public String getIndexFlagAsHex( ) { - - if( null == this.indexFlag) return null; - return Util.bytes2HexString(indexFlag); - } - - - public Data setIndexFlag( byte[] bytes ) { - - this.indexFlag = bytes; - return this; - } - - - public byte[] getIndexAsBin( ) { - - return this.index; - } - - - public String getIndexAsStr( ) { - - if( null == this.index) return null; - return Arrays.toString(this.index); - } - - - public String getIndexAsHex( ) { - - if( null == this.index) return null; - return Util.bytes2HexString(index); - } - - - public Data setIndex( byte[] bytes ) { - - this.index = bytes; - return this; - } - - - public byte[] getKeyAsBin( ) { - - return this.key; - } - - - public String getKeyAsStr( ) { - - if( null == this.key) return null; - return Arrays.toString(this.key); - } - - - public String getKeyAsHex( ) { - - if( null == this.key) return null; - return Util.bytes2HexString(key); - } - - - public Data setKey( byte[] bytes ) { - - this.key = bytes; - return this; - } - - - public byte[] getCheckFlagAsBin( ) { - - return this.checkFlag; - } - - - public String getCheckFlagAsStr( ) { - - if( null == this.checkFlag) return null; - return Arrays.toString(this.checkFlag); - } - - - public String getCheckFlagAsHex( ) { - - if( null == this.checkFlag) return null; - return Util.bytes2HexString(checkFlag); - } - - - public Data setCheckFlag( byte[] bytes ) { - - this.checkFlag = bytes; - return this; - } - - - public byte[] getCheckValueAsBin( ) { - - return this.checkValue; - } - - - public String getCheckValueAsStr( ) { - - if( null == this.checkValue) return null; - return Arrays.toString(this.checkValue); - } - - - public String getCheckValueAsHex( ) { - - if( null == this.checkValue) return null; - return Util.bytes2HexString(checkValue); - } - - - public Data setCheckValue( byte[] bytes ) { - - this.checkValue = bytes; - return this; - } - - - public byte[] getStartTimeAsBin( ) { - - return this.startTime; - } - - - public String getStartTimeAsStr( ) { - - if( null == this.startTime) return null; - return Arrays.toString(this.startTime); - } - - - public String getStartTimeAsHex( ) { - - if( null == this.startTime) return null; - return Util.bytes2HexString(startTime); - } - - - public Data setStartTime( byte[] bytes ) { - - this.startTime = bytes; - return this; - } - - - public byte[] getEndTimeAsBin( ) { - - return this.endTime; - } - - - public String getEndTimeAsStr( ) { - - if( null == this.endTime) return null; - return Arrays.toString(this.endTime); - } - - - public String getEndTimeAsHex( ) { - - if( null == this.endTime) return null; - return Util.bytes2HexString(endTime); - } - - - public Data setEndTime( byte[] bytes ) { - - this.endTime = bytes; - return this; - } - - - public byte[] getBusinessKeyAsBin( ) { - - return this.businessKey; - } - - - public String getBusinessKeyAsStr( ) { - - if( null == this.businessKey) return null; - return Arrays.toString(this.businessKey); - } - - - public String getBusinessKeyAsHex( ) { - - if( null == this.businessKey) return null; - return Util.bytes2HexString(businessKey); - } - - - public Data setBusinessKey( byte[] bytes ) { - - this.businessKey = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != indexFlag ){ - soup.put("indexFlag", this.indexFlag); - } - - if( null != index ){ - soup.put("index", this.index); - } - - if( null != key ){ - soup.put("key", this.key); - } - - if( null != checkFlag ){ - soup.put("checkFlag", this.checkFlag); - } - - if( null != checkValue ){ - soup.put("checkValue", this.checkValue); - } - - if( null != startTime ){ - soup.put("startTime", this.startTime); - } - - if( null != endTime ){ - soup.put("endTime", this.endTime); - } - - if( null != businessKey ){ - soup.put("businessKey", this.businessKey); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("indexFlag") ){ - this.indexFlag = ((PacketSection) soup.get("indexFlag")).getBytes(); - } - - if( soup.containsKey("index") ){ - this.index = ((PacketSection) soup.get("index")).getBytes(); - } - - if( soup.containsKey("key") ){ - this.key = ((PacketSection) soup.get("key")).getBytes(); - } - - if( soup.containsKey("checkFlag") ){ - this.checkFlag = ((PacketSection) soup.get("checkFlag")).getBytes(); - } - - if( soup.containsKey("checkValue") ){ - this.checkValue = ((PacketSection) soup.get("checkValue")).getBytes(); - } - - if( soup.containsKey("startTime") ){ - this.startTime = ((PacketSection) soup.get("startTime")).getBytes(); - } - - if( soup.containsKey("endTime") ){ - this.endTime = ((PacketSection) soup.get("endTime")).getBytes(); - } - - if( soup.containsKey("businessKey") ){ - this.businessKey = ((PacketSection) soup.get("businessKey")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4C42")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4C42"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPVMAC校验不过(Util.hexString2Bytes("3031")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV无效的用户密钥存储索引(Util.hexString2Bytes("3231")), - OPV无效的索引值(Util.hexString2Bytes("3232")), - OPV无效的密钥方案(Util.hexString2Bytes("3236")), - OPV数据长度错(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3031".equals(Util.bytes2HexString(this.error))) { - return "MAC校验不过"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效的用户密钥存储索引"; - } - if( "3232".equals(Util.bytes2HexString(this.error))) { - return "无效的索引值"; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return "无效的密钥方案"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "数据长度错"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3031".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3232".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 6; - } - return null; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4C43")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4C43"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOLF.java b/src/main/java/racal/sunyard/main/dto/DTOLF.java deleted file mode 100644 index 442aed1..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOLF.java +++ /dev/null @@ -1,801 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOLF { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] indexFlag = null; - private byte[] index = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getIndexFlagAsBin( ) { - - return this.indexFlag; - } - - - public String getIndexFlagAsStr( ) { - - if( null == this.indexFlag) return null; - return Arrays.toString(this.indexFlag); - } - - - public String getIndexFlagAsHex( ) { - - if( null == this.indexFlag) return null; - return Util.bytes2HexString(indexFlag); - } - - - public Data setIndexFlag( byte[] bytes ) { - - this.indexFlag = bytes; - return this; - } - - - public byte[] getIndexAsBin( ) { - - return this.index; - } - - - public String getIndexAsStr( ) { - - if( null == this.index) return null; - return Arrays.toString(this.index); - } - - - public String getIndexAsHex( ) { - - if( null == this.index) return null; - return Util.bytes2HexString(index); - } - - - public Data setIndex( byte[] bytes ) { - - this.index = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != indexFlag ){ - soup.put("indexFlag", this.indexFlag); - } - - if( null != index ){ - soup.put("index", this.index); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("indexFlag") ){ - this.indexFlag = ((PacketSection) soup.get("indexFlag")).getBytes(); - } - - if( soup.containsKey("index") ){ - this.index = ((PacketSection) soup.get("index")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4C46")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4C46"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] keyHead = null; - private byte[] key = null; - private byte[] keyCheck = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV用户密钥存储区没有装载数据(Util.hexString2Bytes("3132")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV无效的用户密钥存储索引(Util.hexString2Bytes("3231")), - OPV无效的索引值(Util.hexString2Bytes("3232")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户密钥存储区没有装载数据"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效的用户密钥存储索引"; - } - if( "3232".equals(Util.bytes2HexString(this.error))) { - return "无效的索引值"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3232".equals(Util.bytes2HexString(this.error))) { - return 4; - } - return null; - } - - - public byte[] getKeyHeadAsBin( ) { - - return this.keyHead; - } - - - public String getKeyHeadAsStr( ) { - - if( null == this.keyHead) return null; - return Arrays.toString(this.keyHead); - } - - - public String getKeyHeadAsHex( ) { - - if( null == this.keyHead) return null; - return Util.bytes2HexString(keyHead); - } - - - public Data setKeyHead( byte[] bytes ) { - - this.keyHead = bytes; - return this; - } - - - public byte[] getKeyAsBin( ) { - - return this.key; - } - - - public String getKeyAsStr( ) { - - if( null == this.key) return null; - return Arrays.toString(this.key); - } - - - public String getKeyAsHex( ) { - - if( null == this.key) return null; - return Util.bytes2HexString(key); - } - - - public Data setKey( byte[] bytes ) { - - this.key = bytes; - return this; - } - - - public byte[] getKeyCheckAsBin( ) { - - return this.keyCheck; - } - - - public String getKeyCheckAsStr( ) { - - if( null == this.keyCheck) return null; - return Arrays.toString(this.keyCheck); - } - - - public String getKeyCheckAsHex( ) { - - if( null == this.keyCheck) return null; - return Util.bytes2HexString(keyCheck); - } - - - public Data setKeyCheck( byte[] bytes ) { - - this.keyCheck = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != keyHead ){ - soup.put("keyHead", this.keyHead); - } - - if( null != key ){ - soup.put("key", this.key); - } - - if( null != keyCheck ){ - soup.put("keyCheck", this.keyCheck); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("keyHead") ){ - this.keyHead = ((PacketSection) soup.get("keyHead")).getBytes(); - } - - if( soup.containsKey("key") ){ - this.key = ((PacketSection) soup.get("key")).getBytes(); - } - - if( soup.containsKey("keyCheck") ){ - this.keyCheck = ((PacketSection) soup.get("keyCheck")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4C47")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4C47"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOLG.java b/src/main/java/racal/sunyard/main/dto/DTOLG.java deleted file mode 100644 index b241e18..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOLG.java +++ /dev/null @@ -1,945 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOLG { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] indexFlag = null; - private byte[] index = null; - private byte[] key = null; - private byte[] checkFlag = null; - private byte[] checkValue = null; - private byte[] startTime = null; - private byte[] endTime = null; - private byte[] oldEndTime = null; - private byte[] businessKey = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getIndexFlagAsBin( ) { - - return this.indexFlag; - } - - - public String getIndexFlagAsStr( ) { - - if( null == this.indexFlag) return null; - return Arrays.toString(this.indexFlag); - } - - - public String getIndexFlagAsHex( ) { - - if( null == this.indexFlag) return null; - return Util.bytes2HexString(indexFlag); - } - - - public Data setIndexFlag( byte[] bytes ) { - - this.indexFlag = bytes; - return this; - } - - - public byte[] getIndexAsBin( ) { - - return this.index; - } - - - public String getIndexAsStr( ) { - - if( null == this.index) return null; - return Arrays.toString(this.index); - } - - - public String getIndexAsHex( ) { - - if( null == this.index) return null; - return Util.bytes2HexString(index); - } - - - public Data setIndex( byte[] bytes ) { - - this.index = bytes; - return this; - } - - - public byte[] getKeyAsBin( ) { - - return this.key; - } - - - public String getKeyAsStr( ) { - - if( null == this.key) return null; - return Arrays.toString(this.key); - } - - - public String getKeyAsHex( ) { - - if( null == this.key) return null; - return Util.bytes2HexString(key); - } - - - public Data setKey( byte[] bytes ) { - - this.key = bytes; - return this; - } - - - public byte[] getCheckFlagAsBin( ) { - - return this.checkFlag; - } - - - public String getCheckFlagAsStr( ) { - - if( null == this.checkFlag) return null; - return Arrays.toString(this.checkFlag); - } - - - public String getCheckFlagAsHex( ) { - - if( null == this.checkFlag) return null; - return Util.bytes2HexString(checkFlag); - } - - - public Data setCheckFlag( byte[] bytes ) { - - this.checkFlag = bytes; - return this; - } - - - public byte[] getCheckValueAsBin( ) { - - return this.checkValue; - } - - - public String getCheckValueAsStr( ) { - - if( null == this.checkValue) return null; - return Arrays.toString(this.checkValue); - } - - - public String getCheckValueAsHex( ) { - - if( null == this.checkValue) return null; - return Util.bytes2HexString(checkValue); - } - - - public Data setCheckValue( byte[] bytes ) { - - this.checkValue = bytes; - return this; - } - - - public byte[] getStartTimeAsBin( ) { - - return this.startTime; - } - - - public String getStartTimeAsStr( ) { - - if( null == this.startTime) return null; - return Arrays.toString(this.startTime); - } - - - public String getStartTimeAsHex( ) { - - if( null == this.startTime) return null; - return Util.bytes2HexString(startTime); - } - - - public Data setStartTime( byte[] bytes ) { - - this.startTime = bytes; - return this; - } - - - public byte[] getEndTimeAsBin( ) { - - return this.endTime; - } - - - public String getEndTimeAsStr( ) { - - if( null == this.endTime) return null; - return Arrays.toString(this.endTime); - } - - - public String getEndTimeAsHex( ) { - - if( null == this.endTime) return null; - return Util.bytes2HexString(endTime); - } - - - public Data setEndTime( byte[] bytes ) { - - this.endTime = bytes; - return this; - } - - - public byte[] getOldEndTimeAsBin( ) { - - return this.oldEndTime; - } - - - public String getOldEndTimeAsStr( ) { - - if( null == this.oldEndTime) return null; - return Arrays.toString(this.oldEndTime); - } - - - public String getOldEndTimeAsHex( ) { - - if( null == this.oldEndTime) return null; - return Util.bytes2HexString(oldEndTime); - } - - - public Data setOldEndTime( byte[] bytes ) { - - this.oldEndTime = bytes; - return this; - } - - - public byte[] getBusinessKeyAsBin( ) { - - return this.businessKey; - } - - - public String getBusinessKeyAsStr( ) { - - if( null == this.businessKey) return null; - return Arrays.toString(this.businessKey); - } - - - public String getBusinessKeyAsHex( ) { - - if( null == this.businessKey) return null; - return Util.bytes2HexString(businessKey); - } - - - public Data setBusinessKey( byte[] bytes ) { - - this.businessKey = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != indexFlag ){ - soup.put("indexFlag", this.indexFlag); - } - - if( null != index ){ - soup.put("index", this.index); - } - - if( null != key ){ - soup.put("key", this.key); - } - - if( null != checkFlag ){ - soup.put("checkFlag", this.checkFlag); - } - - if( null != checkValue ){ - soup.put("checkValue", this.checkValue); - } - - if( null != startTime ){ - soup.put("startTime", this.startTime); - } - - if( null != endTime ){ - soup.put("endTime", this.endTime); - } - - if( null != oldEndTime ){ - soup.put("oldEndTime", this.oldEndTime); - } - - if( null != businessKey ){ - soup.put("businessKey", this.businessKey); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("indexFlag") ){ - this.indexFlag = ((PacketSection) soup.get("indexFlag")).getBytes(); - } - - if( soup.containsKey("index") ){ - this.index = ((PacketSection) soup.get("index")).getBytes(); - } - - if( soup.containsKey("key") ){ - this.key = ((PacketSection) soup.get("key")).getBytes(); - } - - if( soup.containsKey("checkFlag") ){ - this.checkFlag = ((PacketSection) soup.get("checkFlag")).getBytes(); - } - - if( soup.containsKey("checkValue") ){ - this.checkValue = ((PacketSection) soup.get("checkValue")).getBytes(); - } - - if( soup.containsKey("startTime") ){ - this.startTime = ((PacketSection) soup.get("startTime")).getBytes(); - } - - if( soup.containsKey("endTime") ){ - this.endTime = ((PacketSection) soup.get("endTime")).getBytes(); - } - - if( soup.containsKey("oldEndTime") ){ - this.oldEndTime = ((PacketSection) soup.get("oldEndTime")).getBytes(); - } - - if( soup.containsKey("businessKey") ){ - this.businessKey = ((PacketSection) soup.get("businessKey")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4C47")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4C47"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV无效的用户密钥存储索引(Util.hexString2Bytes("3231")), - OPV无效的密钥方案(Util.hexString2Bytes("3236")), - OPV数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效的用户密钥存储索引"; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return "无效的密钥方案"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 4; - } - return null; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4C48")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4C48"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOMA.java b/src/main/java/racal/sunyard/main/dto/DTOMA.java deleted file mode 100644 index 95fdb1e..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOMA.java +++ /dev/null @@ -1,976 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOMA { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] businessKey = null; - private byte[] alg = null; - private byte[] keyType = null; - private byte[] fullMode = null; - private byte[] mACLen = null; - private byte[] key = null; - private byte[] mACData = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getBusinessKeyAsBin( ) { - - return this.businessKey; - } - - - public String getBusinessKeyAsStr( ) { - - if( null == this.businessKey) return null; - return Arrays.toString(this.businessKey); - } - - - public String getBusinessKeyAsHex( ) { - - if( null == this.businessKey) return null; - return Util.bytes2HexString(businessKey); - } - - - public Data setBusinessKey( byte[] bytes ) { - - this.businessKey = bytes; - return this; - } - - - public byte[] getAlgAsBin( ) { - - return this.alg; - } - - - public String getAlgAsStr( ) { - - if( null == this.alg) return null; - return Arrays.toString(this.alg); - } - - - public String getAlgAsHex( ) { - - if( null == this.alg) return null; - return Util.bytes2HexString(alg); - } - - - public Data setAlg( byte[] bytes ) { - - this.alg = bytes; - return this; - } -public enum AlgOptions { - - OPVDES(Util.hexString2Bytes("30")), - OPV3DES(Util.hexString2Bytes("31")), - OPVSM4(Util.hexString2Bytes("32")), - OPVAES(Util.hexString2Bytes("33")), - OPVIDEA(Util.hexString2Bytes("34")), - OPVSM1(Util.hexString2Bytes("35")), - OPV3DESX919(Util.hexString2Bytes("36")); - private byte[] bin; - AlgOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getAlgCn( ) { - - if( null == alg) { return null; } - if( "30".equals(Util.bytes2HexString(this.alg))) { - return "DES"; - } - if( "31".equals(Util.bytes2HexString(this.alg))) { - return "3DES"; - } - if( "32".equals(Util.bytes2HexString(this.alg))) { - return "SM4"; - } - if( "33".equals(Util.bytes2HexString(this.alg))) { - return "AES"; - } - if( "34".equals(Util.bytes2HexString(this.alg))) { - return "IDEA"; - } - if( "35".equals(Util.bytes2HexString(this.alg))) { - return "SM1"; - } - if( "36".equals(Util.bytes2HexString(this.alg))) { - return "3DESX919"; - } - return null; - } - - - public Integer getAlgOptionIndex( ) { - - if( null == alg) { return null; } - if( "30".equals(Util.bytes2HexString(this.alg))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.alg))) { - return 1; - } - if( "32".equals(Util.bytes2HexString(this.alg))) { - return 2; - } - if( "33".equals(Util.bytes2HexString(this.alg))) { - return 3; - } - if( "34".equals(Util.bytes2HexString(this.alg))) { - return 4; - } - if( "35".equals(Util.bytes2HexString(this.alg))) { - return 5; - } - if( "36".equals(Util.bytes2HexString(this.alg))) { - return 6; - } - return null; - } - - - public byte[] getKeyTypeAsBin( ) { - - return this.keyType; - } - - - public String getKeyTypeAsStr( ) { - - if( null == this.keyType) return null; - return Arrays.toString(this.keyType); - } - - - public String getKeyTypeAsHex( ) { - - if( null == this.keyType) return null; - return Util.bytes2HexString(keyType); - } - - - public Data setKeyType( byte[] bytes ) { - - this.keyType = bytes; - return this; - } -public enum KeyTypeOptions { - - OPVTAK(Util.hexString2Bytes("30")), - OPVZAK(Util.hexString2Bytes("31")); - private byte[] bin; - KeyTypeOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getKeyTypeCn( ) { - - if( null == keyType) { return null; } - if( "30".equals(Util.bytes2HexString(this.keyType))) { - return "TAK"; - } - if( "31".equals(Util.bytes2HexString(this.keyType))) { - return "ZAK"; - } - return null; - } - - - public Integer getKeyTypeOptionIndex( ) { - - if( null == keyType) { return null; } - if( "30".equals(Util.bytes2HexString(this.keyType))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.keyType))) { - return 1; - } - return null; - } - - - public byte[] getFullModeAsBin( ) { - - return this.fullMode; - } - - - public String getFullModeAsStr( ) { - - if( null == this.fullMode) return null; - return Arrays.toString(this.fullMode); - } - - - public String getFullModeAsHex( ) { - - if( null == this.fullMode) return null; - return Util.bytes2HexString(fullMode); - } - - - public Data setFullMode( byte[] bytes ) { - - this.fullMode = bytes; - return this; - } -public enum FullModeOptions { - - OPV弱填充(Util.hexString2Bytes("30")), - OPV强填充(Util.hexString2Bytes("31")); - private byte[] bin; - FullModeOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getFullModeCn( ) { - - if( null == fullMode) { return null; } - if( "30".equals(Util.bytes2HexString(this.fullMode))) { - return "弱填充"; - } - if( "31".equals(Util.bytes2HexString(this.fullMode))) { - return "强填充"; - } - return null; - } - - - public Integer getFullModeOptionIndex( ) { - - if( null == fullMode) { return null; } - if( "30".equals(Util.bytes2HexString(this.fullMode))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.fullMode))) { - return 1; - } - return null; - } - - - public byte[] getMACLenAsBin( ) { - - return this.mACLen; - } - - - public String getMACLenAsStr( ) { - - if( null == this.mACLen) return null; - return Arrays.toString(this.mACLen); - } - - - public String getMACLenAsHex( ) { - - if( null == this.mACLen) return null; - return Util.bytes2HexString(mACLen); - } - - - public Data setMACLen( byte[] bytes ) { - - this.mACLen = bytes; - return this; - } -public enum MACLenOptions { - - OPV4(Util.hexString2Bytes("31")), - OPV8(Util.hexString2Bytes("32")), - OPV16(Util.hexString2Bytes("33")); - private byte[] bin; - MACLenOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getMACLenCn( ) { - - if( null == mACLen) { return null; } - if( "31".equals(Util.bytes2HexString(this.mACLen))) { - return "4"; - } - if( "32".equals(Util.bytes2HexString(this.mACLen))) { - return "8"; - } - if( "33".equals(Util.bytes2HexString(this.mACLen))) { - return "16"; - } - return null; - } - - - public Integer getMACLenOptionIndex( ) { - - if( null == mACLen) { return null; } - if( "31".equals(Util.bytes2HexString(this.mACLen))) { - return 0; - } - if( "32".equals(Util.bytes2HexString(this.mACLen))) { - return 1; - } - if( "33".equals(Util.bytes2HexString(this.mACLen))) { - return 2; - } - return null; - } - - - public byte[] getKeyAsBin( ) { - - return this.key; - } - - - public String getKeyAsStr( ) { - - if( null == this.key) return null; - return Arrays.toString(this.key); - } - - - public String getKeyAsHex( ) { - - if( null == this.key) return null; - return Util.bytes2HexString(key); - } - - - public Data setKey( byte[] bytes ) { - - this.key = bytes; - return this; - } - - - public byte[] getMACDataAsBin( ) { - - return this.mACData; - } - - - public String getMACDataAsStr( ) { - - if( null == this.mACData) return null; - return Arrays.toString(this.mACData); - } - - - public String getMACDataAsHex( ) { - - if( null == this.mACData) return null; - return Util.bytes2HexString(mACData); - } - - - public Data setMACData( byte[] bytes ) { - - this.mACData = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != businessKey ){ - soup.put("businessKey", this.businessKey); - } - - if( null != alg ){ - soup.put("alg", this.alg); - soup.put("alg$option", getAlgOptionIndex()); - } - - if( null != keyType ){ - soup.put("keyType", this.keyType); - soup.put("keyType$option", getKeyTypeOptionIndex()); - } - - if( null != fullMode ){ - soup.put("fullMode", this.fullMode); - soup.put("fullMode$option", getFullModeOptionIndex()); - } - - if( null != mACLen ){ - soup.put("MACLen", this.mACLen); - soup.put("MACLen$option", getMACLenOptionIndex()); - } - - if( null != key ){ - soup.put("key", this.key); - } - - if( null != mACData ){ - soup.put("MACData", this.mACData); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("businessKey") ){ - this.businessKey = ((PacketSection) soup.get("businessKey")).getBytes(); - } - - if( soup.containsKey("alg") ){ - this.alg = ((PacketSection) soup.get("alg")).getBytes(); - } - - if( soup.containsKey("keyType") ){ - this.keyType = ((PacketSection) soup.get("keyType")).getBytes(); - } - - if( soup.containsKey("fullMode") ){ - this.fullMode = ((PacketSection) soup.get("fullMode")).getBytes(); - } - - if( soup.containsKey("MACLen") ){ - this.mACLen = ((PacketSection) soup.get("MACLen")).getBytes(); - } - - if( soup.containsKey("key") ){ - this.key = ((PacketSection) soup.get("key")).getBytes(); - } - - if( soup.containsKey("MACData") ){ - this.mACData = ((PacketSection) soup.get("MACData")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4D41")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4D41"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] mAC = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPVTAK奇偶校验错(Util.hexString2Bytes("3130")), - OPV用户存储区没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误报告给管理员(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV无效的用户存储索引(Util.hexString2Bytes("3231")), - OPV密钥方案错误(Util.hexString2Bytes("3236")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "TAK奇偶校验错"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK错误;报告给管理员"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效的用户存储索引"; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return "密钥方案错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 7; - } - return null; - } - - - public byte[] getMACAsBin( ) { - - return this.mAC; - } - - - public String getMACAsStr( ) { - - if( null == this.mAC) return null; - return Arrays.toString(this.mAC); - } - - - public String getMACAsHex( ) { - - if( null == this.mAC) return null; - return Util.bytes2HexString(mAC); - } - - - public Data setMAC( byte[] bytes ) { - - this.mAC = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != mAC ){ - soup.put("MAC", this.mAC); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("MAC") ){ - this.mAC = ((PacketSection) soup.get("MAC")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4D42")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4D42"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOMAXF.java b/src/main/java/racal/sunyard/main/dto/DTOMAXF.java deleted file mode 100644 index e2c82aa..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOMAXF.java +++ /dev/null @@ -1,858 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOMAXF { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] businessKey = null; - private byte[] iVKey = null; - private byte[] iV = null; - private byte[] tAK = null; - private byte[] mACData = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getBusinessKeyAsBin( ) { - - return this.businessKey; - } - - - public String getBusinessKeyAsStr( ) { - - if( null == this.businessKey) return null; - return Arrays.toString(this.businessKey); - } - - - public String getBusinessKeyAsHex( ) { - - if( null == this.businessKey) return null; - return Util.bytes2HexString(businessKey); - } - - - public Data setBusinessKey( byte[] bytes ) { - - this.businessKey = bytes; - return this; - } - - - public byte[] getIVKeyAsBin( ) { - - return this.iVKey; - } - - - public String getIVKeyAsStr( ) { - - if( null == this.iVKey) return null; - return Arrays.toString(this.iVKey); - } - - - public String getIVKeyAsHex( ) { - - if( null == this.iVKey) return null; - return Util.bytes2HexString(iVKey); - } - - - public Data setIVKey( byte[] bytes ) { - - this.iVKey = bytes; - return this; - } - - - public byte[] getIVAsBin( ) { - - return this.iV; - } - - - public String getIVAsStr( ) { - - if( null == this.iV) return null; - return Arrays.toString(this.iV); - } - - - public String getIVAsHex( ) { - - if( null == this.iV) return null; - return Util.bytes2HexString(iV); - } - - - public Data setIV( byte[] bytes ) { - - this.iV = bytes; - return this; - } - - - public byte[] getTAKAsBin( ) { - - return this.tAK; - } - - - public String getTAKAsStr( ) { - - if( null == this.tAK) return null; - return Arrays.toString(this.tAK); - } - - - public String getTAKAsHex( ) { - - if( null == this.tAK) return null; - return Util.bytes2HexString(tAK); - } - - - public Data setTAK( byte[] bytes ) { - - this.tAK = bytes; - return this; - } - - - public byte[] getMACDataAsBin( ) { - - return this.mACData; - } - - - public String getMACDataAsStr( ) { - - if( null == this.mACData) return null; - return Arrays.toString(this.mACData); - } - - - public String getMACDataAsHex( ) { - - if( null == this.mACData) return null; - return Util.bytes2HexString(mACData); - } - - - public Data setMACData( byte[] bytes ) { - - this.mACData = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != businessKey ){ - soup.put("businessKey", this.businessKey); - } - - if( null != iVKey ){ - soup.put("IVKey", this.iVKey); - } - - if( null != iV ){ - soup.put("IV", this.iV); - } - - if( null != tAK ){ - soup.put("TAK", this.tAK); - } - - if( null != mACData ){ - soup.put("MACData", this.mACData); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("businessKey") ){ - this.businessKey = ((PacketSection) soup.get("businessKey")).getBytes(); - } - - if( soup.containsKey("IVKey") ){ - this.iVKey = ((PacketSection) soup.get("IVKey")).getBytes(); - } - - if( soup.containsKey("IV") ){ - this.iV = ((PacketSection) soup.get("IV")).getBytes(); - } - - if( soup.containsKey("TAK") ){ - this.tAK = ((PacketSection) soup.get("TAK")).getBytes(); - } - - if( soup.containsKey("MACData") ){ - this.mACData = ((PacketSection) soup.get("MACData")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4D41")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4D41"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] mAC = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPVTAK奇偶校验错(Util.hexString2Bytes("3130")), - OPV用户存储区没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误报告给管理员(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV无效的用户存储索引(Util.hexString2Bytes("3231")), - OPV密钥方案错误(Util.hexString2Bytes("3236")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "TAK奇偶校验错"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK错误;报告给管理员"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效的用户存储索引"; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return "密钥方案错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 7; - } - return null; - } - - - public byte[] getMACAsBin( ) { - - return this.mAC; - } - - - public String getMACAsStr( ) { - - if( null == this.mAC) return null; - return Arrays.toString(this.mAC); - } - - - public String getMACAsHex( ) { - - if( null == this.mAC) return null; - return Util.bytes2HexString(mAC); - } - - - public Data setMAC( byte[] bytes ) { - - this.mAC = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != mAC ){ - soup.put("MAC", this.mAC); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("MAC") ){ - this.mAC = ((PacketSection) soup.get("MAC")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4D42")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4D42"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOMC.java b/src/main/java/racal/sunyard/main/dto/DTOMC.java deleted file mode 100644 index ffef0b1..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOMC.java +++ /dev/null @@ -1,976 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOMC { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] businessKey = null; - private byte[] alg = null; - private byte[] keyType = null; - private byte[] fullMode = null; - private byte[] mACLen = null; - private byte[] key = null; - private byte[] mAC = null; - private byte[] mACData = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getBusinessKeyAsBin( ) { - - return this.businessKey; - } - - - public String getBusinessKeyAsStr( ) { - - if( null == this.businessKey) return null; - return Arrays.toString(this.businessKey); - } - - - public String getBusinessKeyAsHex( ) { - - if( null == this.businessKey) return null; - return Util.bytes2HexString(businessKey); - } - - - public Data setBusinessKey( byte[] bytes ) { - - this.businessKey = bytes; - return this; - } - - - public byte[] getAlgAsBin( ) { - - return this.alg; - } - - - public String getAlgAsStr( ) { - - if( null == this.alg) return null; - return Arrays.toString(this.alg); - } - - - public String getAlgAsHex( ) { - - if( null == this.alg) return null; - return Util.bytes2HexString(alg); - } - - - public Data setAlg( byte[] bytes ) { - - this.alg = bytes; - return this; - } -public enum AlgOptions { - - OPVDES(Util.hexString2Bytes("30")), - OPV3DES(Util.hexString2Bytes("31")), - OPVSM4(Util.hexString2Bytes("32")), - OPVAES(Util.hexString2Bytes("33")), - OPVIDEA(Util.hexString2Bytes("34")), - OPVSM1(Util.hexString2Bytes("35")), - OPV3DESX919(Util.hexString2Bytes("36")); - private byte[] bin; - AlgOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getAlgCn( ) { - - if( null == alg) { return null; } - if( "30".equals(Util.bytes2HexString(this.alg))) { - return "DES"; - } - if( "31".equals(Util.bytes2HexString(this.alg))) { - return "3DES"; - } - if( "32".equals(Util.bytes2HexString(this.alg))) { - return "SM4"; - } - if( "33".equals(Util.bytes2HexString(this.alg))) { - return "AES"; - } - if( "34".equals(Util.bytes2HexString(this.alg))) { - return "IDEA"; - } - if( "35".equals(Util.bytes2HexString(this.alg))) { - return "SM1"; - } - if( "36".equals(Util.bytes2HexString(this.alg))) { - return "3DESX919"; - } - return null; - } - - - public Integer getAlgOptionIndex( ) { - - if( null == alg) { return null; } - if( "30".equals(Util.bytes2HexString(this.alg))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.alg))) { - return 1; - } - if( "32".equals(Util.bytes2HexString(this.alg))) { - return 2; - } - if( "33".equals(Util.bytes2HexString(this.alg))) { - return 3; - } - if( "34".equals(Util.bytes2HexString(this.alg))) { - return 4; - } - if( "35".equals(Util.bytes2HexString(this.alg))) { - return 5; - } - if( "36".equals(Util.bytes2HexString(this.alg))) { - return 6; - } - return null; - } - - - public byte[] getKeyTypeAsBin( ) { - - return this.keyType; - } - - - public String getKeyTypeAsStr( ) { - - if( null == this.keyType) return null; - return Arrays.toString(this.keyType); - } - - - public String getKeyTypeAsHex( ) { - - if( null == this.keyType) return null; - return Util.bytes2HexString(keyType); - } - - - public Data setKeyType( byte[] bytes ) { - - this.keyType = bytes; - return this; - } -public enum KeyTypeOptions { - - OPVTAK(Util.hexString2Bytes("30")), - OPVZAK(Util.hexString2Bytes("31")); - private byte[] bin; - KeyTypeOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getKeyTypeCn( ) { - - if( null == keyType) { return null; } - if( "30".equals(Util.bytes2HexString(this.keyType))) { - return "TAK"; - } - if( "31".equals(Util.bytes2HexString(this.keyType))) { - return "ZAK"; - } - return null; - } - - - public Integer getKeyTypeOptionIndex( ) { - - if( null == keyType) { return null; } - if( "30".equals(Util.bytes2HexString(this.keyType))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.keyType))) { - return 1; - } - return null; - } - - - public byte[] getFullModeAsBin( ) { - - return this.fullMode; - } - - - public String getFullModeAsStr( ) { - - if( null == this.fullMode) return null; - return Arrays.toString(this.fullMode); - } - - - public String getFullModeAsHex( ) { - - if( null == this.fullMode) return null; - return Util.bytes2HexString(fullMode); - } - - - public Data setFullMode( byte[] bytes ) { - - this.fullMode = bytes; - return this; - } -public enum FullModeOptions { - - OPV弱填充(Util.hexString2Bytes("30")), - OPV强填充(Util.hexString2Bytes("31")); - private byte[] bin; - FullModeOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getFullModeCn( ) { - - if( null == fullMode) { return null; } - if( "30".equals(Util.bytes2HexString(this.fullMode))) { - return "弱填充"; - } - if( "31".equals(Util.bytes2HexString(this.fullMode))) { - return "强填充"; - } - return null; - } - - - public Integer getFullModeOptionIndex( ) { - - if( null == fullMode) { return null; } - if( "30".equals(Util.bytes2HexString(this.fullMode))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.fullMode))) { - return 1; - } - return null; - } - - - public byte[] getMACLenAsBin( ) { - - return this.mACLen; - } - - - public String getMACLenAsStr( ) { - - if( null == this.mACLen) return null; - return Arrays.toString(this.mACLen); - } - - - public String getMACLenAsHex( ) { - - if( null == this.mACLen) return null; - return Util.bytes2HexString(mACLen); - } - - - public Data setMACLen( byte[] bytes ) { - - this.mACLen = bytes; - return this; - } -public enum MACLenOptions { - - OPV4(Util.hexString2Bytes("31")), - OPV8(Util.hexString2Bytes("32")), - OPV16(Util.hexString2Bytes("33")); - private byte[] bin; - MACLenOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getMACLenCn( ) { - - if( null == mACLen) { return null; } - if( "31".equals(Util.bytes2HexString(this.mACLen))) { - return "4"; - } - if( "32".equals(Util.bytes2HexString(this.mACLen))) { - return "8"; - } - if( "33".equals(Util.bytes2HexString(this.mACLen))) { - return "16"; - } - return null; - } - - - public Integer getMACLenOptionIndex( ) { - - if( null == mACLen) { return null; } - if( "31".equals(Util.bytes2HexString(this.mACLen))) { - return 0; - } - if( "32".equals(Util.bytes2HexString(this.mACLen))) { - return 1; - } - if( "33".equals(Util.bytes2HexString(this.mACLen))) { - return 2; - } - return null; - } - - - public byte[] getKeyAsBin( ) { - - return this.key; - } - - - public String getKeyAsStr( ) { - - if( null == this.key) return null; - return Arrays.toString(this.key); - } - - - public String getKeyAsHex( ) { - - if( null == this.key) return null; - return Util.bytes2HexString(key); - } - - - public Data setKey( byte[] bytes ) { - - this.key = bytes; - return this; - } - - - public byte[] getMACAsBin( ) { - - return this.mAC; - } - - - public String getMACAsStr( ) { - - if( null == this.mAC) return null; - return Arrays.toString(this.mAC); - } - - - public String getMACAsHex( ) { - - if( null == this.mAC) return null; - return Util.bytes2HexString(mAC); - } - - - public Data setMAC( byte[] bytes ) { - - this.mAC = bytes; - return this; - } - - - public byte[] getMACDataAsBin( ) { - - return this.mACData; - } - - - public String getMACDataAsStr( ) { - - if( null == this.mACData) return null; - return Arrays.toString(this.mACData); - } - - - public String getMACDataAsHex( ) { - - if( null == this.mACData) return null; - return Util.bytes2HexString(mACData); - } - - - public Data setMACData( byte[] bytes ) { - - this.mACData = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != businessKey ){ - soup.put("businessKey", this.businessKey); - } - - if( null != alg ){ - soup.put("alg", this.alg); - soup.put("alg$option", getAlgOptionIndex()); - } - - if( null != keyType ){ - soup.put("keyType", this.keyType); - soup.put("keyType$option", getKeyTypeOptionIndex()); - } - - if( null != fullMode ){ - soup.put("fullMode", this.fullMode); - soup.put("fullMode$option", getFullModeOptionIndex()); - } - - if( null != mACLen ){ - soup.put("MACLen", this.mACLen); - soup.put("MACLen$option", getMACLenOptionIndex()); - } - - if( null != key ){ - soup.put("key", this.key); - } - - if( null != mAC ){ - soup.put("MAC", this.mAC); - } - - if( null != mACData ){ - soup.put("MACData", this.mACData); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("businessKey") ){ - this.businessKey = ((PacketSection) soup.get("businessKey")).getBytes(); - } - - if( soup.containsKey("alg") ){ - this.alg = ((PacketSection) soup.get("alg")).getBytes(); - } - - if( soup.containsKey("keyType") ){ - this.keyType = ((PacketSection) soup.get("keyType")).getBytes(); - } - - if( soup.containsKey("fullMode") ){ - this.fullMode = ((PacketSection) soup.get("fullMode")).getBytes(); - } - - if( soup.containsKey("MACLen") ){ - this.mACLen = ((PacketSection) soup.get("MACLen")).getBytes(); - } - - if( soup.containsKey("key") ){ - this.key = ((PacketSection) soup.get("key")).getBytes(); - } - - if( soup.containsKey("MAC") ){ - this.mAC = ((PacketSection) soup.get("MAC")).getBytes(); - } - - if( soup.containsKey("MACData") ){ - this.mACData = ((PacketSection) soup.get("MACData")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4D43")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4D43"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPVTAK奇偶校验错(Util.hexString2Bytes("3130")), - OPV用户存储区没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误报告给管理员(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV无效的用户存储索引(Util.hexString2Bytes("3231")), - OPV密钥方案错误(Util.hexString2Bytes("3236")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "TAK奇偶校验错"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK错误;报告给管理员"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效的用户存储索引"; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return "密钥方案错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 7; - } - return null; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4D44")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4D44"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOMF.java b/src/main/java/racal/sunyard/main/dto/DTOMF.java deleted file mode 100644 index ef561f8..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOMF.java +++ /dev/null @@ -1,1009 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOMF { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] zmk = null; - private byte[] tak = null; - private byte[] businessKey = null; - private byte[] separator = null; - private byte[] zmkSolution = null; - private byte[] lmkSolution = null; - private byte[] keyCheckType = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getZmkAsBin( ) { - - return this.zmk; - } - - - public String getZmkAsStr( ) { - - if( null == this.zmk) return null; - return Arrays.toString(this.zmk); - } - - - public String getZmkAsHex( ) { - - if( null == this.zmk) return null; - return Util.bytes2HexString(zmk); - } - - - public Data setZmk( byte[] bytes ) { - - this.zmk = bytes; - return this; - } - - - public byte[] getTakAsBin( ) { - - return this.tak; - } - - - public String getTakAsStr( ) { - - if( null == this.tak) return null; - return Arrays.toString(this.tak); - } - - - public String getTakAsHex( ) { - - if( null == this.tak) return null; - return Util.bytes2HexString(tak); - } - - - public Data setTak( byte[] bytes ) { - - this.tak = bytes; - return this; - } - - - public byte[] getBusinessKeyAsBin( ) { - - return this.businessKey; - } - - - public String getBusinessKeyAsStr( ) { - - if( null == this.businessKey) return null; - return Arrays.toString(this.businessKey); - } - - - public String getBusinessKeyAsHex( ) { - - if( null == this.businessKey) return null; - return Util.bytes2HexString(businessKey); - } - - - public Data setBusinessKey( byte[] bytes ) { - - this.businessKey = bytes; - return this; - } - - - public byte[] getSeparatorAsBin( ) { - - return this.separator; - } - - - public String getSeparatorAsStr( ) { - - if( null == this.separator) return null; - return Arrays.toString(this.separator); - } - - - public String getSeparatorAsHex( ) { - - if( null == this.separator) return null; - return Util.bytes2HexString(separator); - } - - - public Data setSeparator( byte[] bytes ) { - - this.separator = bytes; - return this; - } - - - public byte[] getZmkSolutionAsBin( ) { - - return this.zmkSolution; - } - - - public String getZmkSolutionAsStr( ) { - - if( null == this.zmkSolution) return null; - return Arrays.toString(this.zmkSolution); - } - - - public String getZmkSolutionAsHex( ) { - - if( null == this.zmkSolution) return null; - return Util.bytes2HexString(zmkSolution); - } - - - public Data setZmkSolution( byte[] bytes ) { - - this.zmkSolution = bytes; - return this; - } - - - public byte[] getLmkSolutionAsBin( ) { - - return this.lmkSolution; - } - - - public String getLmkSolutionAsStr( ) { - - if( null == this.lmkSolution) return null; - return Arrays.toString(this.lmkSolution); - } - - - public String getLmkSolutionAsHex( ) { - - if( null == this.lmkSolution) return null; - return Util.bytes2HexString(lmkSolution); - } - - - public Data setLmkSolution( byte[] bytes ) { - - this.lmkSolution = bytes; - return this; - } - - - public byte[] getKeyCheckTypeAsBin( ) { - - return this.keyCheckType; - } - - - public String getKeyCheckTypeAsStr( ) { - - if( null == this.keyCheckType) return null; - return Arrays.toString(this.keyCheckType); - } - - - public String getKeyCheckTypeAsHex( ) { - - if( null == this.keyCheckType) return null; - return Util.bytes2HexString(keyCheckType); - } - - - public Data setKeyCheckType( byte[] bytes ) { - - this.keyCheckType = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != zmk ){ - soup.put("zmk", this.zmk); - } - - if( null != tak ){ - soup.put("tak", this.tak); - } - - if( null != businessKey ){ - soup.put("businessKey", this.businessKey); - } - - if( null != separator ){ - soup.put("separator", this.separator); - } - - if( null != zmkSolution ){ - soup.put("zmkSolution", this.zmkSolution); - } - - if( null != lmkSolution ){ - soup.put("lmkSolution", this.lmkSolution); - } - - if( null != keyCheckType ){ - soup.put("keyCheckType", this.keyCheckType); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("zmk") ){ - this.zmk = ((PacketSection) soup.get("zmk")).getBytes(); - } - - if( soup.containsKey("tak") ){ - this.tak = ((PacketSection) soup.get("tak")).getBytes(); - } - - if( soup.containsKey("businessKey") ){ - this.businessKey = ((PacketSection) soup.get("businessKey")).getBytes(); - } - - if( soup.containsKey("separator") ){ - this.separator = ((PacketSection) soup.get("separator")).getBytes(); - } - - if( soup.containsKey("zmkSolution") ){ - this.zmkSolution = ((PacketSection) soup.get("zmkSolution")).getBytes(); - } - - if( soup.containsKey("lmkSolution") ){ - this.lmkSolution = ((PacketSection) soup.get("lmkSolution")).getBytes(); - } - - if( soup.containsKey("keyCheckType") ){ - this.keyCheckType = ((PacketSection) soup.get("keyCheckType")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4D46")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4D46"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] takLmkHead = null; - private byte[] takLmk = null; - private byte[] keyCheck = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPVZMK奇偶校验错(Util.hexString2Bytes("3130")), - OPVTMKTPK或PVK奇偶校验错(Util.hexString2Bytes("3131")), - OPV用户存储区中没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV无效用户存储区索引(Util.hexString2Bytes("3231")), - OPV密钥方案错误(Util.hexString2Bytes("3236")), - OPV数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "ZMK 奇偶校验错"; - } - if( "3131".equals(Util.bytes2HexString(this.error))) { - return "TMK、TPK 或 PVK 奇偶校验错"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区中没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效用户存储区索引"; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return "密钥方案错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3131".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 8; - } - return null; - } - - - public byte[] getTakLmkHeadAsBin( ) { - - return this.takLmkHead; - } - - - public String getTakLmkHeadAsStr( ) { - - if( null == this.takLmkHead) return null; - return Arrays.toString(this.takLmkHead); - } - - - public String getTakLmkHeadAsHex( ) { - - if( null == this.takLmkHead) return null; - return Util.bytes2HexString(takLmkHead); - } - - - public Data setTakLmkHead( byte[] bytes ) { - - this.takLmkHead = bytes; - return this; - } - - - public byte[] getTakLmkAsBin( ) { - - return this.takLmk; - } - - - public String getTakLmkAsStr( ) { - - if( null == this.takLmk) return null; - return Arrays.toString(this.takLmk); - } - - - public String getTakLmkAsHex( ) { - - if( null == this.takLmk) return null; - return Util.bytes2HexString(takLmk); - } - - - public Data setTakLmk( byte[] bytes ) { - - this.takLmk = bytes; - return this; - } - - - public byte[] getKeyCheckAsBin( ) { - - return this.keyCheck; - } - - - public String getKeyCheckAsStr( ) { - - if( null == this.keyCheck) return null; - return Arrays.toString(this.keyCheck); - } - - - public String getKeyCheckAsHex( ) { - - if( null == this.keyCheck) return null; - return Util.bytes2HexString(keyCheck); - } - - - public Data setKeyCheck( byte[] bytes ) { - - this.keyCheck = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != takLmkHead ){ - soup.put("takLmkHead", this.takLmkHead); - } - - if( null != takLmk ){ - soup.put("takLmk", this.takLmk); - } - - if( null != keyCheck ){ - soup.put("keyCheck", this.keyCheck); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("takLmkHead") ){ - this.takLmkHead = ((PacketSection) soup.get("takLmkHead")).getBytes(); - } - - if( soup.containsKey("takLmk") ){ - this.takLmk = ((PacketSection) soup.get("takLmk")).getBytes(); - } - - if( soup.containsKey("keyCheck") ){ - this.keyCheck = ((PacketSection) soup.get("keyCheck")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4D47")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4D47"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOMG.java b/src/main/java/racal/sunyard/main/dto/DTOMG.java deleted file mode 100644 index b3a2fb7..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOMG.java +++ /dev/null @@ -1,1009 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOMG { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] zmk = null; - private byte[] tak = null; - private byte[] businessKey = null; - private byte[] separator = null; - private byte[] zmkSolution = null; - private byte[] lmkSolution = null; - private byte[] keyCheckType = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getZmkAsBin( ) { - - return this.zmk; - } - - - public String getZmkAsStr( ) { - - if( null == this.zmk) return null; - return Arrays.toString(this.zmk); - } - - - public String getZmkAsHex( ) { - - if( null == this.zmk) return null; - return Util.bytes2HexString(zmk); - } - - - public Data setZmk( byte[] bytes ) { - - this.zmk = bytes; - return this; - } - - - public byte[] getTakAsBin( ) { - - return this.tak; - } - - - public String getTakAsStr( ) { - - if( null == this.tak) return null; - return Arrays.toString(this.tak); - } - - - public String getTakAsHex( ) { - - if( null == this.tak) return null; - return Util.bytes2HexString(tak); - } - - - public Data setTak( byte[] bytes ) { - - this.tak = bytes; - return this; - } - - - public byte[] getBusinessKeyAsBin( ) { - - return this.businessKey; - } - - - public String getBusinessKeyAsStr( ) { - - if( null == this.businessKey) return null; - return Arrays.toString(this.businessKey); - } - - - public String getBusinessKeyAsHex( ) { - - if( null == this.businessKey) return null; - return Util.bytes2HexString(businessKey); - } - - - public Data setBusinessKey( byte[] bytes ) { - - this.businessKey = bytes; - return this; - } - - - public byte[] getSeparatorAsBin( ) { - - return this.separator; - } - - - public String getSeparatorAsStr( ) { - - if( null == this.separator) return null; - return Arrays.toString(this.separator); - } - - - public String getSeparatorAsHex( ) { - - if( null == this.separator) return null; - return Util.bytes2HexString(separator); - } - - - public Data setSeparator( byte[] bytes ) { - - this.separator = bytes; - return this; - } - - - public byte[] getZmkSolutionAsBin( ) { - - return this.zmkSolution; - } - - - public String getZmkSolutionAsStr( ) { - - if( null == this.zmkSolution) return null; - return Arrays.toString(this.zmkSolution); - } - - - public String getZmkSolutionAsHex( ) { - - if( null == this.zmkSolution) return null; - return Util.bytes2HexString(zmkSolution); - } - - - public Data setZmkSolution( byte[] bytes ) { - - this.zmkSolution = bytes; - return this; - } - - - public byte[] getLmkSolutionAsBin( ) { - - return this.lmkSolution; - } - - - public String getLmkSolutionAsStr( ) { - - if( null == this.lmkSolution) return null; - return Arrays.toString(this.lmkSolution); - } - - - public String getLmkSolutionAsHex( ) { - - if( null == this.lmkSolution) return null; - return Util.bytes2HexString(lmkSolution); - } - - - public Data setLmkSolution( byte[] bytes ) { - - this.lmkSolution = bytes; - return this; - } - - - public byte[] getKeyCheckTypeAsBin( ) { - - return this.keyCheckType; - } - - - public String getKeyCheckTypeAsStr( ) { - - if( null == this.keyCheckType) return null; - return Arrays.toString(this.keyCheckType); - } - - - public String getKeyCheckTypeAsHex( ) { - - if( null == this.keyCheckType) return null; - return Util.bytes2HexString(keyCheckType); - } - - - public Data setKeyCheckType( byte[] bytes ) { - - this.keyCheckType = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != zmk ){ - soup.put("zmk", this.zmk); - } - - if( null != tak ){ - soup.put("tak", this.tak); - } - - if( null != businessKey ){ - soup.put("businessKey", this.businessKey); - } - - if( null != separator ){ - soup.put("separator", this.separator); - } - - if( null != zmkSolution ){ - soup.put("zmkSolution", this.zmkSolution); - } - - if( null != lmkSolution ){ - soup.put("lmkSolution", this.lmkSolution); - } - - if( null != keyCheckType ){ - soup.put("keyCheckType", this.keyCheckType); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("zmk") ){ - this.zmk = ((PacketSection) soup.get("zmk")).getBytes(); - } - - if( soup.containsKey("tak") ){ - this.tak = ((PacketSection) soup.get("tak")).getBytes(); - } - - if( soup.containsKey("businessKey") ){ - this.businessKey = ((PacketSection) soup.get("businessKey")).getBytes(); - } - - if( soup.containsKey("separator") ){ - this.separator = ((PacketSection) soup.get("separator")).getBytes(); - } - - if( soup.containsKey("zmkSolution") ){ - this.zmkSolution = ((PacketSection) soup.get("zmkSolution")).getBytes(); - } - - if( soup.containsKey("lmkSolution") ){ - this.lmkSolution = ((PacketSection) soup.get("lmkSolution")).getBytes(); - } - - if( soup.containsKey("keyCheckType") ){ - this.keyCheckType = ((PacketSection) soup.get("keyCheckType")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4D47")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4D47"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] takZmkHead = null; - private byte[] takZmk = null; - private byte[] keyCheck = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPVZMK奇偶校验错(Util.hexString2Bytes("3130")), - OPVTMKTPK或PVK奇偶校验错(Util.hexString2Bytes("3131")), - OPV用户存储区没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV无效用户存储区索引(Util.hexString2Bytes("3231")), - OPV密钥方案错误(Util.hexString2Bytes("3236")), - OPV数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "ZMK 奇偶校验错"; - } - if( "3131".equals(Util.bytes2HexString(this.error))) { - return "TMK、TPK 或 PVK 奇偶校验错"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效用户存储区索引"; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return "密钥方案错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3131".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 8; - } - return null; - } - - - public byte[] getTakZmkHeadAsBin( ) { - - return this.takZmkHead; - } - - - public String getTakZmkHeadAsStr( ) { - - if( null == this.takZmkHead) return null; - return Arrays.toString(this.takZmkHead); - } - - - public String getTakZmkHeadAsHex( ) { - - if( null == this.takZmkHead) return null; - return Util.bytes2HexString(takZmkHead); - } - - - public Data setTakZmkHead( byte[] bytes ) { - - this.takZmkHead = bytes; - return this; - } - - - public byte[] getTakZmkAsBin( ) { - - return this.takZmk; - } - - - public String getTakZmkAsStr( ) { - - if( null == this.takZmk) return null; - return Arrays.toString(this.takZmk); - } - - - public String getTakZmkAsHex( ) { - - if( null == this.takZmk) return null; - return Util.bytes2HexString(takZmk); - } - - - public Data setTakZmk( byte[] bytes ) { - - this.takZmk = bytes; - return this; - } - - - public byte[] getKeyCheckAsBin( ) { - - return this.keyCheck; - } - - - public String getKeyCheckAsStr( ) { - - if( null == this.keyCheck) return null; - return Arrays.toString(this.keyCheck); - } - - - public String getKeyCheckAsHex( ) { - - if( null == this.keyCheck) return null; - return Util.bytes2HexString(keyCheck); - } - - - public Data setKeyCheck( byte[] bytes ) { - - this.keyCheck = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != takZmkHead ){ - soup.put("takZmkHead", this.takZmkHead); - } - - if( null != takZmk ){ - soup.put("takZmk", this.takZmk); - } - - if( null != keyCheck ){ - soup.put("keyCheck", this.keyCheck); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("takZmkHead") ){ - this.takZmkHead = ((PacketSection) soup.get("takZmkHead")).getBytes(); - } - - if( soup.containsKey("takZmk") ){ - this.takZmk = ((PacketSection) soup.get("takZmk")).getBytes(); - } - - if( soup.containsKey("keyCheck") ){ - this.keyCheck = ((PacketSection) soup.get("keyCheck")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4D48")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4D48"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOMS.java b/src/main/java/racal/sunyard/main/dto/DTOMS.java deleted file mode 100644 index 0572497..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOMS.java +++ /dev/null @@ -1,1174 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOMS { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] block = null; - private byte[] keyType = null; - private byte[] mode = null; - private byte[] dataType = null; - private byte[] key = null; - private byte[] iv = null; - private byte[] msgLen = null; - private byte[] msg = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getBlockAsBin( ) { - - return this.block; - } - - - public String getBlockAsStr( ) { - - if( null == this.block) return null; - return Arrays.toString(this.block); - } - - - public String getBlockAsHex( ) { - - if( null == this.block) return null; - return Util.bytes2HexString(block); - } - - - public Data setBlock( byte[] bytes ) { - - this.block = bytes; - return this; - } -public enum BlockOptions { - - OPV仅一块(Util.hexString2Bytes("30")), - OPV第一块(Util.hexString2Bytes("31")), - OPV中间块(Util.hexString2Bytes("32")), - OPV最后块(Util.hexString2Bytes("33")); - private byte[] bin; - BlockOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getBlockCn( ) { - - if( null == block) { return null; } - if( "30".equals(Util.bytes2HexString(this.block))) { - return "仅一块"; - } - if( "31".equals(Util.bytes2HexString(this.block))) { - return "第一块"; - } - if( "32".equals(Util.bytes2HexString(this.block))) { - return "中间块"; - } - if( "33".equals(Util.bytes2HexString(this.block))) { - return "最后块"; - } - return null; - } - - - public Integer getBlockOptionIndex( ) { - - if( null == block) { return null; } - if( "30".equals(Util.bytes2HexString(this.block))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.block))) { - return 1; - } - if( "32".equals(Util.bytes2HexString(this.block))) { - return 2; - } - if( "33".equals(Util.bytes2HexString(this.block))) { - return 3; - } - return null; - } - - - public byte[] getKeyTypeAsBin( ) { - - return this.keyType; - } - - - public String getKeyTypeAsStr( ) { - - if( null == this.keyType) return null; - return Arrays.toString(this.keyType); - } - - - public String getKeyTypeAsHex( ) { - - if( null == this.keyType) return null; - return Util.bytes2HexString(keyType); - } - - - public Data setKeyType( byte[] bytes ) { - - this.keyType = bytes; - return this; - } -public enum KeyTypeOptions { - - OPVTAK(Util.hexString2Bytes("30")), - OPVZAK(Util.hexString2Bytes("31")); - private byte[] bin; - KeyTypeOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getKeyTypeCn( ) { - - if( null == keyType) { return null; } - if( "30".equals(Util.bytes2HexString(this.keyType))) { - return "TAK"; - } - if( "31".equals(Util.bytes2HexString(this.keyType))) { - return "ZAK"; - } - return null; - } - - - public Integer getKeyTypeOptionIndex( ) { - - if( null == keyType) { return null; } - if( "30".equals(Util.bytes2HexString(this.keyType))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.keyType))) { - return 1; - } - return null; - } - - - public byte[] getModeAsBin( ) { - - return this.mode; - } - - - public String getModeAsStr( ) { - - if( null == this.mode) return null; - return Arrays.toString(this.mode); - } - - - public String getModeAsHex( ) { - - if( null == this.mode) return null; - return Util.bytes2HexString(mode); - } - - - public Data setMode( byte[] bytes ) { - - this.mode = bytes; - return this; - } -public enum ModeOptions { - - OPV单倍长度DES密钥AnsiX99(Util.hexString2Bytes("30")), - OPV双倍长度DES密钥AnsiX919(Util.hexString2Bytes("31")), - OPVSM4CBC弱填充0x00银联(Util.hexString2Bytes("32")), - OPV3DESCBC弱填充0x00银联(Util.hexString2Bytes("33")); - private byte[] bin; - ModeOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getModeCn( ) { - - if( null == mode) { return null; } - if( "30".equals(Util.bytes2HexString(this.mode))) { - return "单倍长度DES密钥.Ansi X9.9"; - } - if( "31".equals(Util.bytes2HexString(this.mode))) { - return "双倍长度DES密钥,Ansi X9.19"; - } - if( "32".equals(Util.bytes2HexString(this.mode))) { - return " SM4-CBC,弱填充0x00,银联"; - } - if( "33".equals(Util.bytes2HexString(this.mode))) { - return "3DES-CBC, ,弱填充0x00,银联"; - } - return null; - } - - - public Integer getModeOptionIndex( ) { - - if( null == mode) { return null; } - if( "30".equals(Util.bytes2HexString(this.mode))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.mode))) { - return 1; - } - if( "32".equals(Util.bytes2HexString(this.mode))) { - return 2; - } - if( "33".equals(Util.bytes2HexString(this.mode))) { - return 3; - } - return null; - } - - - public byte[] getDataTypeAsBin( ) { - - return this.dataType; - } - - - public String getDataTypeAsStr( ) { - - if( null == this.dataType) return null; - return Arrays.toString(this.dataType); - } - - - public String getDataTypeAsHex( ) { - - if( null == this.dataType) return null; - return Util.bytes2HexString(dataType); - } - - - public Data setDataType( byte[] bytes ) { - - this.dataType = bytes; - return this; - } -public enum DataTypeOptions { - - OPV二进制(Util.hexString2Bytes("30")), - OPV十六进制(Util.hexString2Bytes("31")); - private byte[] bin; - DataTypeOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getDataTypeCn( ) { - - if( null == dataType) { return null; } - if( "30".equals(Util.bytes2HexString(this.dataType))) { - return "二进制"; - } - if( "31".equals(Util.bytes2HexString(this.dataType))) { - return "十六进制"; - } - return null; - } - - - public Integer getDataTypeOptionIndex( ) { - - if( null == dataType) { return null; } - if( "30".equals(Util.bytes2HexString(this.dataType))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.dataType))) { - return 1; - } - return null; - } - - - public byte[] getKeyAsBin( ) { - - return this.key; - } - - - public String getKeyAsStr( ) { - - if( null == this.key) return null; - return Arrays.toString(this.key); - } - - - public String getKeyAsHex( ) { - - if( null == this.key) return null; - return Util.bytes2HexString(key); - } - - - public Data setKey( byte[] bytes ) { - - this.key = bytes; - return this; - } - - - public byte[] getIvAsBin( ) { - - return this.iv; - } - - - public String getIvAsStr( ) { - - if( null == this.iv) return null; - return Arrays.toString(this.iv); - } - - - public String getIvAsHex( ) { - - if( null == this.iv) return null; - return Util.bytes2HexString(iv); - } - - - public Data setIv( byte[] bytes ) { - - this.iv = bytes; - return this; - } - - - public byte[] getMsgLenAsBin( ) { - - return this.msgLen; - } - - - public String getMsgLenAsStr( ) { - - if( null == this.msgLen) return null; - return Arrays.toString(this.msgLen); - } - - - public String getMsgLenAsHex( ) { - - if( null == this.msgLen) return null; - return Util.bytes2HexString(msgLen); - } - - - public Data setMsgLen( byte[] bytes ) { - - this.msgLen = bytes; - return this; - } - - - public byte[] getMsgAsBin( ) { - - return this.msg; - } - - - public String getMsgAsStr( ) { - - if( null == this.msg) return null; - return Arrays.toString(this.msg); - } - - - public String getMsgAsHex( ) { - - if( null == this.msg) return null; - return Util.bytes2HexString(msg); - } - - - public Data setMsg( byte[] bytes ) { - - this.msg = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != block ){ - soup.put("block", this.block); - soup.put("block$option", getBlockOptionIndex()); - } - - if( null != keyType ){ - soup.put("keyType", this.keyType); - soup.put("keyType$option", getKeyTypeOptionIndex()); - } - - if( null != mode ){ - soup.put("mode", this.mode); - soup.put("mode$option", getModeOptionIndex()); - } - - if( null != dataType ){ - soup.put("dataType", this.dataType); - soup.put("dataType$option", getDataTypeOptionIndex()); - } - - if( null != key ){ - soup.put("key", this.key); - } - - if( null != iv ){ - soup.put("iv", this.iv); - } - - if( null != msgLen ){ - soup.put("msgLen", this.msgLen); - } - - if( null != msg ){ - soup.put("msg", this.msg); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("block") ){ - this.block = ((PacketSection) soup.get("block")).getBytes(); - } - - if( soup.containsKey("keyType") ){ - this.keyType = ((PacketSection) soup.get("keyType")).getBytes(); - } - - if( soup.containsKey("mode") ){ - this.mode = ((PacketSection) soup.get("mode")).getBytes(); - } - - if( soup.containsKey("dataType") ){ - this.dataType = ((PacketSection) soup.get("dataType")).getBytes(); - } - - if( soup.containsKey("key") ){ - this.key = ((PacketSection) soup.get("key")).getBytes(); - } - - if( soup.containsKey("iv") ){ - this.iv = ((PacketSection) soup.get("iv")).getBytes(); - } - - if( soup.containsKey("msgLen") ){ - this.msgLen = ((PacketSection) soup.get("msgLen")).getBytes(); - } - - if( soup.containsKey("msg") ){ - this.msg = ((PacketSection) soup.get("msg")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4D53")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4D53"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] mAB = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV无效消息类型代码(Util.hexString2Bytes("3033")), - OPV无效密钥类型代码(Util.hexString2Bytes("3034")), - OPV无效消息块号(Util.hexString2Bytes("3035")), - OPV无效密钥长度代码(Util.hexString2Bytes("3036")), - OPVZAK奇偶校验错(Util.hexString2Bytes("3130")), - OPV用户存储区没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误报告给管理员(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV无效的用户存储索引(Util.hexString2Bytes("3231")), - OPV无效密钥长度(Util.hexString2Bytes("3237")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3033".equals(Util.bytes2HexString(this.error))) { - return "无效消息类型代码"; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return "无效密钥类型代码"; - } - if( "3035".equals(Util.bytes2HexString(this.error))) { - return "无效消息块号"; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return "无效密钥长度代码"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "ZAK奇偶校验错"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK错误;报告给管理员"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效的用户存储索引"; - } - if( "3237".equals(Util.bytes2HexString(this.error))) { - return "无效密钥长度"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3033".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3035".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 9; - } - if( "3237".equals(Util.bytes2HexString(this.error))) { - return 10; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 11; - } - return null; - } - - - public byte[] getMABAsBin( ) { - - return this.mAB; - } - - - public String getMABAsStr( ) { - - if( null == this.mAB) return null; - return Arrays.toString(this.mAB); - } - - - public String getMABAsHex( ) { - - if( null == this.mAB) return null; - return Util.bytes2HexString(mAB); - } - - - public Data setMAB( byte[] bytes ) { - - this.mAB = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != mAB ){ - soup.put("MAB", this.mAB); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("MAB") ){ - this.mAB = ((PacketSection) soup.get("MAB")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4D54")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4D54"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOMU.java b/src/main/java/racal/sunyard/main/dto/DTOMU.java deleted file mode 100644 index bb6bd77..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOMU.java +++ /dev/null @@ -1,939 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOMU { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] block = null; - private byte[] keyType = null; - private byte[] mode = null; - private byte[] dataType = null; - private byte[] key = null; - private byte[] iv = null; - private byte[] mACDataLen = null; - private byte[] mACData = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getBlockAsBin( ) { - - return this.block; - } - - - public String getBlockAsStr( ) { - - if( null == this.block) return null; - return Arrays.toString(this.block); - } - - - public String getBlockAsHex( ) { - - if( null == this.block) return null; - return Util.bytes2HexString(block); - } - - - public Data setBlock( byte[] bytes ) { - - this.block = bytes; - return this; - } - - - public byte[] getKeyTypeAsBin( ) { - - return this.keyType; - } - - - public String getKeyTypeAsStr( ) { - - if( null == this.keyType) return null; - return Arrays.toString(this.keyType); - } - - - public String getKeyTypeAsHex( ) { - - if( null == this.keyType) return null; - return Util.bytes2HexString(keyType); - } - - - public Data setKeyType( byte[] bytes ) { - - this.keyType = bytes; - return this; - } -public enum KeyTypeOptions { - - OPVTAK(Util.hexString2Bytes("30")), - OPVZAK(Util.hexString2Bytes("31")); - private byte[] bin; - KeyTypeOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getKeyTypeCn( ) { - - if( null == keyType) { return null; } - if( "30".equals(Util.bytes2HexString(this.keyType))) { - return "TAK"; - } - if( "31".equals(Util.bytes2HexString(this.keyType))) { - return "ZAK"; - } - return null; - } - - - public Integer getKeyTypeOptionIndex( ) { - - if( null == keyType) { return null; } - if( "30".equals(Util.bytes2HexString(this.keyType))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.keyType))) { - return 1; - } - return null; - } - - - public byte[] getModeAsBin( ) { - - return this.mode; - } - - - public String getModeAsStr( ) { - - if( null == this.mode) return null; - return Arrays.toString(this.mode); - } - - - public String getModeAsHex( ) { - - if( null == this.mode) return null; - return Util.bytes2HexString(mode); - } - - - public Data setMode( byte[] bytes ) { - - this.mode = bytes; - return this; - } -public enum ModeOptions { - - OPVDES(Util.hexString2Bytes("30")), - OPVDES3(Util.hexString2Bytes("31")), - OPVSM4(Util.hexString2Bytes("32")); - private byte[] bin; - ModeOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getModeCn( ) { - - if( null == mode) { return null; } - if( "30".equals(Util.bytes2HexString(this.mode))) { - return "DES"; - } - if( "31".equals(Util.bytes2HexString(this.mode))) { - return "DES3"; - } - if( "32".equals(Util.bytes2HexString(this.mode))) { - return "SM4"; - } - return null; - } - - - public Integer getModeOptionIndex( ) { - - if( null == mode) { return null; } - if( "30".equals(Util.bytes2HexString(this.mode))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.mode))) { - return 1; - } - if( "32".equals(Util.bytes2HexString(this.mode))) { - return 2; - } - return null; - } - - - public byte[] getDataTypeAsBin( ) { - - return this.dataType; - } - - - public String getDataTypeAsStr( ) { - - if( null == this.dataType) return null; - return Arrays.toString(this.dataType); - } - - - public String getDataTypeAsHex( ) { - - if( null == this.dataType) return null; - return Util.bytes2HexString(dataType); - } - - - public Data setDataType( byte[] bytes ) { - - this.dataType = bytes; - return this; - } -public enum DataTypeOptions { - - OPV二进制(Util.hexString2Bytes("30")), - OPV十六进制(Util.hexString2Bytes("31")); - private byte[] bin; - DataTypeOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getDataTypeCn( ) { - - if( null == dataType) { return null; } - if( "30".equals(Util.bytes2HexString(this.dataType))) { - return "二进制"; - } - if( "31".equals(Util.bytes2HexString(this.dataType))) { - return "十六进制"; - } - return null; - } - - - public Integer getDataTypeOptionIndex( ) { - - if( null == dataType) { return null; } - if( "30".equals(Util.bytes2HexString(this.dataType))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.dataType))) { - return 1; - } - return null; - } - - - public byte[] getKeyAsBin( ) { - - return this.key; - } - - - public String getKeyAsStr( ) { - - if( null == this.key) return null; - return Arrays.toString(this.key); - } - - - public String getKeyAsHex( ) { - - if( null == this.key) return null; - return Util.bytes2HexString(key); - } - - - public Data setKey( byte[] bytes ) { - - this.key = bytes; - return this; - } - - - public byte[] getIvAsBin( ) { - - return this.iv; - } - - - public String getIvAsStr( ) { - - if( null == this.iv) return null; - return Arrays.toString(this.iv); - } - - - public String getIvAsHex( ) { - - if( null == this.iv) return null; - return Util.bytes2HexString(iv); - } - - - public Data setIv( byte[] bytes ) { - - this.iv = bytes; - return this; - } - - - public byte[] getMACDataLenAsBin( ) { - - return this.mACDataLen; - } - - - public String getMACDataLenAsStr( ) { - - if( null == this.mACDataLen) return null; - return Arrays.toString(this.mACDataLen); - } - - - public String getMACDataLenAsHex( ) { - - if( null == this.mACDataLen) return null; - return Util.bytes2HexString(mACDataLen); - } - - - public Data setMACDataLen( byte[] bytes ) { - - this.mACDataLen = bytes; - return this; - } - - - public byte[] getMACDataAsBin( ) { - - return this.mACData; - } - - - public String getMACDataAsStr( ) { - - if( null == this.mACData) return null; - return Arrays.toString(this.mACData); - } - - - public String getMACDataAsHex( ) { - - if( null == this.mACData) return null; - return Util.bytes2HexString(mACData); - } - - - public Data setMACData( byte[] bytes ) { - - this.mACData = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != block ){ - soup.put("block", this.block); - } - - if( null != keyType ){ - soup.put("keyType", this.keyType); - soup.put("keyType$option", getKeyTypeOptionIndex()); - } - - if( null != mode ){ - soup.put("mode", this.mode); - soup.put("mode$option", getModeOptionIndex()); - } - - if( null != dataType ){ - soup.put("dataType", this.dataType); - soup.put("dataType$option", getDataTypeOptionIndex()); - } - - if( null != key ){ - soup.put("key", this.key); - } - - if( null != iv ){ - soup.put("iv", this.iv); - } - - if( null != mACDataLen ){ - soup.put("MACDataLen", this.mACDataLen); - } - - if( null != mACData ){ - soup.put("MACData", this.mACData); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("block") ){ - this.block = ((PacketSection) soup.get("block")).getBytes(); - } - - if( soup.containsKey("keyType") ){ - this.keyType = ((PacketSection) soup.get("keyType")).getBytes(); - } - - if( soup.containsKey("mode") ){ - this.mode = ((PacketSection) soup.get("mode")).getBytes(); - } - - if( soup.containsKey("dataType") ){ - this.dataType = ((PacketSection) soup.get("dataType")).getBytes(); - } - - if( soup.containsKey("key") ){ - this.key = ((PacketSection) soup.get("key")).getBytes(); - } - - if( soup.containsKey("iv") ){ - this.iv = ((PacketSection) soup.get("iv")).getBytes(); - } - - if( soup.containsKey("MACDataLen") ){ - this.mACDataLen = ((PacketSection) soup.get("MACDataLen")).getBytes(); - } - - if( soup.containsKey("MACData") ){ - this.mACData = ((PacketSection) soup.get("MACData")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4D55")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4D55"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] mAC = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPVTAK奇偶校验错(Util.hexString2Bytes("3130")), - OPV用户存储区没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误报告给管理员(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV无效的用户存储索引(Util.hexString2Bytes("3231")), - OPV密钥方案错误(Util.hexString2Bytes("3236")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "TAK奇偶校验错"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK错误;报告给管理员"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效的用户存储索引"; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return "密钥方案错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 7; - } - return null; - } - - - public byte[] getMACAsBin( ) { - - return this.mAC; - } - - - public String getMACAsStr( ) { - - if( null == this.mAC) return null; - return Arrays.toString(this.mAC); - } - - - public String getMACAsHex( ) { - - if( null == this.mAC) return null; - return Util.bytes2HexString(mAC); - } - - - public Data setMAC( byte[] bytes ) { - - this.mAC = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != mAC ){ - soup.put("MAC", this.mAC); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("MAC") ){ - this.mAC = ((PacketSection) soup.get("MAC")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4D56")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4D56"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTONE.java b/src/main/java/racal/sunyard/main/dto/DTONE.java deleted file mode 100644 index 71c3ea5..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTONE.java +++ /dev/null @@ -1,915 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTONE { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] keyType = null; - private byte[] solution = null; - private byte[] flag = null; - private byte[] print = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getKeyTypeAsBin( ) { - - return this.keyType; - } - - - public String getKeyTypeAsStr( ) { - - if( null == this.keyType) return null; - return Arrays.toString(this.keyType); - } - - - public String getKeyTypeAsHex( ) { - - if( null == this.keyType) return null; - return Util.bytes2HexString(keyType); - } - - - public Data setKeyType( byte[] bytes ) { - - this.keyType = bytes; - return this; - } - - - public byte[] getSolutionAsBin( ) { - - return this.solution; - } - - - public String getSolutionAsStr( ) { - - if( null == this.solution) return null; - return Arrays.toString(this.solution); - } - - - public String getSolutionAsHex( ) { - - if( null == this.solution) return null; - return Util.bytes2HexString(solution); - } - - - public Data setSolution( byte[] bytes ) { - - this.solution = bytes; - return this; - } - - - public byte[] getFlagAsBin( ) { - - return this.flag; - } - - - public String getFlagAsStr( ) { - - if( null == this.flag) return null; - return Arrays.toString(this.flag); - } - - - public String getFlagAsHex( ) { - - if( null == this.flag) return null; - return Util.bytes2HexString(flag); - } - - - public Data setFlag( byte[] bytes ) { - - this.flag = bytes; - return this; - } - - - public byte[] getPrintAsBin( ) { - - return this.print; - } - - - public String getPrintAsStr( ) { - - if( null == this.print) return null; - return Arrays.toString(this.print); - } - - - public String getPrintAsHex( ) { - - if( null == this.print) return null; - return Util.bytes2HexString(print); - } - - - public Data setPrint( byte[] bytes ) { - - this.print = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != keyType ){ - soup.put("keyType", this.keyType); - } - - if( null != solution ){ - soup.put("solution", this.solution); - } - - if( null != flag ){ - soup.put("flag", this.flag); - } - - if( null != print ){ - soup.put("print", this.print); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("keyType") ){ - this.keyType = ((PacketSection) soup.get("keyType")).getBytes(); - } - - if( soup.containsKey("solution") ){ - this.solution = ((PacketSection) soup.get("solution")).getBytes(); - } - - if( soup.containsKey("flag") ){ - this.flag = ((PacketSection) soup.get("flag")).getBytes(); - } - - if( soup.containsKey("print") ){ - this.print = ((PacketSection) soup.get("print")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4E45")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4E45"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] keyHead = null; - private byte[] key = null; - private byte[] keyCheck = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV密钥奇偶校验错(Util.hexString2Bytes("3031")), - OPVZMK奇偶校验错(Util.hexString2Bytes("3130")), - OPV用户存储区中没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV不在授权状态(Util.hexString2Bytes("3137")), - OPV无效用户存储区索引(Util.hexString2Bytes("3231")), - OPV无效的密钥类型(Util.hexString2Bytes("3238")), - OPV无效的密钥方案(Util.hexString2Bytes("3236")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3031".equals(Util.bytes2HexString(this.error))) { - return "密钥奇偶校验错"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "ZMK 奇偶校验错"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区中没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3137".equals(Util.bytes2HexString(this.error))) { - return "不在授权状态"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效用户存储区索引"; - } - if( "3238".equals(Util.bytes2HexString(this.error))) { - return "无效的密钥类型"; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return "无效的密钥方案"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3031".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3137".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3238".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return 9; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 10; - } - return null; - } - - - public byte[] getKeyHeadAsBin( ) { - - return this.keyHead; - } - - - public String getKeyHeadAsStr( ) { - - if( null == this.keyHead) return null; - return Arrays.toString(this.keyHead); - } - - - public String getKeyHeadAsHex( ) { - - if( null == this.keyHead) return null; - return Util.bytes2HexString(keyHead); - } - - - public Data setKeyHead( byte[] bytes ) { - - this.keyHead = bytes; - return this; - } - - - public byte[] getKeyAsBin( ) { - - return this.key; - } - - - public String getKeyAsStr( ) { - - if( null == this.key) return null; - return Arrays.toString(this.key); - } - - - public String getKeyAsHex( ) { - - if( null == this.key) return null; - return Util.bytes2HexString(key); - } - - - public Data setKey( byte[] bytes ) { - - this.key = bytes; - return this; - } - - - public byte[] getKeyCheckAsBin( ) { - - return this.keyCheck; - } - - - public String getKeyCheckAsStr( ) { - - if( null == this.keyCheck) return null; - return Arrays.toString(this.keyCheck); - } - - - public String getKeyCheckAsHex( ) { - - if( null == this.keyCheck) return null; - return Util.bytes2HexString(keyCheck); - } - - - public Data setKeyCheck( byte[] bytes ) { - - this.keyCheck = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != keyHead ){ - soup.put("keyHead", this.keyHead); - } - - if( null != key ){ - soup.put("key", this.key); - } - - if( null != keyCheck ){ - soup.put("keyCheck", this.keyCheck); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("keyHead") ){ - this.keyHead = ((PacketSection) soup.get("keyHead")).getBytes(); - } - - if( soup.containsKey("key") ){ - this.key = ((PacketSection) soup.get("key")).getBytes(); - } - - if( soup.containsKey("keyCheck") ){ - this.keyCheck = ((PacketSection) soup.get("keyCheck")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4E46")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4E46"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTONG.java b/src/main/java/racal/sunyard/main/dto/DTONG.java deleted file mode 100644 index 97a23d0..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTONG.java +++ /dev/null @@ -1,803 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTONG { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] alg = null; - private byte[] pINBLOCK = null; - private byte[] account = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getAlgAsBin( ) { - - return this.alg; - } - - - public String getAlgAsStr( ) { - - if( null == this.alg) return null; - return Arrays.toString(this.alg); - } - - - public String getAlgAsHex( ) { - - if( null == this.alg) return null; - return Util.bytes2HexString(alg); - } - - - public Data setAlg( byte[] bytes ) { - - this.alg = bytes; - return this; - } -public enum AlgOptions { - - OPV3DES(Util.hexString2Bytes("30")), - OPVSM4(Util.hexString2Bytes("31")); - private byte[] bin; - AlgOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getAlgCn( ) { - - if( null == alg) { return null; } - if( "30".equals(Util.bytes2HexString(this.alg))) { - return "3DES"; - } - if( "31".equals(Util.bytes2HexString(this.alg))) { - return "SM4"; - } - return null; - } - - - public Integer getAlgOptionIndex( ) { - - if( null == alg) { return null; } - if( "30".equals(Util.bytes2HexString(this.alg))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.alg))) { - return 1; - } - return null; - } - - - public byte[] getPINBLOCKAsBin( ) { - - return this.pINBLOCK; - } - - - public String getPINBLOCKAsStr( ) { - - if( null == this.pINBLOCK) return null; - return Arrays.toString(this.pINBLOCK); - } - - - public String getPINBLOCKAsHex( ) { - - if( null == this.pINBLOCK) return null; - return Util.bytes2HexString(pINBLOCK); - } - - - public Data setPINBLOCK( byte[] bytes ) { - - this.pINBLOCK = bytes; - return this; - } - - - public byte[] getAccountAsBin( ) { - - return this.account; - } - - - public String getAccountAsStr( ) { - - if( null == this.account) return null; - return Arrays.toString(this.account); - } - - - public String getAccountAsHex( ) { - - if( null == this.account) return null; - return Util.bytes2HexString(account); - } - - - public Data setAccount( byte[] bytes ) { - - this.account = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != alg ){ - soup.put("alg", this.alg); - soup.put("alg$option", getAlgOptionIndex()); - } - - if( null != pINBLOCK ){ - soup.put("PINBLOCK", this.pINBLOCK); - } - - if( null != account ){ - soup.put("account", this.account); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("alg") ){ - this.alg = ((PacketSection) soup.get("alg")).getBytes(); - } - - if( soup.containsKey("PINBLOCK") ){ - this.pINBLOCK = ((PacketSection) soup.get("PINBLOCK")).getBytes(); - } - - if( soup.containsKey("account") ){ - this.account = ((PacketSection) soup.get("account")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4E47")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4E47"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] pIN = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV加密PIN错误(Util.hexString2Bytes("3134")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV不在授权状态(Util.hexString2Bytes("3137")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3134".equals(Util.bytes2HexString(this.error))) { - return "加密PIN错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3137".equals(Util.bytes2HexString(this.error))) { - return "不在授权状态"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3134".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3137".equals(Util.bytes2HexString(this.error))) { - return 4; - } - return null; - } - - - public byte[] getPINAsBin( ) { - - return this.pIN; - } - - - public String getPINAsStr( ) { - - if( null == this.pIN) return null; - return Arrays.toString(this.pIN); - } - - - public String getPINAsHex( ) { - - if( null == this.pIN) return null; - return Util.bytes2HexString(pIN); - } - - - public Data setPIN( byte[] bytes ) { - - this.pIN = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != pIN ){ - soup.put("PIN", this.pIN); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("PIN") ){ - this.pIN = ((PacketSection) soup.get("PIN")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4E48")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4E48"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOOC.java b/src/main/java/racal/sunyard/main/dto/DTOOC.java deleted file mode 100644 index 5467b27..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOOC.java +++ /dev/null @@ -1,930 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOOC { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] print = null; - private byte[] delimiter = null; - private byte[] zmkSolution = null; - private byte[] lmkSolution = null; - private byte[] keyCheckType = null; - private byte[] businessKey = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getPrintAsBin( ) { - - return this.print; - } - - - public String getPrintAsStr( ) { - - if( null == this.print) return null; - return Arrays.toString(this.print); - } - - - public String getPrintAsHex( ) { - - if( null == this.print) return null; - return Util.bytes2HexString(print); - } - - - public Data setPrint( byte[] bytes ) { - - this.print = bytes; - return this; - } - - - public byte[] getDelimiterAsBin( ) { - - return this.delimiter; - } - - - public String getDelimiterAsStr( ) { - - if( null == this.delimiter) return null; - return Arrays.toString(this.delimiter); - } - - - public String getDelimiterAsHex( ) { - - if( null == this.delimiter) return null; - return Util.bytes2HexString(delimiter); - } - - - public Data setDelimiter( byte[] bytes ) { - - this.delimiter = bytes; - return this; - } - - - public byte[] getZmkSolutionAsBin( ) { - - return this.zmkSolution; - } - - - public String getZmkSolutionAsStr( ) { - - if( null == this.zmkSolution) return null; - return Arrays.toString(this.zmkSolution); - } - - - public String getZmkSolutionAsHex( ) { - - if( null == this.zmkSolution) return null; - return Util.bytes2HexString(zmkSolution); - } - - - public Data setZmkSolution( byte[] bytes ) { - - this.zmkSolution = bytes; - return this; - } - - - public byte[] getLmkSolutionAsBin( ) { - - return this.lmkSolution; - } - - - public String getLmkSolutionAsStr( ) { - - if( null == this.lmkSolution) return null; - return Arrays.toString(this.lmkSolution); - } - - - public String getLmkSolutionAsHex( ) { - - if( null == this.lmkSolution) return null; - return Util.bytes2HexString(lmkSolution); - } - - - public Data setLmkSolution( byte[] bytes ) { - - this.lmkSolution = bytes; - return this; - } - - - public byte[] getKeyCheckTypeAsBin( ) { - - return this.keyCheckType; - } - - - public String getKeyCheckTypeAsStr( ) { - - if( null == this.keyCheckType) return null; - return Arrays.toString(this.keyCheckType); - } - - - public String getKeyCheckTypeAsHex( ) { - - if( null == this.keyCheckType) return null; - return Util.bytes2HexString(keyCheckType); - } - - - public Data setKeyCheckType( byte[] bytes ) { - - this.keyCheckType = bytes; - return this; - } - - - public byte[] getBusinessKeyAsBin( ) { - - return this.businessKey; - } - - - public String getBusinessKeyAsStr( ) { - - if( null == this.businessKey) return null; - return Arrays.toString(this.businessKey); - } - - - public String getBusinessKeyAsHex( ) { - - if( null == this.businessKey) return null; - return Util.bytes2HexString(businessKey); - } - - - public Data setBusinessKey( byte[] bytes ) { - - this.businessKey = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != print ){ - soup.put("print", this.print); - } - - if( null != delimiter ){ - soup.put("delimiter", this.delimiter); - } - - if( null != zmkSolution ){ - soup.put("zmkSolution", this.zmkSolution); - } - - if( null != lmkSolution ){ - soup.put("lmkSolution", this.lmkSolution); - } - - if( null != keyCheckType ){ - soup.put("keyCheckType", this.keyCheckType); - } - - if( null != businessKey ){ - soup.put("businessKey", this.businessKey); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("print") ){ - this.print = ((PacketSection) soup.get("print")).getBytes(); - } - - if( soup.containsKey("delimiter") ){ - this.delimiter = ((PacketSection) soup.get("delimiter")).getBytes(); - } - - if( soup.containsKey("zmkSolution") ){ - this.zmkSolution = ((PacketSection) soup.get("zmkSolution")).getBytes(); - } - - if( soup.containsKey("lmkSolution") ){ - this.lmkSolution = ((PacketSection) soup.get("lmkSolution")).getBytes(); - } - - if( soup.containsKey("keyCheckType") ){ - this.keyCheckType = ((PacketSection) soup.get("keyCheckType")).getBytes(); - } - - if( soup.containsKey("businessKey") ){ - this.businessKey = ((PacketSection) soup.get("businessKey")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4F43")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4F43"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] keyHead = null; - private byte[] key = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV密钥奇偶校验错(Util.hexString2Bytes("3031")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV打印机没有准备好(Util.hexString2Bytes("3136")), - OPV不在授权状态(Util.hexString2Bytes("3137")), - OPV没有装载格式定义(Util.hexString2Bytes("3138")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3031".equals(Util.bytes2HexString(this.error))) { - return "密钥奇偶校验错"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3136".equals(Util.bytes2HexString(this.error))) { - return "打印机没有准备好"; - } - if( "3137".equals(Util.bytes2HexString(this.error))) { - return "不在授权状态"; - } - if( "3138".equals(Util.bytes2HexString(this.error))) { - return "没有装载格式定义"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3031".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3136".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3137".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3138".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 7; - } - return null; - } - - - public byte[] getKeyHeadAsBin( ) { - - return this.keyHead; - } - - - public String getKeyHeadAsStr( ) { - - if( null == this.keyHead) return null; - return Arrays.toString(this.keyHead); - } - - - public String getKeyHeadAsHex( ) { - - if( null == this.keyHead) return null; - return Util.bytes2HexString(keyHead); - } - - - public Data setKeyHead( byte[] bytes ) { - - this.keyHead = bytes; - return this; - } - - - public byte[] getKeyAsBin( ) { - - return this.key; - } - - - public String getKeyAsStr( ) { - - if( null == this.key) return null; - return Arrays.toString(this.key); - } - - - public String getKeyAsHex( ) { - - if( null == this.key) return null; - return Util.bytes2HexString(key); - } - - - public Data setKey( byte[] bytes ) { - - this.key = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != keyHead ){ - soup.put("keyHead", this.keyHead); - } - - if( null != key ){ - soup.put("key", this.key); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("keyHead") ){ - this.keyHead = ((PacketSection) soup.get("keyHead")).getBytes(); - } - - if( soup.containsKey("key") ){ - this.key = ((PacketSection) soup.get("key")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("4F44")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("4F44"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOPA.java b/src/main/java/racal/sunyard/main/dto/DTOPA.java deleted file mode 100644 index 9b2cae0..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOPA.java +++ /dev/null @@ -1,692 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOPA { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] format = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getFormatAsBin( ) { - - return this.format; - } - - - public String getFormatAsStr( ) { - - if( null == this.format) return null; - return Arrays.toString(this.format); - } - - - public String getFormatAsHex( ) { - - if( null == this.format) return null; - return Util.bytes2HexString(format); - } - - - public Data setFormat( byte[] bytes ) { - - this.format = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != format ){ - soup.put("format", this.format); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("format") ){ - this.format = ((PacketSection) soup.get("format")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("5041")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("5041"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV公钥不符合编码规则(Util.hexString2Bytes("3034")), - OPV无效的加密标识(Util.hexString2Bytes("3036")), - OPV无效的附加模式标识(Util.hexString2Bytes("3037")), - OPV密钥奇偶校验错误(Util.hexString2Bytes("3130")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVDSP错误(Util.hexString2Bytes("3437")), - OPV密钥块长度错误(Util.hexString2Bytes("3736")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return "公钥不符合编码规则"; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return "无效的加密标识"; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return "无效的附加模式标识"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "密钥奇偶校验错误"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return "DSP 错误"; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return "密钥块长度错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 9; - } - return null; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("5042")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("5042"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOPE.java b/src/main/java/racal/sunyard/main/dto/DTOPE.java deleted file mode 100644 index 17f7dd6..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOPE.java +++ /dev/null @@ -1,953 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOPE { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] fileType = null; - private byte[] account = null; - private byte[] algorithmKey = null; - private byte[] encryptionAlg = null; - private byte[] pinBlock = null; - private byte[] pinLen = null; - private byte[] print = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getFileTypeAsBin( ) { - - return this.fileType; - } - - - public String getFileTypeAsStr( ) { - - if( null == this.fileType) return null; - return Arrays.toString(this.fileType); - } - - - public String getFileTypeAsHex( ) { - - if( null == this.fileType) return null; - return Util.bytes2HexString(fileType); - } - - - public Data setFileType( byte[] bytes ) { - - this.fileType = bytes; - return this; - } - - - public byte[] getAccountAsBin( ) { - - return this.account; - } - - - public String getAccountAsStr( ) { - - if( null == this.account) return null; - return Arrays.toString(this.account); - } - - - public String getAccountAsHex( ) { - - if( null == this.account) return null; - return Util.bytes2HexString(account); - } - - - public Data setAccount( byte[] bytes ) { - - this.account = bytes; - return this; - } - - - public byte[] getAlgorithmKeyAsBin( ) { - - return this.algorithmKey; - } - - - public String getAlgorithmKeyAsStr( ) { - - if( null == this.algorithmKey) return null; - return Arrays.toString(this.algorithmKey); - } - - - public String getAlgorithmKeyAsHex( ) { - - if( null == this.algorithmKey) return null; - return Util.bytes2HexString(algorithmKey); - } - - - public Data setAlgorithmKey( byte[] bytes ) { - - this.algorithmKey = bytes; - return this; - } - - - public byte[] getEncryptionAlgAsBin( ) { - - return this.encryptionAlg; - } - - - public String getEncryptionAlgAsStr( ) { - - if( null == this.encryptionAlg) return null; - return Arrays.toString(this.encryptionAlg); - } - - - public String getEncryptionAlgAsHex( ) { - - if( null == this.encryptionAlg) return null; - return Util.bytes2HexString(encryptionAlg); - } - - - public Data setEncryptionAlg( byte[] bytes ) { - - this.encryptionAlg = bytes; - return this; - } -public enum EncryptionAlgOptions { - - OPVDES(Util.hexString2Bytes("30")), - OPV3DES默认(Util.hexString2Bytes("31")), - OPVSM4(Util.hexString2Bytes("32")); - private byte[] bin; - EncryptionAlgOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getEncryptionAlgCn( ) { - - if( null == encryptionAlg) { return null; } - if( "30".equals(Util.bytes2HexString(this.encryptionAlg))) { - return "DES"; - } - if( "31".equals(Util.bytes2HexString(this.encryptionAlg))) { - return "3DES(默认)"; - } - if( "32".equals(Util.bytes2HexString(this.encryptionAlg))) { - return "SM4"; - } - return null; - } - - - public Integer getEncryptionAlgOptionIndex( ) { - - if( null == encryptionAlg) { return null; } - if( "30".equals(Util.bytes2HexString(this.encryptionAlg))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.encryptionAlg))) { - return 1; - } - if( "32".equals(Util.bytes2HexString(this.encryptionAlg))) { - return 2; - } - return null; - } - - - public byte[] getPinBlockAsBin( ) { - - return this.pinBlock; - } - - - public String getPinBlockAsStr( ) { - - if( null == this.pinBlock) return null; - return Arrays.toString(this.pinBlock); - } - - - public String getPinBlockAsHex( ) { - - if( null == this.pinBlock) return null; - return Util.bytes2HexString(pinBlock); - } - - - public Data setPinBlock( byte[] bytes ) { - - this.pinBlock = bytes; - return this; - } - - - public byte[] getPinLenAsBin( ) { - - return this.pinLen; - } - - - public String getPinLenAsStr( ) { - - if( null == this.pinLen) return null; - return Arrays.toString(this.pinLen); - } - - - public String getPinLenAsHex( ) { - - if( null == this.pinLen) return null; - return Util.bytes2HexString(pinLen); - } - - - public Data setPinLen( byte[] bytes ) { - - this.pinLen = bytes; - return this; - } - - - public byte[] getPrintAsBin( ) { - - return this.print; - } - - - public String getPrintAsStr( ) { - - if( null == this.print) return null; - return Arrays.toString(this.print); - } - - - public String getPrintAsHex( ) { - - if( null == this.print) return null; - return Util.bytes2HexString(print); - } - - - public Data setPrint( byte[] bytes ) { - - this.print = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != fileType ){ - soup.put("fileType", this.fileType); - } - - if( null != account ){ - soup.put("account", this.account); - } - - if( null != algorithmKey ){ - soup.put("algorithmKey", this.algorithmKey); - } - - if( null != encryptionAlg ){ - soup.put("encryptionAlg", this.encryptionAlg); - soup.put("encryptionAlg$option", getEncryptionAlgOptionIndex()); - } - - if( null != pinBlock ){ - soup.put("pinBlock", this.pinBlock); - } - - if( null != pinLen ){ - soup.put("pinLen", this.pinLen); - } - - if( null != print ){ - soup.put("print", this.print); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("fileType") ){ - this.fileType = ((PacketSection) soup.get("fileType")).getBytes(); - } - - if( soup.containsKey("account") ){ - this.account = ((PacketSection) soup.get("account")).getBytes(); - } - - if( soup.containsKey("algorithmKey") ){ - this.algorithmKey = ((PacketSection) soup.get("algorithmKey")).getBytes(); - } - - if( soup.containsKey("encryptionAlg") ){ - this.encryptionAlg = ((PacketSection) soup.get("encryptionAlg")).getBytes(); - } - - if( soup.containsKey("pinBlock") ){ - this.pinBlock = ((PacketSection) soup.get("pinBlock")).getBytes(); - } - - if( soup.containsKey("pinLen") ){ - this.pinLen = ((PacketSection) soup.get("pinLen")).getBytes(); - } - - if( soup.containsKey("print") ){ - this.print = ((PacketSection) soup.get("print")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("5045")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("5045"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV来自主机的PIN错误(Util.hexString2Bytes("3134")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV打印机没有准备好没有连接上(Util.hexString2Bytes("3136")), - OPV不在授权状态(Util.hexString2Bytes("3137")), - OPV没有装载格式定义(Util.hexString2Bytes("3138")), - OPVPIN块错误(Util.hexString2Bytes("3230")), - OPV无效的账号(Util.hexString2Bytes("3232")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3134".equals(Util.bytes2HexString(this.error))) { - return "来自主机的PIN错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3136".equals(Util.bytes2HexString(this.error))) { - return "打印机没有准备好,没有连接上"; - } - if( "3137".equals(Util.bytes2HexString(this.error))) { - return "不在授权状态"; - } - if( "3138".equals(Util.bytes2HexString(this.error))) { - return "没有装载格式定义"; - } - if( "3230".equals(Util.bytes2HexString(this.error))) { - return "PIN块错误"; - } - if( "3232".equals(Util.bytes2HexString(this.error))) { - return "无效的账号"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3134".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3136".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3137".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3138".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3230".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3232".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 9; - } - return null; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("5046")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("5046"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOQ1.java b/src/main/java/racal/sunyard/main/dto/DTOQ1.java deleted file mode 100644 index e8460d2..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOQ1.java +++ /dev/null @@ -1,1180 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOQ1 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] alg = null; - private byte[] roundModel = null; - private byte[] fullMode = null; - private byte[] dEK = null; - private byte[] businessKey = null; - private byte[] dataLength = null; - private byte[] infoData = null; - private byte[] vectorLength = null; - private byte[] vector = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getAlgAsBin( ) { - - return this.alg; - } - - - public String getAlgAsStr( ) { - - if( null == this.alg) return null; - return Arrays.toString(this.alg); - } - - - public String getAlgAsHex( ) { - - if( null == this.alg) return null; - return Util.bytes2HexString(alg); - } - - - public Data setAlg( byte[] bytes ) { - - this.alg = bytes; - return this; - } -public enum AlgOptions { - - OPVDES(Util.hexString2Bytes("31")), - OPV3DES(Util.hexString2Bytes("32")), - OPVIDEA(Util.hexString2Bytes("33")), - OPVSM1(Util.hexString2Bytes("34")), - OPVAES(Util.hexString2Bytes("35")), - OPVSM4(Util.hexString2Bytes("36")); - private byte[] bin; - AlgOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getAlgCn( ) { - - if( null == alg) { return null; } - if( "31".equals(Util.bytes2HexString(this.alg))) { - return "DES"; - } - if( "32".equals(Util.bytes2HexString(this.alg))) { - return "3DES"; - } - if( "33".equals(Util.bytes2HexString(this.alg))) { - return "IDEA"; - } - if( "34".equals(Util.bytes2HexString(this.alg))) { - return "SM1"; - } - if( "35".equals(Util.bytes2HexString(this.alg))) { - return "AES"; - } - if( "36".equals(Util.bytes2HexString(this.alg))) { - return "SM4"; - } - return null; - } - - - public Integer getAlgOptionIndex( ) { - - if( null == alg) { return null; } - if( "31".equals(Util.bytes2HexString(this.alg))) { - return 0; - } - if( "32".equals(Util.bytes2HexString(this.alg))) { - return 1; - } - if( "33".equals(Util.bytes2HexString(this.alg))) { - return 2; - } - if( "34".equals(Util.bytes2HexString(this.alg))) { - return 3; - } - if( "35".equals(Util.bytes2HexString(this.alg))) { - return 4; - } - if( "36".equals(Util.bytes2HexString(this.alg))) { - return 5; - } - return null; - } - - - public byte[] getRoundModelAsBin( ) { - - return this.roundModel; - } - - - public String getRoundModelAsStr( ) { - - if( null == this.roundModel) return null; - return Arrays.toString(this.roundModel); - } - - - public String getRoundModelAsHex( ) { - - if( null == this.roundModel) return null; - return Util.bytes2HexString(roundModel); - } - - - public Data setRoundModel( byte[] bytes ) { - - this.roundModel = bytes; - return this; - } -public enum RoundModelOptions { - - OPVECB(Util.hexString2Bytes("31")), - OPVCBC(Util.hexString2Bytes("32")), - OPVCFB(Util.hexString2Bytes("33")), - OPVOFB(Util.hexString2Bytes("34")); - private byte[] bin; - RoundModelOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getRoundModelCn( ) { - - if( null == roundModel) { return null; } - if( "31".equals(Util.bytes2HexString(this.roundModel))) { - return "ECB"; - } - if( "32".equals(Util.bytes2HexString(this.roundModel))) { - return "CBC"; - } - if( "33".equals(Util.bytes2HexString(this.roundModel))) { - return "CFB"; - } - if( "34".equals(Util.bytes2HexString(this.roundModel))) { - return "OFB"; - } - return null; - } - - - public Integer getRoundModelOptionIndex( ) { - - if( null == roundModel) { return null; } - if( "31".equals(Util.bytes2HexString(this.roundModel))) { - return 0; - } - if( "32".equals(Util.bytes2HexString(this.roundModel))) { - return 1; - } - if( "33".equals(Util.bytes2HexString(this.roundModel))) { - return 2; - } - if( "34".equals(Util.bytes2HexString(this.roundModel))) { - return 3; - } - return null; - } - - - public byte[] getFullModeAsBin( ) { - - return this.fullMode; - } - - - public String getFullModeAsStr( ) { - - if( null == this.fullMode) return null; - return Arrays.toString(this.fullMode); - } - - - public String getFullModeAsHex( ) { - - if( null == this.fullMode) return null; - return Util.bytes2HexString(fullMode); - } - - - public Data setFullMode( byte[] bytes ) { - - this.fullMode = bytes; - return this; - } -public enum FullModeOptions { - - OPV0(Util.hexString2Bytes("30")), - OPV1(Util.hexString2Bytes("31")), - OPV2(Util.hexString2Bytes("32")); - private byte[] bin; - FullModeOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getFullModeCn( ) { - - if( null == fullMode) { return null; } - if( "30".equals(Util.bytes2HexString(this.fullMode))) { - return "0"; - } - if( "31".equals(Util.bytes2HexString(this.fullMode))) { - return "1"; - } - if( "32".equals(Util.bytes2HexString(this.fullMode))) { - return "2"; - } - return null; - } - - - public Integer getFullModeOptionIndex( ) { - - if( null == fullMode) { return null; } - if( "30".equals(Util.bytes2HexString(this.fullMode))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.fullMode))) { - return 1; - } - if( "32".equals(Util.bytes2HexString(this.fullMode))) { - return 2; - } - return null; - } - - - public byte[] getDEKAsBin( ) { - - return this.dEK; - } - - - public String getDEKAsStr( ) { - - if( null == this.dEK) return null; - return Arrays.toString(this.dEK); - } - - - public String getDEKAsHex( ) { - - if( null == this.dEK) return null; - return Util.bytes2HexString(dEK); - } - - - public Data setDEK( byte[] bytes ) { - - this.dEK = bytes; - return this; - } - - - public byte[] getBusinessKeyAsBin( ) { - - return this.businessKey; - } - - - public String getBusinessKeyAsStr( ) { - - if( null == this.businessKey) return null; - return Arrays.toString(this.businessKey); - } - - - public String getBusinessKeyAsHex( ) { - - if( null == this.businessKey) return null; - return Util.bytes2HexString(businessKey); - } - - - public Data setBusinessKey( byte[] bytes ) { - - this.businessKey = bytes; - return this; - } - - - public byte[] getDataLengthAsBin( ) { - - return this.dataLength; - } - - - public String getDataLengthAsStr( ) { - - if( null == this.dataLength) return null; - return Arrays.toString(this.dataLength); - } - - - public String getDataLengthAsHex( ) { - - if( null == this.dataLength) return null; - return Util.bytes2HexString(dataLength); - } - - - public Data setDataLength( byte[] bytes ) { - - this.dataLength = bytes; - return this; - } - - - public byte[] getInfoDataAsBin( ) { - - return this.infoData; - } - - - public String getInfoDataAsStr( ) { - - if( null == this.infoData) return null; - return Arrays.toString(this.infoData); - } - - - public String getInfoDataAsHex( ) { - - if( null == this.infoData) return null; - return Util.bytes2HexString(infoData); - } - - - public Data setInfoData( byte[] bytes ) { - - this.infoData = bytes; - return this; - } - - - public byte[] getVectorLengthAsBin( ) { - - return this.vectorLength; - } - - - public String getVectorLengthAsStr( ) { - - if( null == this.vectorLength) return null; - return Arrays.toString(this.vectorLength); - } - - - public String getVectorLengthAsHex( ) { - - if( null == this.vectorLength) return null; - return Util.bytes2HexString(vectorLength); - } - - - public Data setVectorLength( byte[] bytes ) { - - this.vectorLength = bytes; - return this; - } - - - public byte[] getVectorAsBin( ) { - - return this.vector; - } - - - public String getVectorAsStr( ) { - - if( null == this.vector) return null; - return Arrays.toString(this.vector); - } - - - public String getVectorAsHex( ) { - - if( null == this.vector) return null; - return Util.bytes2HexString(vector); - } - - - public Data setVector( byte[] bytes ) { - - this.vector = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != alg ){ - soup.put("alg", this.alg); - soup.put("alg$option", getAlgOptionIndex()); - } - - if( null != roundModel ){ - soup.put("roundModel", this.roundModel); - soup.put("roundModel$option", getRoundModelOptionIndex()); - } - - if( null != fullMode ){ - soup.put("fullMode", this.fullMode); - soup.put("fullMode$option", getFullModeOptionIndex()); - } - - if( null != dEK ){ - soup.put("DEK", this.dEK); - } - - if( null != businessKey ){ - soup.put("businessKey", this.businessKey); - } - - if( null != dataLength ){ - soup.put("dataLength", this.dataLength); - } - - if( null != infoData ){ - soup.put("infoData", this.infoData); - } - - if( null != vectorLength ){ - soup.put("vectorLength", this.vectorLength); - } - - if( null != vector ){ - soup.put("vector", this.vector); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("alg") ){ - this.alg = ((PacketSection) soup.get("alg")).getBytes(); - } - - if( soup.containsKey("roundModel") ){ - this.roundModel = ((PacketSection) soup.get("roundModel")).getBytes(); - } - - if( soup.containsKey("fullMode") ){ - this.fullMode = ((PacketSection) soup.get("fullMode")).getBytes(); - } - - if( soup.containsKey("DEK") ){ - this.dEK = ((PacketSection) soup.get("DEK")).getBytes(); - } - - if( soup.containsKey("businessKey") ){ - this.businessKey = ((PacketSection) soup.get("businessKey")).getBytes(); - } - - if( soup.containsKey("dataLength") ){ - this.dataLength = ((PacketSection) soup.get("dataLength")).getBytes(); - } - - if( soup.containsKey("infoData") ){ - this.infoData = ((PacketSection) soup.get("infoData")).getBytes(); - } - - if( soup.containsKey("vectorLength") ){ - this.vectorLength = ((PacketSection) soup.get("vectorLength")).getBytes(); - } - - if( soup.containsKey("vector") ){ - this.vector = ((PacketSection) soup.get("vector")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("5131")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("5131"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] dataLength = null; - private byte[] infoData = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPVLMK错误报告给管理员(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV密钥方案错误(Util.hexString2Bytes("3236")), - OPV数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK错误;报告给管理员"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return "密钥方案错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 4; - } - return null; - } - - - public byte[] getDataLengthAsBin( ) { - - return this.dataLength; - } - - - public String getDataLengthAsStr( ) { - - if( null == this.dataLength) return null; - return Arrays.toString(this.dataLength); - } - - - public String getDataLengthAsHex( ) { - - if( null == this.dataLength) return null; - return Util.bytes2HexString(dataLength); - } - - - public Data setDataLength( byte[] bytes ) { - - this.dataLength = bytes; - return this; - } - - - public byte[] getInfoDataAsBin( ) { - - return this.infoData; - } - - - public String getInfoDataAsStr( ) { - - if( null == this.infoData) return null; - return Arrays.toString(this.infoData); - } - - - public String getInfoDataAsHex( ) { - - if( null == this.infoData) return null; - return Util.bytes2HexString(infoData); - } - - - public Data setInfoData( byte[] bytes ) { - - this.infoData = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != dataLength ){ - soup.put("dataLength", this.dataLength); - } - - if( null != infoData ){ - soup.put("infoData", this.infoData); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("dataLength") ){ - this.dataLength = ((PacketSection) soup.get("dataLength")).getBytes(); - } - - if( soup.containsKey("infoData") ){ - this.infoData = ((PacketSection) soup.get("infoData")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("5132")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("5132"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOQ2.java b/src/main/java/racal/sunyard/main/dto/DTOQ2.java deleted file mode 100644 index 25a330c..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOQ2.java +++ /dev/null @@ -1,1180 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOQ2 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] alg = null; - private byte[] roundModel = null; - private byte[] fullMode = null; - private byte[] dEK = null; - private byte[] businessKey = null; - private byte[] dataLength = null; - private byte[] infoData = null; - private byte[] vectorLength = null; - private byte[] vector = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getAlgAsBin( ) { - - return this.alg; - } - - - public String getAlgAsStr( ) { - - if( null == this.alg) return null; - return Arrays.toString(this.alg); - } - - - public String getAlgAsHex( ) { - - if( null == this.alg) return null; - return Util.bytes2HexString(alg); - } - - - public Data setAlg( byte[] bytes ) { - - this.alg = bytes; - return this; - } -public enum AlgOptions { - - OPVDES(Util.hexString2Bytes("31")), - OPV3DES(Util.hexString2Bytes("32")), - OPVIDEA(Util.hexString2Bytes("33")), - OPVSM1(Util.hexString2Bytes("34")), - OPVAES(Util.hexString2Bytes("35")), - OPVSM4(Util.hexString2Bytes("36")); - private byte[] bin; - AlgOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getAlgCn( ) { - - if( null == alg) { return null; } - if( "31".equals(Util.bytes2HexString(this.alg))) { - return "DES"; - } - if( "32".equals(Util.bytes2HexString(this.alg))) { - return "3DES"; - } - if( "33".equals(Util.bytes2HexString(this.alg))) { - return "IDEA"; - } - if( "34".equals(Util.bytes2HexString(this.alg))) { - return "SM1"; - } - if( "35".equals(Util.bytes2HexString(this.alg))) { - return "AES"; - } - if( "36".equals(Util.bytes2HexString(this.alg))) { - return "SM4"; - } - return null; - } - - - public Integer getAlgOptionIndex( ) { - - if( null == alg) { return null; } - if( "31".equals(Util.bytes2HexString(this.alg))) { - return 0; - } - if( "32".equals(Util.bytes2HexString(this.alg))) { - return 1; - } - if( "33".equals(Util.bytes2HexString(this.alg))) { - return 2; - } - if( "34".equals(Util.bytes2HexString(this.alg))) { - return 3; - } - if( "35".equals(Util.bytes2HexString(this.alg))) { - return 4; - } - if( "36".equals(Util.bytes2HexString(this.alg))) { - return 5; - } - return null; - } - - - public byte[] getRoundModelAsBin( ) { - - return this.roundModel; - } - - - public String getRoundModelAsStr( ) { - - if( null == this.roundModel) return null; - return Arrays.toString(this.roundModel); - } - - - public String getRoundModelAsHex( ) { - - if( null == this.roundModel) return null; - return Util.bytes2HexString(roundModel); - } - - - public Data setRoundModel( byte[] bytes ) { - - this.roundModel = bytes; - return this; - } -public enum RoundModelOptions { - - OPVECB(Util.hexString2Bytes("31")), - OPVCBC(Util.hexString2Bytes("32")), - OPVCFB(Util.hexString2Bytes("33")), - OPVOFB(Util.hexString2Bytes("34")); - private byte[] bin; - RoundModelOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getRoundModelCn( ) { - - if( null == roundModel) { return null; } - if( "31".equals(Util.bytes2HexString(this.roundModel))) { - return "ECB"; - } - if( "32".equals(Util.bytes2HexString(this.roundModel))) { - return "CBC"; - } - if( "33".equals(Util.bytes2HexString(this.roundModel))) { - return "CFB"; - } - if( "34".equals(Util.bytes2HexString(this.roundModel))) { - return "OFB"; - } - return null; - } - - - public Integer getRoundModelOptionIndex( ) { - - if( null == roundModel) { return null; } - if( "31".equals(Util.bytes2HexString(this.roundModel))) { - return 0; - } - if( "32".equals(Util.bytes2HexString(this.roundModel))) { - return 1; - } - if( "33".equals(Util.bytes2HexString(this.roundModel))) { - return 2; - } - if( "34".equals(Util.bytes2HexString(this.roundModel))) { - return 3; - } - return null; - } - - - public byte[] getFullModeAsBin( ) { - - return this.fullMode; - } - - - public String getFullModeAsStr( ) { - - if( null == this.fullMode) return null; - return Arrays.toString(this.fullMode); - } - - - public String getFullModeAsHex( ) { - - if( null == this.fullMode) return null; - return Util.bytes2HexString(fullMode); - } - - - public Data setFullMode( byte[] bytes ) { - - this.fullMode = bytes; - return this; - } -public enum FullModeOptions { - - OPV0(Util.hexString2Bytes("30")), - OPV1(Util.hexString2Bytes("31")), - OPV2(Util.hexString2Bytes("32")); - private byte[] bin; - FullModeOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getFullModeCn( ) { - - if( null == fullMode) { return null; } - if( "30".equals(Util.bytes2HexString(this.fullMode))) { - return "0"; - } - if( "31".equals(Util.bytes2HexString(this.fullMode))) { - return "1"; - } - if( "32".equals(Util.bytes2HexString(this.fullMode))) { - return "2"; - } - return null; - } - - - public Integer getFullModeOptionIndex( ) { - - if( null == fullMode) { return null; } - if( "30".equals(Util.bytes2HexString(this.fullMode))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.fullMode))) { - return 1; - } - if( "32".equals(Util.bytes2HexString(this.fullMode))) { - return 2; - } - return null; - } - - - public byte[] getDEKAsBin( ) { - - return this.dEK; - } - - - public String getDEKAsStr( ) { - - if( null == this.dEK) return null; - return Arrays.toString(this.dEK); - } - - - public String getDEKAsHex( ) { - - if( null == this.dEK) return null; - return Util.bytes2HexString(dEK); - } - - - public Data setDEK( byte[] bytes ) { - - this.dEK = bytes; - return this; - } - - - public byte[] getBusinessKeyAsBin( ) { - - return this.businessKey; - } - - - public String getBusinessKeyAsStr( ) { - - if( null == this.businessKey) return null; - return Arrays.toString(this.businessKey); - } - - - public String getBusinessKeyAsHex( ) { - - if( null == this.businessKey) return null; - return Util.bytes2HexString(businessKey); - } - - - public Data setBusinessKey( byte[] bytes ) { - - this.businessKey = bytes; - return this; - } - - - public byte[] getDataLengthAsBin( ) { - - return this.dataLength; - } - - - public String getDataLengthAsStr( ) { - - if( null == this.dataLength) return null; - return Arrays.toString(this.dataLength); - } - - - public String getDataLengthAsHex( ) { - - if( null == this.dataLength) return null; - return Util.bytes2HexString(dataLength); - } - - - public Data setDataLength( byte[] bytes ) { - - this.dataLength = bytes; - return this; - } - - - public byte[] getInfoDataAsBin( ) { - - return this.infoData; - } - - - public String getInfoDataAsStr( ) { - - if( null == this.infoData) return null; - return Arrays.toString(this.infoData); - } - - - public String getInfoDataAsHex( ) { - - if( null == this.infoData) return null; - return Util.bytes2HexString(infoData); - } - - - public Data setInfoData( byte[] bytes ) { - - this.infoData = bytes; - return this; - } - - - public byte[] getVectorLengthAsBin( ) { - - return this.vectorLength; - } - - - public String getVectorLengthAsStr( ) { - - if( null == this.vectorLength) return null; - return Arrays.toString(this.vectorLength); - } - - - public String getVectorLengthAsHex( ) { - - if( null == this.vectorLength) return null; - return Util.bytes2HexString(vectorLength); - } - - - public Data setVectorLength( byte[] bytes ) { - - this.vectorLength = bytes; - return this; - } - - - public byte[] getVectorAsBin( ) { - - return this.vector; - } - - - public String getVectorAsStr( ) { - - if( null == this.vector) return null; - return Arrays.toString(this.vector); - } - - - public String getVectorAsHex( ) { - - if( null == this.vector) return null; - return Util.bytes2HexString(vector); - } - - - public Data setVector( byte[] bytes ) { - - this.vector = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != alg ){ - soup.put("alg", this.alg); - soup.put("alg$option", getAlgOptionIndex()); - } - - if( null != roundModel ){ - soup.put("roundModel", this.roundModel); - soup.put("roundModel$option", getRoundModelOptionIndex()); - } - - if( null != fullMode ){ - soup.put("fullMode", this.fullMode); - soup.put("fullMode$option", getFullModeOptionIndex()); - } - - if( null != dEK ){ - soup.put("DEK", this.dEK); - } - - if( null != businessKey ){ - soup.put("businessKey", this.businessKey); - } - - if( null != dataLength ){ - soup.put("dataLength", this.dataLength); - } - - if( null != infoData ){ - soup.put("infoData", this.infoData); - } - - if( null != vectorLength ){ - soup.put("vectorLength", this.vectorLength); - } - - if( null != vector ){ - soup.put("vector", this.vector); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("alg") ){ - this.alg = ((PacketSection) soup.get("alg")).getBytes(); - } - - if( soup.containsKey("roundModel") ){ - this.roundModel = ((PacketSection) soup.get("roundModel")).getBytes(); - } - - if( soup.containsKey("fullMode") ){ - this.fullMode = ((PacketSection) soup.get("fullMode")).getBytes(); - } - - if( soup.containsKey("DEK") ){ - this.dEK = ((PacketSection) soup.get("DEK")).getBytes(); - } - - if( soup.containsKey("businessKey") ){ - this.businessKey = ((PacketSection) soup.get("businessKey")).getBytes(); - } - - if( soup.containsKey("dataLength") ){ - this.dataLength = ((PacketSection) soup.get("dataLength")).getBytes(); - } - - if( soup.containsKey("infoData") ){ - this.infoData = ((PacketSection) soup.get("infoData")).getBytes(); - } - - if( soup.containsKey("vectorLength") ){ - this.vectorLength = ((PacketSection) soup.get("vectorLength")).getBytes(); - } - - if( soup.containsKey("vector") ){ - this.vector = ((PacketSection) soup.get("vector")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("5132")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("5132"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] dataLength = null; - private byte[] infoData = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPVLMK错误报告给管理员(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV密钥方案错误(Util.hexString2Bytes("3236")), - OPV数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK错误;报告给管理员"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return "密钥方案错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 4; - } - return null; - } - - - public byte[] getDataLengthAsBin( ) { - - return this.dataLength; - } - - - public String getDataLengthAsStr( ) { - - if( null == this.dataLength) return null; - return Arrays.toString(this.dataLength); - } - - - public String getDataLengthAsHex( ) { - - if( null == this.dataLength) return null; - return Util.bytes2HexString(dataLength); - } - - - public Data setDataLength( byte[] bytes ) { - - this.dataLength = bytes; - return this; - } - - - public byte[] getInfoDataAsBin( ) { - - return this.infoData; - } - - - public String getInfoDataAsStr( ) { - - if( null == this.infoData) return null; - return Arrays.toString(this.infoData); - } - - - public String getInfoDataAsHex( ) { - - if( null == this.infoData) return null; - return Util.bytes2HexString(infoData); - } - - - public Data setInfoData( byte[] bytes ) { - - this.infoData = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != dataLength ){ - soup.put("dataLength", this.dataLength); - } - - if( null != infoData ){ - soup.put("infoData", this.infoData); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("dataLength") ){ - this.dataLength = ((PacketSection) soup.get("dataLength")).getBytes(); - } - - if( soup.containsKey("infoData") ){ - this.infoData = ((PacketSection) soup.get("infoData")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("5133")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("5133"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOQN.java b/src/main/java/racal/sunyard/main/dto/DTOQN.java deleted file mode 100644 index e5e2cb0..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOQN.java +++ /dev/null @@ -1,691 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOQN { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] keyLen = null; - private byte[] sk = null; - private byte[] startTime = null; - private byte[] endTime = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getKeyLenAsBin( ) { - - return this.keyLen; - } - - - public String getKeyLenAsStr( ) { - - if( null == this.keyLen) return null; - return Arrays.toString(this.keyLen); - } - - - public String getKeyLenAsHex( ) { - - if( null == this.keyLen) return null; - return Util.bytes2HexString(keyLen); - } - - - public Data setKeyLen( byte[] bytes ) { - - this.keyLen = bytes; - return this; - } - - - public byte[] getSkAsBin( ) { - - return this.sk; - } - - - public String getSkAsStr( ) { - - if( null == this.sk) return null; - return Arrays.toString(this.sk); - } - - - public String getSkAsHex( ) { - - if( null == this.sk) return null; - return Util.bytes2HexString(sk); - } - - - public Data setSk( byte[] bytes ) { - - this.sk = bytes; - return this; - } - - - public byte[] getStartTimeAsBin( ) { - - return this.startTime; - } - - - public String getStartTimeAsStr( ) { - - if( null == this.startTime) return null; - return Arrays.toString(this.startTime); - } - - - public String getStartTimeAsHex( ) { - - if( null == this.startTime) return null; - return Util.bytes2HexString(startTime); - } - - - public Data setStartTime( byte[] bytes ) { - - this.startTime = bytes; - return this; - } - - - public byte[] getEndTimeAsBin( ) { - - return this.endTime; - } - - - public String getEndTimeAsStr( ) { - - if( null == this.endTime) return null; - return Arrays.toString(this.endTime); - } - - - public String getEndTimeAsHex( ) { - - if( null == this.endTime) return null; - return Util.bytes2HexString(endTime); - } - - - public Data setEndTime( byte[] bytes ) { - - this.endTime = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - soup.put("keyLen", Util.hexString2Bytes("30323536")); - if( null != keyLen ){ - soup.put("keyLen", this.keyLen); - } - - if( null != sk ){ - soup.put("sk", this.sk); - } - - if( null != startTime ){ - soup.put("startTime", this.startTime); - } - - if( null != endTime ){ - soup.put("endTime", this.endTime); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - this.keyLen = Util.hexString2Bytes("30323536"); - if( soup.containsKey("keyLen") ){ - this.keyLen = ((PacketSection) soup.get("keyLen")).getBytes(); - } - - if( soup.containsKey("sk") ){ - this.sk = ((PacketSection) soup.get("sk")).getBytes(); - } - - if( soup.containsKey("startTime") ){ - this.startTime = ((PacketSection) soup.get("startTime")).getBytes(); - } - - if( soup.containsKey("endTime") ){ - this.endTime = ((PacketSection) soup.get("endTime")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("514E")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("514E"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] pk = null; - private byte[] sk = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV无效的哈希标识(Util.hexString2Bytes("3035")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVDSP错误(Util.hexString2Bytes("3437")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3035".equals(Util.bytes2HexString(this.error))) { - return "无效的哈希标识"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return "DSP 错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3035".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 4; - } - return null; - } - - - public byte[] getPkAsBin( ) { - - return this.pk; - } - - - public String getPkAsStr( ) { - - if( null == this.pk) return null; - return Arrays.toString(this.pk); - } - - - public String getPkAsHex( ) { - - if( null == this.pk) return null; - return Util.bytes2HexString(pk); - } - - - public Data setPk( byte[] bytes ) { - - this.pk = bytes; - return this; - } - - - public byte[] getSkAsBin( ) { - - return this.sk; - } - - - public String getSkAsStr( ) { - - if( null == this.sk) return null; - return Arrays.toString(this.sk); - } - - - public String getSkAsHex( ) { - - if( null == this.sk) return null; - return Util.bytes2HexString(sk); - } - - - public Data setSk( byte[] bytes ) { - - this.sk = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != pk ){ - soup.put("pk", this.pk); - } - - if( null != sk ){ - soup.put("sk", this.sk); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("pk") ){ - this.pk = ((PacketSection) soup.get("pk")).getBytes(); - } - - if( soup.containsKey("sk") ){ - this.sk = ((PacketSection) soup.get("sk")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("514F")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("514F"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOQQ.java b/src/main/java/racal/sunyard/main/dto/DTOQQ.java deleted file mode 100644 index 8c69123..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOQQ.java +++ /dev/null @@ -1,718 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOQQ { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] privateKeyTag = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getPrivateKeyTagAsBin( ) { - - return this.privateKeyTag; - } - - - public String getPrivateKeyTagAsStr( ) { - - if( null == this.privateKeyTag) return null; - return Arrays.toString(this.privateKeyTag); - } - - - public String getPrivateKeyTagAsHex( ) { - - if( null == this.privateKeyTag) return null; - return Util.bytes2HexString(privateKeyTag); - } - - - public Data setPrivateKeyTag( byte[] bytes ) { - - this.privateKeyTag = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != privateKeyTag ){ - soup.put("privateKeyTag", this.privateKeyTag); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("privateKeyTag") ){ - this.privateKeyTag = ((PacketSection) soup.get("privateKeyTag")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("5151")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("5151"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] publicLen = null; - private byte[] publicKey = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV无效的私钥类型(Util.hexString2Bytes("3033")), - OPV无效私钥标记(Util.hexString2Bytes("3034")), - OPV无效的哈希标识(Util.hexString2Bytes("3035")), - OPV无效的签名标识(Util.hexString2Bytes("3036")), - OPV无效的附加标识(Util.hexString2Bytes("3037")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVDSP错误(Util.hexString2Bytes("3437")), - OPV私钥错误(Util.hexString2Bytes("3439")), - OPV无效摘要信息语法仅仅无哈希模式(Util.hexString2Bytes("3734")), - OPV公钥长度错误(Util.hexString2Bytes("3736")), - OPV私钥长度错误(Util.hexString2Bytes("3738")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3033".equals(Util.bytes2HexString(this.error))) { - return "无效的私钥类型"; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return "无效私钥标记"; - } - if( "3035".equals(Util.bytes2HexString(this.error))) { - return "无效的哈希标识"; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return "无效的签名标识"; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return "无效的附加标识"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return "DSP 错误"; - } - if( "3439".equals(Util.bytes2HexString(this.error))) { - return "私钥错误"; - } - if( "3734".equals(Util.bytes2HexString(this.error))) { - return "无效摘要信息语法(仅仅无哈希模式)"; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return "公钥长度错误"; - } - if( "3738".equals(Util.bytes2HexString(this.error))) { - return "私钥长度错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3033".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3035".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3439".equals(Util.bytes2HexString(this.error))) { - return 9; - } - if( "3734".equals(Util.bytes2HexString(this.error))) { - return 10; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return 11; - } - if( "3738".equals(Util.bytes2HexString(this.error))) { - return 12; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 13; - } - return null; - } - - - public byte[] getPublicLenAsBin( ) { - - return this.publicLen; - } - - - public String getPublicLenAsStr( ) { - - if( null == this.publicLen) return null; - return Arrays.toString(this.publicLen); - } - - - public String getPublicLenAsHex( ) { - - if( null == this.publicLen) return null; - return Util.bytes2HexString(publicLen); - } - - - public Data setPublicLen( byte[] bytes ) { - - this.publicLen = bytes; - return this; - } - - - public byte[] getPublicKeyAsBin( ) { - - return this.publicKey; - } - - - public String getPublicKeyAsStr( ) { - - if( null == this.publicKey) return null; - return Arrays.toString(this.publicKey); - } - - - public String getPublicKeyAsHex( ) { - - if( null == this.publicKey) return null; - return Util.bytes2HexString(publicKey); - } - - - public Data setPublicKey( byte[] bytes ) { - - this.publicKey = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != publicLen ){ - soup.put("publicLen", this.publicLen); - } - - if( null != publicKey ){ - soup.put("publicKey", this.publicKey); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("publicLen") ){ - this.publicLen = ((PacketSection) soup.get("publicLen")).getBytes(); - } - - if( soup.containsKey("publicKey") ){ - this.publicKey = ((PacketSection) soup.get("publicKey")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("5152")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("5152"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOQX.java b/src/main/java/racal/sunyard/main/dto/DTOQX.java deleted file mode 100644 index 7091eb5..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOQX.java +++ /dev/null @@ -1,718 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOQX { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] privateKeyTag = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getPrivateKeyTagAsBin( ) { - - return this.privateKeyTag; - } - - - public String getPrivateKeyTagAsStr( ) { - - if( null == this.privateKeyTag) return null; - return Arrays.toString(this.privateKeyTag); - } - - - public String getPrivateKeyTagAsHex( ) { - - if( null == this.privateKeyTag) return null; - return Util.bytes2HexString(privateKeyTag); - } - - - public Data setPrivateKeyTag( byte[] bytes ) { - - this.privateKeyTag = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != privateKeyTag ){ - soup.put("privateKeyTag", this.privateKeyTag); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("privateKeyTag") ){ - this.privateKeyTag = ((PacketSection) soup.get("privateKeyTag")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("5158")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("5158"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] publicLen = null; - private byte[] publicKey = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV无效的私钥类型(Util.hexString2Bytes("3033")), - OPV无效私钥标记(Util.hexString2Bytes("3034")), - OPV无效的哈希标识(Util.hexString2Bytes("3035")), - OPV无效的签名标识(Util.hexString2Bytes("3036")), - OPV无效的附加标识(Util.hexString2Bytes("3037")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPVDSP错误(Util.hexString2Bytes("3437")), - OPV私钥错误(Util.hexString2Bytes("3439")), - OPV无效摘要信息语法仅仅无哈希模式(Util.hexString2Bytes("3734")), - OPV公钥长度错误(Util.hexString2Bytes("3736")), - OPV私钥长度错误(Util.hexString2Bytes("3738")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3033".equals(Util.bytes2HexString(this.error))) { - return "无效的私钥类型"; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return "无效私钥标记"; - } - if( "3035".equals(Util.bytes2HexString(this.error))) { - return "无效的哈希标识"; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return "无效的签名标识"; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return "无效的附加标识"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return "DSP 错误"; - } - if( "3439".equals(Util.bytes2HexString(this.error))) { - return "私钥错误"; - } - if( "3734".equals(Util.bytes2HexString(this.error))) { - return "无效摘要信息语法(仅仅无哈希模式)"; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return "公钥长度错误"; - } - if( "3738".equals(Util.bytes2HexString(this.error))) { - return "私钥长度错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3033".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3034".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3035".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3036".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3037".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3439".equals(Util.bytes2HexString(this.error))) { - return 9; - } - if( "3734".equals(Util.bytes2HexString(this.error))) { - return 10; - } - if( "3736".equals(Util.bytes2HexString(this.error))) { - return 11; - } - if( "3738".equals(Util.bytes2HexString(this.error))) { - return 12; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 13; - } - return null; - } - - - public byte[] getPublicLenAsBin( ) { - - return this.publicLen; - } - - - public String getPublicLenAsStr( ) { - - if( null == this.publicLen) return null; - return Arrays.toString(this.publicLen); - } - - - public String getPublicLenAsHex( ) { - - if( null == this.publicLen) return null; - return Util.bytes2HexString(publicLen); - } - - - public Data setPublicLen( byte[] bytes ) { - - this.publicLen = bytes; - return this; - } - - - public byte[] getPublicKeyAsBin( ) { - - return this.publicKey; - } - - - public String getPublicKeyAsStr( ) { - - if( null == this.publicKey) return null; - return Arrays.toString(this.publicKey); - } - - - public String getPublicKeyAsHex( ) { - - if( null == this.publicKey) return null; - return Util.bytes2HexString(publicKey); - } - - - public Data setPublicKey( byte[] bytes ) { - - this.publicKey = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != publicLen ){ - soup.put("publicLen", this.publicLen); - } - - if( null != publicKey ){ - soup.put("publicKey", this.publicKey); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("publicLen") ){ - this.publicLen = ((PacketSection) soup.get("publicLen")).getBytes(); - } - - if( soup.containsKey("publicKey") ){ - this.publicKey = ((PacketSection) soup.get("publicKey")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("5159")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("5159"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOTC.java b/src/main/java/racal/sunyard/main/dto/DTOTC.java deleted file mode 100644 index d800de5..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOTC.java +++ /dev/null @@ -1,771 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOTC { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] type = null; - private byte[] key = null; - private byte[] print = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getTypeAsBin( ) { - - return this.type; - } - - - public String getTypeAsStr( ) { - - if( null == this.type) return null; - return Arrays.toString(this.type); - } - - - public String getTypeAsHex( ) { - - if( null == this.type) return null; - return Util.bytes2HexString(type); - } - - - public Data setType( byte[] bytes ) { - - this.type = bytes; - return this; - } - - - public byte[] getKeyAsBin( ) { - - return this.key; - } - - - public String getKeyAsStr( ) { - - if( null == this.key) return null; - return Arrays.toString(this.key); - } - - - public String getKeyAsHex( ) { - - if( null == this.key) return null; - return Util.bytes2HexString(key); - } - - - public Data setKey( byte[] bytes ) { - - this.key = bytes; - return this; - } - - - public byte[] getPrintAsBin( ) { - - return this.print; - } - - - public String getPrintAsStr( ) { - - if( null == this.print) return null; - return Arrays.toString(this.print); - } - - - public String getPrintAsHex( ) { - - if( null == this.print) return null; - return Util.bytes2HexString(print); - } - - - public Data setPrint( byte[] bytes ) { - - this.print = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != type ){ - soup.put("type", this.type); - } - - if( null != key ){ - soup.put("key", this.key); - } - - if( null != print ){ - soup.put("print", this.print); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("type") ){ - this.type = ((PacketSection) soup.get("type")).getBytes(); - } - - if( soup.containsKey("key") ){ - this.key = ((PacketSection) soup.get("key")).getBytes(); - } - - if( soup.containsKey("print") ){ - this.print = ((PacketSection) soup.get("print")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("5443")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("5443"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV密钥奇偶校验错(Util.hexString2Bytes("3031")), - OPVZMK奇偶校验错(Util.hexString2Bytes("3130")), - OPV用户存储区中没有装载密钥(Util.hexString2Bytes("3132")), - OPVLMK错误(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV不在授权状态(Util.hexString2Bytes("3137")), - OPV无效用户存储区索引(Util.hexString2Bytes("3231")), - OPV无效的密钥类型(Util.hexString2Bytes("3238")), - OPV无效的密钥方案(Util.hexString2Bytes("3236")), - OPV输入数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3031".equals(Util.bytes2HexString(this.error))) { - return "密钥奇偶校验错"; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return "ZMK 奇偶校验错"; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return "用户存储区中没有装载密钥"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK 错误"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3137".equals(Util.bytes2HexString(this.error))) { - return "不在授权状态"; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return "无效用户存储区索引"; - } - if( "3238".equals(Util.bytes2HexString(this.error))) { - return "无效的密钥类型"; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return "无效的密钥方案"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "输入数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3031".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3130".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3132".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 4; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 5; - } - if( "3137".equals(Util.bytes2HexString(this.error))) { - return 6; - } - if( "3231".equals(Util.bytes2HexString(this.error))) { - return 7; - } - if( "3238".equals(Util.bytes2HexString(this.error))) { - return 8; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return 9; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 10; - } - return null; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("5444")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("5444"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOY0.java b/src/main/java/racal/sunyard/main/dto/DTOY0.java deleted file mode 100644 index 318a36f..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOY0.java +++ /dev/null @@ -1,1275 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOY0 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] srcKeyType = null; - private byte[] sca = null; - private byte[] desKeyType = null; - private byte[] dca = null; - private byte[] roundModel = null; - private byte[] sDEK = null; - private byte[] dDEK = null; - private byte[] dataLength = null; - private byte[] infoData = null; - private byte[] vectorLength = null; - private byte[] vector = null; - private byte[] businessKey = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getSrcKeyTypeAsBin( ) { - - return this.srcKeyType; - } - - - public String getSrcKeyTypeAsStr( ) { - - if( null == this.srcKeyType) return null; - return Arrays.toString(this.srcKeyType); - } - - - public String getSrcKeyTypeAsHex( ) { - - if( null == this.srcKeyType) return null; - return Util.bytes2HexString(srcKeyType); - } - - - public Data setSrcKeyType( byte[] bytes ) { - - this.srcKeyType = bytes; - return this; - } - - - public byte[] getScaAsBin( ) { - - return this.sca; - } - - - public String getScaAsStr( ) { - - if( null == this.sca) return null; - return Arrays.toString(this.sca); - } - - - public String getScaAsHex( ) { - - if( null == this.sca) return null; - return Util.bytes2HexString(sca); - } - - - public Data setSca( byte[] bytes ) { - - this.sca = bytes; - return this; - } -public enum ScaOptions { - - OPVDES(Util.hexString2Bytes("31")), - OPV3DES(Util.hexString2Bytes("32")), - OPVIDEA(Util.hexString2Bytes("33")), - OPVSM1(Util.hexString2Bytes("34")), - OPVAES(Util.hexString2Bytes("35")), - OPVSM4(Util.hexString2Bytes("36")); - private byte[] bin; - ScaOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getScaCn( ) { - - if( null == sca) { return null; } - if( "31".equals(Util.bytes2HexString(this.sca))) { - return "DES"; - } - if( "32".equals(Util.bytes2HexString(this.sca))) { - return "3DES"; - } - if( "33".equals(Util.bytes2HexString(this.sca))) { - return "IDEA"; - } - if( "34".equals(Util.bytes2HexString(this.sca))) { - return "SM1"; - } - if( "35".equals(Util.bytes2HexString(this.sca))) { - return "AES"; - } - if( "36".equals(Util.bytes2HexString(this.sca))) { - return "SM4"; - } - return null; - } - - - public Integer getScaOptionIndex( ) { - - if( null == sca) { return null; } - if( "31".equals(Util.bytes2HexString(this.sca))) { - return 0; - } - if( "32".equals(Util.bytes2HexString(this.sca))) { - return 1; - } - if( "33".equals(Util.bytes2HexString(this.sca))) { - return 2; - } - if( "34".equals(Util.bytes2HexString(this.sca))) { - return 3; - } - if( "35".equals(Util.bytes2HexString(this.sca))) { - return 4; - } - if( "36".equals(Util.bytes2HexString(this.sca))) { - return 5; - } - return null; - } - - - public byte[] getDesKeyTypeAsBin( ) { - - return this.desKeyType; - } - - - public String getDesKeyTypeAsStr( ) { - - if( null == this.desKeyType) return null; - return Arrays.toString(this.desKeyType); - } - - - public String getDesKeyTypeAsHex( ) { - - if( null == this.desKeyType) return null; - return Util.bytes2HexString(desKeyType); - } - - - public Data setDesKeyType( byte[] bytes ) { - - this.desKeyType = bytes; - return this; - } - - - public byte[] getDcaAsBin( ) { - - return this.dca; - } - - - public String getDcaAsStr( ) { - - if( null == this.dca) return null; - return Arrays.toString(this.dca); - } - - - public String getDcaAsHex( ) { - - if( null == this.dca) return null; - return Util.bytes2HexString(dca); - } - - - public Data setDca( byte[] bytes ) { - - this.dca = bytes; - return this; - } -public enum DcaOptions { - - OPVDES(Util.hexString2Bytes("31")), - OPV3DES(Util.hexString2Bytes("32")), - OPVIDEA(Util.hexString2Bytes("33")), - OPVSM1(Util.hexString2Bytes("34")), - OPVAES(Util.hexString2Bytes("35")), - OPVSM4(Util.hexString2Bytes("36")); - private byte[] bin; - DcaOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getDcaCn( ) { - - if( null == dca) { return null; } - if( "31".equals(Util.bytes2HexString(this.dca))) { - return "DES"; - } - if( "32".equals(Util.bytes2HexString(this.dca))) { - return "3DES"; - } - if( "33".equals(Util.bytes2HexString(this.dca))) { - return "IDEA"; - } - if( "34".equals(Util.bytes2HexString(this.dca))) { - return "SM1"; - } - if( "35".equals(Util.bytes2HexString(this.dca))) { - return "AES"; - } - if( "36".equals(Util.bytes2HexString(this.dca))) { - return "SM4"; - } - return null; - } - - - public Integer getDcaOptionIndex( ) { - - if( null == dca) { return null; } - if( "31".equals(Util.bytes2HexString(this.dca))) { - return 0; - } - if( "32".equals(Util.bytes2HexString(this.dca))) { - return 1; - } - if( "33".equals(Util.bytes2HexString(this.dca))) { - return 2; - } - if( "34".equals(Util.bytes2HexString(this.dca))) { - return 3; - } - if( "35".equals(Util.bytes2HexString(this.dca))) { - return 4; - } - if( "36".equals(Util.bytes2HexString(this.dca))) { - return 5; - } - return null; - } - - - public byte[] getRoundModelAsBin( ) { - - return this.roundModel; - } - - - public String getRoundModelAsStr( ) { - - if( null == this.roundModel) return null; - return Arrays.toString(this.roundModel); - } - - - public String getRoundModelAsHex( ) { - - if( null == this.roundModel) return null; - return Util.bytes2HexString(roundModel); - } - - - public Data setRoundModel( byte[] bytes ) { - - this.roundModel = bytes; - return this; - } -public enum RoundModelOptions { - - OPVECB(Util.hexString2Bytes("31")), - OPVCBC(Util.hexString2Bytes("32")), - OPVCFB(Util.hexString2Bytes("33")), - OPVOFB(Util.hexString2Bytes("34")); - private byte[] bin; - RoundModelOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getRoundModelCn( ) { - - if( null == roundModel) { return null; } - if( "31".equals(Util.bytes2HexString(this.roundModel))) { - return "ECB"; - } - if( "32".equals(Util.bytes2HexString(this.roundModel))) { - return "CBC"; - } - if( "33".equals(Util.bytes2HexString(this.roundModel))) { - return "CFB"; - } - if( "34".equals(Util.bytes2HexString(this.roundModel))) { - return "OFB"; - } - return null; - } - - - public Integer getRoundModelOptionIndex( ) { - - if( null == roundModel) { return null; } - if( "31".equals(Util.bytes2HexString(this.roundModel))) { - return 0; - } - if( "32".equals(Util.bytes2HexString(this.roundModel))) { - return 1; - } - if( "33".equals(Util.bytes2HexString(this.roundModel))) { - return 2; - } - if( "34".equals(Util.bytes2HexString(this.roundModel))) { - return 3; - } - return null; - } - - - public byte[] getSDEKAsBin( ) { - - return this.sDEK; - } - - - public String getSDEKAsStr( ) { - - if( null == this.sDEK) return null; - return Arrays.toString(this.sDEK); - } - - - public String getSDEKAsHex( ) { - - if( null == this.sDEK) return null; - return Util.bytes2HexString(sDEK); - } - - - public Data setSDEK( byte[] bytes ) { - - this.sDEK = bytes; - return this; - } - - - public byte[] getDDEKAsBin( ) { - - return this.dDEK; - } - - - public String getDDEKAsStr( ) { - - if( null == this.dDEK) return null; - return Arrays.toString(this.dDEK); - } - - - public String getDDEKAsHex( ) { - - if( null == this.dDEK) return null; - return Util.bytes2HexString(dDEK); - } - - - public Data setDDEK( byte[] bytes ) { - - this.dDEK = bytes; - return this; - } - - - public byte[] getDataLengthAsBin( ) { - - return this.dataLength; - } - - - public String getDataLengthAsStr( ) { - - if( null == this.dataLength) return null; - return Arrays.toString(this.dataLength); - } - - - public String getDataLengthAsHex( ) { - - if( null == this.dataLength) return null; - return Util.bytes2HexString(dataLength); - } - - - public Data setDataLength( byte[] bytes ) { - - this.dataLength = bytes; - return this; - } - - - public byte[] getInfoDataAsBin( ) { - - return this.infoData; - } - - - public String getInfoDataAsStr( ) { - - if( null == this.infoData) return null; - return Arrays.toString(this.infoData); - } - - - public String getInfoDataAsHex( ) { - - if( null == this.infoData) return null; - return Util.bytes2HexString(infoData); - } - - - public Data setInfoData( byte[] bytes ) { - - this.infoData = bytes; - return this; - } - - - public byte[] getVectorLengthAsBin( ) { - - return this.vectorLength; - } - - - public String getVectorLengthAsStr( ) { - - if( null == this.vectorLength) return null; - return Arrays.toString(this.vectorLength); - } - - - public String getVectorLengthAsHex( ) { - - if( null == this.vectorLength) return null; - return Util.bytes2HexString(vectorLength); - } - - - public Data setVectorLength( byte[] bytes ) { - - this.vectorLength = bytes; - return this; - } - - - public byte[] getVectorAsBin( ) { - - return this.vector; - } - - - public String getVectorAsStr( ) { - - if( null == this.vector) return null; - return Arrays.toString(this.vector); - } - - - public String getVectorAsHex( ) { - - if( null == this.vector) return null; - return Util.bytes2HexString(vector); - } - - - public Data setVector( byte[] bytes ) { - - this.vector = bytes; - return this; - } - - - public byte[] getBusinessKeyAsBin( ) { - - return this.businessKey; - } - - - public String getBusinessKeyAsStr( ) { - - if( null == this.businessKey) return null; - return Arrays.toString(this.businessKey); - } - - - public String getBusinessKeyAsHex( ) { - - if( null == this.businessKey) return null; - return Util.bytes2HexString(businessKey); - } - - - public Data setBusinessKey( byte[] bytes ) { - - this.businessKey = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != srcKeyType ){ - soup.put("srcKeyType", this.srcKeyType); - } - - if( null != sca ){ - soup.put("sca", this.sca); - soup.put("sca$option", getScaOptionIndex()); - } - - if( null != desKeyType ){ - soup.put("desKeyType", this.desKeyType); - } - - if( null != dca ){ - soup.put("dca", this.dca); - soup.put("dca$option", getDcaOptionIndex()); - } - - if( null != roundModel ){ - soup.put("roundModel", this.roundModel); - soup.put("roundModel$option", getRoundModelOptionIndex()); - } - - if( null != sDEK ){ - soup.put("sDEK", this.sDEK); - } - - if( null != dDEK ){ - soup.put("dDEK", this.dDEK); - } - - if( null != dataLength ){ - soup.put("dataLength", this.dataLength); - } - - if( null != infoData ){ - soup.put("infoData", this.infoData); - } - - if( null != vectorLength ){ - soup.put("vectorLength", this.vectorLength); - } - - if( null != vector ){ - soup.put("vector", this.vector); - } - - soup.put("businessKey", Util.hexString2Bytes("4E")); - if( null != businessKey ){ - soup.put("businessKey", this.businessKey); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("srcKeyType") ){ - this.srcKeyType = ((PacketSection) soup.get("srcKeyType")).getBytes(); - } - - if( soup.containsKey("sca") ){ - this.sca = ((PacketSection) soup.get("sca")).getBytes(); - } - - if( soup.containsKey("desKeyType") ){ - this.desKeyType = ((PacketSection) soup.get("desKeyType")).getBytes(); - } - - if( soup.containsKey("dca") ){ - this.dca = ((PacketSection) soup.get("dca")).getBytes(); - } - - if( soup.containsKey("roundModel") ){ - this.roundModel = ((PacketSection) soup.get("roundModel")).getBytes(); - } - - if( soup.containsKey("sDEK") ){ - this.sDEK = ((PacketSection) soup.get("sDEK")).getBytes(); - } - - if( soup.containsKey("dDEK") ){ - this.dDEK = ((PacketSection) soup.get("dDEK")).getBytes(); - } - - if( soup.containsKey("dataLength") ){ - this.dataLength = ((PacketSection) soup.get("dataLength")).getBytes(); - } - - if( soup.containsKey("infoData") ){ - this.infoData = ((PacketSection) soup.get("infoData")).getBytes(); - } - - if( soup.containsKey("vectorLength") ){ - this.vectorLength = ((PacketSection) soup.get("vectorLength")).getBytes(); - } - - if( soup.containsKey("vector") ){ - this.vector = ((PacketSection) soup.get("vector")).getBytes(); - } - - this.businessKey = Util.hexString2Bytes("4E"); - if( soup.containsKey("businessKey") ){ - this.businessKey = ((PacketSection) soup.get("businessKey")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("5930")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("5930"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] cipherData = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPVLMK错误报告给管理员(Util.hexString2Bytes("3133")), - OPV输入数据有误(Util.hexString2Bytes("3135")), - OPV密钥方案错误(Util.hexString2Bytes("3236")), - OPV数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK错误;报告给管理员"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据有误"; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return "密钥方案错误"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3236".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 4; - } - return null; - } - - - public byte[] getCipherDataAsBin( ) { - - return this.cipherData; - } - - - public String getCipherDataAsStr( ) { - - if( null == this.cipherData) return null; - return Arrays.toString(this.cipherData); - } - - - public String getCipherDataAsHex( ) { - - if( null == this.cipherData) return null; - return Util.bytes2HexString(cipherData); - } - - - public Data setCipherData( byte[] bytes ) { - - this.cipherData = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != cipherData ){ - soup.put("cipherData", this.cipherData); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("cipherData") ){ - this.cipherData = ((PacketSection) soup.get("cipherData")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("5931")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("5931"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOY8.java b/src/main/java/racal/sunyard/main/dto/DTOY8.java deleted file mode 100644 index 99dd06d..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOY8.java +++ /dev/null @@ -1,693 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOY8 { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] nRandomSize = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getNRandomSizeAsBin( ) { - - return this.nRandomSize; - } - - - public String getNRandomSizeAsStr( ) { - - if( null == this.nRandomSize) return null; - return Arrays.toString(this.nRandomSize); - } - - - public String getNRandomSizeAsHex( ) { - - if( null == this.nRandomSize) return null; - return Util.bytes2HexString(nRandomSize); - } - - - public Data setNRandomSize( byte[] bytes ) { - - this.nRandomSize = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != nRandomSize ){ - soup.put("nRandomSize", this.nRandomSize); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("nRandomSize") ){ - this.nRandomSize = ((PacketSection) soup.get("nRandomSize")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("5938")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("5938"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] random = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPV无效的哈希标识(Util.hexString2Bytes("3035")), - OPV输入数据有误(Util.hexString2Bytes("3135")), - OPVDSP错误报告给管理员(Util.hexString2Bytes("3437")), - OPV数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3035".equals(Util.bytes2HexString(this.error))) { - return "无效的哈希标识"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据有误"; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return "DSP:错误,报告给管理员"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3035".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3437".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 4; - } - return null; - } - - - public byte[] getRandomAsBin( ) { - - return this.random; - } - - - public String getRandomAsStr( ) { - - if( null == this.random) return null; - return Arrays.toString(this.random); - } - - - public String getRandomAsHex( ) { - - if( null == this.random) return null; - return Util.bytes2HexString(random); - } - - - public Data setRandom( byte[] bytes ) { - - this.random = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != random ){ - soup.put("random", this.random); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("random") ){ - this.random = ((PacketSection) soup.get("random")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("5939")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("5939"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/main/java/racal/sunyard/main/dto/DTOYA.java b/src/main/java/racal/sunyard/main/dto/DTOYA.java deleted file mode 100644 index 226bd48..0000000 --- a/src/main/java/racal/sunyard/main/dto/DTOYA.java +++ /dev/null @@ -1,1013 +0,0 @@ -package racal.sunyard.main.dto; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import racal.sunyard.main.script.*; -import com.sunyard.proto.section.*; -import com.sunyard.proto.*; -import com.sunyard.*; - -public class DTOYA { - public static class Req { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] mainKey = null; - private byte[] keyType = null; - private byte[] disperseNum = null; - private byte[] data = null; - private byte[] disperseAlg = null; - private byte[] keyCheckType = null; - private byte[] businessKey = null; - private byte[] tailSep = null; - private byte[] tail = null; - private Req wrapper = null; - - - public Data( Req wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getMainKeyAsBin( ) { - - return this.mainKey; - } - - - public String getMainKeyAsStr( ) { - - if( null == this.mainKey) return null; - return Arrays.toString(this.mainKey); - } - - - public String getMainKeyAsHex( ) { - - if( null == this.mainKey) return null; - return Util.bytes2HexString(mainKey); - } - - - public Data setMainKey( byte[] bytes ) { - - this.mainKey = bytes; - return this; - } - - - public byte[] getKeyTypeAsBin( ) { - - return this.keyType; - } - - - public String getKeyTypeAsStr( ) { - - if( null == this.keyType) return null; - return Arrays.toString(this.keyType); - } - - - public String getKeyTypeAsHex( ) { - - if( null == this.keyType) return null; - return Util.bytes2HexString(keyType); - } - - - public Data setKeyType( byte[] bytes ) { - - this.keyType = bytes; - return this; - } -public enum KeyTypeOptions { - - OPVDEK(Util.hexString2Bytes("303130")), - OPVTAK(Util.hexString2Bytes("303033")); - private byte[] bin; - KeyTypeOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getKeyTypeCn( ) { - - if( null == keyType) { return null; } - if( "303130".equals(Util.bytes2HexString(this.keyType))) { - return "DEK"; - } - if( "303033".equals(Util.bytes2HexString(this.keyType))) { - return "TAK"; - } - return null; - } - - - public Integer getKeyTypeOptionIndex( ) { - - if( null == keyType) { return null; } - if( "303130".equals(Util.bytes2HexString(this.keyType))) { - return 0; - } - if( "303033".equals(Util.bytes2HexString(this.keyType))) { - return 1; - } - return null; - } - - - public byte[] getDisperseNumAsBin( ) { - - return this.disperseNum; - } - - - public String getDisperseNumAsStr( ) { - - if( null == this.disperseNum) return null; - return Arrays.toString(this.disperseNum); - } - - - public String getDisperseNumAsHex( ) { - - if( null == this.disperseNum) return null; - return Util.bytes2HexString(disperseNum); - } - - - public Data setDisperseNum( byte[] bytes ) { - - this.disperseNum = bytes; - return this; - } - - - public byte[] getDataAsBin( ) { - - return this.data; - } - - - public String getDataAsStr( ) { - - if( null == this.data) return null; - return Arrays.toString(this.data); - } - - - public String getDataAsHex( ) { - - if( null == this.data) return null; - return Util.bytes2HexString(data); - } - - - public Data setData( byte[] bytes ) { - - this.data = bytes; - return this; - } - - - public byte[] getDisperseAlgAsBin( ) { - - return this.disperseAlg; - } - - - public String getDisperseAlgAsStr( ) { - - if( null == this.disperseAlg) return null; - return Arrays.toString(this.disperseAlg); - } - - - public String getDisperseAlgAsHex( ) { - - if( null == this.disperseAlg) return null; - return Util.bytes2HexString(disperseAlg); - } - - - public Data setDisperseAlg( byte[] bytes ) { - - this.disperseAlg = bytes; - return this; - } -public enum DisperseAlgOptions { - - OPVDES(Util.hexString2Bytes("31")), - OPV3DES(Util.hexString2Bytes("32")), - OPVIDEA(Util.hexString2Bytes("33")), - OPVSM1(Util.hexString2Bytes("34")), - OPVAES(Util.hexString2Bytes("35")), - OPVSM4(Util.hexString2Bytes("36")); - private byte[] bin; - DisperseAlgOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getDisperseAlgCn( ) { - - if( null == disperseAlg) { return null; } - if( "31".equals(Util.bytes2HexString(this.disperseAlg))) { - return "DES"; - } - if( "32".equals(Util.bytes2HexString(this.disperseAlg))) { - return "3DES"; - } - if( "33".equals(Util.bytes2HexString(this.disperseAlg))) { - return "IDEA"; - } - if( "34".equals(Util.bytes2HexString(this.disperseAlg))) { - return "SM1"; - } - if( "35".equals(Util.bytes2HexString(this.disperseAlg))) { - return "AES"; - } - if( "36".equals(Util.bytes2HexString(this.disperseAlg))) { - return "SM4"; - } - return null; - } - - - public Integer getDisperseAlgOptionIndex( ) { - - if( null == disperseAlg) { return null; } - if( "31".equals(Util.bytes2HexString(this.disperseAlg))) { - return 0; - } - if( "32".equals(Util.bytes2HexString(this.disperseAlg))) { - return 1; - } - if( "33".equals(Util.bytes2HexString(this.disperseAlg))) { - return 2; - } - if( "34".equals(Util.bytes2HexString(this.disperseAlg))) { - return 3; - } - if( "35".equals(Util.bytes2HexString(this.disperseAlg))) { - return 4; - } - if( "36".equals(Util.bytes2HexString(this.disperseAlg))) { - return 5; - } - return null; - } - - - public byte[] getKeyCheckTypeAsBin( ) { - - return this.keyCheckType; - } - - - public String getKeyCheckTypeAsStr( ) { - - if( null == this.keyCheckType) return null; - return Arrays.toString(this.keyCheckType); - } - - - public String getKeyCheckTypeAsHex( ) { - - if( null == this.keyCheckType) return null; - return Util.bytes2HexString(keyCheckType); - } - - - public Data setKeyCheckType( byte[] bytes ) { - - this.keyCheckType = bytes; - return this; - } -public enum KeyCheckTypeOptions { - - OPVKCV向后兼容(Util.hexString2Bytes("30")), - OPVKCV6H(Util.hexString2Bytes("31")); - private byte[] bin; - KeyCheckTypeOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getKeyCheckTypeCn( ) { - - if( null == keyCheckType) { return null; } - if( "30".equals(Util.bytes2HexString(this.keyCheckType))) { - return "KCV 向后兼容"; - } - if( "31".equals(Util.bytes2HexString(this.keyCheckType))) { - return "KCV 6H"; - } - return null; - } - - - public Integer getKeyCheckTypeOptionIndex( ) { - - if( null == keyCheckType) { return null; } - if( "30".equals(Util.bytes2HexString(this.keyCheckType))) { - return 0; - } - if( "31".equals(Util.bytes2HexString(this.keyCheckType))) { - return 1; - } - return null; - } - - - public byte[] getBusinessKeyAsBin( ) { - - return this.businessKey; - } - - - public String getBusinessKeyAsStr( ) { - - if( null == this.businessKey) return null; - return Arrays.toString(this.businessKey); - } - - - public String getBusinessKeyAsHex( ) { - - if( null == this.businessKey) return null; - return Util.bytes2HexString(businessKey); - } - - - public Data setBusinessKey( byte[] bytes ) { - - this.businessKey = bytes; - return this; - } - - - public byte[] getTailSepAsBin( ) { - - return this.tailSep; - } - - - public String getTailSepAsStr( ) { - - if( null == this.tailSep) return null; - return Arrays.toString(this.tailSep); - } - - - public String getTailSepAsHex( ) { - - if( null == this.tailSep) return null; - return Util.bytes2HexString(tailSep); - } - - - public Data setTailSep( byte[] bytes ) { - - this.tailSep = bytes; - return this; - } - - - public byte[] getTailAsBin( ) { - - return this.tail; - } - - - public String getTailAsStr( ) { - - if( null == this.tail) return null; - return Arrays.toString(this.tail); - } - - - public String getTailAsHex( ) { - - if( null == this.tail) return null; - return Util.bytes2HexString(tail); - } - - - public Data setTail( byte[] bytes ) { - - this.tail = bytes; - return this; - } - - - public Req closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != mainKey ){ - soup.put("mainKey", this.mainKey); - } - - if( null != keyType ){ - soup.put("keyType", this.keyType); - soup.put("keyType$option", getKeyTypeOptionIndex()); - } - - if( null != disperseNum ){ - soup.put("disperseNum", this.disperseNum); - } - - if( null != data ){ - soup.put("data", this.data); - } - - if( null != disperseAlg ){ - soup.put("disperseAlg", this.disperseAlg); - soup.put("disperseAlg$option", getDisperseAlgOptionIndex()); - } - - if( null != keyCheckType ){ - soup.put("keyCheckType", this.keyCheckType); - soup.put("keyCheckType$option", getKeyCheckTypeOptionIndex()); - } - - if( null != businessKey ){ - soup.put("businessKey", this.businessKey); - } - - soup.put("tailSep", Util.hexString2Bytes("3139")); - if( null != tailSep ){ - soup.put("tailSep", this.tailSep); - } - - if( null != tail ){ - soup.put("tail", this.tail); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("mainKey") ){ - this.mainKey = ((PacketSection) soup.get("mainKey")).getBytes(); - } - - if( soup.containsKey("keyType") ){ - this.keyType = ((PacketSection) soup.get("keyType")).getBytes(); - } - - if( soup.containsKey("disperseNum") ){ - this.disperseNum = ((PacketSection) soup.get("disperseNum")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = ((PacketSection) soup.get("data")).getBytes(); - } - - if( soup.containsKey("disperseAlg") ){ - this.disperseAlg = ((PacketSection) soup.get("disperseAlg")).getBytes(); - } - - if( soup.containsKey("keyCheckType") ){ - this.keyCheckType = ((PacketSection) soup.get("keyCheckType")).getBytes(); - } - - if( soup.containsKey("businessKey") ){ - this.businessKey = ((PacketSection) soup.get("businessKey")).getBytes(); - } - - this.tailSep = Util.hexString2Bytes("3139"); - if( soup.containsKey("tailSep") ){ - this.tailSep = ((PacketSection) soup.get("tailSep")).getBytes(); - } - - if( soup.containsKey("tail") ){ - this.tail = ((PacketSection) soup.get("tail")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Req setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Req setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Req setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("5941")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Req fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("5941"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - public static class Res { - private byte[] length = null; - private byte[] header = null; - private byte[] command = null; - private Data data = null; - public static class Data { - private byte[] error = null; - private byte[] lmk = null; - private byte[] keySign = null; - private Res wrapper = null; - - - public Data( Res wrapper ) { - - this.wrapper = wrapper; - } - - - public byte[] getErrorAsBin( ) { - - return this.error; - } - - - public String getErrorAsStr( ) { - - if( null == this.error) return null; - return Arrays.toString(this.error); - } - - - public String getErrorAsHex( ) { - - if( null == this.error) return null; - return Util.bytes2HexString(error); - } - - - public Data setError( byte[] bytes ) { - - this.error = bytes; - return this; - } -public enum ErrorOptions { - - OPV无错误(Util.hexString2Bytes("3030")), - OPVLMK错误报告给管理员(Util.hexString2Bytes("3133")), - OPV输入数据错(Util.hexString2Bytes("3135")), - OPV无效的密钥类型(Util.hexString2Bytes("3238")), - OPV数据长度错误(Util.hexString2Bytes("3830")); - private byte[] bin; - ErrorOptions(byte[] bin) { - this.bin = bin; - } - public byte[] getBin() { - return bin; - } - } - - public String getErrorCn( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return "无错误"; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return "LMK错误;报告给管理员"; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return "输入数据错"; - } - if( "3238".equals(Util.bytes2HexString(this.error))) { - return "无效的密钥类型"; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return "数据长度错误"; - } - return null; - } - - - public Integer getErrorOptionIndex( ) { - - if( null == error) { return null; } - if( "3030".equals(Util.bytes2HexString(this.error))) { - return 0; - } - if( "3133".equals(Util.bytes2HexString(this.error))) { - return 1; - } - if( "3135".equals(Util.bytes2HexString(this.error))) { - return 2; - } - if( "3238".equals(Util.bytes2HexString(this.error))) { - return 3; - } - if( "3830".equals(Util.bytes2HexString(this.error))) { - return 4; - } - return null; - } - - - public byte[] getLmkAsBin( ) { - - return this.lmk; - } - - - public String getLmkAsStr( ) { - - if( null == this.lmk) return null; - return Arrays.toString(this.lmk); - } - - - public String getLmkAsHex( ) { - - if( null == this.lmk) return null; - return Util.bytes2HexString(lmk); - } - - - public Data setLmk( byte[] bytes ) { - - this.lmk = bytes; - return this; - } - - - public byte[] getKeySignAsBin( ) { - - return this.keySign; - } - - - public String getKeySignAsStr( ) { - - if( null == this.keySign) return null; - return Arrays.toString(this.keySign); - } - - - public String getKeySignAsHex( ) { - - if( null == this.keySign) return null; - return Util.bytes2HexString(keySign); - } - - - public Data setKeySign( byte[] bytes ) { - - this.keySign = bytes; - return this; - } - - - public Res closeBuilding( ) { - - return this.wrapper; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != error ){ - soup.put("error", this.error); - soup.put("error$option", getErrorOptionIndex()); - } - - if( null != lmk ){ - soup.put("lmk", this.lmk); - } - - if( null != keySign ){ - soup.put("keySign", this.keySign); - } - - return soup; - } - - - public Data fullFromSoup( Map soup ) { - - if( soup.containsKey("error") ){ - this.error = ((PacketSection) soup.get("error")).getBytes(); - } - - if( soup.containsKey("lmk") ){ - this.lmk = ((PacketSection) soup.get("lmk")).getBytes(); - } - - if( soup.containsKey("keySign") ){ - this.keySign = ((PacketSection) soup.get("keySign")).getBytes(); - } - - return this; - } - - } - - - public byte[] getLengthAsBin( ) { - - return this.length; - } - - - public String getLengthAsStr( ) { - - if( null == this.length) return null; - return Arrays.toString(this.length); - } - - - public String getLengthAsHex( ) { - - if( null == this.length) return null; - return Util.bytes2HexString(length); - } - - - public Res setLength( byte[] bytes ) { - - this.length = bytes; - return this; - } - - - public byte[] getHeaderAsBin( ) { - - return this.header; - } - - - public String getHeaderAsStr( ) { - - if( null == this.header) return null; - return Arrays.toString(this.header); - } - - - public String getHeaderAsHex( ) { - - if( null == this.header) return null; - return Util.bytes2HexString(header); - } - - - public Res setHeader( byte[] bytes ) { - - this.header = bytes; - return this; - } - - - public byte[] getCommandAsBin( ) { - - return this.command; - } - - - public String getCommandAsStr( ) { - - if( null == this.command) return null; - return Arrays.toString(this.command); - } - - - public String getCommandAsHex( ) { - - if( null == this.command) return null; - return Util.bytes2HexString(command); - } - - - public Res setCommand( byte[] bytes ) { - - this.command = bytes; - return this; - } - - - public Data buildData( ) { - - this.data = new Data(this); - return this.data; - } - - - public Data newDataBuilder( ) { - - return new Data(this); - } - - - public Data getData( ) { - - return this.data; - } - - - public Map toSoup( ) { - - Map soup = new HashMap(); - if( null != length ){ - soup.put("length", this.length); - } - - if( null != header ){ - soup.put("header", this.header); - } - - soup.put("command", Util.hexString2Bytes("5942")); - if( null != command ){ - soup.put("command", this.command); - } - - if( null != data) { - soup.put("data", this.data.toSoup()); - } - return soup; - } - - - public Res fullFromSoup( Map soup ) { - - if( soup.containsKey("length") ){ - this.length = ((PacketSection) soup.get("length")).getBytes(); - } - - if( soup.containsKey("header") ){ - this.header = ((PacketSection) soup.get("header")).getBytes(); - } - - this.command = Util.hexString2Bytes("5942"); - if( soup.containsKey("command") ){ - this.command = ((PacketSection) soup.get("command")).getBytes(); - } - - if( soup.containsKey("data") ){ - this.data = new Data(this).fullFromSoup( (Map) soup.get("data")); - } - - return this; - } - - } - -} \ No newline at end of file diff --git a/src/test/java/com/sunyard/sydapi/test/TestAllMethods.java b/src/test/java/com/sunyard/sydapi/test/TestAllMethods.java index 0907d47..20199c9 100644 --- a/src/test/java/com/sunyard/sydapi/test/TestAllMethods.java +++ b/src/test/java/com/sunyard/sydapi/test/TestAllMethods.java @@ -1268,6 +1268,8 @@ public class TestAllMethods { String data = "111"; String s = api.netSign(sn, data.getBytes()); + System.out.println("签名: " + s); + boolean b = api.netVerify(sn, data.getBytes(), s); System.out.println(b); } @@ -1279,9 +1281,9 @@ public class TestAllMethods { String sn = "1004282451"; String userId = "1234567812345678"; String data = "111"; - String s = api.netSign(sn, userId, data.getBytes()); + String s = api.unPSign(sn, userId, data.getBytes()); - boolean b = api.netVerify(sn, userId, data.getBytes(), s); + boolean b = api.unPVerify(sn, userId, data.getBytes(), s); System.out.println(b); } @@ -1625,10 +1627,12 @@ public class TestAllMethods { // 8017 @Test public void testGetX509CertFileC() { - String userId = "8001"; + String userId = "8012"; String s = api.GetX509CertFileC(userId, 0); System.out.println(s); + + } // 测试通过