Hello all,
I see in Chapter 12 "Protecting your PDF" the sample who shows how to
protect the PDF. As I see, it's a Java sample but not for Android (or nor
working for me ;)).
I try to create an Android Activity who protects the PDF with a digital
signature but the result is always an exception. My piece of code is:
----------------------------------------------------------------------------
---------
Document document = new Document();
file = externalStoragePath + File.separator + FILE;
PdfWriter writer = PdfWriter.getInstance(document, new
FileOutputStream(file));
Certificate cert = getPublicCertificate("my_own_certificate.cer"); //
generated with keytool
writer.setEncryption(new Certificate[] {cert}, new int[]
{PdfWriter.ALLOW_PRINTING} , PdfWriter.ENCRYPTION_AES_128 |
PdfWriter.DO_NOT_ENCRYPT_METADATA);
writer.createXmpMetadata();
document.open();
addMetaData(document);
addTitlePage(document);
addContent(document);
document.close();
----------------------------------------------------------------------------
----------
where getPublicCertificate function is:
public Certificate getPublicCertificate(String filename)
throws IOException, CertificateException {
InputStream is =
MyApplication.getAppContext().getAssets().open(filename);
CertificateFactory cf = CertificateFactory.getInstance("X.509",
new BouncyCastleProvider());
X509Certificate cert =
(X509Certificate)cf.generateCertificate(is);
return cert;
}
The Exception is raised in writer.setEncryption function and is:
java.security.NoSuchAlgorithmException: AlgorithmParameterGenerator
1.2.840.113549.3.2 implementation not found
I'm using Android 4.2, itextpdf-5.4.0.jar, bcprov-jdk15on-148.jar,
bcpkix-jdk15on-148.jar, bcpg-jdk15on-148.jar, bcmail-jdk15on-148.jar.
Please, any suggestion or sample.
Thanks in advance
Flash Team
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php