public virtual void LtvEnabledTest01()
        {
            String tsaCertFileName = certsSrc + "tsCertRsa.p12";
            String caCertFileName  = certsSrc + "rootRsa.p12";
            String srcFileName     = sourceFolder + "signedDoc.pdf";
            String ltvFileName     = destinationFolder + "ltvEnabledTest01.pdf";
            String ltvTsFileName   = destinationFolder + "ltvEnabledTsTest01.pdf";

            X509Certificate[] tsaChain       = Pkcs12FileHelper.ReadFirstChain(tsaCertFileName, password);
            ICipherParameters tsaPrivateKey  = Pkcs12FileHelper.ReadFirstKey(tsaCertFileName, password, password);
            X509Certificate   caCert         = (X509Certificate)Pkcs12FileHelper.ReadFirstChain(caCertFileName, password)[0];
            ICipherParameters caPrivateKey   = Pkcs12FileHelper.ReadFirstKey(caCertFileName, password, password);
            TestTsaClient     testTsa        = new TestTsaClient(JavaUtil.ArraysAsList(tsaChain), tsaPrivateKey);
            TestOcspClient    testOcspClient = new TestOcspClient().AddBuilderForCertIssuer(caCert, caPrivateKey);
            TestCrlClient     testCrlClient  = new TestCrlClient(caCert, caPrivateKey);
            PdfDocument       document       = new PdfDocument(new PdfReader(srcFileName), new PdfWriter(ltvFileName), new StampingProperties
                                                                   ().UseAppendMode());
            LtvVerification ltvVerification = new LtvVerification(document);

            ltvVerification.AddVerification("Signature1", testOcspClient, testCrlClient, LtvVerification.CertificateOption
                                            .SIGNING_CERTIFICATE, LtvVerification.Level.OCSP_CRL, LtvVerification.CertificateInclusion.YES);
            ltvVerification.Merge();
            document.Close();
            PdfSigner signer = new PdfSigner(new PdfReader(ltvFileName), new FileStream(ltvTsFileName, FileMode.Create
                                                                                        ), new StampingProperties().UseAppendMode());

            signer.Timestamp(testTsa, "timestampSig1");
            BasicCheckLtvDoc("ltvEnabledTsTest01.pdf", "timestampSig1");
        }
        static void addLTVToStream(Stream source, Stream destination, IOcspClient ocsp, ICrlClient crl,
                                   LtvVerification.Level timestampLevel, LtvVerification.Level signatureLevel)
        {
            PdfDocument pdfDoc = new PdfDocument(new PdfReader(source),
                                                 new PdfWriter(destination),
                                                 new StampingProperties().UseAppendMode());

            LtvVerification v             = new LtvVerification(pdfDoc);
            SignatureUtil   signatureUtil = new SignatureUtil(pdfDoc);

            IList <string> names   = signatureUtil.GetSignatureNames();
            String         sigName = names[(names.Count - 1)];

            PdfPKCS7 pkcs7 = signatureUtil.ReadSignatureData(sigName);

            if (pkcs7.IsTsp())
            {
                v.AddVerification(sigName, ocsp, crl, LtvVerification.CertificateOption.WHOLE_CHAIN,
                                  timestampLevel, LtvVerification.CertificateInclusion.YES);
            }
            else
            {
                foreach (String name in names)
                {
                    v.AddVerification(name, ocsp, crl, LtvVerification.CertificateOption.WHOLE_CHAIN,
                                      signatureLevel, LtvVerification.CertificateInclusion.YES);
                }
            }

            v.Merge();
            pdfDoc.Close();
        }
        public static void addLTV(String src, String dest, IOcspClient ocsp, ICrlClient crl, ITSAClient itsaClient)
        {
            PdfReader       reader        = new PdfReader(src);
            PdfWriter       writer        = new PdfWriter(dest);
            PdfDocument     pdfDoc        = new PdfDocument(reader, writer, new StampingProperties().UseAppendMode());
            LtvVerification v             = new LtvVerification(pdfDoc);
            SignatureUtil   signatureUtil = new SignatureUtil(pdfDoc);
            IList <string>  names         = signatureUtil.GetSignatureNames();
            String          sigName       = names[names.Count - 1];
            PdfPKCS7        pkcs7         = signatureUtil.ReadSignatureData(sigName);

            if (pkcs7.IsTsp())
            {
                v.AddVerification(sigName, ocsp, crl, LtvVerification.CertificateOption.WHOLE_CHAIN,
                                  LtvVerification.Level.OCSP_CRL, LtvVerification.CertificateInclusion.NO);
            }
            else
            {
                foreach (var name in names)
                {
                    v.AddVerification(name, ocsp, crl, LtvVerification.CertificateOption.WHOLE_CHAIN,
                                      LtvVerification.Level.OCSP_CRL, LtvVerification.CertificateInclusion.NO);
                }
            }
            v.Merge();
            pdfDoc.Close();
        }
        private void AddLtvInfo(String src, String dest, String sigName, TestOcspClient testOcspClient, TestCrlClient
                                testCrlClient)
        {
            PdfDocument document = new PdfDocument(new PdfReader(src), new PdfWriter(dest), new StampingProperties().UseAppendMode
                                                       ());
            LtvVerification ltvVerification = new LtvVerification(document);

            ltvVerification.AddVerification(sigName, testOcspClient, testCrlClient, LtvVerification.CertificateOption.
                                            WHOLE_CHAIN, LtvVerification.Level.OCSP_CRL, LtvVerification.CertificateInclusion.YES);
            ltvVerification.Merge();
            document.Close();
        }
        public virtual void PadesSignatureLevelLTTest01()
        {
            String outFileName     = destinationFolder + "padesSignatureLevelLTTest01.pdf";
            String srcFileName     = sourceFolder + "signedPAdES-T.pdf";
            String tsaCertFileName = certsSrc + "tsCertRsa.p12";
            String caCertFileName  = certsSrc + "rootRsa.p12";

            X509Certificate[] tsaChain      = Pkcs12FileHelper.ReadFirstChain(tsaCertFileName, password);
            ICipherParameters tsaPrivateKey = Pkcs12FileHelper.ReadFirstKey(tsaCertFileName, password, password);
            X509Certificate   caCert        = (X509Certificate)Pkcs12FileHelper.ReadFirstChain(caCertFileName, password)[0];
            ICipherParameters caPrivateKey  = Pkcs12FileHelper.ReadFirstKey(caCertFileName, password, password);
            ICrlClient        crlClient     = new TestCrlClient(caCert, caPrivateKey);
            TestOcspClient    ocspClient    = new TestOcspClient().AddBuilderForCertIssuer(caCert, caPrivateKey);
            TestTsaClient     testTsa       = new TestTsaClient(JavaUtil.ArraysAsList(tsaChain), tsaPrivateKey);
            PdfDocument       document      = new PdfDocument(new PdfReader(srcFileName), new PdfWriter(outFileName), new StampingProperties
                                                                  ().UseAppendMode());
            LtvVerification ltvVerification = new LtvVerification(document);

            ltvVerification.AddVerification("Signature1", ocspClient, crlClient, LtvVerification.CertificateOption.SIGNING_CERTIFICATE
                                            , LtvVerification.Level.OCSP_CRL, LtvVerification.CertificateInclusion.YES);
            ltvVerification.Merge();
            document.Close();
            BasicCheckDssDict("padesSignatureLevelLTTest01.pdf");
        }