Visual FoxPro
Visual FoxPro
Verify XAdES with External File Reference
See more XML Digital Signatures Examples
Demonstrates how to validate an XML digital signature that contains a reference to an external file. (This is one way of doing it..)Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loSbXml
LOCAL loValidator
LOCAL i
LOCAL lnValid
lnSuccess = 0
* This example requires the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.
* Load the XAdES file to be validated..
loSbXml = CreateObject('Chilkat.StringBuilder')
lnSuccess = loSbXml.LoadFile("qa_data/xml_dsig_valid_samples/externalFile/test.pdf.XAdES","utf-8")
IF (lnSuccess = 0) THEN
? "Failed to load XAdES input file."
RELEASE loSbXml
CANCEL
ENDIF
loValidator = CreateObject('Chilkat.XmlDSig')
* Specify a set of absolute or relative directory paths to be searched for any external file references.
* Directory paths are separated by semicolon chars.
loValidator.ExternalRefDirs = "qa_data/externalFiles;qa_data/xml_dsig_valid_samples/externalFile;c:/someOtherDir"
lnSuccess = loValidator.LoadSignatureSb(loSbXml)
IF (lnSuccess = 0) THEN
? loValidator.LastErrorText
RELEASE loSbXml
RELEASE loValidator
CANCEL
ENDIF
* Validate signatures as usual..
i = 0
DO WHILE i < loValidator.NumSignatures
loValidator.Selector = i
lnValid = loValidator.VerifySignature(1)
? "Signature " + STR(i + 1) + " and all reference digests OK = " + STR(lnValid)
i = i + 1
ENDDO
RELEASE loSbXml
RELEASE loValidator