diff options
Diffstat (limited to 'src/main/java/demo')
-rw-r--r-- | src/main/java/demo/ExtractNonTextualObjectsDemo.java | 4 | ||||
-rw-r--r-- | src/main/java/demo/SignatureCreationDemo.java | 2 | ||||
-rw-r--r-- | src/main/java/demo/SignatureVerificationDemo.java | 32 |
3 files changed, 33 insertions, 5 deletions
diff --git a/src/main/java/demo/ExtractNonTextualObjectsDemo.java b/src/main/java/demo/ExtractNonTextualObjectsDemo.java index 60031f7..6b0f3eb 100644 --- a/src/main/java/demo/ExtractNonTextualObjectsDemo.java +++ b/src/main/java/demo/ExtractNonTextualObjectsDemo.java @@ -31,7 +31,7 @@ public class ExtractNonTextualObjectsDemo { System.err.println("Please provide path of file to be analyzed.");
System.exit(1);
}
-
+
File testFile = new File(args[0]);
try {
@@ -41,7 +41,7 @@ public class ExtractNonTextualObjectsDemo { List nonTextualObjects = PdfAS.extractNonTextualObjects(new PdfDataSourceAdapter(dataSource));
if (nonTextualObjects != null && !nonTextualObjects.isEmpty()) {
- System.out.println("Non-textual objects found.");
+ System.out.println(nonTextualObjects.size() + " non-textual object(s) found.");
Iterator noit = nonTextualObjects.iterator();
while (noit.hasNext()) {
NonTextObjectInfo info = (NonTextObjectInfo) noit.next();
diff --git a/src/main/java/demo/SignatureCreationDemo.java b/src/main/java/demo/SignatureCreationDemo.java index 465a0bf..1f6205d 100644 --- a/src/main/java/demo/SignatureCreationDemo.java +++ b/src/main/java/demo/SignatureCreationDemo.java @@ -78,7 +78,7 @@ public class SignatureCreationDemo { // check if non textual elements have been detected
if (signResult.hasNonTextualObjects()) {
- System.out.println("\nWARNING: Non textual objects detected.");
+ System.out.println("\nWARNING: " + signResult.getNonTextualObjects().size() + " non textual object(s) detected.");
Iterator noit = signResult.getNonTextualObjects().iterator();
while (noit.hasNext()) {
NonTextObjectInfo info = (NonTextObjectInfo) noit.next();
diff --git a/src/main/java/demo/SignatureVerificationDemo.java b/src/main/java/demo/SignatureVerificationDemo.java index 86d1bb8..950472e 100644 --- a/src/main/java/demo/SignatureVerificationDemo.java +++ b/src/main/java/demo/SignatureVerificationDemo.java @@ -12,6 +12,7 @@ import at.gv.egiz.pdfas.api.analyze.AnalyzeParameters; import at.gv.egiz.pdfas.api.analyze.AnalyzeResult;
import at.gv.egiz.pdfas.api.analyze.NonTextObjectInfo;
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;
@@ -71,6 +72,30 @@ public class SignatureVerificationDemo { AnalyzeResult analyzeResult = pdfasAPI.analyze(analyzeParameters);
System.out.println("Successfully analyzed.");
+ // information on non-textual objects can be used after analysis step and/or after verification
+ List signatures = analyzeResult.getSignatures();
+ if (signatures != null && !signatures.isEmpty()) {
+ int counter = 0;
+ Iterator sigIterator = signatures.iterator();
+ while (sigIterator.hasNext()) {
+ counter++;
+ SignatureInformation sigInfo = (SignatureInformation) sigIterator.next();
+ System.out.println("\n------------------------ SIGNATURE #" + counter + " ------------------------");
+ if (sigInfo.hasNonTextualObjects()) {
+ System.out.println("\nWARNING: " + sigInfo.getNonTextualObjects().size() + " non textual object(s) detected for this signature.");
+ Iterator noit = sigInfo.getNonTextualObjects().iterator();
+ while (noit.hasNext()) {
+ NonTextObjectInfo info = (NonTextObjectInfo) noit.next();
+ System.out.println(" -> " + info.toString());
+ }
+ System.out.println();
+
+ } else {
+ System.out.println("\nNo non-textual objects detected for this signature.");
+ }
+ }
+ }
+
// setup verification
VerifyAfterAnalysisParameters vaap = new VerifyAfterAnalysisParameters();
vaap.setAnalyzeResult(analyzeResult);
@@ -82,13 +107,16 @@ public class SignatureVerificationDemo { System.out.println("Verifying...");
VerifyResults verifyResults = pdfasAPI.verify(vaap);
List verifyResultList = verifyResults.getResults();
- System.out.println("Verification complete.");
+ System.out.println("Verification complete.\n");
// iterate over results
PrintWriter out = new PrintWriter(System.out);
Iterator it = verifyResultList.iterator();
+ int counter = 0;
while (it.hasNext()) {
+ counter++;
VerifyResult result = (VerifyResult) it.next();
+ out.println("\n------------------------ SIGNATURE #" + counter + " ------------------------\n");
Main.formatVerifyResult(result, out);
// check if there are timestamps
@@ -98,7 +126,7 @@ public class SignatureVerificationDemo { // check if non textual elements have been detected for this signature
if (result.hasNonTextualObjects()) {
- out.println("\nWARNING: Non textual objects detected for this signature");
+ out.println("\nWARNING: " + result.getNonTextualObjects().size() + " non textual object(s) detected for this signature");
Iterator noit = result.getNonTextualObjects().iterator();
while (noit.hasNext()) {
NonTextObjectInfo info = (NonTextObjectInfo) noit.next();
|