Esempio n. 1
0
        /// <summary>Switches to the previous revision.</summary>
        /// <exception cref="System.IO.IOException"/>
        /// <exception cref="Org.BouncyCastle.Security.GeneralSecurityException"/>
        public virtual void SwitchToPreviousRevision()
        {
            LOGGER.Info("Switching to previous revision.");
            latestRevision = false;
            dss            = document.GetCatalog().GetPdfObject().GetAsDictionary(PdfName.DSS);
            DateTime cal = pkcs7.GetTimeStampDate();

            if (cal == SignUtils.UNDEFINED_TIMESTAMP_DATE)
            {
                cal = pkcs7.GetSignDate();
            }
            // TODO: get date from signature
            signDate = cal.ToUniversalTime();
            IList <String> names = sgnUtil.GetSignatureNames();

            if (names.Count > 1)
            {
                signatureName = names[names.Count - 2];
                document      = new PdfDocument(new PdfReader(sgnUtil.ExtractRevision(signatureName)));
                this.acroForm = PdfAcroForm.GetAcroForm(document, true);
                names         = sgnUtil.GetSignatureNames();
                signatureName = names[names.Count - 1];
                pkcs7         = CoversWholeDocument();
                LOGGER.Info(String.Format("Checking {0}signature {1}", pkcs7.IsTsp() ? "document-level timestamp " : "", signatureName
                                          ));
            }
            else
            {
                LOGGER.Info("No signatures in revision");
                pkcs7 = null;
            }
        }
        public virtual void GetSignaturesTest02()
        {
            String         inPdf          = sourceFolder + "simpleDocument.pdf";
            PdfDocument    pdfDocument    = new PdfDocument(new PdfReader(inPdf));
            SignatureUtil  signatureUtil  = new SignatureUtil(pdfDocument);
            IList <String> signatureNames = signatureUtil.GetSignatureNames();

            NUnit.Framework.Assert.AreEqual(0, signatureNames.Count);
        }
Esempio n. 3
0
        /// <exception cref="Org.BouncyCastle.Security.GeneralSecurityException"/>
        protected internal virtual void InitLtvVerifier(PdfDocument document)
        {
            this.document = document;
            this.acroForm = PdfAcroForm.GetAcroForm(document, true);
            this.sgnUtil  = new SignatureUtil(document);
            IList <String> names = sgnUtil.GetSignatureNames();

            signatureName = names[names.Count - 1];
            this.signDate = DateTimeUtil.GetCurrentUtcTime();
            pkcs7         = CoversWholeDocument();
            LOGGER.Info(MessageFormatUtil.Format("Checking {0}signature {1}", pkcs7.IsTsp() ? "document-level timestamp "
                 : "", signatureName));
        }