You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Adam Nichols (JIRA)" <ji...@apache.org> on 2010/12/17 11:28:05 UTC

[jira] Commented: (PDFBOX-912) PDF signing interface and improvments

    [ https://issues.apache.org/jira/browse/PDFBOX-912?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12972430#action_12972430 ] 

Adam Nichols commented on PDFBOX-912:
-------------------------------------

I looked over the changes to COSWriter and COSWriterXRefEntry and everything looks OK except for one thing which bothers me.  In doWriteSignature(COSDocument doc) there is the following line: byte[] pdfContent = bytes.toByteArray();  This is going to consume a great deal of memory if the PDF is large.  I see that's passed into SignatureInterface, so it seems that we should be able to pass the input stream along with the integer array which is used by the COSFilterInputStream to the SignatureInterface and then just read the data in there a chunk at a time.  Of course this would change the API on the SignatureInterface, but seeing as how signing non-sequential sections seems to be a common (reference the ByteRange key on page 468 of ISO32000-1:2008), this seems like a reasonable thing to do.  If anyone has any comments either for or against changing the SignatureInterface to take an InputStream and int[], speak now or forever hold your peace.

I made trivial updates such as removing code which was added but commented out, expanded on some comments to reference sections in the PDF spec (ISO32000-1:2008), changed the indenting for the new code to be 4 spaces (to be consistent with the old code), and other non-functional changes.  I'll continue to review each line of these enhancements as I have time.  I'm going to hold off on committing everything until everything it reviewed, then I'll commit it all at once (assuming someone else doesn't beat me to it).

> PDF signing interface and improvments
> -------------------------------------
>
>                 Key: PDFBOX-912
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-912
>             Project: PDFBox
>          Issue Type: Improvement
>          Components: PDFReader, PDModel, PDModel.AcroForm, Writing
>    Affects Versions: 1.4.0
>            Reporter: Thomas Chojecki
>            Priority: Minor
>         Attachments: cos_object_improvement_patch.txt, fields_annotations_patch.txt, interface_options_patch.txt, io_patch.txt, main_documents_patch.txt, parser_patch.txt, signature_exception_patch.txt, test.pdf, test_signed.pdf, writer_patch.txt
>
>
> This is a first version of a signing interface for pdfbox. There are some design issues i could not handle without rewriting too much of the code.
> Here we go:
> - incremental update support (tested for signatures with pdf/a compatibility), not compatible with encrypted documents nor with xref-streams
> - cos object improvment
>   -- COSString with ability to force writing hexbin for given string
>   -- COSBase with ability to write direct into a dictionary (that means if this is set, no indirect object will be wrote) (sry hard to explain what i mean, actualy needed for incremental update to lower the rate of indirect objects)
>   -- COSBase with ability to force writing object (this hook help the COSWriter write needed objects for inkremental update)
>   -- COSName added new names
>   -- COSDocument some getter and setter for handling new signature and incremental features
> - SignatureException with some exceptions for handling the bunch of new possible errors
> -Parser improvments
>   -- PDFParser saves now the position of the last startxref
>   -- VisualSignatureParser (hook for parsing visual signature templates) (it's only for prepared visualisation that should be merged with the document)
> -IO improvments
>   -- COSFilterInput helps to find the proper content that should be hashed / signed
>   -- COSStandardOutputStream is tricky, it helps the writer to jump to the right place in the document
>   -- COSWriter got some improvments for incremental update
>   -- COSWriterXRefEntry needed for incremental updates and writing the new Xref table
> - PDDocument
>  -- got a new method addSignature with the needed implementation (do the whole signature stuff)
>  -- cleanup
> - Fields and Annotations
>  -- PDSignature represent the signature dictionary 
>  -- PDSignatureFild / Annotation are the visible & unvisible signature representations
> - Signature Interface and options
>  -- SignatureInterface the interface that shall be implemented for proper signing
>  -- SignatureOptions, some additional options for signing
> Patch splited into pieces
> sry for spelling, didn't include a spellchecker for english.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.