时间戳服务BUG修复

This commit is contained in:
zhangqinbin
2021-04-13 09:49:43 +08:00
parent 61c57a5390
commit 39c387dbed
2 changed files with 20 additions and 9 deletions

View File

@ -64,7 +64,21 @@ public class TimeServiceConstant {
* @param timestamp 时间戳加密原文
* @return 时间戳对象
*/
public TSAVerifyResult verifyTimeStamp(String timestamp){
public TtsAgent.TtsParseResult verifyTimeStamp2(String timestamp){
try{
log.info("timestamp -->"+timestamp);
TSAVerifyResult verifyResult = this.verifyTimeStamp(timestamp);
String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(verifyResult.getSignedTime());
TtsAgent.TtsParseResult ttsParseResult = new TtsAgent.TtsParseResult(time, HelperUtil.bytesToHexString(verifyResult.getData()),
verifyResult.getSignerSubject());
return ttsParseResult;
}catch (Exception e){
log.error("解析时间戳", e);
}
return null;
}
private TSAVerifyResult verifyTimeStamp(String timestamp){
try{
log.info("timestamp -->"+timestamp);
TSAVerifyResult verifyResult = client.verifyTimeStamp(Base64.decodeBase64(timestamp));
@ -83,10 +97,7 @@ public class TimeServiceConstant {
public TtsAgent.TtsParseResult getServiceTimeObj(String data){
try{
String timestamp = this.signTimeStamp(data);
TSAVerifyResult verifyResult = this.verifyTimeStamp(timestamp);
String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(verifyResult.getSignedTime());
TtsAgent.TtsParseResult ttsParseResult = new TtsAgent.TtsParseResult(time, HelperUtil.bytesToHexString(verifyResult.getData()),
verifyResult.getSignerSubject());
TtsAgent.TtsParseResult ttsParseResult = this.verifyTimeStamp2(timestamp);
return ttsParseResult;
}catch (Exception e){
log.error("获取时间戳异常", e);

View File

@ -39,10 +39,10 @@ public class TimeServiceController {
* @return 时间戳对象
*/
@ApiOperation("解析时间戳加密原文")
@GetMapping(value = "/verifyTimeStamp")
public BaseResponse<TSAVerifyResult> verifyTimeStamp(@ApiParam(value = "时间戳加密原文", required = true) @RequestBody String timestamp) {
@PostMapping(value = "/verifyTimeStamp")
public BaseResponse<TtsAgent.TtsParseResult> verifyTimeStamp(@ApiParam(value = "时间戳加密原文", required = true) @RequestBody String timestamp) {
TimeServiceConstant constant = new TimeServiceConstant();
return BaseResponse.success(constant.verifyTimeStamp(timestamp));
return BaseResponse.success(constant.verifyTimeStamp2(timestamp));
}
/**
@ -51,7 +51,7 @@ public class TimeServiceController {
* @return 时间戳对象
*/
@ApiOperation("直接获取时间戳对象(内涵日期)")
@PostMapping(value = "/getServiceTimeObj")
@GetMapping(value = "/getServiceTimeObj")
public BaseResponse<TtsAgent.TtsParseResult> getServiceTimeObj(@ApiParam(value = "待申请时间戳的原文", required = false) @RequestParam(name = "data",required = false) String data) {
TimeServiceConstant constant = new TimeServiceConstant();
return BaseResponse.success(constant.getServiceTimeObj(data));