### Question:
SESV4Container implements ExtendSignatureContainer { @Override public byte[] sign(InputStream inData, String propertyInfo) throws IOException, GeneralSecurityException { MessageDigest md = getDigestFnc(); byte[] dataHash = md.digest(IOUtils.toByteArray(inData)); TBS_Sign toSign = new TBS_Sign() .setVersion(SES_Header.V4) .setEseal(seal) .setTimeInfo(new ASN1GeneralizedTime(new Date())) .setDataHash(dataHash) .setPropertyInfo(propertyInfo); Signature sg = Signature.getInstance("SM3WithSM2", new BouncyCastleProvider()); sg.initSign(privateKey); sg.update(toSign.getEncoded("DER")); final byte[] sigVal = sg.sign(); SES_Signature signature = new SES_Signature() .setToSign(toSign) .setCert(certificate) .setSignatureAlgID(GMObjectIdentifiers.sm2sign_with_sm3) .setSignature(sigVal); return signature.getEncoded("DER"); } SESV4Container(PrivateKey privateKey, SESeal seal, Certificate signCert); @Override MessageDigest getDigestFnc(); @Override ASN1ObjectIdentifier getSignAlgOID(); @Override byte[] sign(InputStream inData, String propertyInfo); @Override byte[] getSeal(); @Override SigType getSignType();  }### Answer:
@Test public void sign() throws GeneralSecurityException, IOException { Path userP12Path = Paths.get("src/test/resources", "USER.p12"); Path sealPath = Paths.get("src/test/resources", "UserV4.esl"); PrivateKey prvKey = PKCS12Tools.ReadPrvKey(userP12Path, "private", "777777"); Certificate signCert = PKCS12Tools.ReadUserCert(userP12Path, "private", "777777"); SESeal seal = SESeal.getInstance(Files.readAllBytes(sealPath)); Path src = Paths.get("src/test/resources", "helloworld.ofd"); Path out = Paths.get("target/SESV4SignDoc.ofd"); try (OFDReader reader = new OFDReader(src); OFDSigner signer = new OFDSigner(reader, out) ) { SESV4Container signContainer = new SESV4Container(prvKey, seal, signCert); signer.setSignMode(SignMode.ContinueSign); signer.setSignContainer(signContainer); signer.addApPos(new NormalStampPos(1, 50, 50, 40, 40)); signer.exeSign(); } System.out.println(">> 生成文件位置: " + out.toAbsolutePath().toAbsolutePath()); }