时间戳服务
This commit is contained in:
@ -64,7 +64,21 @@ public class TimeServiceConstant {
|
|||||||
* @param timestamp 时间戳加密原文
|
* @param timestamp 时间戳加密原文
|
||||||
* @return 时间戳对象
|
* @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{
|
try{
|
||||||
log.info("timestamp -->"+timestamp);
|
log.info("timestamp -->"+timestamp);
|
||||||
TSAVerifyResult verifyResult = client.verifyTimeStamp(Base64.decodeBase64(timestamp));
|
TSAVerifyResult verifyResult = client.verifyTimeStamp(Base64.decodeBase64(timestamp));
|
||||||
@ -83,10 +97,7 @@ public class TimeServiceConstant {
|
|||||||
public TtsAgent.TtsParseResult getServiceTimeObj(String data){
|
public TtsAgent.TtsParseResult getServiceTimeObj(String data){
|
||||||
try{
|
try{
|
||||||
String timestamp = this.signTimeStamp(data);
|
String timestamp = this.signTimeStamp(data);
|
||||||
TSAVerifyResult verifyResult = this.verifyTimeStamp(timestamp);
|
TtsAgent.TtsParseResult ttsParseResult = this.verifyTimeStamp2(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;
|
return ttsParseResult;
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
log.error("获取时间戳异常", e);
|
log.error("获取时间戳异常", e);
|
||||||
|
@ -40,9 +40,9 @@ public class TimeServiceController {
|
|||||||
*/
|
*/
|
||||||
@ApiOperation("解析时间戳加密原文")
|
@ApiOperation("解析时间戳加密原文")
|
||||||
@GetMapping(value = "/verifyTimeStamp")
|
@GetMapping(value = "/verifyTimeStamp")
|
||||||
public BaseResponse<TSAVerifyResult> verifyTimeStamp(@ApiParam(value = "时间戳加密原文", required = true) @RequestBody String timestamp) {
|
public BaseResponse<TtsAgent.TtsParseResult> verifyTimeStamp(@ApiParam(value = "时间戳加密原文", required = true) @RequestBody String timestamp) {
|
||||||
TimeServiceConstant constant = new TimeServiceConstant();
|
TimeServiceConstant constant = new TimeServiceConstant();
|
||||||
return BaseResponse.success(constant.verifyTimeStamp(timestamp));
|
return BaseResponse.success(constant.verifyTimeStamp2(timestamp));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -115,5 +115,23 @@ public interface TtsAgent {
|
|||||||
public void setCert(String cert) {
|
public void setCert(String cert) {
|
||||||
this.cert = cert;
|
this.cert = cert;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getLocalDateTimestamp() {
|
||||||
|
return localDateTimestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TtsParseResult setLocalDateTimestamp(LocalDateTime localDateTimestamp) {
|
||||||
|
this.localDateTimestamp = localDateTimestamp;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getDatestamp() {
|
||||||
|
return datestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TtsParseResult setDatestamp(Date datestamp) {
|
||||||
|
this.datestamp = datestamp;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user