Blogroll

The New Domino Admin

A great source of information for Lotus Domino administrators

ecmarchitect.com

Jeff Potts' excellent ECM/Portal blog

Jared Ottley

Lots of very useful Alfresco articles

Looking for web hosting?  I have been using DreamHost for years and have found them to be reliable, inexpensive and very good at what they do!  Click below to sign up, use promo code 'unorganized' to get a free domain registration and 10 bucks off your first year of hosting!

 

dreamhostBadge

Home Software and Tech Software Development Alfresco PDF Toolkit - Digital Signatures
Alfresco PDF Toolkit - Digital Signatures PDF Print E-mail
Written by Nathan McMinn   
Tuesday, 12 October 2010 18:35

If you work with legal documents such as contracts, PDF document security is probably a part of your requirements.  In previous releases of the Alfresco PDF Toolkit we have added text and image watermarks, document encryption and permission management.  As of version 0.94, we can now add a basic digital signature capability to the list.  Adobe PDF documents support a digital signature facility that uses a private key to add a verifiable signature to a document.  This signing facility allows subsequent consumers to verify that the document was signed by a particular key, the trust chain of that key and whether or not the document has been modified since signing.  Using iText, the Alfresco PDF Toolkit can take a JKS keystore stored in the Alfresco repository and use it to sign a PDF document.  The signature can be applied as either a visible signature block or as an invisible signature.  As usual, you can either download the AMP file (version 0.94) or grab the full source code from Google Code and build it yourself.

 

The simplest way to try this out is to create a self-signed certificate.  This can be done using the "keytool" command line application that is bundled with the JDK.  A full explanation of the keytool and certificate chains is outisde the scope of this article, so please read up on how certificates and keytool work before you implement this on any kind of scale.  To generate a simple keystore that can be used to sign a document, run keytool with the following options:

 

1
keytool -genkey -keyalg RSA -alias "Your Name" -keypass yourpass 
-keystore keystore.ks -dname "cn=Your Name, c=US"

 

Dont' forget to substitute your name, new keystore password and country.  Answer any questions that keytool asks and you will have a "keystore.ks" file created.  To use this file to sign your PDF documents, add the key to a space in Alfresco.  I store mine in my home space, but anywhere will do.  Once you have the keystore uploaded to Alfresco, create a space to receive incoming PDF documents and add a content rule that is triggered when PDF documents are added.  When you are prompted to select the action, select "Sign PDF" from the list.

 

step_1

 

Next, set your signature action parameters.  First, the signature can be applied as a visible or hidden signature.  If you select visible, a small text block will appear showing the name, location and reason for the signature.  The location and size of this block is configurable by using the signature X/Y coordinates (coordinates of the top left corner of the block), height and width.  Next, use the node selector to select the keystore file that you wish to use to sign the document.  You also have to provide the keystore password.  This is the same password you used when you created the keystore.  The signing reason and location can also be provided.  The text that is provided here will show up in the signature block, if it is visible.  Finally, select a destination space where the signed PDF will be stored.

 

 

step_2

 

Once all of the signature options are set, finish adding the rule.  Any PDF documents that are placed into the space will now be signed with the provided key and options, and will be stored in the selected destination.  With a self-signed certificate you will see a warning in Adobe Acrobat stating that the certificate chain cannot be validated.  This is expected.  If you need a fully validated chain, you can request a certificate from a CA and import it into the keystore that is used to sign the document.  This simple signing action covers most of my needs, hopefully others will find it useful as well.  As usual, feature requests and bug reports are welcome!

 

Enjoy!

Last Updated on Wednesday, 13 October 2010 09:38
 

Comments  

 
#26 Ashok Kumar Harnal 2012-05-12 20:00
It will be very useful, if at one go I can digitally sign all pdf files in a folder instead of signing them, one by one. Is batch mode possible?
 
 
#25 AB 2012-01-03 09:37
Any idea when this will work with 3.4d?

When I try to create the rule, I can select the action, but then only see a list of input boxes with no titles in which to enter arguments. Rule cannot be saved.

Looking forward to it!
 
 
#24 2011-06-13 11:11
Clay,

What doesn't work? How does it fail? Do you have any more information? "This does not work" isn't very helpful in diagnosing a problem.
 
 
#23 2011-05-10 21:54
this does not work any other solution
 
 
#22 2011-03-24 10:36
Quoting Nathan:
José,

I originally developed this against Alfresco 3.1.0. I am currently using it with 3.3.3.


Hmmm... I'm using Alfresco 3.4 and I don't see this option available on my rules. Has anyone already tested PDF-toolkit with the latest version of Alfresco?
 
 
#21 2011-03-24 10:16
José,

I originally developed this against Alfresco 3.1.0. I am currently using it with 3.3.3.
 
 
#20 2011-03-22 17:44
What are the Alfresco versions supported for the last release?
 
 
#19 2011-03-03 11:27
Quoting yzhou:
My guess is, two passwords are need, keystore pass, and your private key pass, and there is only one field for password.

Maybe, just a maybe, you can try same password for keystore and key, see if it works ;-)


That was the ticket. The same password for both the cert and the keystore. Good catch thanks.
 
 
#18 2011-03-01 15:25
Quoting BenJamin:
Quoting yzhou:
i want use this one for a demo and after restart everything, when I tried to sign the PDF, I got a error complain password

java.io.IOException: Keystore was tampered with, or password was incorrect

at PDFSignatureAct ionExecuter.java:208

I import the ks file, password is 'password', i will dig more ...



yzhou, any luck? I am also getting this exception. Running v0.96 with Alfresco 3.4a.


My guess is, two passwords are need, keystore pass, and your private key pass, and there is only one field for password.

Maybe, just a maybe, you can try same password for keystore and key, see if it works
 
 
#17 2011-03-01 11:19
Quoting yzhou:
I am wondering if keystore can be integrate with user login credential.

I'd like have a keystore created/imported for each user when system user is configured, and from that time on, when PDF need be signed, the login credential can be used to access keystore, automatically without typing password.

Wait, maybe I DO want ask user type his/her own password so we are sure, who signed this PDF? :D


sorry, typo, i mean, "I DO want" :)
 
RSS Feed Icon

About Me

 

My profile picture

 

My name is Nathan McMinn.  I'm a software engineer, beer geek, wannabe adventurer and genuinely curious guy.  Find me on Facebook, Linkedin or Twitter

Latest Comments