时间戳服务
This commit is contained in:
@ -5,6 +5,7 @@ import cn.com.jit.tsa.client.TSAClient;
|
||||
import cn.com.jit.tsa.client.TSAClientFactory;
|
||||
import cn.com.jit.tsa.client.TSASignedResult;
|
||||
import cn.com.jit.tsa.client.TSAVerifyResult;
|
||||
import com.chinaunicom.mall.ebtp.extend.timeService.tsa.SystemTime;
|
||||
import com.chinaunicom.mall.ebtp.extend.timeService.tsa.TtsAgent;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
@ -12,6 +13,8 @@ import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Properties;
|
||||
|
||||
@Slf4j
|
||||
@ -108,4 +111,51 @@ public class TimeServiceConstant {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 直接获取获取时间戳 时间1
|
||||
* @param data 待申请时间戳的原文
|
||||
* @return date时间
|
||||
*/
|
||||
public Date getServiceDate(String data){
|
||||
try{
|
||||
String timestamp = this.signTimeStamp(data);
|
||||
TSAVerifyResult verifyResult = this.verifyTimeStamp(timestamp);
|
||||
Date date = verifyResult.getSignedTime();
|
||||
return verifyResult.getSignedTime();
|
||||
}catch (Exception e){
|
||||
log.error("获取时间戳异常", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* 直接获取获取时间戳 时间1
|
||||
* @param data 待申请时间戳的原文
|
||||
* @return date时间
|
||||
*/
|
||||
public SystemTime getServiceSystemTime(String data){
|
||||
try{
|
||||
String timestamp = this.signTimeStamp(data);
|
||||
TSAVerifyResult verifyResult = this.verifyTimeStamp(timestamp);
|
||||
Date date = verifyResult.getSignedTime();
|
||||
SystemTime systemTime = new SystemTime()
|
||||
.setYear(date.getYear())
|
||||
.setMonth(date.getMonth()+1)
|
||||
.setDate(date.getDate())
|
||||
.setHour(date.getHours())
|
||||
.setMinute(date.getMinutes())
|
||||
.setSecond(date.getSeconds());
|
||||
return systemTime;
|
||||
}catch (Exception e){
|
||||
log.error("获取时间戳异常", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void main(String arge[]){
|
||||
Date date = new Date();
|
||||
System.out.println("-----------"+date.getYear());
|
||||
System.out.println("-----------"+date.getMonth());
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
@RestController
|
||||
@Api(tags = "")
|
||||
@RequestMapping("/v1/timeService")
|
||||
public class TiemServiceController {
|
||||
public class TimeServiceController {
|
||||
|
||||
/**
|
||||
* 申请时间戳
|
@ -0,0 +1,48 @@
|
||||
package com.chinaunicom.mall.ebtp.extend.timeService.tsa;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 实体类 BizBidOpenroom
|
||||
*
|
||||
* @auto.generated
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class SystemTime {
|
||||
|
||||
|
||||
/**
|
||||
* 年
|
||||
*/
|
||||
private Integer year;
|
||||
|
||||
/**
|
||||
* 月
|
||||
*/
|
||||
private Integer month;
|
||||
|
||||
/**
|
||||
* 日
|
||||
*/
|
||||
private Integer date;
|
||||
|
||||
/**
|
||||
* 时
|
||||
*/
|
||||
private Integer hour;
|
||||
|
||||
/**
|
||||
* 分
|
||||
*/
|
||||
private Integer minute;
|
||||
|
||||
/**
|
||||
* 秒
|
||||
*/
|
||||
private Integer second;
|
||||
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user