Am 12.10.2016 um 17:17 schrieb Jonathan Barbero:
Hi,

  I have been playing with the signing example of PDF Box 2.0.3.
I would like to apply a certification signature (
https://helpx.adobe.com/acrobat/kb/certificate-signatures.html )
How could I do ?  Do you have any example ?

Thanks,
  Jonathan.


There is no example, but the test TestPublicKeyEncryption.java from the source download should help too.

https://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/encryption/TestPublicKeyEncryption.java?view=markup

There's also a segment in the Encrypt command line tool:


                    if( certFile != null )
                    {
PublicKeyProtectionPolicy ppp = new PublicKeyProtectionPolicy(); PublicKeyRecipient recip = new PublicKeyRecipient();
                        recip.setPermission(ap);


CertificateFactory cf = CertificateFactory.getInstance("X.509");

                        InputStream inStream = null;
                        try
                        {
                            inStream = new FileInputStream(certFile);
X509Certificate certificate = (X509Certificate)cf.generateCertificate(inStream);
                            recip.setX509(certificate);
                        }
                        finally
                        {
                            if (inStream != null)
                            {
                                inStream.close();
                            }
                        }

                        ppp.addRecipient(recip);

                        ppp.setEncryptionKeyLength(keyLength);

                        document.protect(ppp);
                    }
                    else
                    {
                      .....
                    }
                    document.save( outfile );
                }


Tilman


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: users-h...@pdfbox.apache.org

Reply via email to