diff --git a/lib/jit-vstk-jdk15-2.0.50-20150603.060911-1.jar b/lib/jit-vstk-jdk15-2.0.50-20150603.060911-1.jar new file mode 100644 index 0000000..865b55e Binary files /dev/null and b/lib/jit-vstk-jdk15-2.0.50-20150603.060911-1.jar differ diff --git a/pom.xml b/pom.xml index 636c58e..2a0b67f 100644 --- a/pom.xml +++ b/pom.xml @@ -66,7 +66,18 @@ poi-ooxml-schemas 4.1.2 - + + commons-httpclient + commons-httpclient + 3.1 + + + jit.vstk + jit-vstk + 2.0.50 + system + ${basedir}/lib/jit-vstk-jdk15-2.0.50-20150603.060911-1.jar + org.apache.velocity velocity-tools @@ -108,6 +119,13 @@ **/mapper/*Mapper.xml + + lib + BOOT-INF/lib/ + + **/*.jar + + diff --git a/pro.yaml b/pro.yaml index 394197b..ba8569a 100644 --- a/pro.yaml +++ b/pro.yaml @@ -47,25 +47,25 @@ spec: mountPath: /log ports: - containerPort: 18018 #[8] 容器需要监听的端口号,与配置文件中的server.port参数相同,与参数[4]相同 - livenessProbe: - failureThreshold: 3 - httpGet: - port: 18018 #[11] pod存活检测端口,修改为该微服务配置文件中server.port的端口号,与参数[5]相同 - path: /actuator/prometheus - scheme: HTTP - initialDelaySeconds: 300 - periodSeconds: 60 - successThreshold: 1 - timeoutSeconds: 2 - readinessProbe: - failureThreshold: 1 - httpGet: - port: 18018 #[12] pod就绪检测端口,修改为该微服务配置文件中server.port的端口号,与参数[5]相同 - path: /actuator/prometheus - scheme: HTTP - periodSeconds: 5 - successThreshold: 2 - timeoutSeconds: 2 + #livenessProbe: + # failureThreshold: 3 + # httpGet: + # port: 18018 #[11] pod存活检测端口,修改为该微服务配置文件中server.port的端口号,与参数[5]相同 + # path: /actuator/prometheus + # scheme: HTTP + # initialDelaySeconds: 300 + # periodSeconds: 60 + # successThreshold: 1 + # timeoutSeconds: 2 + #readinessProbe: + # failureThreshold: 1 + # httpGet: + # port: 18018 #[12] pod就绪检测端口,修改为该微服务配置文件中server.port的端口号,与参数[5]相同 + # path: /actuator/prometheus + # scheme: HTTP + # periodSeconds: 5 + # successThreshold: 2 + # timeoutSeconds: 2 resources: requests: cpu: 1000m @@ -75,7 +75,7 @@ spec: memory: 6Gi env: - name: APP_NAME - value: biz-ebtp-extend + value: biz_ebtp_extend - name: AGENT_LICENCE value: 527BFA7B28577578 - name: APOLLO_CONFIGSERVICE diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/templatewarehouse/sevice/impl/BizBidClientVersionServiceImpl.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/templatewarehouse/sevice/impl/BizBidClientVersionServiceImpl.java index 4d21496..727c1f3 100644 --- a/src/main/java/com/chinaunicom/mall/ebtp/extend/templatewarehouse/sevice/impl/BizBidClientVersionServiceImpl.java +++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/templatewarehouse/sevice/impl/BizBidClientVersionServiceImpl.java @@ -1,35 +1,30 @@ package com.chinaunicom.mall.ebtp.extend.templatewarehouse.sevice.impl; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.convertor.ModelConvertor; -import com.chinaunicom.mall.ebtp.common.util.JsonUtils; -import com.chinaunicom.mall.ebtp.extend.export.enums.ExportExceptionEnum; -import com.chinaunicom.mall.ebtp.extend.feign.client.DocumentCenterService; -import com.chinaunicom.mall.ebtp.extend.templatewarehouse.entity.BizBidClientVersion; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang.time.DateFormatUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import com.chinaunicom.mall.ebtp.extend.templatewarehouse.dao.BizBidClientVersionMapper; -import com.chinaunicom.mall.ebtp.extend.templatewarehouse.sevice.BizBidClientVersionService; -import com.chinaunicom.mall.ebtp.common.base.service.impl.BaseServiceImpl; -import sun.nio.cs.ext.GBK; +import java.io.IOException; +import java.net.URLEncoder; +import java.util.Map; +import java.util.Optional; import javax.annotation.Resource; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; -import java.io.*; -import java.net.URLEncoder; -import java.text.DateFormat; -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; + +import org.springframework.stereotype.Service; + +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.convertor.ModelConvertor; +import com.chinaunicom.mall.ebtp.common.base.service.impl.BaseServiceImpl; +import com.chinaunicom.mall.ebtp.common.util.JsonUtils; +import com.chinaunicom.mall.ebtp.extend.export.enums.ExportExceptionEnum; +import com.chinaunicom.mall.ebtp.extend.feign.client.DocumentCenterService; +import com.chinaunicom.mall.ebtp.extend.templatewarehouse.dao.BizBidClientVersionMapper; +import com.chinaunicom.mall.ebtp.extend.templatewarehouse.entity.BizBidClientVersion; +import com.chinaunicom.mall.ebtp.extend.templatewarehouse.sevice.BizBidClientVersionService; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; /** * 对数据表 biz_bid_client_version 操作的 serviceImpl diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/timeService/TimeServiceConstant.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/timeService/TimeServiceConstant.java new file mode 100644 index 0000000..3f300f2 --- /dev/null +++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/timeService/TimeServiceConstant.java @@ -0,0 +1,165 @@ +package com.chinaunicom.mall.ebtp.extend.timeService; + +import cn.com.jit.assp.css.client.util.HelperUtil; +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; +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 +public class TimeServiceConstant { + + public static TSAClient client; + + public TimeServiceConstant(){ + try{ + Properties prop = new Properties(); + ClassPathResource classPathResource = new ClassPathResource("cssconfig.properties"); + InputStream inputStream =classPathResource.getInputStream(); + prop.load(inputStream); + inputStream.close(); + + // 获得TSAClient工厂实例 + TSAClientFactory factory = TSAClientFactory.newInstance(prop); + // 获得TSAClient + client = (TSAClient) factory.getTSAClient(); + }catch (Exception e){ + log.error("读取配置文件或连接时间戳服务器异常", e); + } + } + /** + * 申请时间戳 + * @param data 待申请时间戳的原文 + * @return 时间戳加密原文 + */ + public String signTimeStamp(String data){ + try{ + data = data!=null&&!"".equals(data)?data:"system"; + //第三步:申请时间戳,向时间戳服务器发起申请时间戳请求,返回时间戳结果 + TSASignedResult result = client.signTimeStamp("SHA1", data.getBytes("UTF-8")); + //第四步:获取时间戳数据,tsaData为时间戳数据,验证时间戳时使用,如果不是实时验证,需要将时间戳数据保存在应用服务器 + byte[] tsaData = result.getSignedData(); + log.info("tsaData -->"+tsaData); + String timestamp = Base64.encodeBase64String(tsaData); + log.info("timestamp -->"+timestamp); + return timestamp; + }catch (Exception e){ + log.error("申请时间戳异常", e); + } + return null; + } + /** + * 解析时间戳 + * @param timestamp 时间戳加密原文 + * @return 时间戳对象 + */ + public TSAVerifyResult verifyTimeStamp(String timestamp){ + try{ + log.info("timestamp -->"+timestamp); + TSAVerifyResult verifyResult = client.verifyTimeStamp(Base64.decodeBase64(timestamp)); + return verifyResult; + }catch (Exception e){ + log.error("解析时间戳", e); + } + return null; + } + + /** + * 获取时间戳 + * @param data 待申请时间戳的原文 + * @return 时间戳对象 + */ + 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()); + return ttsParseResult; + }catch (Exception e){ + log.error("获取时间戳异常", e); + } + return null; + } + + /** + * 直接获取获取时间戳 时间1 + * @param data 待申请时间戳的原文 + * @return 时间 + */ + public String getServiceTime(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()); + + return time; + }catch (Exception e){ + log.error("获取时间戳异常", e); + } + 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 date; + }catch (Exception e){ + log.error("获取时间戳异常", e); + } + return null; + } + /** + * 获取年月日时分秒分割存储对象 + * @param data 待申请时间戳的原文 + * @return SystemTime + */ + 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()+1900) + .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()+1900)); + System.out.println("-----------"+(date.getMonth()+1)); + System.out.println("-----------"+date.getDate()); + System.out.println("-----------"+date.getHours()); + System.out.println("-----------"+date.getMinutes()); + System.out.println("-----------"+date.getSeconds()); + } +} diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/timeService/controller/TimeServiceController.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/timeService/controller/TimeServiceController.java new file mode 100644 index 0000000..d2e8503 --- /dev/null +++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/timeService/controller/TimeServiceController.java @@ -0,0 +1,112 @@ +package com.chinaunicom.mall.ebtp.extend.timeService.controller; + +import cn.com.jit.tsa.client.TSAVerifyResult; +import com.chinaunicom.mall.ebtp.common.base.entity.BaseResponse; +import com.chinaunicom.mall.ebtp.extend.timeService.TimeServiceConstant; +import com.chinaunicom.mall.ebtp.extend.timeService.tsa.SystemTime; +import com.chinaunicom.mall.ebtp.extend.timeService.tsa.TtsAgent; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + + +@RestController +@Api(tags = "") +@RequestMapping("/v1/timeService") +public class TimeServiceController { + + /** + * 申请时间戳 + * @param data 待申请时间戳的原文 + * @return 时间戳加密原文 + */ + @ApiOperation("申请时间戳") + @GetMapping(value = "/signTimeStamp") + public BaseResponse signTimeStamp(@ApiParam(value = "待申请时间戳的原文", required = false) @RequestParam(name = "data",required = false) String data) { + TimeServiceConstant constant = new TimeServiceConstant(); + return BaseResponse.success(constant.signTimeStamp(data)); + } + + /** + * 解析时间戳 + * @param timestamp 时间戳加密原文 + * @return 时间戳对象 + */ + @ApiOperation("解析时间戳加密原文") + @GetMapping(value = "/verifyTimeStamp") + public BaseResponse verifyTimeStamp(@ApiParam(value = "时间戳加密原文", required = true) @RequestBody String timestamp) { + TimeServiceConstant constant = new TimeServiceConstant(); + return BaseResponse.success(constant.verifyTimeStamp(timestamp)); + } + + /** + * 获取时间戳 + * @param data 待申请时间戳的原文 + * @return 时间戳对象 + */ + @ApiOperation("直接获取时间戳对象(内涵日期)") + @PostMapping(value = "/getServiceTimeObj") + public BaseResponse getServiceTimeObj(@ApiParam(value = "待申请时间戳的原文", required = false) @RequestParam(name = "data",required = false) String data) { + TimeServiceConstant constant = new TimeServiceConstant(); + return BaseResponse.success(constant.getServiceTimeObj(data)); + } + /** + * 直接获取获取时间戳 + * @param data 待申请时间戳的原文 + * @return 时间戳对象 + */ + @ApiOperation("直接获取日期字符串") + @GetMapping(value = "/getServiceTime") + public BaseResponse getServiceTime(@ApiParam(value = "待申请时间戳的原文", required = false) @RequestParam(name = "data",required = false) String data) { + TimeServiceConstant constant = new TimeServiceConstant(); + return BaseResponse.success(constant.getServiceTime(data)); + } + /** + * 获取年月日时分秒分割存储对象 + * @param data 待申请时间戳的原文 + * @return SystemTime + */ + @ApiOperation("获取日期对象SystemTime") + @GetMapping(value = "/getServiceSystemTime") + public BaseResponse getServiceSystemTime(@ApiParam(value = "待申请时间戳的原文", required = false) @RequestParam(name = "data",required = false) String data) { + TimeServiceConstant constant = new TimeServiceConstant(); + return BaseResponse.success(constant.getServiceSystemTime(data)); + } + /** + * 获取开标剩余时间倒数 + * @return + */ + @ApiOperation("获取开标剩余时间倒数") + @GetMapping("/getDescOpenRoomTime") + @PreAuthorize("hasAnyAuthority('ebtp-agency-project-manager','ebtp-purchase','ebtp-supplier')") + public BaseResponse getDescOpenRoomTime(@RequestParam(name = "openTime",required = true) String openTime){ + try { + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + TimeServiceConstant constant = new TimeServiceConstant(); + + Date now = constant.getServiceDate("getDescOpenRoomTime");;//当前时间 + Date date = df.parse(openTime);//过去 + long l = date.getTime()-now.getTime(); + long day = l / (24 * 60 * 60 * 1000); + long hour = (l / (60 * 60 * 1000) - day * 24); + long min = ((l / (60 * 1000)) - day * 24 * 60 - hour * 60); + long s = (l / 1000 - day * 24 * 60 * 60 - hour * 60 * 60 - min * 60); + + SystemTime systemTime = new SystemTime() + .setDate((int) day) + .setHour((int) hour) + .setMinute((int)min) + .setSecond((int)s); + return BaseResponse.success(systemTime); + } catch (ParseException e) { + e.printStackTrace(); + } + return BaseResponse.success(new SystemTime()); + } +} diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/timeService/tsa/SystemTime.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/timeService/tsa/SystemTime.java new file mode 100644 index 0000000..8915664 --- /dev/null +++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/timeService/tsa/SystemTime.java @@ -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; + + + +} diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/timeService/tsa/TtsAgent.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/timeService/tsa/TtsAgent.java new file mode 100644 index 0000000..62e02b5 --- /dev/null +++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/timeService/tsa/TtsAgent.java @@ -0,0 +1,101 @@ +package com.chinaunicom.mall.ebtp.extend.timeService.tsa; + +/** + * CA 时间戳服务接口 + * + * @工程: EPS(4.0) + * + * @模块: + * + * @作者: 李志慧 + * + * @创建日期: 2016年3月17日 + * + * @修改记录(修改时间、作者、原因): + */ +public interface TtsAgent { + + /** + * 创建hash 的时间戳 + * + * @作者: 李志慧 @创建日期: 2016年3月17日 + * + * @参数: hash 数据hash值 + * @返回值: String + * + * @修改记录(修改时间、作者、原因): + */ + String createTimestamp(String hash); + + /** + * 时间戳验证 + * + * @作者: 李志慧 @创建日期: 2016年3月17日 + * + * @参数: timestamp 时间戳 + * @返回值: boolean + * + * @修改记录(修改时间、作者、原因): + */ + boolean verifyTimestamp(String timestamp); + + /** + * 解析时间戳 + * + * @作者: 李志慧 @创建日期: 2016年3月17日 + * + * @参数: timestamp 时间戳 + * @返回值: TtsParseResult + * + * @修改记录(修改时间、作者、原因): + */ + TtsParseResult parseTimestamp(String timestamp); + + /** + * 时间戳解析结果 + * + * @作者: 李志慧 + * + */ + public class TtsParseResult { + // 时间 + private String timestamp; + + // hash 值 + private String hash; + + // 签名证书 + private String cert; + + public TtsParseResult(String timestamp, String hash, String cert) { + super(); + this.timestamp = timestamp; + this.hash = hash; + this.cert = cert; + } + + public String getTimestamp() { + return timestamp; + } + + public void setTimestamp(String timestamp) { + this.timestamp = timestamp; + } + + public String getHash() { + return hash; + } + + public void setHash(String hash) { + this.hash = hash; + } + + public String getCert() { + return cert; + } + + public void setCert(String cert) { + this.cert = cert; + } + } +} \ No newline at end of file diff --git a/src/main/resources/application-pro.yml b/src/main/resources/application-pro.yml index 4128b33..885f90f 100644 --- a/src/main/resources/application-pro.yml +++ b/src/main/resources/application-pro.yml @@ -121,7 +121,6 @@ mybatis-plus: logic-delete-value: deleted # 逻辑已删除值 logic-not-delete-value: normal # 逻辑未删除值 - # --------------feign ------------ feign: httpclient: @@ -168,9 +167,8 @@ mconfig: tender: biz-service-ebtp-tender #投标服务 documentcenter: core-service-document-center #文档中心 - document: - clientHttpUrl: http://10.242.31.158:8100/auth/oauth/token?grant_type=client_credentials&client_id=bVS46ElU&client_secret=58ea04ba02475c8da2321cc99849d2a10f15b749 + clientHttpUrl: http://10.238.25.112:8100/auth/oauth/token?grant_type=client_credentials&client_id=bVS46ElU&client_secret=58ea04ba02475c8da2321cc99849d2a10f15b749 # 用户暴露给 prometheus 的健康数据 management: diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index f2b90d5..027b4e3 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,3 +1,3 @@ spring: profiles: - active: uat \ No newline at end of file + active: test \ No newline at end of file diff --git a/src/main/resources/cssconfig.properties b/src/main/resources/cssconfig.properties new file mode 100644 index 0000000..b4c1764 --- /dev/null +++ b/src/main/resources/cssconfig.properties @@ -0,0 +1,41 @@ +#ServerURL=http://192.168.9.110:8000/signxmlhandler +ServerURL=http://10.249.247.133:8000/signserver/service/xml +#ServerURL=http://192.168.9.110:8000/signserver/service/xml +DigestAlg=SHA1 +#Encrypt Algorithm: des3/scb2 +EncAlg=des3 +CertBaseInfo = version;issuerdn;subjectdn;serialnumber;notbefore;notafter +TSACertBaseInfo = issuerdn;subjectdn;serialnumber;signedTime;signedTSA;signedTimeByMS +CertExtendInfo = +AppID= +CertAlias = +BaseInfo =digestalg;digestdata;plaindata;dscert +SendMsgFormat=0 +HashActionPosition=0 +PrintLog=false +#console/file/log4j ####log4j not implement +logTarget=console +logFilePath=/temp/jit.dss.vstk.log +#rfc3161/rfc2630 +TSAType=rfc3161 +#dsCert/issuerDNAndSN +p1VerifyCertId=dsCert +Compatible=true +dss.client.class=cn.com.jit.assp.client.DSSClientHttpUrlConnectionImpl +#dss.client.class=cn.com.jit.assp.client.DSSClientHttpClientImpl +#default/encAfterDec/secretEnvelop(use this mode after using VCTK do envelop) secretEnvelop:develop->RSAdecrypt->RSAencrypt->envelop +envelopType=default +#default unit KB and default size is 0,0 is not block; +packageSize=0 + +#default:10000 unit: ms +timeout=10000 +connectTimeOut=10000 +# default : system unicode +FileSystemCharSet=UTF-8 +vstkVersion=20 +EncryptMode=ecb +#package size every time, unit is byte +send_size=1048576 +#bigger than this will take big data modle, unit is byte +bigdata_limit=20971520 \ No newline at end of file