1 /*
2  * @(#) $Id: VerifySignature.java,v 1.2 2003/07/08 08:13:52 pankaj Exp $
3  *
4  * Copyright (c) 2002-03 by Pankaj Kumar (http://www.pankaj-k.net). 
5  * All rights reserved.
6  *
7  * The license governing the use of this file can be found in the 
8  * root directory of the containing software.
9  */
10
11import org.w3c.dom.Document;
12
13import com.verisign.xmlsig.Verifier;
14import com.verisign.xpath.XPath;
15
16public class VerifySignature {
17    public static void main(String[] args) throws Exception {
18        // Input to signature verification
19        String sigfile = "sig.xml";
20        System.out.println("Verifying signature in file \"" + sigfile + "\"");
21
22        // Read the XML file
23        Document doc = XmlUtility.readXML(sigfile);
24
25        String ns[] = {"ds", "http://www.w3.org/2000/09/xmldsig#"};
26        XPath signatureLocation = new XPath("//ds:Signature", ns);
27        Verifier verifier = new Verifier(doc, signatureLocation);
28        boolean isVerified = verifier.verify();
29
30        System.out.println();
31        System.out.println("Signature Verification " + (isVerified ? "SUCCESSFUL!!":"FAILED!!"));
32    }
33}