sdf api
This commit is contained in:
@@ -29,4 +29,7 @@ public interface SpDeviceMapper extends BaseMapper<Device> {
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.sunyard.chsm.model.dto;
|
||||
|
||||
import com.sunyard.chsm.enums.DeviceTmkStatus;
|
||||
import com.sunyard.chsm.sdf.adapter.SdfApiAdapter;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
@@ -17,5 +18,7 @@ public class DeviceCheckRes {
|
||||
private boolean hasError = false;
|
||||
private String message;
|
||||
|
||||
private SdfApiAdapter sdfApiAdapter;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
package com.sunyard.chsm.sdf.context;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author liulu
|
||||
* @since 2024/11/5
|
||||
*/
|
||||
@Data
|
||||
public class DeviceContext {
|
||||
|
||||
private String serviceIp;
|
||||
private Integer servicePort;
|
||||
private String manufacturer;
|
||||
private String manufacturerModel;
|
||||
private String accessCredentials;
|
||||
private String jnaLibName;
|
||||
|
||||
private Integer weight;
|
||||
|
||||
|
||||
}
|
||||
@@ -167,13 +167,14 @@ public class TmkService {
|
||||
}
|
||||
Optional.ofNullable(hs).ifPresent(sdfApi::closeSession);
|
||||
Optional.ofNullable(hd).ifPresent(sdfApi::closeDevice);
|
||||
res.setSdfApiAdapter(sdfApi);
|
||||
log.debug("==========> end check device : {}", res);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
public void checkSoftDeviceTmk() {
|
||||
if (!isTmkInit() || !enableSoftDevice()) {
|
||||
if (!isTmkInit() || !isEnableSoftDevice()) {
|
||||
return;
|
||||
}
|
||||
byte[] softTmk = getSoftDeviceEncTmk();
|
||||
@@ -203,7 +204,7 @@ public class TmkService {
|
||||
if (Objects.nonNull(device)) {
|
||||
return device;
|
||||
}
|
||||
if (enableSoftDevice()) {
|
||||
if (isEnableSoftDevice()) {
|
||||
device = new Device();
|
||||
device.setManufacturerModel(BouncyCastleProvider.PROVIDER_NAME);
|
||||
device.setEncKeyIdx(1);
|
||||
@@ -219,11 +220,16 @@ public class TmkService {
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isTmkInit() {
|
||||
public boolean isTmkInit() {
|
||||
ParamConf conf = paramConfMapper.selectByKey(ParamConfKeyConstant.TMK_INIT);
|
||||
return conf != null && String.valueOf(true).equals(conf.getValue());
|
||||
}
|
||||
|
||||
public boolean isEnableSoftDevice() {
|
||||
ParamConf conf = paramConfMapper.selectByKey(ParamConfKeyConstant.ENABLE_SOFT_DEVICE);
|
||||
return conf != null && String.valueOf(true).equals(conf.getValue());
|
||||
}
|
||||
|
||||
private void updateTmkInit(boolean value) {
|
||||
ParamConf conf = paramConfMapper.selectByKey(ParamConfKeyConstant.TMK_INIT);
|
||||
if (conf == null) {
|
||||
@@ -238,15 +244,10 @@ public class TmkService {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean enableSoftDevice() {
|
||||
ParamConf conf = paramConfMapper.selectByKey(ParamConfKeyConstant.ENABLE_SOFT_DEVICE);
|
||||
return conf != null && String.valueOf(true).equals(conf.getValue());
|
||||
}
|
||||
|
||||
private byte[] getSoftDeviceEncTmk() {
|
||||
boolean tmkInit = isTmkInit();
|
||||
Assert.isTrue(tmkInit, "主密钥未初始化");
|
||||
boolean enabled = enableSoftDevice();
|
||||
boolean enabled = isEnableSoftDevice();
|
||||
Assert.isTrue(enabled, "未启用软设备");
|
||||
ParamConf conf = paramConfMapper.selectByKey(ParamConfKeyConstant.SOFT_ENC_TMK);
|
||||
if (conf == null || ObjectUtils.isEmpty(conf.getValue())) {
|
||||
|
||||
Reference in New Issue
Block a user