| | |
| | | |
| | | String reqdatastr = JSONObject.toJSONString(payReqData); |
| | | |
| | | String mac = this.getMD5(appId + this.getBase64(reqdatastr)); |
| | | String mac = this.getMD5(appId+"||"+ this.getBase64(payReqData)); |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("appid", appId); |
| | | jsonObject.put("mac", mac); |
| | | jsonObject.put("reqdata", this.getBase64(reqdatastr)); |
| | | jsonObject.put("reqdata", this.getBase64(payReqData)); |
| | | Map<String, String> header = new HashMap(); |
| | | header.put("Accept", "application/json;charset=utf-8"); |
| | | header.put("Content-Type", "application/json;charset=utf-8"); |
| | |
| | | JSONObject jsonObject2 = result.getJSONObject("respdata"); |
| | | String signfile = jsonObject2.getString("fileData"); |
| | | String orderNo1 = jsonObject2.getString("orderNo"); |
| | | String xmlFilePath = "F:/files/" + orderNo1 + ".xml"; |
| | | // /home/www/swspkmas/files/ |
| | | // String xmlFilePath = "/home/www/swspkmas/files/" + orderNo1 + ".xml"; |
| | | String xmlFilePath = "F:\\text\\" + orderNo1 + ".xml"; |
| | | generateBase64StringToFile(signfile, xmlFilePath); |
| | | String trr2 = ""; |
| | | |
| | |
| | | Map<String, Object> mmp = new HashMap(); |
| | | |
| | | try { |
| | | String filePath = "/www/wwwroot/exam/cssconfig.properties"; |
| | | String filePath = "F:\\text/cssconfig.properties"; |
| | | System.out.println("配置文件路径:" + filePath); |
| | | MOFClient client = new MOFClient(filePath); |
| | | System.out.println("证书标识为:" + certId); |
| | |
| | | } |
| | | } |
| | | |
| | | public String getBase64(String str) { |
| | | String encodedStr = org.apache.commons.codec.binary.Base64.encodeBase64String(str.getBytes()); |
| | | return encodedStr; |
| | | public String getBase64(PayReqData str) { |
| | | // String encodedStr = org.apache.commons.codec.binary.Base64.encodeBase64String(str.getBytes()); |
| | | String reqData = Base64.getEncoder().encodeToString(JSONObject.toJSONString(str).getBytes()); |
| | | |
| | | return reqData; |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | // Map<String, Object> mmp = new HashMap<>(); |
| | | |
| | | try { |
| | | String filePath = "F:\\text\\cssconfig.properties"; |
| | | // String filePath = "/home/www/swspkmas/cssconfig.properties"; |
| | | String filePath = "F:\\text/cssconfig.properties"; |
| | | System.out.println("配置文件路径:" + filePath); |
| | | MOFClient client = new MOFClient(filePath); |
| | | System.out.println("证书标识为:" + certId); |
| | |
| | | SignResult result = null; |
| | | String certId = "11650000MB1957293J"; |
| | | try { |
| | | MOFClient client = new MOFClient("F:\\text\\cssconfig.properties"); |
| | | MOFClient client = new MOFClient("/home/www/swspkmas/cssconfig.properties"); |
| | | result = client.sign(certId, strData.getBytes(StandardCharsets.UTF_8)); |
| | | log.info("***签名成功***"); |
| | | log.info("签名返回结果为:" + result); |
| | |
| | | public MOFVerifyResult verify(byte[] strData, String signData) { |
| | | MOFVerifyResult verify = null; |
| | | try { |
| | | MOFClient client = new MOFClient("F:\\text\\cssconfig.properties"); |
| | | MOFClient client = new MOFClient("/home/www/swspkmas/cssconfig.properties"); |
| | | |
| | | verify = client.verifySign(strData, signData.getBytes(StandardCharsets.UTF_8)); |
| | | log.info("验签成功"); |
| | |
| | | public EnvelopResult encryptEnvelop(byte[] plain) { |
| | | EnvelopResult envelopResult = null; |
| | | try { |
| | | AdvanceSignClient client = new AdvanceSignClient("F:\\text\\cssconfig.properties"); |
| | | AdvanceSignClient client = new AdvanceSignClient("/home/www/swspkmas/cssconfig.properties"); |
| | | String certId = "rsa"; |
| | | CertIdParams certIdParams = new CertIdParams(certId); |
| | | //将封装好的加密证书参数对象放入 数组中 |
| | |
| | | public DecryptResult decryptEnvelop(String signData) { |
| | | DecryptResult result = null; |
| | | try { |
| | | AdvanceSignClient client = new AdvanceSignClient("F:\\text\\cssconfig.properties"); |
| | | AdvanceSignClient client = new AdvanceSignClient("/home/www/swspkmas/cssconfig.properties"); |
| | | byte[] enc_data = signData.getBytes(); |
| | | result = client.decryptEnvelop(enc_data); |
| | | log.info("解密数字信封结果成功"); |