Nice! Thank you very much! (Btw, it could be nice to integrate in a future release a method certify() in the PDSignature object).
obrigado! 2016-10-18 15:42 GMT+02:00 Diego Azevedo <dazev...@esec.com.br>: > Hello Damien, > > I made a typo: > > dictionary.setItem("Reference", reference*s*); // Add Array to Signature > dictionary > > There is no point in creating the array, add the "SigRef" dictionary to > it... and not use the array on the "Sig" dictionary. So... just add the > 'S' to the variable and re-run it. Just tested here, and it worked fine =) > > []'s > > -- > > > > > > > *_______________________________________________ Diego Azevedo Developer > E-SEC Segurança Digital www.esec.com.br <http://www.esec.com.br> +55 61 > 3323-4410 <%2B55%2061%203323-4410>* > > > On 18/10/2016 10:21, Damien Butaye wrote: > > Hello Diego, > > Thank you for your help. I just tried your code but it seems that it > doesn't work. The result has nor signature nor certify element. I'll try > again. > If you have any idea, don't hesitate ;) > > Damien. > > 2016-10-18 13:04 GMT+02:00 Diego Azevedo <dazev...@esec.com.br>: > >> 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.setItem("Type", COSName.getPDFName("TransformP >> arams")); >> 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 <thaush...@t-online.de> >> <thaush...@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-unsubscr...@pdfbox.apache.org >> For additional commands, e-mail: users-h...@pdfbox.apache.org >> >>