### Question:
DigitalValidateContainer implements SignedDataValidateContainer { @Override public void validate(SigType type, String alg, byte[] tbsContent, byte[] signedValue) throws InvalidSignedValueException, GeneralSecurityException { if (type != SigType.Sign) { throw new IllegalArgumentException("签名类型(type)必须是 Sign，不支持电子印章验证"); } Signature sg = Signature.getInstance(alg, new BouncyCastleProvider()); sg.initVerify(pk); sg.update(tbsContent); if (!sg.verify(signedValue)) { throw new InvalidSignedValueException("签名值不一致"); } } DigitalValidateContainer(PublicKey pk);  DigitalValidateContainer(Certificate certificate); @Override void validate(SigType type, String alg, byte[] tbsContent, byte[] signedValue); public PublicKey pk; }### Answer:
@Test void validate() throws IOException, GeneralSecurityException { Path src = Paths.get("target/DigitalSign", "DigitalSign.ofd"); Path userP12Path = Paths.get("src/test/resources", "USER.p12"); Certificate cert = PKCS12Tools.ReadUserCert(userP12Path, "private", "777777"); try (OFDReader reader = new OFDReader(src); OFDValidator validator = new OFDValidator(reader)) { DigitalValidateContainer dsc = new DigitalValidateContainer(cert); validator.setValidator(dsc); validator.exeValidate(); System.out.println(">> 验证通过"); } }