Signature Validation

Table of Contents

About the Signature Validation Example

The Signature Validation example demonstrates how to use the ICEpdf API to access a documents signatures and if present validate and present summary information of the validation results.

The source-code for this example is located at:

A primer on using Maven or Gradle build commands can be found here (Maven) and here (Gradle)

// open the url
Document document = new Document();

// open the file.
document.setFile(filePath);

// signatures can be found off the Catalog as InteractiveForms.
InteractiveForm interactiveForm = document.getCatalog().getInteractiveForm();
if (interactiveForm != null) {
    ArrayList<SignatureWidgetAnnotation> signatureFields = interactiveForm.getSignatureFields();
    // found some signatures!
    if (signatureFields != null) {
        // must be called in order to verify signatures cover full length of document.
        // signatures cover length of document, there could still be an issue with the signature
        // but we know the signature(s) cover all the bytes in the file.
        interactiveForm.isSignaturesCoverDocumentLength();
        // validate each signature.
        for (SignatureWidgetAnnotation signatureWidgetAnnotation : signatureFields) {
            SignatureValidator signatureValidator = signatureWidgetAnnotation.getSignatureValidator();
            try {
                // annotation summary
                SignatureVerification.printSignatureSummary(signatureWidgetAnnotation);
                // validate the signature and certificate.
                signatureValidator.validate();
                // print out some important properties of the validator state.
                SignatureVerification.printValidationSummary(signatureValidator);
            } catch (SignatureIntegrityException e) {
                System.out.println("Signature failed to validate: " + signatureValidator.toString());
                e.printStackTrace();
            }
        }
    }
}
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

© Copyright 2017 ICEsoft Technologies Canada Corp.