Quick Start (MTOM): Verifying multiple digital signatures using the web service API

The following C# code example verifies multiple digital signatures that are located in a signed PDF document that is based on a PDF file named LoanAllSigs.pdf. The verification time is set to current time and the revocation checking option is set to best effort. (SeeVerifying Multiple Digital Signatures.)

???/** 
    * Ensure that you create a .NET project that uses  
    * MS Visual Studio 2008 and version 3.5 of the .NET 
    * framework. This is required to invoke a  
    * LiveCycle service using MTOM. 
    *      
    * For information, see "Invoking LiveCycle using MTOM" in Programming with LiveCycle   
    */ 
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.ServiceModel; 
using System.IO; 
using VerifyAllSignatures.ServiceReference1; 
 
namespace VerifyAllSignatures 
{ 
       class Program 
       { 
           static void Main(string[] args) 
           { 
               try 
               { 
                   //Create a SignatureServiceClient object 
                   SignatureServiceClient sigClient = new SignatureServiceClient(); 
                   sigClient.Endpoint.Address = new System.ServiceModel.EndpointAddress("http://hiro-xp:8080/soap/services/SignatureService?blob=mtom"); 
 
                   //Enable BASIC HTTP authentication 
                   BasicHttpBinding b = (BasicHttpBinding)sigClient.Endpoint.Binding; 
                   b.MessageEncoding = WSMessageEncoding.Mtom; 
                   sigClient.ClientCredentials.UserName.UserName = "administrator"; 
                   sigClient.ClientCredentials.UserName.Password = "password"; 
                   b.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic; 
                   b.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly; 
                   b.MaxReceivedMessageSize = 2000000; 
                   b.MaxBufferSize = 2000000; 
                   b.ReaderQuotas.MaxArrayLength = 2000000; 
 
                   //Create a BLOB to store a PDF document 
                   BLOB inDoc = new BLOB(); 
 
                   //Specify a PDF document that contains the signatures to verify 
                   string path = "C:\\Adobe\LoanAllSigs.pdf"; 
                   FileStream fs = new FileStream(path, FileMode.Open); 
 
                   //Get the length of the file stream  
                   int len = (int)fs.Length; 
                   byte[] ByteArray = new byte[len]; 
 
                   //Populate the byte array with the contents of the FileStream object 
                   fs.Read(ByteArray, 0, len); 
                   inDoc.MTOM = ByteArray; 
 
                   //Create a PKIOptions object that contains PKI run-time options 
                   PKIOptions pkiOptions = new PKIOptions(); 
                   pkiOptions.verificationTime = VerificationTime.CURRENT_TIME; 
                   pkiOptions.revocationCheckStyle = RevocationCheckStyle.BestEffort; 
 
                   //Verify the digital signature 
                   PDFDocumentVerificationInfo allSigs = sigClient.verifyPDFDocument( 
                    inDoc, 
                    pkiOptions, 
                    null); 
 
                   //Retrieve an array of objects where each object is a  
                   //PDFSignatureVerificationInfo object 
                   MyArrayOf_xsd_anyType allSignatures = allSigs.verificationInfos; 
 
                   //Get the number of elements in the array 
                   //0-based index means 
                   int arrLen = allSignatures.Count; 
                   String myStatus = ""; 
                   String myType = ""; 
                   String signerMsg = ""; 
 
                   //Iterate through the array to get each PDFSignatureVerificationInfo object 
                   for (int i = 0; i < arrLen; i++) 
                   { 
                       PDFSignatureVerificationInfo signInfo = (PDFSignatureVerificationInfo)allSignatures[i]; 
                       SignatureStatus? sigStatus = signInfo.status; 
 
                       if (sigStatus == SignatureStatus.DynamicFormSignatureUnknown) 
                           myStatus = "The signatures located in the dynamic PDF form are unknown"; 
                       else if (sigStatus == SignatureStatus.DocumentSignatureUnknown) 
                           myStatus = "The signatures located in the PDF document are unknown"; 
                       else if (sigStatus == SignatureStatus.CertifiedDynamicFormSignatureTamper) 
                           myStatus = "The signatures located in a certified PDF form are valid"; 
                       else if (sigStatus == SignatureStatus.SignedDynamicFormSignatureTamper) 
                           myStatus = "The signatures located in a signed dynamic PDF form are valid"; 
                       else if (sigStatus == SignatureStatus.CertifiedDocumentSignatureTamper) 
                           myStatus = "The signatures located in a certified PDF document are valid"; 
                       else if (sigStatus == SignatureStatus.SignedDocumentSignatureTamper) 
                           myStatus = "The signatures located in a signed PDF document are valid"; 
                       else if (sigStatus == SignatureStatus.SignatureFormatError) 
                           myStatus = "The format of a signature in a signed document is invalid"; 
                       else if (sigStatus == SignatureStatus.DynamicFormSigNoChanges) 
                           myStatus = "No changes were made to the signed dynamic PDF form"; 
                       else if (sigStatus == SignatureStatus.DocumentSigNoChanges) 
                           myStatus = "No changes were made to the signed PDF document"; 
                       else if (sigStatus == SignatureStatus.DynamicFormCertificationSigNoChanges) 
                           myStatus = "No changes were made to the certified dynamic PDF form"; 
                       else if (sigStatus == SignatureStatus.DocumentCertificationSigNoChanges) 
                           myStatus = "No changes were made to the certified PDF document"; 
                       else if (sigStatus == SignatureStatus.DocSigWithChanges) 
                           myStatus = "There were changes to a signed PDF document"; 
                       else if (sigStatus == SignatureStatus.CertificationSigWithChanges) 
                           myStatus = "There were changes made to the PDF document."; 
 
                       //Get the signature type 
                       SignatureType sigType = signInfo.signatureType; 
 
                       if (sigType.type == PDFSignatureType.AUTHORSIG) 
                           myType = "Certification"; 
                       else if (sigType.type == PDFSignatureType.RECIPIENTSIG) 
                           myType = "Recipient"; 
 
                       //Get the identity of the signer 
                       IdentityInformation signerId = signInfo.signer; 
                       if (signerId.status == IdentityStatus.UNKNOWN) 
                           signerMsg = "Identity Unknown"; 
                       else if (signerId.status == IdentityStatus.TRUSTED) 
                           signerMsg = "Identity Trusted"; 
                       else if (signerId.status == IdentityStatus.NOTTRUSTED) 
                           signerMsg = "Identity Not Trusted"; 
 
                       Console.Write("The status of the signature is: " + myStatus + ". The signer identity is " + signerMsg + ". The signature type is " + myType + "."); 
                   } 
               } 
               catch (Exception ee) 
               { 
                   Console.WriteLine(ee.Message); 
               } 
           } 
       } 
} 
 

// Ethnio survey code removed