i was running the code presented in in_action/chapter16/SignedPdf.java
i modify it to my values, and try to run.
all went ok till the code trys to close the stamper, then it throws an
exception.
what is wrong ?
Regards.
----the
code--------------------------------------------------------------------------
KeyStore ks = KeyStore.getInstance("pkcs12");
ks.load(new FileInputStream("F:\\mypfxfile.pfx"),"1234".toCharArray());
String alias = (String)ks.aliases().nextElement();
PrivateKey key = (PrivateKey)ks.getKey(alias,"1234".toCharArray());
Certificate[] chain = ks.getCertificateChain(alias);
reader = new PdfReader("F:\\unsigned_message.pdf");
FileOutputStream os = new
FileOutputStream("F:\\signed_message_invisible.pdf");
PdfStamper stamper = PdfStamper.createSignature(reader, os, '\0');
PdfSignatureAppearance appearance = stamper.getSignatureAppearance();
appearance.setCrypto(key, chain, null, PdfSignatureAppearance.SELF_SIGNED);
appearance.setReason("It's personal.");
appearance.setLocation("Foobar");
stamper.close();
----the
exception---------------------------------------------------------------------------
Exception in thread "main" java.lang.NoClassDefFoundError:
org/bouncycastle/asn1/DEREncodable
at com.lowagie.text.pdf.PdfSigGenericPKCS.setSignInfo(Unknown Source)
at com.lowagie.text.pdf.PdfSignatureAppearance.preClose(Unknown Source)
at com.lowagie.text.pdf.PdfSignatureAppearance.preClose(Unknown Source)
at com.lowagie.text.pdf.PdfStamper.close(Unknown Source)
at tokenTest.SignedPdf.main(SignedPdf.java:142)
Caused by: java.lang.ClassNotFoundException:
org.bouncycastle.asn1.DEREncodable
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 5 more
--
View this message in context:
http://www.nabble.com/error-using-code-in-chapter16-SignedPdf.java-tp17980238p17980238.html
Sent from the iText - General mailing list archive at Nabble.com.
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Do you like iText?
Buy the iText book: http://www.1t3xt.com/docs/book.php
Or leave a tip: https://tipit.to/itexttipjar