From 86d58bef746c914139f7189f2b4dfe5f77b45fb5 Mon Sep 17 00:00:00 2001 From: tknall Date: Tue, 14 Dec 2010 13:43:36 +0000 Subject: git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@707 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- src/main/java/demo/SignatureVerificationDemo.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/main/java/demo') diff --git a/src/main/java/demo/SignatureVerificationDemo.java b/src/main/java/demo/SignatureVerificationDemo.java index 4b17f11..f7b8d53 100644 --- a/src/main/java/demo/SignatureVerificationDemo.java +++ b/src/main/java/demo/SignatureVerificationDemo.java @@ -15,6 +15,7 @@ import at.gv.egiz.pdfas.api.commons.Constants; import at.gv.egiz.pdfas.api.commons.SignatureInformation; import at.gv.egiz.pdfas.api.exceptions.PdfAsException; import at.gv.egiz.pdfas.api.io.DataSource; +import at.gv.egiz.pdfas.api.verify.VerifyAfterAnalysisParameters; import at.gv.egiz.pdfas.api.verify.VerifyAfterReconstructXMLDsigParameters; import at.gv.egiz.pdfas.api.verify.VerifyResult; import at.gv.egiz.pdfas.api.verify.VerifyResults; @@ -113,8 +114,8 @@ public class SignatureVerificationDemo { // retrieve reconstructed signature ReconstructXMLDsigAfterAnalysisParameters recstrParams = new ReconstructXMLDsigAfterAnalysisParameters(); - recstrParams.setSignatureDevice(Constants.SIGNATURE_DEVICE_BKU); recstrParams.setAnalyzeResult(analyzeResult); + recstrParams.setSignatureDevice(Constants.SIGNATURE_DEVICE_MOA); ReconstructXMLDsigResult recstrResult = pdfasAPI.reconstructXMLDSIG(recstrParams); // it is now possible to retrieve the reconstructed XMLDSig and the underlying signed @@ -137,6 +138,7 @@ public class SignatureVerificationDemo { */ // setup verification + // verification without intermediate step of reconstruction /* VerifyAfterAnalysisParameters vaap = new VerifyAfterAnalysisParameters(); @@ -144,20 +146,30 @@ public class SignatureVerificationDemo { vaap.setReturnHashInputData(true); vaap.setSignatureDevice(Constants.SIGNATURE_DEVICE_MOA); vaap.setVerificationTime(null); - */ + // try to validate all signatures (do not throw exceptions while validating single signatures) + // use result.isVerificationDone() in order to find out if a signatures was successfully verified + vaap.setSuppressVerifyExceptions(true); + */ + // verification with intermediate step of reconstruction VerifyAfterReconstructXMLDsigParameters varp = new VerifyAfterReconstructXMLDsigParameters(); varp.setReconstructXMLDsigResult(recstrResult); varp.setReturnHashInputData(true); - varp.setSignatureDevice(Constants.SIGNATURE_DEVICE_MOA); + // not needed since already set in recstrParams (the reconstruction step) + // varp.setSignatureDevice(Constants.SIGNATURE_DEVICE_MOA); varp.setVerificationTime(null); + // try to validate all signatures (do not throw exceptions while validating single signatures) + // use result.isVerificationDone() in order to find out if a signatures was successfully verified + varp.setSuppressVerifyExceptions(true); // invoke verification System.out.println("Verifying..."); + // without intermediate step of reconstruction /* VerifyResults verifyResults = pdfasAPI.verify(vaap); */ + // with intermediate step of reconstruction VerifyResults verifyResults = pdfasAPI.verify(varp); -- cgit v1.2.3