iText digital signature using javax.smartcardio - itext

I'm trying to sign a pdf with belgian eId smart Card. I've installed Eclipse, downloaded Java SDK 1.6, added the itext 5.4.5 jars smardcardsign-1.0 jars as external jars to the building path.
I want to test example "4.6 signing a string for authentication" from Bruno's whitepaper "Digital Signature for PDF documents".
I copied C4_05_SignWithBEID.java file from itext download site.
I've got an error "AUTHN_CERT_FILE_ID can not be resolved or is not a field"
for line X509Certificate cert = card.readCertificate(BeIDCertificates.AUTHN_CERT_FILE_ID);
When I check the properties for class BeIdCertificates the "AUTHN_CERT_FILE_ID" is not available.
Has someone a complete source for the example 4.8 signing a document using the EidSignature class ?

Please don't copy/paste from examples I have written without reading the accompanying book, in this case the free eBook "Digital Signatures for PDF documents".
The example you mention is taken from section 4.2.2 from that book, entitled "Extracting data from the Belgian eID using smartcardsign."
Allow me to quote myself (page 105):
We can use the javax.smartcardio API to access any smart card, but
unfortunately it's usually not that simple. Every card has its own
file structure, its own applications, its own data definitions, and so
on. Apart from the ISO/IEC specification, you'll always need the
specifications of the card you want to use. I've written a small
library that wraps the generic Java API classes in objects such as
CardReaders, SmartCard and SmartCardWithKey. I wrote a special
class for the Belgian eID, named BeIDCard. You can find this library
on SourceForge. It’s meant as a light-weight library that
supports only the basic functionality.
You can find the link to that library in the footnotes: http://sourceforge.net/projects/smartcardsign/
The class BeIDCertificates is part of this library, and it has a constant named AUTHN_CERT_FILE_ID.

Related

how to convert HTML page to PDF using ITEXT or PDFCROWD API

PDF created will be based on dynamic HTML page.
Using ITEXT 5 or 7 with XMLWORKERHELPERCLASS would be lengthy process.
If i am using pdfcrowd API it seems to be ok but not able to generate on localhost or any other private ip. I am ready to pay for their services if they achieve above issue.
First you need to get iText 7 (the core library) and the pdfHtml add-on (the part that will parse the HTML+CSS and convert it to iText objects). Go to github to find out how to download these.
Suppose that you have this HTML:
With this corresponding CSS:
Then you can use this code snippet:
ConverterProperties converterProperties =
new ConverterProperties().setBaseUri(resoureLocation);
HtmlConverter.convertToPdf(
new FileInputStream(HTMLSource),
new FileOutputStream(pdfDestination), converterProperties);
Where resourceLocation points at your base URI, HTMLSource is the path to your HTML file, and pdfDestination is the path where you want the resulting PDF to be written.
When you execute this code, you will get the following PDF:
Note that buying a commercial license may be necessary if you intend to use iText in the context of a proprietary software project.

AEM - import static pages?

We're considering using Adobe Experience Manager for an upcoming project. But we have a number of pre-made static pages we'd like to import into this project. What would be the best way to 'import' these pages into an AEM project?
Note: these pages are HTML that may contain some CSS and JS.
You can serve static HTML, CSS and JS files from AEM. There are multiple ways of getting your files in AEM including but not limited to:
1) Through CRXDE, goto Create > Create File... name your HTML file and save. On the jcr:content subnode, double click on the jcr:data binary property, upload your HTML file and click save.
2) cURL your files into AEM. See the documentation on the SlingPostServlet. You can write a script in Bash, Python or your language of choice to loop over your files and POST to the AEM instance.
3) Go to CRXDE Package Manager, create a simple package, download it and unzip the file. Examine the contents of the zip including the .content.xml files and the /META-INF/vault/filter.xml file. Add your HTML files and update the package filters, zip up the files, upload the package to AEM through the CRXDE Package Manager and install.
Adding to what "nateyolles" has already mentioned,
Adobe Experience Manager provides several options (direct/Indirect) for either importing or exporting data (within the AEM tool they are labeled importers and are found under the tools area). Lets look at each option so you can decide which one will best service your current needs.
1) Site Importer – Allows you to import either a web page or an entire website into AEM. For site imports, you will need to need to specify the project title, site URL (of page or site to import), thumbnail image for the template, the sitemap (for the pages in CQ using the template) and whether or not you want to overwrite (if page or site exist in AEM)
"Use of Site Importer tool"
Link:- https://docs.adobe.com/docs/en/aem/6-2/develop/dev-tools/site-importer.html
2) Feed Importer – The feed import option within Adobe Experience Manager provides the ability to import content via a feed (whether that be an RSS feed or an Atom feed). This can be extremely beneficial to blog creators, like myself, who might want to bring in the content of their blog (from say WordPress, Drupal or another CMS) into an AEM environment.
3) Offline Importer – This functionality, within Adobe Experience Manager, provides the ability to import content from Microsoft Office Word document files into AEM templates (ending with the file extension of .doc). Please note that you should reach out to Adobe’s consulting team for asssistance on this so that they can set up the inputs in the most optimal way to receive your offline data.
4) Import from older version of CQ – This is a pretty straightforward way to import or upgrade from an older version of CQ. If you are familar with AEM, you can stop existing instance, if you have a stand alone instance of AEM replace the jar file, and restart
If you have an application server instance, you will follow these steps:
Stop existing instance, replace the war file and restart.
5) Bulk Editor – This feature provides a multitude of functionality within AEM. For starters, you can make large changes to content at once. Secondly, you can export content to CSV (Microsoft Excel) files.
Kautuk Sahni
(Adobe AEM Community)

iText: how to locate/obtain Linux shared-library to implement PDF Digital signatures with USB Token?

I'm trying to follow the instructions documented on page 96 of the (excellent) book "Digital Signatures in PDF Documents" section 4.1.2 titled "Signing a document using a USB token (part 2: PKCS#11)".
Specifically, Code Sample 4.2 starts with the following line:
public static final String DLL = "c:/windows/system32/dkck201.dll";
This code example is for a Windows machine. If I'm using Linux (CentOS 64 bit) with a USB Token (such as the example's iKey 4000), what file would I use and where does it come from (e.g. the token manufacturer, the PDF Digital Certificate provider, the CentOS operating system, Java, etc...)?
The text states: Make you have the correct path to the CRYPTOKI (PKCS#11) DLL. If you want to make this work on Linux, you’ll need a path to a .so-file such as libCryptoki2_64.so, libpkcs11.so…
I don't know much about this topic. I searched but those two .so files listed above for Linux do not appear to be on my machine. However, the following files ARE on the machine -- but I'm not sure if one might be a suitable substitute:
/usr/lib64/pkcs11
/usr/lib64/libCrypto.so
/usr/lib64/libeTPkcs11.so
~/jre/lib/amd64/libj2pkcs11.so
~/jre/lib/ext/sunpkcs11.jar
Can someone advise me how to obtain (or locate) an .so file that could be used with a USB Token on Linux 64b? Or at least describe in general terms what this file is, where is comes from, etc.?
Any help much appreciated!
It is almost always the best to get PKCS#11 library from your token/card vendor. I believe that one of my older answers to similar question should give you a little more insight into the topic.

itext JavaScript version

first time here posting, though I have benefited many times from other postings on stackoverflow. I am the principal developer of Jmol, which I have recently ported to JavaScript/HTML5. The Jmol applet interfaces with another applet, JSpecView, which in its current form as a Java applet utilizes a slimmed down version of itext.1.4.5.jar to create PDF files of spectra.
I am interested in converting iTtext Java code to JavaScript so that a JavaScript version of the JSpecView applet can create PDF files directly.
Q: Has this already been accomplished?
Q: JSpecView is an Open-Source project licensed under LGPL. All our source code is available. Is this a problem?
Bob Hanson
Principal Developer, Jmol/JSmol
A: I don't think such a port has been done before. But why would you not use an existing JavaScript pdf library? Or what is wrong with doing the PDF generation on the server side? Why would you do more work than is necessary? I've done a quick google on JS PDF libraries and found:
http://jspdf.com/
https://github.com/mozilla/pdf.js
And the following stackoverflow question:
Generating PDF files with Javascript
A: I think it shouldn't be a problem porting it to JavaScript as you'd be porting to the same license (of course, if you're using a version of iText before the license switch to AGPL), but IANAL.

Access adobe digital editions from the command line

I'm looking to create a script for my 80-year old grandmother that downloads the books she needs, and converts them using the command-line version of Calibre, to kindle format so she can read them on her kindle. She gets a lot of her books from a service in the form of Adobe .epub books. AFAIK, none of these books have DRM on them prior to being converted, so let me be clear - I'm not asking how to strip DRM from an ebook.
What I am asking is whether there is a way to programmatically (from the command line is fine if Adobe Digital Editions supports CL args) use the ticket file to request a book from the library, and download it, in .epub form, to the local hard drive. I simply don't want my grandmother to have to go through all of the unneeded screens in Adobe Digital Editions' interface - she gets confused easily, and the interface tends to be overwhelming for her. I simply want to write a function (it can be a system() call to a command... that's fine) that will allow her to take a file received from the library or digital service and automatically retrieve the proper .epub file.
I have all of the other steps ready to go... I just can't find any way to retrieve the book from the service without using the DE interface.
Any suggestions?
Check this S.O. posting, I know it will help ;-)
pdf-adobe-digital-edition