Verifying a Signature

NodeList nodes 
  = doc.getElementsByTagNameNS(XMLSignature.XMLNS, "Signature");
DOMValidateContext dvc 
  = new DOMValidateContext(new X509KeySelector(), nodes.item(0));
XMLSignature signature = factory.unmarshalXMLSignature(dvc);
if (signature.validate(dvc)) {
  System.err.println(
    "Signature failed! Document may have been tampered with.");
} 

Previous | Next | Top | Cafe con Leche

Copyright 2007 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified March 12, 2007