pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Diego Azevedo <dazev...@esec.com.br>
Subject Re: How to certify a PDF
Date Tue, 18 Oct 2016 11:04:49 GMT
 From what I'm reading on ISO 32000, the certification Signature is a 
normal signature, but with a DocMDP transform method. So the ou should 
do something like this:

    PDSignature signature = new PDSignature;
    [..] //do your thing
    COSDictinary dictionary = signature.getCOSObject();

    //Create a reference dictionary
    COSDictionary reference = new COSDictionary();
    reference.setItem("Type", COSName.getPDFName("SigRef"));
    reference.setItem("TransformMethod", COSName.getPDFName("DocMDP"));
    reference.setItem("DigestMethod", COSName.getPDFName("SHA1"));
    //Only MD5 or SHA1... Go with the least worse

    //Now we add DocMDP specific stuff
    COSDictionary transformParameters = new COSDictionary();
    transformParameters.setInteger("P", <1, 2 or 3>); // 1- no changes
    permited; 2- fill forms and signing; 3- Same as 2 plus annotation
    creation, deletion an modification.
    transformParameters.setItem("V", COSName.getPDFName("1.2")); // This
    is right, it's a name, not a number.

    // Add everything in order
    reference.setItem("TransformParams", transformParameters ); // Add
    DocMDP stuff to the SigRef Dictionary;
    COSArray references = new COSArray();
    references.add(reference); // Add SigRef Dictionary to a Array
    dictionary.setItem("Reference", reference); // Add Array to
    Signature dictionary

I didn't try it myself, just wrote based on PdfBox API and ISO 
specification. May have errors.

On 18/10/2016 06:12, Damien Butaye wrote:
> Hello Tilman,
>   Here follows two links explaining the difference :
>     1. http://www.investintech.com/resources/articles/certifyingsigningpdf/
>     2.
>     http://stackoverflow.com/questions/16710439/how-to-add-blank-page-in-digitally-signed-pdf-using-java/16711745#16711745
> Damien.
> 2016-10-18 8:49 GMT+02:00 Tilman Hausherr <THausherr@t-online.de>:
>> Dear all,
>>>     I'm looking for a solution to certify a PDF. Currently I'm able to
>>> sign a
>>> PDF using PDFBox but I can't certify it. Is-it possible to do it with
>>> PDFBox?
>>> Thank you for your help!
>> What's the difference? (See my other answer from today)
>> Tilman
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org


Diego Azevedo
E-SEC Segurança Digital
www.esec.com.br <http://www.esec.com.br>
61 3323-4410*

Os dados transmitidos, incluindo quaisquer anexos, são destinados apenas 
para a pessoa ou entidade ao qual está endereçada e pode conter material 
confidencial e/ou privilegiado. É proibida qualquer revisão, 
retransmissão, disseminação ou outro uso desta informação, ou a tomada 
de qualquer ação com base na confiança, por pessoas ou empresas que não 
o destinatário, e qualquer responsabilidade daí decorrente é negada. Se 
você recebeu por engano, favor contatar o remetente e apague o material 
de qualquer computador

The information transmitted, including any attachments, is intended only 
for the person or entity to which it is addressed and may contain 
confidential and/or privileged material. Any review, retransmission, 
dissemination or other use of, or taking of any action in reliance upon, 
this information by persons or entities other than the intended 
recipient is prohibited, and all liability arising therefrom is 
disclaimed. If you received this in error, please contact the sender and 
delete the material from any computer

View raw message