Hi,
I also wanted to know some information. Is there any commercial product or API in java which does the manipulation of signature?
Also, I have read article on Adobe working towards a plugin which allows for validation of signatures signed by CA's via OCSP call when used with the Adobe. Is anyone aware of that kind of product?
regards
siva.
On 11/10/05, Sivakumar Balakrishnan <[EMAIL PROTECTED]> wrote:
Hi,The code snippet is below,As I mentioned in my previous mail, the hash would be sent to an external entity and the signature would come back, which has to be embedded into the original pdf.public static void fillSignature(String[] args) {
try {
log("reading the input...");
PdfReader reader = new PdfReader(args[0]);
FileOutputStream fout = new FileOutputStream(args[1]);
PdfStamper stp = PdfStamper.createSignature(reader, fout, '\0');
Calendar now = Calendar.getInstance();
PdfSignatureAppearance sap = stp.getSignatureAppearance();
log("creating visible signature ...");
sap.setVisibleSignature(new Rectangle(100, 100, 200, 200), 1, null);
sap.setLayer2Text("This is some custom made text.\n\nDate: some date");
PdfDictionary dic = new PdfDictionary();
dic.put (PdfName.TYPE, PdfName.SIG);
dic.put(PdfName.FILTER, new PdfName("ADOBE.PPKLITE"));
dic.put(PdfName.SUBFILTER, new PdfName("adbe.pkcs7.detached"));
dic.put(PdfName.M, new PdfDate(now));
log("setting the dictionary to the appearance...");
sap.setCryptoDictionary(dic);
HashMap exc = new HashMap();
exc.put(PdfName.CONTENTS, new Integer(0x2802));
log("preclosing the signature appearance");
sap.preClose(exc);
PdfDictionary dic2 = new PdfDictionary();
byte sg[] = readFile("signature_pdf.p7s");
byte[] out = new byte[(0x2800)/2];
log("Sg Length : "+sg.length+" Out Length : "+out.length);
System.arraycopy(sg, 0, out, 0, sg.length);
dic2.put(PdfName.CONTENTS, new PdfString(sg).setHexWriting(true));
sap.close(dic2);
log("complete");
} catch (Exception e) {
log("exception is ..."+e);
}
}
regardssiva.On 11/9/05, Tamas Nemeth <[EMAIL PROTECTED] > wrote:Hi!
Yes, I could successfully attach external signature to my pdf file.
Have you allocated enough space for your /contets field?
Can you send some code snippet, which maybe can help to solve your problem?
regards,
Tamas
2005/11/9, Sivakumar Balakrishnan < [EMAIL PROTECTED]>:
> Hi Tamas,
> I saw your posting in the mailing lists, I am also having the same
> scenario, but I am getting the error, "Unexpected Byte Range".
>
> My scenario is,
> I have to make a hash out of the pdf and send to an external
> entity, which creates the pkcs7.
> I have to insert the pkcs7 into the original pdf.
>
> I've followed the sample "how to sign with external siganture", except
> for the code, which generates the signature, I've put the generated pksc7
> bytes. I keep getting the above error, "Byte Range is invalid."
>
> Are you able to successfully attach the signature with the original pdf.
>
> regards
> siva
