exam-system/src/main/java/com/gkhy/exam/pay/utils/BillSign.java
对比新文件 @@ -0,0 +1,147 @@ package com.gkhy.exam.pay.utils; import org.apache.commons.io.FileUtils; import org.dom4j.*; import java.io.File; import java.io.IOException; public class BillSign { ISignCommond signCommond; private static final String HEADER_TAG = "Header"; private static final String EINVOICE_TAG = "EInvoiceData"; public BillSign(ISignCommond signCommond) { /* 28 */ this.signCommond = signCommond; } public String signBill(byte[] bytes) throws BillSignException { /* 41 */ return signBill(new String(bytes)); } public String signBill(File file) throws BillSignException { /* 54 */ if (!file.exists()) { /* 55 */ throw new BillSignException("文件不存在。文件名称" + file.getAbsolutePath()); } try { /* 59 */ byte[] bytes = FileUtils.readFileToByteArray(file); /* 60 */ return signBill(new String(bytes)); /* 61 */ } catch (IOException e) { /* 62 */ throw new BillSignException("文件读取失败。文件名称" + file.getAbsolutePath(), e); } } public String signBill(String xml) throws BillSignException { /* 78 */ Document xmlDoc = null; try { /* 80 */ xmlDoc = DocumentHelper.parseText(xml); /* 81 */ } catch (DocumentException e) { /* 82 */ throw new BillSignException("解析票据文件失败。", e); } /* 86 */ String plain = readRefSignDto(xmlDoc); /* 89 */ Node signNode = genUnitSignNode(plain); /* 92 */ addUnitSign(xmlDoc, signNode); /* 94 */ return xmlDoc.asXML(); } private Node genUnitSignNode(String plain) { /* 100 */ SignDto signDto = this.signCommond.signSm3Detach(plain); /* 102 */ Document document = DocumentHelper.createDocument(); /* 103 */ Element signature = document.addElement("Signature"); /* 104 */ signature.addAttribute("id", "InvoicingParty"); /* 106 */ Element signedInfo = signature.addElement("SignedInfo"); /* 107 */ signedInfo.addElement("Reference").addAttribute("URI", "/EInvoice/Header|/EInvoice/EInvoiceData"); /* 108 */ signedInfo.addElement("SignatureAlgorithm").setText(signDto.getSignatureAlgorithm()); /* 109 */ signedInfo.addElement("SignatureFormat").setText(signDto.getSignatureFormat()); /* 111 */ signature.addElement("SignatureTime").setText(signDto.getSignatureTime()); /* 112 */ signature.addElement("SignatureValue").setText(signDto.getSignatureValue()); /* 114 */ Element keyInfo = signature.addElement("KeyInfo"); /* 115 */ keyInfo.addElement("SerialNumber").setText(signDto.getSerialNumber()); /* 116 */ keyInfo.addElement("X509IssuerName").setText(signDto.getIssuerDn()); /* 117 */ return (Node) signature; } private String readRefSignDto(Document xmlDoc) throws BillSignException { /* 130 */ Element root = xmlDoc.getRootElement(); /* 131 */ if (root.element("Header") == null || root.element("EInvoiceData") == null) { /* 132 */ throw new BillSignException("票据文件格式不正确"); } /* 134 */ return root.element("Header").asXML() + root.element("EInvoiceData").asXML(); } private void addUnitSign(Document xmlDoc, Node signNode) { /* 146 */ Element eInvoiceSignature = xmlDoc.getRootElement().addElement("EInvoiceSignature"); /* 147 */ eInvoiceSignature.add(signNode); } } exam-system/src/main/java/com/gkhy/exam/pay/utils/BillSignException.java
对比新文件 @@ -0,0 +1,27 @@ package com.gkhy.exam.pay.utils; public class BillSignException extends Exception { private static final long serialVersionUID = -7628601258343504944L; public BillSignException() { } public BillSignException(String message) { /* 21 */ super(message); } public BillSignException(String message, Throwable cause) { /* 25 */ super(message, cause); } public BillSignException(Throwable cause) { /* 29 */ super(cause); } } exam-system/src/main/java/com/gkhy/exam/pay/utils/ClientFactory.java
对比新文件 @@ -0,0 +1,245 @@ /* */ package com.gkhy.exam.pay.utils; /* */ /* */ import com.gkhy.exam.pay.utils.config.SdkConfig; import com.gkhy.exam.pay.utils.config.StringUtil; import java.io.IOException; import java.io.InputStream; import java.util.Properties; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public class ClientFactory /* */ { /* */ private static boolean onReady = false; /* */ /* */ public static void initConfig() { /* 25 */ if (!onReady) { /* 26 */ InputStream read = null; /* */ try { /* 28 */ read = ClientFactory.class.getClassLoader().getResourceAsStream("config.properties"); /* */ /* 30 */ if (read != null) { /* 31 */ Properties properties = new Properties(); /* 32 */ properties.load(read); /* 33 */ String appId = properties.getProperty("appId"); /* 34 */ String fsServiceUrl = properties.getProperty("remote.fsweb.service"); /* 35 */ String fsPublicUrl = properties.getProperty("remote.fsweb.public"); /* 36 */ sdkConfig(appId, fsServiceUrl, fsPublicUrl); /* */ } else { /* */ /* 39 */ if (SdkConfig.appId == null) { /* 40 */ SdkConfig.loadSDKProperties(); /* */ } /* 42 */ openClient(); /* */ } /* 44 */ } catch (Exception e) { /* 45 */ e.printStackTrace(); /* 46 */ throw new RuntimeException("加载配置文件错误!"); /* */ } finally { /* */ try { /* 49 */ if (read != null) { /* 50 */ read.close(); /* */ } /* 52 */ } catch (IOException e) { /* 53 */ e.printStackTrace(); /* 54 */ throw new RuntimeException("加载配置文件错误!"); /* */ } /* */ } /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public static ResponseDataVo<?> sdkConfig(String appId, String fsServiceUrl, String fsPublicUrl) { /* 70 */ if (!StringUtil.verificationEmpty(appId) && !StringUtil.verificationEmpty(fsServiceUrl) && /* 71 */ !StringUtil.verificationEmpty(fsPublicUrl)) { /* 72 */ SdkConfig.appId = appId; /* 73 */ SdkConfig.fsServiceUrl = fsServiceUrl; /* 74 */ SdkConfig.fsPublicUrl = fsPublicUrl; /* 75 */ openClient(); /* 76 */ return new ResponseDataVo("0000", null, "设置成功"); /* */ } /* 78 */ return new ResponseDataVo("1111", null, "设置失败"); /* */ } /* */ /* */ /* */ public static void logConfig(String logPath, String logMaxFileSize, String logTotalSizeCap, boolean logAdditive) { /* 83 */ if (logPath != null) { /* 84 */ SdkConfig.logPath = logPath; /* */ } /* 86 */ if (logMaxFileSize != null) { /* 87 */ SdkConfig.logMaxFileSize = logMaxFileSize; /* */ } /* 89 */ if (logTotalSizeCap != null) { /* 90 */ SdkConfig.logTotalSizeCap = logTotalSizeCap; /* */ } /* 92 */ SdkConfig.logAdditive = logAdditive; /* */ /* 94 */ // LoggerBuilder.reLoad(); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ static void openClient() { /* 104 */ onReady = true; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ static void closeClient() { /* 114 */ onReady = false; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ // public static BillClient getBillClient() { // /* 124 */ // initConfig(); // /* */ // /* 126 */ // if (!onReady) { // /* 127 */ // throw new RuntimeException( // /* 128 */ "Your configuration item verification failed. Please call the sdkconfig function to set"); // /* */ // } // /* */ // /* 131 */ // BillClient billClient = (BillClient) (new ClientValidatorAndLogProxy(new BillClientImpl())).newProxyInstance(); // /* 132 */ // return billClient; // /* */ // } // // /* */ // /* */ // /* */ // /* */ // /* */ // /* */ // /* */ // /* */ // public static PaymentClient getPaymentClient() { // /* 142 */ // initConfig(); // /* 143 */ // if (!onReady) { // /* 144 */ // throw new RuntimeException( // /* 145 */ "Your configuration item verification failed. Please call the sdkconfig function to set"); // /* */ // } // /* */ // /* 148 */ // PaymentClient paymentClient = (PaymentClient) (new ClientValidatorAndLogProxy(new PaymentClientImpl())) ///* 149 */.newProxyInstance(); // /* 150 */ // return paymentClient; // /* */ // } /* */ } /* Location: D:\jar\sign_util-1.0-SNAPSHOT.20240227.jar!\BOOT-INF\lib\SNAPSHOT-1.0.0.jar!\com\xjhys\edu\fee\sdk\client\impl\ClientFactory.class * Java compiler version: 8 (52.0) * JD-Core Version: 1.1.3 */ exam-system/src/main/java/com/gkhy/exam/pay/utils/DemoUtils.java
对比新文件 @@ -0,0 +1,276 @@ package com.gkhy.exam.pay.utils; import cn.hutool.http.HttpUtil; import com.alibaba.fastjson2.JSONObject; import org.apache.commons.codec.binary.Base64; import sun.misc.BASE64Encoder; import java.io.*; import java.math.BigDecimal; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.HashMap; import java.util.Map; public class DemoUtils { public JSONObject faqiV2(JSONObject res) { System.out.println("发起接到参数===" + res.toJSONString()); String certNo = res.getString("certNo"); String payerType = res.getString("payerType"); String payUser = res.getString("payUser"); String checker = res.getString("checker"); String enterCode = res.getString("enterCode"); String busCode = res.getString("busCode"); BigDecimal price = res.getBigDecimal("price"); String handlingPerson = res.getString("handlingPerson"); String orderDesc = res.getString("orderDesc"); String invoiceSocialCode = res.getString("invoiceSocialCode"); int amount = res.getIntValue("amount"); String orderNo = "dadadad"; Double money = Double.valueOf(amount * price.doubleValue()); String reqdatastr = "{\"desc\": \"" + orderDesc + "\",\"payerType\": \"" + payerType + "\",\"checker\": \"" + checker + "\",\"amount\": 2,\"orderNo\": \"" + orderNo + "\",\"feeDatas\": [{\"amount\": " + amount + ",\"price\": " + (amount * price.doubleValue()) + ",\"busCode\": \"" + busCode + "\"}],\"money\": " + money + ",\"certNo\": \"" + certNo + "\",\"handlingPerson\": \"" + handlingPerson + "\",\"invoiceSocialCode\": \"" + invoiceSocialCode + "\",\"enterCode\": \"" + enterCode + "\",\"payerName\": \"" + payUser + "\"}"; String mac = getMD5("A1749891493E4CDDBFE4506357B1F0AB||" + getBase64(reqdatastr)); JSONObject jsonObject = new JSONObject(); jsonObject.put("appid", "A1749891493E4CDDBFE4506357B1F0AB"); jsonObject.put("mac", mac); jsonObject.put("reqdata", getBase64(reqdatastr)); Map<String, String> header = new HashMap<>(); header.put("Accept", "application/json;charset=utf-8"); header.put("Content-Type", "application/json;charset=utf-8"); String resultStr = HttpUtil.post("http://finpt.xjcz.gov.cn/fs-service/fs-pay/invoice.do ", (Map) jsonObject); System.out.println("发起入参===" + jsonObject); JSONObject result = JSONObject.parseObject(resultStr); System.out.println("发起回参===" + result); result.put("postData", reqdatastr); JSONObject jsonObject2 = result.getJSONObject("respdata"); String signfile = jsonObject2.getString("fileData"); String orderNo1 = jsonObject2.getString("orderNo"); String xmlFilePath = "F:/nginx-1.15.8/files/payH5/" + orderNo1 + ".xml"; generateBase64StringToFile(signfile, xmlFilePath); String trr2 = ""; try { File file2 = new File(xmlFilePath); FileReader reader1 = new FileReader(file2); BufferedReader bReader = new BufferedReader(reader1); StringBuilder sb = new StringBuilder(); String s = ""; while ((s = bReader.readLine()) != null) { sb.append(s); } bReader.close(); trr2 = sb.toString(); } catch (Exception e) { e.printStackTrace(); } String jmsignfile = signFilejdnew(trr2); String zuizhongpath = montageXmlV3(xmlFilePath, jmsignfile); String zzsignfile = convertFileToBase64(zuizhongpath); uploadXml(orderNo1, zzsignfile); File file = new File(xmlFilePath); file.delete(); File file1 = new File(zuizhongpath); file1.delete(); return result; } public String getMD5(String input) { try { MessageDigest md = MessageDigest.getInstance("MD5"); byte[] messageDigest = md.digest(input.getBytes()); StringBuilder hexString = new StringBuilder(); for (byte b : messageDigest) { hexString.append(String.format("%02x", new Object[]{Byte.valueOf(b)})); } return hexString.toString(); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } } public String getBase64(String str) { String encodedStr = Base64.encodeBase64String(str.getBytes()); return encodedStr; } public static boolean generateBase64StringToFile(String fileStr, String fileFilePath) { if (fileStr == null) { return false; } try { byte[] b = Base64.decodeBase64(fileStr); for (int i = 0; i < b.length; i++) { if (b[i] < 0) { b[i] = (byte) (b[i] + 256); } } OutputStream out = new FileOutputStream(fileFilePath); out.write(b); out.flush(); out.close(); return true; } catch (Exception e) { return false; } } public String signFilejdnew(String plain) { BillSign sign = new BillSign((ISignCommond) new Object()); try { String xx = sign.signBill(plain); return xx; } catch (BillSignException e) { e.printStackTrace(); return null; } } public String uploadXml(String orderNo, String signFile) { ResponseDataVo<?> res = ClientFactory.sdkConfig("A1749891493E4CDDBFE4506357B1F0AB", "http://finpt.xjcz.gov.cn/fs-service", "http://finpt.xjcz.gov.cn/fs-service"); SignatureFileVo signatureFile = new SignatureFileVo(); signatureFile.setFileData(signFile); signatureFile.setOrderNo(orderNo); // BillClient billClient = ClientFactory.getBillClient(); // ResponseDataVo<UploadXmlReponseDataVo> response = billClient.uploadXml(signatureFile); // // String mac = getMD5("A1749891493E4CDDBFE4506357B1F0AB||" + getBase64(signatureFile.toString())); // JSONObject jsonObject = new JSONObject(); // jsonObject.put("appid", "A1749891493E4CDDBFE4506357B1F0AB"); // jsonObject.put("mac", mac); // jsonObject.put("reqdata", getBase64(signatureFile.toString())); return null; } // public JSONObject signFileV2(JSONObject job) throws Exception { // JSONObject xysfResult = new JSONObject(); // String certId = "11650000MB1957293J"; // String plain = job.getString("data").trim(); // MOFSignResult result = null; // Map<String, Object> mmp = new HashMap<>(); // // try { // String filePath = "F:/cssconfig.properties"; // System.out.println("配置文件路径:" + filePath); // // MOFClient client = new MOFClient(filePath); // System.out.println("证书标识为:" + certId); // System.out.println("待签名数据:" + plain); // // // result = client.sign(certId, plain.getBytes(StandardCharsets.UTF_8)); // /* 323 */ // System.out.println("签名返回结果:" + JSONObject.toJSONString(result)); // // /* 325 */ // byte[] signData = result.getSignData(); // // /* 327 */ // String base64Str = new String(Base64.encode(signData)); // /* 328 */ // mmp.put("signResult", base64Str); // // /* 330 */ // MOFVerifyResult resultVer = client.verifySign(signData, plain.getBytes(StandardCharsets.UTF_8)); // /* 331 */ // System.out.println("验签结果为:" + JSONObject.toJSONString(resultVer)); // // /* 333 */ // mmp.put("issure", resultVer.getIssure()); // /* 334 */ // mmp.put("sn", resultVer.getSn()); // /* 335 */ // mmp.put("signTime", resultVer.getSignTime()); // // /* 337 */ // xysfResult.put("success", Boolean.valueOf(true)); // /* 338 */ // xysfResult.put("content", mmp); // /* 339 */ // return xysfResult; // } // /* 341 */ catch (NewCSSException e) { // /* 342 */ // System.out.println("****签名失败****"); // /* 343 */ // System.out.println("错误号为:" + e.getCode()); // /* 344 */ // System.out.println("错误描述为:" + e.getDescription()); // /* 345 */ // xysfResult.put("success", Boolean.valueOf(false)); // /* 346 */ // xysfResult.put("msg", "系统错误"); // /* 347 */ // return xysfResult; // } // } public static String montageXmlV3(String ywfilePath, String xmlStr) { try { /* 358 */ String outputxmlpath = ywfilePath.replace(".xml", "_3.xml"); /* 360 */ xmlStr = xmlStr.trim().replace("\n", ""); /* 361 */ FileWriter writer = new FileWriter(outputxmlpath); /* 362 */ writer.write(xmlStr); /* 363 */ writer.close(); /* 364 */ return outputxmlpath; } /* 366 */ catch (Exception e) { /* 367 */ e.printStackTrace(); /* 369 */ return null; } } public static String convertFileToBase64(String imgPath) { /* 374 */ byte[] data = null; try { /* 377 */ InputStream in = new FileInputStream(imgPath); /* 378 */ data = new byte[in.available()]; /* 379 */ in.read(data); /* 380 */ in.close(); /* 381 */ } catch (IOException e) { /* 382 */ e.printStackTrace(); } /* 385 */ BASE64Encoder encoder = new BASE64Encoder(); /* 386 */ String base64Str = encoder.encode(data); /* 387 */ return base64Str; } } exam-system/src/main/java/com/gkhy/exam/pay/utils/ISignCommond.java
对比新文件 @@ -0,0 +1,6 @@ package com.gkhy.exam.pay.utils; public interface ISignCommond { SignDto signSm3Detach(String paramString); } exam-system/src/main/java/com/gkhy/exam/pay/utils/ResponseDataVo.java
对比新文件 @@ -0,0 +1,105 @@ /* */ package com.gkhy.exam.pay.utils; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public class ResponseDataVo<T> /* */ { /* */ private String respcode; /* */ private String respmsg; /* */ private T respdata; /* */ /* */ public String getRespcode() { /* 21 */ return this.respcode; /* */ } /* */ /* */ public void setRespcode(String respcode) { /* 25 */ this.respcode = respcode; /* */ } /* */ /* */ public String getRespmsg() { /* 29 */ return this.respmsg; /* */ } /* */ /* */ public void setRespmsg(String respmsg) { /* 33 */ this.respmsg = respmsg; /* */ } /* */ /* */ public T getRespdata() { /* 37 */ return this.respdata; /* */ } /* */ /* */ public void setRespdata(T respdata) { /* 41 */ this.respdata = respdata; /* */ } /* */ /* */ /* */ /* */ public ResponseDataVo() { } /* */ /* */ /* */ public ResponseDataVo(String respcode, String respmsg, T respdata) { /* 50 */ this.respcode = respcode; /* 51 */ this.respmsg = respmsg; /* 52 */ this.respdata = respdata; /* */ } /* */ /* */ /* */ public String toString() { /* 57 */ return "ResponseData [respcode=" + this.respcode + ", respmsg=" + this.respmsg + ", respdata=" + this.respdata + "]"; /* */ } /* */ } /* Location: D:\jar\sign_util-1.0-SNAPSHOT.20240227.jar!\BOOT-INF\lib\SNAPSHOT-1.0.0.jar!\com\xjhys\edu\fee\sdk\model\ResponseDataVo.class * Java compiler version: 8 (52.0) * JD-Core Version: 1.1.3 */ exam-system/src/main/java/com/gkhy/exam/pay/utils/SignDto.java
@@ -2,7 +2,6 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import java.util.TimeZone; public class SignDto { @@ -10,73 +9,66 @@ private String signatureFormat; private String signatureTime; private String signatureValue; private String serialNumber; private String issuerDn; private String serialNumber; private static final String UTC_DATE_TIME = "dd MMM yyyy HH:mm:ss z"; private static final String UTC_DATE_TIME = "dd MM yyyy HH:mm:ss z"; public static String formatWithTime(Date date) { SimpleDateFormat sdf = new SimpleDateFormat(UTC_DATE_TIME, Locale.CHINA); public static String formatWithTimeZone(Date date) { /* 48 */ SimpleDateFormat sdf = new SimpleDateFormat(); /* 49 */ sdf.setTimeZone(TimeZone.getTimeZone("GMT+8")); /* 50 */ sdf.applyPattern("dd MMM yyyy HH:mm:ss z"); /* 51 */ return sdf.format(date); } public SignDto(String signatureAlgorithm, String signatureFormat, Date signatureTime, String signatureValue, String serialNumber, String issuerDn) { this.signatureAlgorithm = signatureAlgorithm; this.signatureFormat = signatureFormat; this.signatureTime = formatWithTime(signatureTime); public SignDto(Date signatureTime, String signatureValue, String issuerDn, String serialNumber) { /* 56 */ this.signatureAlgorithm = "sm3"; /* 57 */ this.signatureFormat = "DETACH"; /* 58 */ this.signatureTime = formatWithTimeZone(signatureTime); /* 59 */ this.signatureValue = signatureValue; this.serialNumber = serialNumber; /* 60 */ this.issuerDn = issuerDn; /* 61 */ this.serialNumber = serialNumber; } // Getters and Setters public String getSignatureAlgorithm() { return signatureAlgorithm; } public void setSignatureAlgorithm(String signatureAlgorithm) { this.signatureAlgorithm = signatureAlgorithm; /* 65 */ return this.signatureAlgorithm; } public String getSignatureFormat() { return signatureFormat; } public void setSignatureFormat(String signatureFormat) { this.signatureFormat = signatureFormat; /* 69 */ return this.signatureFormat; } public String getSignatureTime() { return signatureTime; } public void setSignatureTime(String signatureTime) { this.signatureTime = signatureTime; /* 73 */ return this.signatureTime; } public String getSignatureValue() { return signatureValue; } public void setSignatureValue(String signatureValue) { this.signatureValue = signatureValue; } public String getSerialNumber() { return serialNumber; } public void setSerialNumber(String serialNumber) { this.serialNumber = serialNumber; /* 77 */ return this.signatureValue; } public String getIssuerDn() { return issuerDn; /* 81 */ return this.issuerDn; } public void setIssuerDn(String issuerDn) { this.issuerDn = issuerDn; public String getSerialNumber() { /* 85 */ return this.serialNumber; } } exam-system/src/main/java/com/gkhy/exam/pay/utils/SignatureFileVo.java
对比新文件 @@ -0,0 +1,55 @@ package com.gkhy.exam.pay.utils; /* */ public class SignatureFileVo /* */ { /* */ // @Validator(validatorType = 2, rangeInt = {1, 50}) /* */ private String orderNo; /* */ // @Validator(validatorType = 1) /* */ private String fileData; /* */ /* */ public String getOrderNo() { /* 24 */ return this.orderNo; /* */ } /* */ /* */ public void setOrderNo(String orderNo) { /* 28 */ this.orderNo = orderNo; /* */ } /* */ /* */ public String getFileData() { /* 32 */ return this.fileData; /* */ } /* */ /* */ public void setFileData(String fileData) { /* 36 */ this.fileData = fileData; /* */ } /* */ /* */ /* */ public String toString() { /* 41 */ return "SignatureFile [orderNo=" + this.orderNo + ", fileData=" + this.fileData + "]"; /* */ } /* */ } exam-system/src/main/java/com/gkhy/exam/pay/utils/UploadXmlReponseDataVo.java
对比新文件 @@ -0,0 +1,46 @@ /* */ package com.gkhy.exam.pay.utils; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public class UploadXmlReponseDataVo /* */ { /* */ private String orderId; /* */ /* */ public String getOrderId() { /* 14 */ return this.orderId; /* */ } /* */ /* */ public void setOrderId(String orderId) { /* 18 */ this.orderId = orderId; /* */ } /* */ /* */ /* */ public String toString() { /* 23 */ return "UploadXmlReponseData [orderId=" + this.orderId + "]"; /* */ } /* */ } /* Location: D:\jar\sign_util-1.0-SNAPSHOT.20240227.jar!\BOOT-INF\lib\SNAPSHOT-1.0.0.jar!\com\xjhys\edu\fee\sdk\model\UploadXmlReponseDataVo.class * Java compiler version: 8 (52.0) * JD-Core Version: 1.1.3 */ exam-system/src/main/java/com/gkhy/exam/pay/utils/config/PropertiesConfig.java
对比新文件 @@ -0,0 +1,18 @@ package com.gkhy.exam.pay.utils.config; import java.lang.annotation.*; @Target({ElementType.FIELD, ElementType.METHOD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @Documented public @interface PropertiesConfig { String fileName() default ""; String name() default ""; } /* Location: D:\jar\sign_util-1.0-SNAPSHOT.20240227.jar!\BOOT-INF\lib\SNAPSHOT-1.0.0.jar!\com\xjhys\edu\fee\sdk\annotation\PropertiesConfig.class * Java compiler version: 8 (52.0) * JD-Core Version: 1.1.3 */ exam-system/src/main/java/com/gkhy/exam/pay/utils/config/PropertiesUtil.java
对比新文件 @@ -0,0 +1,218 @@ /* */ package com.gkhy.exam.pay.utils.config; /* */ /* */ import com.xjhys.edu.fee.sdk.annotation.PropertiesConfig; import java.io.IOException; import java.io.InputStream; import java.lang.reflect.Field; import java.net.URL; import java.sql.Date; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Properties; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public class PropertiesUtil /* */ { /* */ public static final String PROPERTIES_SUFFIX_NAME = "properties"; /* */ public static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss"; /* */ public static final String RESOURCES_PATH = "/"; /* */ public static final String INT_NAME = "int"; /* */ public static final String DOUBLE_NAME = "double"; /* */ public static final String FLOAT_NAME = "float"; /* */ public static final String LONG_NAME = "long"; /* */ public static final String METHOD_SET = "set"; /* */ /* */ public static Properties loadPropertiesFile(InputStream in) throws IOException { /* 43 */ Properties p = new Properties(); /* 44 */ p.load(in); /* 45 */ return p; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public static void loadData(Object propertiesBean) throws IOException { /* 56 */ if (propertiesBean == null) { /* */ return; /* */ } /* 59 */ PropertiesConfig pc = propertiesBean.getClass().<PropertiesConfig>getAnnotation(PropertiesConfig.class); /* 60 */ String fileNmae = pc.fileName(); /* 61 */ loadData(fileNmae, propertiesBean); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public static void loadData(String fileNmae, Object propertiesBean) throws IOException { /* 75 */ if (propertiesBean == null) { /* */ return; /* */ } /* 78 */ URL url = PropertiesUtil.class.getResource("/" + fileNmae); /* 79 */ InputStream openStream = url.openStream(); /* 80 */ Properties p = loadPropertiesFile(openStream); /* 81 */ Field[] fs = propertiesBean.getClass().getDeclaredFields(); /* 82 */ for (int i = 0; i < fs.length; i++) { /* 83 */ Field field = fs[i]; /* 84 */ PropertiesConfig pc = field.<PropertiesConfig>getAnnotation(PropertiesConfig.class); /* 85 */ String pKey = field.getName(); /* 86 */ String value = null; /* 87 */ if (pc != null) { /* 88 */ value = p.getProperty(pc.name()); /* */ } else { /* 90 */ value = p.getProperty(pKey); /* */ } /* 92 */ if (value != null) { /* 93 */ field.setAccessible(true); /* */ try { /* 95 */ field.set(propertiesBean, conversion(value, field.getType())); /* 96 */ } catch (IllegalArgumentException e) { /* */ /* 98 */ e.printStackTrace(); /* 99 */ } catch (IllegalAccessException e) { /* */ /* 101 */ e.printStackTrace(); /* */ } /* */ } /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public static Object conversion(String value, Class<?> type) { /* 118 */ if (value == null) { /* 119 */ return null; /* */ } /* 121 */ if ("int".equals(type.getName()) || type.getName().equals(Integer.class.getName())) /* 122 */ return Integer.valueOf(value); /* 123 */ if ("double".equals(type.getName()) || type.getName().equals(Double.class.getName())) /* 124 */ return Double.valueOf(value); /* 125 */ if ("float".equals(type.getName()) || type.getName().equals(Float.class.getName())) /* 126 */ return Float.valueOf(value); /* 127 */ if ("long".equals(type.getName()) || type.getName().equals(Long.class.getName())) /* 128 */ return Long.valueOf(value); /* 129 */ if (type.getName().equals(Date.class.getName())) { /* 130 */ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); /* */ try { /* 132 */ return format.parse(value); /* 133 */ } catch (ParseException e) { /* */ /* 135 */ e.printStackTrace(); /* */ } /* */ } /* */ /* 139 */ return value; /* */ } /* */ } /* Location: D:\jar\sign_util-1.0-SNAPSHOT.20240227.jar!\BOOT-INF\lib\SNAPSHOT-1.0.0.jar!\com\xjhys\edu\fee\sd\\utils\PropertiesUtil.class * Java compiler version: 8 (52.0) * JD-Core Version: 1.1.3 */ exam-system/src/main/java/com/gkhy/exam/pay/utils/config/SdkConfig.java
对比新文件 @@ -0,0 +1,99 @@ /* */ package com.gkhy.exam.pay.utils.config; /* */ /* */ import java.io.File; import java.io.IOException; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ @PropertiesConfig(fileName = "sdk.properties") /* */ public class SdkConfig /* */ { /* */ static { /* 20 */ loadSDKProperties(); /* */ } /* */ /* */ /* */ /* 25 */ public static final String tempPath = String.valueOf(System.getProperty("java.io.tmpdir")) + File.separator; /* */ /* */ /* */ public static int connectionRequestTimeOut; /* */ /* */ /* */ public static int connectionTimeout; /* */ /* */ /* */ public static int socketTimeOut; /* */ /* */ /* */ public static String logPath; /* */ /* */ /* */ public static String logMaxFileSize; /* */ /* */ /* */ public static String logTotalSizeCap; /* */ /* */ /* */ public static int logMaxHistory; /* */ /* */ public static boolean logAdditive = true; /* */ /* */ @PropertiesConfig(name = "appId") /* */ public static String appId; /* */ /* */ @PropertiesConfig(name = "remote.fsweb.service") /* */ public static String fsServiceUrl; /* */ /* */ @PropertiesConfig(name = "remote.fsweb.public") /* */ public static String fsPublicUrl; /* */ /* */ /* */ public static void loadSDKProperties() { /* */ try { /* 62 */ PropertiesUtil.loadData(new SdkConfig()); /* */ /* 64 */ logPath = StringUtil.appendMsg(new String[]{tempPath, logPath}); /* */ /* 66 */ fsPublicUrl = StringUtil.getUrl(fsPublicUrl); /* 67 */ fsServiceUrl = StringUtil.getUrl(fsServiceUrl); /* 68 */ } catch (IOException e) { /* 69 */ e.printStackTrace(); /* */ } /* */ } /* */ } /* Location: D:\jar\sign_util-1.0-SNAPSHOT.20240227.jar!\BOOT-INF\lib\SNAPSHOT-1.0.0.jar!\com\xjhys\edu\fee\sdk\config\SdkConfig.class * Java compiler version: 8 (52.0) * JD-Core Version: 1.1.3 */ exam-system/src/main/java/com/gkhy/exam/pay/utils/config/StringUtil.java
对比新文件 @@ -0,0 +1,89 @@ /* */ package com.gkhy.exam.pay.utils.config; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public class StringUtil /* */ { /* */ public static String appendMsg(String... values) { /* 17 */ StringBuilder sb = new StringBuilder(); /* 18 */ if (values != null && values.length > 0) { /* 19 */ for (int i = 0; i < values.length; i++) { /* 20 */ sb.append(values[i]); /* */ } /* */ } /* 23 */ return sb.toString(); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public static String getUrl(String url) { /* 31 */ if (url == null) { /* 32 */ return null; /* */ } /* 34 */ url = url.replaceAll("[\\t\\n\\r\\s+]", "").replaceAll("/+", "/").replaceFirst("/", "//").replaceAll("/+$", ""); /* 35 */ return url; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public static boolean verificationEmpty(String value) { /* 43 */ if (value == null) { /* 44 */ return true; /* */ } /* 46 */ value = value.replaceAll("[\\t\\n\\r\\s+]", ""); /* 47 */ if ("".equals(value)) { /* 48 */ return true; /* */ } /* 50 */ return false; /* */ } /* */ } /* Location: D:\jar\sign_util-1.0-SNAPSHOT.20240227.jar!\BOOT-INF\lib\SNAPSHOT-1.0.0.jar!\com\xjhys\edu\fee\sd\\utils\StringUtil.class * Java compiler version: 8 (52.0) * JD-Core Version: 1.1.3 */ exam-system/src/main/resources/sdk.properties
对比新文件 @@ -0,0 +1,20 @@ #从连接池中获取连接的超时时间(单位:ms) connectionRequestTimeOut=5000 #与服务器连接的超时时间(单位:ms) connectionTimeout=5000 #从服务器获取响应数据的超时时间(单位:ms) socketTimeOut=10000 #日志地址 logPath=sdklog #日志文件最大值 2GB logMaxFileSize=2MB #日志总量最大值 logTotalSizeCap=20MB #最大历史记录数量 logMaxHistory=15 #网站接入码 appId=4896FAE0994B46B0A29237DC575C0CCD #非税业务平台地址 remote.fsweb.service=http://finpt.xjcz.gov.cn/fs-service-test #非税支付平台地址 remote.fsweb.public=http://finpt.xjcz.gov.cn/fs-public-test