Пример #1
0
        virtual protected void SignXades(String src, String dest, ICipherParameters pk,
                                         X509Certificate[] chain, String digestAlgorithm, bool includeSignaturePolicy)
        {
            // Creating the reader and the stamper
            PdfReader  reader  = new PdfReader(src);
            FileStream os      = new FileStream(dest, FileMode.Create);
            PdfStamper stamper = PdfStamper.createXmlSignature(reader, os);
            // Creating the appearance
            XmlSignatureAppearance appearance = stamper.XmlSignatureAppearance;

            appearance.SetXmlLocator(new XfaXmlLocator(stamper));
            appearance.SetDescription("Simple xfa form");
            // Creating the signature

            IExternalSignature pks = new PrivateKeySignature(pk, digestAlgorithm);

            MakeXmlSignature.SignXades(appearance, pks, chain, includeSignaturePolicy);
        }
Пример #2
0
        virtual protected void SignXadesPackage(String src, String dest, XfaXpathConstructor.XdpPackage xdpPackage,
                                                ICipherParameters pk, X509Certificate[] chain, String digestAlgorithm, bool includeSignaturePolicy)
        {
            // Creating the reader and the stamper
            PdfReader  reader  = new PdfReader(src);
            FileStream os      = new FileStream(dest, FileMode.Create);
            PdfStamper stamper = PdfStamper.createXmlSignature(reader, os);
            // Creating the appearance
            XmlSignatureAppearance appearance = stamper.XmlSignatureAppearance;

            //Set XfaXmlLocator to control getting and setting Document
            appearance.SetXmlLocator(new XfaXmlLocator(stamper));
            appearance.SetDescription("Simple xfa form");
            // Set XpathConstructor, to construct xpath expression for signing an xdp package
            appearance.SetXpathConstructor(new XfaXpathConstructor(xdpPackage));
            // Creating the signature
            IExternalSignature pks = new PrivateKeySignature(pk, digestAlgorithm);

            MakeXmlSignature.SignXades(appearance, pks, chain, includeSignaturePolicy);
        }