| | |
| | | import javax.net.ssl.SSLContext; |
| | | import javax.net.ssl.TrustManager; |
| | | import javax.net.ssl.X509TrustManager; |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.IOException; |
| | | import java.io.OutputStreamWriter; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.io.*; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.security.KeyManagementException; |
| | | import java.security.NoSuchAlgorithmException; |
| | |
| | | Map<String, String> param = new HashMap<>(); |
| | | |
| | | HttpPost httpPost = new HttpPost("http://finpt.xjcz.gov.cn/fs-service-test/fs-pay/invoice.do"); |
| | | |
| | | log.info("请求地址:"+"http://finpt.xjcz.gov.cn/fs-service-test/fs-pay/invoice.do"); |
| | | //请求参数转为json格式base64编码 |
| | | String reqData = Base64.getEncoder().encodeToString(JSONObject.toJSONString(payReqData).getBytes()); |
| | | String mac = "ED76A5F1703540BE977D34780B371FEB" + "||" + reqData; |
| | | mac = DigestUtils.md5Hex(mac.getBytes()); |
| | | param.put("appid", "ED76A5F1703540BE977D34780B371FEB"); |
| | | log.info("请求appid:"+"ED76A5F1703540BE977D34780B371FEB"); |
| | | param.put("reqdata", reqData); |
| | | param.put("mac", mac); |
| | | |
| | |
| | | } |
| | | |
| | | //上传财政电子票据签名文件 |
| | | public ResultVo uploadXml(String orderId, String plain) throws IOException { |
| | | public ResultVo uploadXml(String orderId, byte[] plain) throws IOException { |
| | | Map<String, String> params = new HashMap<>(); |
| | | |
| | | Sign sign = new Sign(); |
| | |
| | | |
| | | |
| | | //签名 |
| | | public SignResult sign(String strData) { |
| | | public SignResult sign(byte[] strData) { |
| | | SignResult result = null; |
| | | String certId = "rsa"; |
| | | try { |
| | | AdvanceSignClient client = new AdvanceSignClient("cssconfig.properties"); |
| | | result = client.sign(certId,strData.getBytes()); |
| | | result = client.sign(certId,strData); |
| | | log.info("***签名成功***"); |
| | | byte[] signData = result.getSignData(); |
| | | String s = new String(Base64.getEncoder().encode(signData)); |
| | |
| | | /** |
| | | * 验签名 |
| | | */ |
| | | public VerifyResult verify(String strData,String signData){ |
| | | public VerifyResult verify(byte[] strData,String signData){ |
| | | VerifyResult verify = null; |
| | | try { |
| | | AdvanceSignClient client = new AdvanceSignClient("cssconfig.properties"); |
| | | byte[] plain = strData.getBytes(); |
| | | AdvanceSignClient client = new AdvanceSignClient("src/main/resources/cssconfig.properties"); |
| | | byte[] plain = strData; |
| | | byte[] sign = signData.getBytes(); |
| | | |
| | | verify = client.verify(sign, plain); |