| | |
| | | package com.gkhy.exam.pay.utils; |
| | | |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import org.apache.commons.io.FileUtils; |
| | | import org.dom4j.*; |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.util.Map; |
| | | |
| | | public class BillSign { |
| | | ISignCommond signCommond; |
| | |
| | | |
| | | } |
| | | |
| | | public BillSign(){} |
| | | |
| | | public String signBill(byte[] bytes) throws BillSignException { |
| | | |
| | | public String signBill(byte[] bytes) throws Exception { |
| | | /* 41 */ |
| | | return signBill(new String(bytes)); |
| | | |
| | |
| | | /* 62 */ |
| | | throw new BillSignException("文件读取失败。文件名称" + file.getAbsolutePath(), e); |
| | | |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | public String signBill(String xml) throws BillSignException { |
| | | public String signBill(String xml) throws Exception { |
| | | /* 78 */ |
| | | Document xmlDoc = null; |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | private Node genUnitSignNode(String plain) { |
| | | private Node genUnitSignNode(String plain) throws Exception { |
| | | /* 100 */ |
| | | SignDto signDto = this.signCommond.signSm3Detach(plain); |
| | | PayUtils payUtils = new PayUtils(); |
| | | JSONObject jsonObject = payUtils.signFileV2(plain); |
| | | SignDto content = (SignDto) jsonObject.get("content"); |
| | | |
| | | /* 102 */ |
| | | Document document = DocumentHelper.createDocument(); |
| | |
| | | /* 107 */ |
| | | signedInfo.addElement("Reference").addAttribute("URI", "/EInvoice/Header|/EInvoice/EInvoiceData"); |
| | | /* 108 */ |
| | | signedInfo.addElement("SignatureAlgorithm").setText(signDto.getSignatureAlgorithm()); |
| | | signedInfo.addElement("SignatureAlgorithm").setText(content.getSignatureAlgorithm()); |
| | | /* 109 */ |
| | | signedInfo.addElement("SignatureFormat").setText(signDto.getSignatureFormat()); |
| | | signedInfo.addElement("SignatureFormat").setText(content.getSignatureFormat()); |
| | | |
| | | /* 111 */ |
| | | signature.addElement("SignatureTime").setText(signDto.getSignatureTime()); |
| | | signature.addElement("SignatureTime").setText(content.getSignatureTime()); |
| | | /* 112 */ |
| | | signature.addElement("SignatureValue").setText(signDto.getSignatureValue()); |
| | | signature.addElement("SignatureValue").setText(content.getSignatureValue()); |
| | | |
| | | /* 114 */ |
| | | Element keyInfo = signature.addElement("KeyInfo"); |
| | | /* 115 */ |
| | | keyInfo.addElement("SerialNumber").setText(signDto.getSerialNumber()); |
| | | keyInfo.addElement("SerialNumber").setText(content.getSerialNumber()); |
| | | /* 116 */ |
| | | keyInfo.addElement("X509IssuerName").setText(signDto.getIssuerDn()); |
| | | keyInfo.addElement("X509IssuerName").setText(content.getIssuerDn()); |
| | | /* 117 */ |
| | | return (Node) signature; |
| | | |
| | | } |
| | | |
| | | |
| | | private String readRefSignDto(Document xmlDoc) throws BillSignException { |
| | | public String readRefSignDto(Document xmlDoc) throws BillSignException { |
| | | /* 130 */ |
| | | Element root = xmlDoc.getRootElement(); |
| | | /* 131 */ |