This commit is contained in:
liulu 2024-12-10 11:10:05 +08:00
parent 29c5fb261f
commit aabc9c56e1
4 changed files with 12 additions and 5 deletions

View File

@ -151,6 +151,7 @@ public class TmkService {
}
res.setStatus(DeviceTmkStatus.finished);
} else {
log.debug("tmk not init, start encrypt and import test ...");
byte[] random = sdfApi.generateRandom(hs, 16);
EccCipher eccCipher = sdfApi.externalEncryptECC(hs, pubKey, random);
String hk = sdfApi.importKeyWithISKECC(hs, check.getEncKeyIdx(), eccCipher);
@ -177,7 +178,9 @@ public class TmkService {
device.setServiceIp("127.0.0.1");
device.setServicePort(8889);
device.setAccessCredentials("543");
device.setEncTmk(CodecUtils.encodeHex(getSoftDeviceEncTmk()));
if (isTmkInit()) {
device.setEncTmk(CodecUtils.encodeHex(getSoftDeviceEncTmk()));
}
return device;
}

View File

@ -73,10 +73,12 @@ public abstract class DeviceDTO {
* 管理端口
*/
private Integer managePort;
@NotNull(message = "加密密钥索引不能为空")
private Integer encKeyIdx;
/**
* 访问凭证
*/
@NotBlank(message = "访问凭证不能为空")
private String accessCredentials;
/**
* 备注

View File

@ -20,6 +20,7 @@ import java.time.Duration;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.Executors;
/**
* @author liulu
@ -50,8 +51,8 @@ public class DeviceTask implements InitializingBean {
if (CollectionUtils.isEmpty(records)) {
break;
}
for (Device record : records) {
threadPoolTaskExecutor.execute(() -> {
Executors.newSingleThreadExecutor().execute(() -> {
for (Device record : records) {
DeviceCheckRes checkRes = tmkService.checkDevice(record);
Device up = new Device();
up.setId(record.getId());
@ -69,8 +70,8 @@ public class DeviceTask implements InitializingBean {
}
up.setEncTmk(checkRes.getEncTmk());
spDeviceMapper.updateById(up);
});
}
}
});
}
}

View File

@ -140,6 +140,7 @@ logging:
level:
root: info
com.sunyard.chsm.mapper: debug
com.sunyard.chsm.service.TmkService: debug
# org.springframework.web: trace
# config: classpath:log4j2.xml