修改短链接、修改日志
This commit is contained in:
parent
719388494b
commit
004e6451ee
@ -14,7 +14,11 @@ import java.util.List;
|
|||||||
* 上海黄金交易所 - 数据库加密方案
|
* 上海黄金交易所 - 数据库加密方案
|
||||||
*/
|
*/
|
||||||
public class SydApi4Database implements SydApi {
|
public class SydApi4Database implements SydApi {
|
||||||
static Logger log = LogFactory.getLogger();
|
|
||||||
|
static {
|
||||||
|
SydApi.SYD_SetLogConfig("./logs/", 0);
|
||||||
|
}
|
||||||
|
|
||||||
private SydApi4j[] hsms = null;
|
private SydApi4j[] hsms = null;
|
||||||
private boolean isShortLinkMode = false;
|
private boolean isShortLinkMode = false;
|
||||||
|
|
||||||
@ -28,37 +32,36 @@ public class SydApi4Database implements SydApi {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SydApi SYD_Short_Connect_Ex(String[] pcIpList, int[] iPortList, int iConnectTimeOut, int allDealTimeOut) {
|
public SydApi SYD_Short_Connect_Ex(String[] pcIpList, int[] iPortList, int iConnectTimeOut, int allDealTimeOut) {
|
||||||
if (LogFactory.iLogLevel==3) {
|
Logger log = LogFactory.getLogger();
|
||||||
|
if (LogFactory.iLogLevel == 3) {
|
||||||
log.debug("SYD_Connect_Ex方法接收参数:pcIpList:{},iPortList:{},iConnectTimeOut:{},iDealTimeOut:{}", Arrays.toString(pcIpList), Arrays.toString(iPortList), iConnectTimeOut, allDealTimeOut);
|
log.debug("SYD_Connect_Ex方法接收参数:pcIpList:{},iPortList:{},iConnectTimeOut:{},iDealTimeOut:{}", Arrays.toString(pcIpList), Arrays.toString(iPortList), iConnectTimeOut, allDealTimeOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pcIpList.length!=iPortList.length) {
|
if (pcIpList.length != iPortList.length) {
|
||||||
throw new IllegalArgumentException("ip与端口数量不一致");
|
throw new IllegalArgumentException("ip与端口数量不一致");
|
||||||
}
|
}
|
||||||
|
|
||||||
SydApi4j[] apis = new SydApi4j[pcIpList.length];
|
SydApi4j[] apis = new SydApi4j[pcIpList.length];
|
||||||
int iDealTimeOut = allDealTimeOut / pcIpList.length;
|
int iDealTimeOut = allDealTimeOut / pcIpList.length;
|
||||||
boolean connected = false;
|
boolean connected = false;
|
||||||
for (int i = 0; i < pcIpList.length ; i++) {
|
for (int i = 0; i < pcIpList.length; i++) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
apis[i] = (SydApi4j) new SydApi4j().connect(pcIpList[i], iPortList[i], null, iConnectTimeOut, iDealTimeOut);
|
apis[i] = (SydApi4j) new SydApi4j().connect(pcIpList[i], iPortList[i], null, iConnectTimeOut, iDealTimeOut);
|
||||||
connected = true;
|
connected = true;
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch ( Exception e) {
|
|
||||||
// 忽略错误
|
// 忽略错误
|
||||||
log.error("网络连接错误 {} {} - 忽略",pcIpList[i], iPortList[i]);
|
log.error("网络连接错误 {} {} - 忽略", pcIpList[i], iPortList[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if( ! connected ) {
|
if (!connected) {
|
||||||
// TODO
|
// TODO
|
||||||
throw new SydApiException("连接错误",-1);
|
throw new SydApiException("连接错误", -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
hsms = apis;
|
hsms = apis;
|
||||||
isShortLinkMode = true;
|
isShortLinkMode = true;
|
||||||
return this;
|
return this;
|
||||||
@ -67,7 +70,7 @@ public class SydApi4Database implements SydApi {
|
|||||||
@Override
|
@Override
|
||||||
public void SYD_Disconnect_Ex() {
|
public void SYD_Disconnect_Ex() {
|
||||||
if (isShortLinkMode) {
|
if (isShortLinkMode) {
|
||||||
if ( null == hsms ){
|
if (null == hsms) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,7 +92,8 @@ public class SydApi4Database implements SydApi {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String SYD_SM3_Hash_ShortData(byte[] pcData) {
|
public String SYD_SM3_Hash_ShortData(byte[] pcData) {
|
||||||
if (LogFactory.iLogLevel==3) {
|
Logger log = LogFactory.getLogger();
|
||||||
|
if (LogFactory.iLogLevel == 3) {
|
||||||
log.debug("SYD_SM3_Hash_ShortData方法接收参数:pcData:{}", Arrays.toString(pcData));
|
log.debug("SYD_SM3_Hash_ShortData方法接收参数:pcData:{}", Arrays.toString(pcData));
|
||||||
}
|
}
|
||||||
if (null == this.hsms || this.hsms.length < 1) {
|
if (null == this.hsms || this.hsms.length < 1) {
|
||||||
@ -99,13 +103,13 @@ public class SydApi4Database implements SydApi {
|
|||||||
SydApiException le = null;
|
SydApiException le = null;
|
||||||
for (SydApi4j api : this.hsms) {
|
for (SydApi4j api : this.hsms) {
|
||||||
|
|
||||||
if ( null == api ) {
|
if (null == api) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
byte[] hash = api.SYD_SM3_LongData(pcData, null, 0);
|
byte[] hash = api.SYD_SM3_LongData(pcData, null, 0);
|
||||||
log.debug("api.SYD_SM3_LongData方法返回值:{}",Arrays.toString(hash));
|
log.debug("api.SYD_SM3_LongData方法返回值:{}", Arrays.toString(hash));
|
||||||
return Util.bytes2HexString(hash);
|
return Util.bytes2HexString(hash);
|
||||||
} catch (SydApiException e) {
|
} catch (SydApiException e) {
|
||||||
le = e;
|
le = e;
|
||||||
@ -120,7 +124,8 @@ public class SydApi4Database implements SydApi {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LongDataReturn<String, String> SYD_SM3_Hash_LongData(byte[] pcData, int iPkgNum, String pcProcData) {
|
public LongDataReturn<String, String> SYD_SM3_Hash_LongData(byte[] pcData, int iPkgNum, String pcProcData) {
|
||||||
if (LogFactory.iLogLevel==3) {
|
Logger log = LogFactory.getLogger();
|
||||||
|
if (LogFactory.iLogLevel == 3) {
|
||||||
log.debug("SYD_SM3_Hash_LongData方法接收参数:pcData:{},iPkgNum:{},pcProcData:{}", Arrays.toString(pcData), iPkgNum, pcProcData);
|
log.debug("SYD_SM3_Hash_LongData方法接收参数:pcData:{},iPkgNum:{},pcProcData:{}", Arrays.toString(pcData), iPkgNum, pcProcData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,17 +136,17 @@ public class SydApi4Database implements SydApi {
|
|||||||
byte[] procData = null;
|
byte[] procData = null;
|
||||||
if (2 == iPkgNum || 3 == iPkgNum) {
|
if (2 == iPkgNum || 3 == iPkgNum) {
|
||||||
procData = Util.hexString2Bytes(pcProcData);
|
procData = Util.hexString2Bytes(pcProcData);
|
||||||
log.debug("Util.hexString2Bytes方法返回值:{}",Arrays.toString(procData));
|
log.debug("Util.hexString2Bytes方法返回值:{}", Arrays.toString(procData));
|
||||||
|
|
||||||
}
|
}
|
||||||
SydApiException le = null;
|
SydApiException le = null;
|
||||||
for (SydApi4j api : this.hsms) {
|
for (SydApi4j api : this.hsms) {
|
||||||
if ( null == api ) {
|
if (null == api) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
byte[] hash = api.SYD_SM3_LongData(pcData, procData, iPkgNum);
|
byte[] hash = api.SYD_SM3_LongData(pcData, procData, iPkgNum);
|
||||||
log.debug("api.SYD_SM3_LongData方法返回值:{}",Arrays.toString(hash));
|
log.debug("api.SYD_SM3_LongData方法返回值:{}", Arrays.toString(hash));
|
||||||
if (0 == iPkgNum || 3 == iPkgNum) {
|
if (0 == iPkgNum || 3 == iPkgNum) {
|
||||||
return new LongDataReturn<String, String>(null, Util.bytes2HexString(hash));
|
return new LongDataReturn<String, String>(null, Util.bytes2HexString(hash));
|
||||||
} else {
|
} else {
|
||||||
@ -160,10 +165,11 @@ public class SydApi4Database implements SydApi {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] SYD_SM4_ShortData(int iKeyIndex, byte[] pcData, int iFlag) {
|
public byte[] SYD_SM4_ShortData(int iKeyIndex, byte[] pcData, int iFlag) {
|
||||||
if (LogFactory.iLogLevel==3) {
|
Logger log = LogFactory.getLogger();
|
||||||
|
if (LogFactory.iLogLevel == 3) {
|
||||||
log.debug("SYD_SM4_ShortData方法接收参数:iKeyIndex:{},pcData:{},iFlag:{}", iKeyIndex, Arrays.toString(pcData), iFlag);
|
log.debug("SYD_SM4_ShortData方法接收参数:iKeyIndex:{},pcData:{},iFlag:{}", iKeyIndex, Arrays.toString(pcData), iFlag);
|
||||||
}
|
}
|
||||||
if (iFlag==Consts.ECB_DEC && null==pcData||pcData.length==0){
|
if (iFlag == Consts.ECB_DEC && null == pcData || pcData.length == 0) {
|
||||||
throw new SydApiException(19);
|
throw new SydApiException(19);
|
||||||
}
|
}
|
||||||
if (null == this.hsms || this.hsms.length < 1) {
|
if (null == this.hsms || this.hsms.length < 1) {
|
||||||
@ -173,7 +179,7 @@ public class SydApi4Database implements SydApi {
|
|||||||
String keyIndex = String.format("%08d", iKeyIndex);
|
String keyIndex = String.format("%08d", iKeyIndex);
|
||||||
SydApiException le = null;
|
SydApiException le = null;
|
||||||
for (SydApi4j api : this.hsms) {
|
for (SydApi4j api : this.hsms) {
|
||||||
if ( null == api ) {
|
if (null == api) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -203,12 +209,13 @@ public class SydApi4Database implements SydApi {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<byte[]> SYD_SM4_BatchData(int[] iKeyIndex, List<byte[]> pcData, int iFlag) {
|
public List<byte[]> SYD_SM4_BatchData(int[] iKeyIndex, List<byte[]> pcData, int iFlag) {
|
||||||
if (LogFactory.iLogLevel==3) {
|
Logger log = LogFactory.getLogger();
|
||||||
|
if (LogFactory.iLogLevel == 3) {
|
||||||
log.debug("SYD_SM4_BatchData方法接收参数:iKeyIndex:{},pcData元素个数为:{},iFlag:{}", iKeyIndex, pcData.size(), iFlag);
|
log.debug("SYD_SM4_BatchData方法接收参数:iKeyIndex:{},pcData元素个数为:{},iFlag:{}", iKeyIndex, pcData.size(), iFlag);
|
||||||
}
|
}
|
||||||
if (iFlag==Consts.ECB_DEC){
|
if (iFlag == Consts.ECB_DEC) {
|
||||||
for (byte[] pcdata:pcData){
|
for (byte[] pcdata : pcData) {
|
||||||
if (null==pcData||pcdata.length==0) {
|
if (null == pcData || pcdata.length == 0) {
|
||||||
throw new SydApiException(19);
|
throw new SydApiException(19);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -224,7 +231,7 @@ public class SydApi4Database implements SydApi {
|
|||||||
|
|
||||||
SydApiException le = null;
|
SydApiException le = null;
|
||||||
for (SydApi4j api : this.hsms) {
|
for (SydApi4j api : this.hsms) {
|
||||||
if ( null == api ) {
|
if (null == api) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -247,10 +254,11 @@ public class SydApi4Database implements SydApi {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] SYD_SM4_LongData(int iKeyIndex, byte[] pcData, int iPkgNum, int iFlag) {
|
public byte[] SYD_SM4_LongData(int iKeyIndex, byte[] pcData, int iPkgNum, int iFlag) {
|
||||||
if (LogFactory.iLogLevel==3) {
|
Logger log = LogFactory.getLogger();
|
||||||
|
if (LogFactory.iLogLevel == 3) {
|
||||||
log.debug("SYD_SM4_LongData方法接收参数:iKeyIndex:{},pcData:{},iPkgNum:{},iFlag:{}", iKeyIndex, Arrays.toString(pcData), iPkgNum, iFlag);
|
log.debug("SYD_SM4_LongData方法接收参数:iKeyIndex:{},pcData:{},iPkgNum:{},iFlag:{}", iKeyIndex, Arrays.toString(pcData), iPkgNum, iFlag);
|
||||||
}
|
}
|
||||||
if (iFlag==Consts.ECB_DEC&&null==pcData||pcData.length==0){
|
if (iFlag == Consts.ECB_DEC && null == pcData || pcData.length == 0) {
|
||||||
throw new SydApiException(19);
|
throw new SydApiException(19);
|
||||||
}
|
}
|
||||||
if (null == this.hsms || this.hsms.length < 1) {
|
if (null == this.hsms || this.hsms.length < 1) {
|
||||||
@ -260,7 +268,7 @@ public class SydApi4Database implements SydApi {
|
|||||||
|
|
||||||
SydApiException le = null;
|
SydApiException le = null;
|
||||||
for (SydApi4j api : this.hsms) {
|
for (SydApi4j api : this.hsms) {
|
||||||
if ( null == api ) {
|
if (null == api) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -293,7 +301,8 @@ public class SydApi4Database implements SydApi {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] SYD_SM4Mac_BatchData(int[] iKeyIndex, List<byte[]> pcData) {
|
public String[] SYD_SM4Mac_BatchData(int[] iKeyIndex, List<byte[]> pcData) {
|
||||||
if (LogFactory.iLogLevel==3) {
|
Logger log = LogFactory.getLogger();
|
||||||
|
if (LogFactory.iLogLevel == 3) {
|
||||||
log.debug("SYD_SM4Mac_BatchData:iKeyIndex:{},pcData元素个数为:{}", iKeyIndex, pcData.size());
|
log.debug("SYD_SM4Mac_BatchData:iKeyIndex:{},pcData元素个数为:{}", iKeyIndex, pcData.size());
|
||||||
}
|
}
|
||||||
if (null == this.hsms || this.hsms.length < 1) {
|
if (null == this.hsms || this.hsms.length < 1) {
|
||||||
@ -306,7 +315,7 @@ public class SydApi4Database implements SydApi {
|
|||||||
}
|
}
|
||||||
SydApiException le = null;
|
SydApiException le = null;
|
||||||
for (SydApi4j api : this.hsms) {
|
for (SydApi4j api : this.hsms) {
|
||||||
if ( null == api ) {
|
if (null == api) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -333,7 +342,8 @@ public class SydApi4Database implements SydApi {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean[] SYD_SM4Mac_BatchData(int[] iKeyIndex, List<byte[]> pcData, String[] pcMac) {
|
public boolean[] SYD_SM4Mac_BatchData(int[] iKeyIndex, List<byte[]> pcData, String[] pcMac) {
|
||||||
if (LogFactory.iLogLevel==3) {
|
Logger log = LogFactory.getLogger();
|
||||||
|
if (LogFactory.iLogLevel == 3) {
|
||||||
log.debug("SYD_SM4Mac_BatchData方法接收参数:iKeyIndex:{},pcData元素个数为:{},pcMac:{}", iKeyIndex, pcData.size(), Arrays.toString(pcMac));
|
log.debug("SYD_SM4Mac_BatchData方法接收参数:iKeyIndex:{},pcData元素个数为:{},pcMac:{}", iKeyIndex, pcData.size(), Arrays.toString(pcMac));
|
||||||
}
|
}
|
||||||
if (null == this.hsms || this.hsms.length < 1) {
|
if (null == this.hsms || this.hsms.length < 1) {
|
||||||
@ -346,7 +356,7 @@ public class SydApi4Database implements SydApi {
|
|||||||
}
|
}
|
||||||
SydApiException le = null;
|
SydApiException le = null;
|
||||||
for (SydApi4j api : this.hsms) {
|
for (SydApi4j api : this.hsms) {
|
||||||
if ( null == api ) {
|
if (null == api) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -373,7 +383,8 @@ public class SydApi4Database implements SydApi {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LongDataReturn<String, String> SYD_SM4Mac_LongData(int iKeyIndex, byte[] pcData, int iPkgNum, String pcProcData) {
|
public LongDataReturn<String, String> SYD_SM4Mac_LongData(int iKeyIndex, byte[] pcData, int iPkgNum, String pcProcData) {
|
||||||
if (LogFactory.iLogLevel==3) {
|
Logger log = LogFactory.getLogger();
|
||||||
|
if (LogFactory.iLogLevel == 3) {
|
||||||
log.debug("SYD_SM4Mac_LongData方法接收参数:iKeyIndex:{},pcData:{},iPkgNum:{},pcProcData:{}", iKeyIndex, Arrays.toString(pcData), iPkgNum, pcProcData);
|
log.debug("SYD_SM4Mac_LongData方法接收参数:iKeyIndex:{},pcData:{},iPkgNum:{},pcProcData:{}", iKeyIndex, Arrays.toString(pcData), iPkgNum, pcProcData);
|
||||||
}
|
}
|
||||||
if (null == this.hsms || this.hsms.length < 1) {
|
if (null == this.hsms || this.hsms.length < 1) {
|
||||||
@ -391,7 +402,7 @@ public class SydApi4Database implements SydApi {
|
|||||||
|
|
||||||
SydApiException le = null;
|
SydApiException le = null;
|
||||||
for (SydApi4j api : this.hsms) {
|
for (SydApi4j api : this.hsms) {
|
||||||
if ( null == api ) {
|
if (null == api) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -416,6 +427,7 @@ public class SydApi4Database implements SydApi {
|
|||||||
} catch (SydApiException e) {
|
} catch (SydApiException e) {
|
||||||
le = e;
|
le = e;
|
||||||
if (e.getRetCode() < 0) {
|
if (e.getRetCode() < 0) {
|
||||||
|
log.error("HA 重试");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
throw e;
|
throw e;
|
||||||
@ -426,7 +438,8 @@ public class SydApi4Database implements SydApi {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LongDataReturn<String, Boolean> SYD_SM4Mac_LongData(int iKeyIndex, byte[] pcData, int iPkgNum, String pcProcData, String pcMac) {
|
public LongDataReturn<String, Boolean> SYD_SM4Mac_LongData(int iKeyIndex, byte[] pcData, int iPkgNum, String pcProcData, String pcMac) {
|
||||||
if (LogFactory.iLogLevel==3) {
|
Logger log = LogFactory.getLogger();
|
||||||
|
if (LogFactory.iLogLevel == 3) {
|
||||||
log.debug("SYD_SM4Mac_LongData方法接收参数:iKeyIndex:{},pcData:{},iPkgNum:{},pcProcData:{}", iKeyIndex, Arrays.toString(pcData), iPkgNum, pcProcData, pcMac);
|
log.debug("SYD_SM4Mac_LongData方法接收参数:iKeyIndex:{},pcData:{},iPkgNum:{},pcProcData:{}", iKeyIndex, Arrays.toString(pcData), iPkgNum, pcProcData, pcMac);
|
||||||
}
|
}
|
||||||
LongDataReturn<String, String> ret = SYD_SM4Mac_LongData(iKeyIndex, pcData, iPkgNum, pcProcData);
|
LongDataReturn<String, String> ret = SYD_SM4Mac_LongData(iKeyIndex, pcData, iPkgNum, pcProcData);
|
||||||
@ -442,7 +455,8 @@ public class SydApi4Database implements SydApi {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String SYD_SM4Mac_ShortData(int iKeyIndex, byte[] pcData) {
|
public String SYD_SM4Mac_ShortData(int iKeyIndex, byte[] pcData) {
|
||||||
if (LogFactory.iLogLevel==3) {
|
Logger log = LogFactory.getLogger();
|
||||||
|
if (LogFactory.iLogLevel == 3) {
|
||||||
log.debug("SYD_SM4Mac_ShortData方法接收参数:iKeyIndex:{},pcData:{},iFlag:{}", iKeyIndex, Arrays.toString(pcData));
|
log.debug("SYD_SM4Mac_ShortData方法接收参数:iKeyIndex:{},pcData:{},iFlag:{}", iKeyIndex, Arrays.toString(pcData));
|
||||||
}
|
}
|
||||||
if (null == this.hsms || this.hsms.length < 1) {
|
if (null == this.hsms || this.hsms.length < 1) {
|
||||||
@ -450,10 +464,10 @@ public class SydApi4Database implements SydApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String keyIndex = "SK" + SYMUtil.genPrivateKeyMark("000000", "00A", String.format("%08d", iKeyIndex));
|
String keyIndex = "SK" + SYMUtil.genPrivateKeyMark("000000", "00A", String.format("%08d", iKeyIndex));
|
||||||
log.debug("\"SK\" + SYMUtil.genPrivateKeyMark方法返回值:{}",keyIndex);
|
log.debug("\"SK\" + SYMUtil.genPrivateKeyMark方法返回值:{}", keyIndex);
|
||||||
SydApiException le = null;
|
SydApiException le = null;
|
||||||
for (SydApi4j api : this.hsms) {
|
for (SydApi4j api : this.hsms) {
|
||||||
if ( null == api ) {
|
if (null == api) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -473,7 +487,8 @@ public class SydApi4Database implements SydApi {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean SYD_SM4Mac_ShortData(int iKeyIndex, byte[] pcData, String pcMac) {
|
public boolean SYD_SM4Mac_ShortData(int iKeyIndex, byte[] pcData, String pcMac) {
|
||||||
if (LogFactory.iLogLevel==3) {
|
Logger log = LogFactory.getLogger();
|
||||||
|
if (LogFactory.iLogLevel == 3) {
|
||||||
log.debug("SYD_SM4Mac_ShortData方法接收参数:{}", iKeyIndex, Arrays.toString(pcData), pcMac);
|
log.debug("SYD_SM4Mac_ShortData方法接收参数:{}", iKeyIndex, Arrays.toString(pcData), pcMac);
|
||||||
}
|
}
|
||||||
if (null == this.hsms || this.hsms.length < 1) {
|
if (null == this.hsms || this.hsms.length < 1) {
|
||||||
@ -485,7 +500,7 @@ public class SydApi4Database implements SydApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String mac = this.SYD_SM4Mac_ShortData(iKeyIndex, pcData);
|
String mac = this.SYD_SM4Mac_ShortData(iKeyIndex, pcData);
|
||||||
log.debug(this+".SYD_SM4Mac_ShortData方法返回值:{}",mac);
|
log.debug(this + ".SYD_SM4Mac_ShortData方法返回值:{}", mac);
|
||||||
return pcMac.equals(mac);
|
return pcMac.equals(mac);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,7 +8,9 @@ import org.apache.logging.log4j.Logger;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class SydApiBuilder {
|
public class SydApiBuilder {
|
||||||
Logger log = LogFactory.getLogger();
|
static {
|
||||||
|
SydApi.SYD_SetLogConfig("./logs/", 0);
|
||||||
|
}
|
||||||
private SydApiPool pool;
|
private SydApiPool pool;
|
||||||
public SydApiBuilder(
|
public SydApiBuilder(
|
||||||
String[] pcIpList,
|
String[] pcIpList,
|
||||||
@ -16,6 +18,7 @@ public class SydApiBuilder {
|
|||||||
int iConnectTimeOut,
|
int iConnectTimeOut,
|
||||||
int iDealTimeOut
|
int iDealTimeOut
|
||||||
) {
|
) {
|
||||||
|
Logger log = LogFactory.getLogger();
|
||||||
log.debug("创建链接");
|
log.debug("创建链接");
|
||||||
log.debug("SydApiBuilder构造方法接收参数:pcIpList:{},iPortList:{},iConnectTimeOut:{},iDealTimeOut:{}", Arrays.toString(pcIpList),Arrays.toString(iPortList),iConnectTimeOut,iDealTimeOut);
|
log.debug("SydApiBuilder构造方法接收参数:pcIpList:{},iPortList:{},iConnectTimeOut:{},iDealTimeOut:{}", Arrays.toString(pcIpList),Arrays.toString(iPortList),iConnectTimeOut,iDealTimeOut);
|
||||||
HsmLinkInfo[] linkInfo = HsmLinkInfo.mutiHsmLinkInfo(pcIpList, iPortList, iConnectTimeOut, iDealTimeOut);
|
HsmLinkInfo[] linkInfo = HsmLinkInfo.mutiHsmLinkInfo(pcIpList, iPortList, iConnectTimeOut, iDealTimeOut);
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package com.sunyard.sge.database.pool;
|
package com.sunyard.sge.database.pool;
|
||||||
|
|
||||||
|
|
||||||
|
import com.sunyard.sge.database.SydApi;
|
||||||
import com.sunyard.sge.log.LogFactory;
|
import com.sunyard.sge.log.LogFactory;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
@ -11,6 +12,10 @@ import java.util.Arrays;
|
|||||||
* 到加密机的链接信息
|
* 到加密机的链接信息
|
||||||
*/
|
*/
|
||||||
public class HsmLinkInfo {
|
public class HsmLinkInfo {
|
||||||
|
static {
|
||||||
|
SydApi.SYD_SetLogConfig("./logs/", 0);
|
||||||
|
}
|
||||||
|
static Logger log = LogFactory.getLogger();
|
||||||
private String pcIp;
|
private String pcIp;
|
||||||
private int iPort;
|
private int iPort;
|
||||||
private int iConnectTimeOut;
|
private int iConnectTimeOut;
|
||||||
@ -25,7 +30,7 @@ public class HsmLinkInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static HsmLinkInfo[] mutiHsmLinkInfo(String[] pcIpList, int[] iPortList, int iConnectTimeOut, int iAllDealTimeOut) {
|
public static HsmLinkInfo[] mutiHsmLinkInfo(String[] pcIpList, int[] iPortList, int iConnectTimeOut, int iAllDealTimeOut) {
|
||||||
Logger log = LogFactory.getLogger();
|
|
||||||
log.debug("mutiHsmLinkInfo方法接收参数:pcIpList:{},iPortList:{},iConnectTimeOut:{},iDealTimeOut:{}", Arrays.toString(pcIpList),Arrays.toString(iPortList),iConnectTimeOut,iAllDealTimeOut);
|
log.debug("mutiHsmLinkInfo方法接收参数:pcIpList:{},iPortList:{},iConnectTimeOut:{},iDealTimeOut:{}", Arrays.toString(pcIpList),Arrays.toString(iPortList),iConnectTimeOut,iAllDealTimeOut);
|
||||||
log.debug("链接参数整理");
|
log.debug("链接参数整理");
|
||||||
if (null == pcIpList &&
|
if (null == pcIpList &&
|
||||||
|
|||||||
@ -9,6 +9,9 @@ import org.apache.logging.log4j.Logger;
|
|||||||
import racal.sunyard.main.SydApi4j;
|
import racal.sunyard.main.SydApi4j;
|
||||||
|
|
||||||
public class SydApiPool extends ThreadBasedConnectPool<SydApi> {
|
public class SydApiPool extends ThreadBasedConnectPool<SydApi> {
|
||||||
|
static {
|
||||||
|
SydApi.SYD_SetLogConfig("./logs/", 0);
|
||||||
|
}
|
||||||
|
|
||||||
private HsmLinkInfo[] linkInfos;
|
private HsmLinkInfo[] linkInfos;
|
||||||
|
|
||||||
|
|||||||
@ -62,7 +62,7 @@ public class LogFactory {
|
|||||||
|
|
||||||
// 日志打印方式——输出为文件
|
// 日志打印方式——输出为文件
|
||||||
Appender appender = FileAppender.createAppender(
|
Appender appender = FileAppender.createAppender(
|
||||||
String.format( pcLogPath + getToday() + ".log"),
|
String.format( pcLogPath +"sydapi_"+getToday() + ".log"),
|
||||||
"true", "false",
|
"true", "false",
|
||||||
logName, null, "true", "true", null, layout, null, null, null, config);
|
logName, null, "true", "true", null, layout, null, null, null, config);
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
package com.sunyard.sge.pool;
|
package com.sunyard.sge.pool;
|
||||||
|
|
||||||
|
import com.sunyard.sge.database.SydApi;
|
||||||
|
import com.sunyard.sge.database.SydApi4Database;
|
||||||
import com.sunyard.sge.log.LogFactory;
|
import com.sunyard.sge.log.LogFactory;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
@ -12,7 +14,9 @@ import java.util.concurrent.ScheduledExecutorService;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class ThreadBasedConnectPool<T> {
|
public class ThreadBasedConnectPool<T> {
|
||||||
|
static {
|
||||||
|
SydApi.SYD_SetLogConfig("./logs/", 0);
|
||||||
|
}
|
||||||
|
|
||||||
// ThreadLocal
|
// ThreadLocal
|
||||||
private final Map<Thread, ObjectInPool<T>> map = new HashMap<>();
|
private final Map<Thread, ObjectInPool<T>> map = new HashMap<>();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user