From 1483d928d358f1073e58510f3e12b1cf4984f269 Mon Sep 17 00:00:00 2001 From: Andreas Fitzek Date: Wed, 2 Oct 2013 10:31:50 +0200 Subject: Verification results handed out ot application --- .../main/java/at/gv/egiz/pdfas/lib/api/PdfAs.java | 2 +- .../java/at/gv/egiz/pdfas/lib/impl/PdfAsImpl.java | 22 ++++++++-------------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAs.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAs.java index 4b491064..92b2001a 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAs.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAs.java @@ -28,7 +28,7 @@ public interface PdfAs { * @param parameter The verification parameter * @return A list of verification Results */ - public List verify(VerifyParameter parameter); + public List verify(VerifyParameter parameter) throws PdfAsException; /** * Gets a copy of the PDF-AS configuration, to allow the application to 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 a8cee107..d2a21518 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 @@ -12,6 +12,7 @@ import java.io.File; import java.io.IOException; import java.io.OutputStream; import java.security.SignatureException; +import java.util.ArrayList; import java.util.List; import org.apache.pdfbox.cos.COSArray; @@ -192,8 +193,9 @@ public class PdfAsImpl implements PdfAs, IConfigurationConstants { } } - public List verify(VerifyParameter parameter) { + public List verify(VerifyParameter parameter) throws PdfAsException { try { + List result = new ArrayList(); ISettings settings = (ISettings) parameter.getConfiguration(); VerifierDispatcher verifier = new VerifierDispatcher(settings); PDDocument doc = PDDocument.load(new ByteArrayInputStream(parameter @@ -251,20 +253,12 @@ public class PdfAsImpl implements PdfAs, IConfigurationConstants { IVerifyFilter verifyFilter = verifier.getVerifier(dict.getNameAsString("Filter"), dict.getNameAsString("SubFilter")); - verifyFilter.verify(contentData.toByteArray(), content.getBytes()); + List results = + verifyFilter.verify(contentData.toByteArray(), content.getBytes()); - /* - * Iterator> iterator = - * dict.entrySet().iterator(); - * - * while(iterator.hasNext()) { Map.Entry - * entry = iterator.next(); System.out.println("Key: " - * +entry.getKey().toString()); - * - * } - */ - + result.addAll(results); } + return result; } } catch (IOException e) { e.printStackTrace(); @@ -272,7 +266,7 @@ public class PdfAsImpl implements PdfAs, IConfigurationConstants { // TODO Auto-generated catch block e.printStackTrace(); } - return null; + throw new PdfAsException(); } public Configuration getConfiguration() { -- cgit v1.2.3