| | |
| | | |
| | | import cn.com.jit.new_vstk.AdvanceSignClient; |
| | | import cn.com.jit.new_vstk.Bean.*; |
| | | import cn.com.jit.new_vstk.SignClient; |
| | | import cn.com.jit.new_vstk.exception.NewCSSException; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.gkhy.exam.pay.entity.PayReqData; |
| | |
| | | public ResultVo uploadXml(String orderId, byte[] plain) throws IOException { |
| | | Map<String, String> params = new HashMap<>(); |
| | | |
| | | Sign sign = new Sign(); |
| | | SignResult sign1 = this.sign(plain); |
| | | log.info("签名结果为:"+ Arrays.toString(sign1.getSignData())); |
| | | VerifyResult verify = this.verify(plain, new String(sign1.getSignData())); |
| | | SignDto signDto = new SignDto("SM3", "Base64", new Date(), verify.getReturnData(), verify.getSerialNumber(), verify.getIssure()); |
| | | Element signature = sign.getSignature(signDto); |
| | | // Sign sign = new Sign(); |
| | | // SignResult sign1 = this.sign(plain); |
| | | // log.info("签名结果为:"+ Arrays.toString(sign1.getSignData())); |
| | | // VerifyResult verify = this.verify(plain, sign1.getSignData()); |
| | | // SignDto signDto = new SignDto("SM3", "Base64", new Date(), verify.getReturnData(), verify.getSerialNumber(), verify.getIssure()); |
| | | // Element signature = sign.getSignature(signDto); |
| | | |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("orderNo",orderId); |
| | | jsonObject.put("fileData", Base64.getEncoder().encodeToString(convertElementToByteArray(signature))); |
| | | jsonObject.put("fileData", Base64.getEncoder().encodeToString(plain)); |
| | | |
| | | String reqdata = Base64.getEncoder().encodeToString(jsonObject.toJSONString().getBytes()); |
| | | String mac = appId+"||" +reqdata; |
| | | String mac = "ED76A5F1703540BE977D34780B371FEB"+"||" +reqdata; |
| | | mac = DigestUtils.md5Hex(mac.getBytes()); |
| | | |
| | | params.put("appid",appId); |
| | | params.put("appid","ED76A5F1703540BE977D34780B371FEB"); |
| | | params.put("reqdata",reqdata); |
| | | params.put("mac",mac); |
| | | |
| | | HttpPost httpPost = new HttpPost(uploadXmlUrl); |
| | | HttpPost httpPost = new HttpPost("http://finpt.xjcz.gov.cn/fs-service-test/fs-pay/uploadXml.do"); |
| | | httpPost.setEntity(assemblyFormEntity(params,"utf-8")); |
| | | HttpClient httpClient = getHttpClient(uploadXmlUrl); |
| | | HttpClient httpClient = getHttpClient("http://finpt.xjcz.gov.cn/fs-service-test/fs-pay/uploadXml.do"); |
| | | HttpResultVo execute = httpClient.execute(httpPost, getResponseHandler()); |
| | | String stringContent = execute.getStringContent(); |
| | | ResultVo resultVo = JSONObject.parseObject(stringContent, ResultVo.class); |
| | |
| | | SignResult result = null; |
| | | String certId = "11650000MB1957293J"; |
| | | try { |
| | | AdvanceSignClient client = new AdvanceSignClient("D:\\work\\cssconfig.properties"); |
| | | AdvanceSignClient client = new AdvanceSignClient("F:\\text\\cssconfig.properties"); |
| | | result = client.sign(certId,strData); |
| | | log.info("***签名成功***"); |
| | | byte[] signData = result.getSignData(); |
| | |
| | | /** |
| | | * 验签名 |
| | | */ |
| | | public VerifyResult verify(byte[] strData,String signData){ |
| | | public VerifyResult verify(byte[] strData,byte[] signData){ |
| | | VerifyResult verify = null; |
| | | try { |
| | | AdvanceSignClient client = new AdvanceSignClient("F:\\text\\cssconfig.properties"); |
| | | SignClient client = new SignClient("F:\\text\\cssconfig.properties"); |
| | | byte[] plain = strData; |
| | | byte[] sign = signData.getBytes(); |
| | | byte[] sign = signData; |
| | | |
| | | verify = client.verify(sign, plain); |
| | | log.info("验签成功"); |
| | |
| | | /** |
| | | * 制作数字信封 |
| | | */ |
| | | public EnvelopResult encryptEnvelop(String plain){ |
| | | public EnvelopResult encryptEnvelop(byte[] plain){ |
| | | EnvelopResult envelopResult = null; |
| | | try { |
| | | AdvanceSignClient client = new AdvanceSignClient("F:\\text\\cssconfig.properties"); |
| | |
| | | CertIdParams certIdParams = new CertIdParams(certId); |
| | | //将封装好的加密证书参数对象放入 数组中 |
| | | CertParams[] envelopCerts = new CertIdParams[]{certIdParams}; |
| | | byte[] bytes = plain.getBytes(); |
| | | /* 制作信封 */ |
| | | envelopResult = client.encryptEnvelop(envelopCerts, bytes); |
| | | envelopResult = client.encryptEnvelop(envelopCerts, plain); |
| | | byte[] envelopData = envelopResult.getEnvelopData(); |
| | | log.info("信封结果:["+envelopData+"]"); |
| | | } catch (NewCSSException e) { |