Hi Paulo, as there is no central point for e.g security provider registration I would fall back to a static block where you can check the provider version and / or the avialable BC objects.
Greetings Andreas > I've no idea on how to do it in a reliable way, where to to put the > verifying code, make sure no static objects where called, check that > only one BC version is in the classpath. > > Paulo > > On Fri, Apr 13, 2012 at 9:58 AM, Andreas Kuehne <[email protected]> wrote: >> Hi Paulo, >> >> maybe it would be useful to include a check for the BC version (range) ? >> >> Greetings >> >> Andreas >>> Unless you are using the SVN HEAD you sould use BC 1.46. >>> >>> Paulo >>> >>> On Thu, Apr 12, 2012 at 8:06 PM, denixx baykin <[email protected]> >>> wrote: >>>> Hi. I tried to self sign the pdf file and get an exception. >>>> Which version of bouncycastle should I use? >>>> Can I find that version in the Internet? >>>> >>>> Here is a detailed stacktrace: >>>> Exception in thread "main" java.lang.NoClassDefFoundError: >>>> org/bouncycastle/asn1/DEREncodable >>>> at >>>> com.itextpdf.text.pdf.PdfSignatureAppearance.getAppearance(PdfSignatureAppearance.java:409) >>>> at >>>> com.itextpdf.text.pdf.PdfSignatureAppearance.preClose(PdfSignatureAppearance.java:951) >>>> at >>>> com.itextpdf.text.pdf.PdfSignatureAppearance.preClose(PdfSignatureAppearance.java:897) >>>> at com.itextpdf.text.pdf.PdfStamper.close(PdfStamper.java:194) >>>> at Test2_QRCode.main(Test2_QRCode.java:221) >>>> 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) >>>> ... 5 more >>>> >>>> (Test2_QRCode.java:221) it's a "stp.close();" >>>> >>>> Here is a code of sign process: >>>> try { >>>> //creating the document "pdf.pdf". >>>> ... >>>> //done. >>>> KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType()); >>>> ks.load(new FileInputStream("keystore.ks"), "password".toCharArray()); >>>> String alias = (String)ks.aliases().nextElement(); >>>> PrivateKey key = (PrivateKey)ks.getKey(alias, "pasword".toCharArray()); >>>> Certificate[] chain = ks.getCertificateChain(alias); >>>> PdfReader reader = new PdfReader("pdf.pdf"); >>>> FileOutputStream fout = new FileOutputStream("signed.pdf"); >>>> PdfStamper stp = PdfStamper.createSignature(reader, fout, '\0'); >>>> PdfSignatureAppearance sap = stp.getSignatureAppearance(); >>>> sap.setCrypto(key, chain, null, PdfSignatureAppearance.SELF_SIGNED); >>>> sap.setReason("I'm the author"); >>>> sap.setLocation("Lisbon"); >>>> // comment next line to have an invisible signature >>>> sap.setVisibleSignature(new Rectangle(100, 100, 200, 200), 1, null); >>>> stp.close(); >>>> } catch (Exception e) { >>>> e.printStackTrace(); >>>> } >>>> >>>> I attached the files bcprov-jdk15on-147.jar and bcpkix-jdk15on-147.jar to >>>> the project. bcprov-jdk15on-147.jar have org/bouncycastle/asn1 package >>>> inside. But doesn't have org/bouncycastle/asn1/DEREncodable. It >>>> has org/bouncycastle/asn1/DEREncodableVector. >>>> >>>> ------------------------------------------------------------------------------ >>>> For Developers, A Lot Can Happen In A Second. >>>> Boundary is the first to Know...and Tell You. >>>> Monitor Your Applications in Ultra-Fine Resolution. Try it FREE! >>>> http://p.sf.net/sfu/Boundary-d2dvs2 >>>> _______________________________________________ >>>> iText-questions mailing list >>>> [email protected] >>>> 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 >>> ------------------------------------------------------------------------------ >>> For Developers, A Lot Can Happen In A Second. >>> Boundary is the first to Know...and Tell You. >>> Monitor Your Applications in Ultra-Fine Resolution. Try it FREE! >>> http://p.sf.net/sfu/Boundary-d2dvs2 >>> _______________________________________________ >>> iText-questions mailing list >>> [email protected] >>> 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 >>> >> >> -- >> Andreas Kühne >> phone: +49 177 293 24 97 >> mailto: [email protected] >> >> Trustable Ltd. Niederlassung Deutschland Ströverstr. 18 - 59427 Unna >> Amtsgericht Hamm HRB 5868 >> >> Directors Andreas Kühne, Heiko Veit >> >> Company UK Company No: 5218868 Registered in England and Wales >> >> >> ------------------------------------------------------------------------------ >> For Developers, A Lot Can Happen In A Second. >> Boundary is the first to Know...and Tell You. >> Monitor Your Applications in Ultra-Fine Resolution. Try it FREE! >> http://p.sf.net/sfu/Boundary-d2dvs2 >> _______________________________________________ >> iText-questions mailing list >> [email protected] >> 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 > ------------------------------------------------------------------------------ > For Developers, A Lot Can Happen In A Second. > Boundary is the first to Know...and Tell You. > Monitor Your Applications in Ultra-Fine Resolution. Try it FREE! > http://p.sf.net/sfu/Boundary-d2dvs2 > _______________________________________________ > iText-questions mailing list > [email protected] > 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 > -- Andreas Kühne phone: +49 177 293 24 97 mailto: [email protected] Trustable Ltd. Niederlassung Deutschland Ströverstr. 18 - 59427 Unna Amtsgericht Hamm HRB 5868 Directors Andreas Kühne, Heiko Veit Company UK Company No: 5218868 Registered in England and Wales ------------------------------------------------------------------------------ For Developers, A Lot Can Happen In A Second. Boundary is the first to Know...and Tell You. Monitor Your Applications in Ultra-Fine Resolution. Try it FREE! http://p.sf.net/sfu/Boundary-d2dvs2 _______________________________________________ iText-questions mailing list [email protected] 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
