From 9b615852df5f56eeb67c4dd021a56e72d31a2498 Mon Sep 17 00:00:00 2001 From: tknall Date: Mon, 14 Dec 2009 13:47:48 +0000 Subject: Error code created for protected pdf documents. SettingsReader: Debug message for getInternalResource added (TRACE) multipart/formdata: align multipart charset with data charset added FIXME notes for FileHelper.readFromFile Signature/Verification-Demo updated git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@507 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- src/main/java/demo/SignatureCreationDemo.java | 15 +++++++++++++-- src/main/java/demo/SignatureVerificationDemo.java | 15 ++++++++++++--- 2 files changed, 25 insertions(+), 5 deletions(-) (limited to 'src/main/java/demo') diff --git a/src/main/java/demo/SignatureCreationDemo.java b/src/main/java/demo/SignatureCreationDemo.java index c43b45e..465a0bf 100644 --- a/src/main/java/demo/SignatureCreationDemo.java +++ b/src/main/java/demo/SignatureCreationDemo.java @@ -12,6 +12,7 @@ import at.gv.egiz.pdfas.api.exceptions.PdfAsException; import at.gv.egiz.pdfas.api.io.DataSource; import at.gv.egiz.pdfas.api.sign.SignParameters; import at.gv.egiz.pdfas.api.sign.SignResult; +import at.gv.egiz.pdfas.api.timestamp.DummyTimeStamper; import at.gv.egiz.pdfas.io.FileBasedDataSink; import at.gv.egiz.pdfas.io.FileBasedDataSource; @@ -55,10 +56,20 @@ public class SignatureCreationDemo { SignParameters signParameters = new SignParameters(); signParameters.setDocument(dataSource); signParameters.setOutput(dataSink); - signParameters.setSignatureType(Constants.SIGNATURE_TYPE_BINARY); signParameters.setSignatureDevice(Constants.SIGNATURE_DEVICE_MOA); - signParameters.setSignatureProfileId("SIGNATURBLOCK_DE"); signParameters.setSignaturePositioning(null); + // standard signature + signParameters.setSignatureType(Constants.SIGNATURE_TYPE_TEXTUAL); + signParameters.setSignatureProfileId("SIGNATURBLOCK_DE"); + + // --- enable in case of BAIK SIGNATURE --- + /* + signParameters.setSignatureType(Constants.SIGNATURE_TYPE_BINARY); + // signParameters.setSignatureProfileId("BAIK_URKUNDE_SIGNATUR"); + signParameters.setSignatureProfileId("BAIK_ARCHIV_SIGNATUR"); + // use BAIK TimeStamp + signParameters.setTimeStamperImpl(new DummyTimeStamper()); + */ // sign System.out.println("Signing..."); diff --git a/src/main/java/demo/SignatureVerificationDemo.java b/src/main/java/demo/SignatureVerificationDemo.java index 6df4973..86d1bb8 100644 --- a/src/main/java/demo/SignatureVerificationDemo.java +++ b/src/main/java/demo/SignatureVerificationDemo.java @@ -90,15 +90,24 @@ public class SignatureVerificationDemo { while (it.hasNext()) { VerifyResult result = (VerifyResult) it.next(); Main.formatVerifyResult(result, out); + + // check if there are timestamps + if (result.getTimeStampValue() != null) { + out.println("\nTimeStamp value available for this signature"); + } + + // check if non textual elements have been detected for this signature if (result.hasNonTextualObjects()) { - System.out.println("\nWARNING: Non textual objects detected."); + out.println("\nWARNING: Non textual objects detected for this signature"); Iterator noit = result.getNonTextualObjects().iterator(); while (noit.hasNext()) { NonTextObjectInfo info = (NonTextObjectInfo) noit.next(); - System.out.println(" -> " + info.toString()); + out.println(" -> " + info.toString()); } - System.out.println(); + out.println(); + } else { + out.println("\nNo non-textual objects detected for this signature."); } } out.flush(); -- cgit v1.2.3