From 1219abaf9f0029e39f5fbdf342fd4ebf07144b5b Mon Sep 17 00:00:00 2001 From: Andreas Fitzek Date: Fri, 11 Jul 2014 13:38:49 +0200 Subject: added Signature Verification Level --- .../main/java/at/gv/egiz/pdfas/lib/impl/PdfAsImpl.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'pdf-as-lib/src/main/java') diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsImpl.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsImpl.java index 40e7faf5..7815717e 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsImpl.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsImpl.java @@ -232,6 +232,16 @@ public class PdfAsImpl implements PdfAs, IConfigurationConstants { .getDictionaryObject(COSName.ACRO_FORM); COSArray fields = (COSArray) acroForm .getDictionaryObject(COSName.FIELDS); + + int lastSig = -1; + for (int i = 0; i < fields.size(); i++) { + COSDictionary field = (COSDictionary) fields.getObject(i); + String type = field.getNameAsString("FT"); + if ("Sig".equals(type)) { + lastSig = i; + } + } + for (int i = 0; i < fields.size(); i++) { COSDictionary field = (COSDictionary) fields.getObject(i); String type = field.getNameAsString("FT"); @@ -242,7 +252,11 @@ public class PdfAsImpl implements PdfAs, IConfigurationConstants { // verify only specific siganture! verifyThis = signatureToVerify == currentSignature; } - + + if(signatureToVerify == -2) { + verifyThis = i == lastSig; + } + if (verifyThis) { logger.trace("Found Signature: "); COSBase base = field.getDictionaryObject("V"); -- cgit v1.2.3