[
https://issues.apache.org/jira/browse/PDFBOX-3971?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16213871#comment-16213871
]
Tilman Hausherr edited comment on PDFBOX-3971 at 10/21/17 12:09 PM:
--------------------------------------------------------------------
This looks useful, that part is indeed missing in our current code. Could you
please reformat / refactor according to this:
https://pdfbox.apache.org/codingconventions.html
And also change code like this
{code}
COSArray array = (COSArray)
this.dictionary.getItem(COSName.getPDFName("KeyUsage"));
if(array == null){
return false;
}
{code}
to something like this (check the type):
{code}
COSBase base = this.dictionary.getItem(COSName.KEY_USAGE);
if (base instanceof COSArray)
{
COSArray array = (COSArray) base:
// do stuff
}
{code}
I know we still have some of these in existing code but I try at least to avoid
it for new code.
Also change code like this
{code}
+ public void setCertificate(PDSeedValueCertificate certificate)
+ {
+ if (certificate != null)
+ {
+ dictionary.setItem(COSName.CERT, certificate.getCOSObject());
+ }
+ }
{code}
to this:
{code}
+ public void setCertificate(PDSeedValueCertificate certificate)
+ {
+ dictionary.setItem(COSName.CERT, certificate);
+ }
{code}
because setItem can handle null values.
was (Author: tilman):
This looks useful, that part is indeed missing in our current code. Could you
please reformat / reformat according to this:
https://pdfbox.apache.org/codingconventions.html
And also change code like this
{code}
COSArray array = (COSArray)
this.dictionary.getItem(COSName.getPDFName("KeyUsage"));
if(array == null){
return false;
}
{code}
to something like this (check the type):
{code}
COSBase base = this.dictionary.getItem(COSName.KEY_USAGE);
if (base instanceof COSArray)
{
COSArray array = (COSArray) base:
// do stuff
}
{code}
I know we still have some of these in existing code but I try at least to avoid
it for new code.
Also change code like this
{code}
+ public void setCertificate(PDSeedValueCertificate certificate)
+ {
+ if (certificate != null)
+ {
+ dictionary.setItem(COSName.CERT, certificate.getCOSObject());
+ }
+ }
{code}
to this:
{code}
+ public void setCertificate(PDSeedValueCertificate certificate)
+ {
+ dictionary.setItem(COSName.CERT, certificate);
+ }
{code}
because setItem can handle null values.
> Add Certificate Dictionary to seed value in signature field
> -----------------------------------------------------------
>
> Key: PDFBOX-3971
> URL: https://issues.apache.org/jira/browse/PDFBOX-3971
> Project: PDFBox
> Issue Type: Improvement
> Components: Signing
> Reporter: Hossam Hazem
> Labels: documentation, features, newbie, patch, test
> Attachments: COSName.patch, PDSeedValue.patch,
> PDSeedValueCertificate.java
>
>
> This dictionary is important as it gives the ability to put certificate
> constraints on a signature field, like if you want signatures that are signed
> by a specific issuer or authority to only be used in a field.
> currently tested Issuer constraint and it worked, acrobat reader ignores
> other certificates and only allow the issuer given to sign the field.
> documentation is not complete waiting for the initial acceptance to complete.
> new class PDSeedValueCertificate is added which refers to this certificate.
> PDSeedValue is modified to add the new dictionary.
> COSName is modified to add the new pdf names that are included in the
> dictionary.
> reference for this dictionary can be found in PDF reference 1.7 section
> 12.7.4.5 table 235 page 457 in here
> http://www.adobe.com/content/dam/acom/en/devnet/pdf/PDF32000_2008.pdf
> or chapter 8 table 8.84 page 700 in here
> http://archimedespalimpsest.net/Documents/External/pdf_reference_1-7.pdf
> and in here
> https://www.adobe.com/devnet-docs/acrobatetk/tools/DigSig/Acrobat_DigitalSignatures_in_PDF.pdf
> this is my first contribution, hope everything goes well.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]