I'm trying to validate xml signed with
<CanonicalizationMethod Algorithm="http://www.w3.org/TR/1999/WD-xml-c14n-19991115"/>
But I get an exception:
javax.xml.crypto.MarshalException: java.security.NoSuchAlgorithmException: no such algorithm: http://www.w3.org/TR/1999/WD-xml-c14n-19991115 for provider XMLDSig
I don't like option to change xml input. Looks like implementing of some custom canonicalization method or force java to use other is much better, but I can't figure out how to do this.
final NodeList signatureNodeList = document.getElementsByTagName(SIGNATURE_TAG_NAME);
if (signatureNodeList.getLength() == 0)
return false;
for(int i = 0; i < signatureNodeList.getLength(); i++){
final DOMValidateContext validateContext = new DOMValidateContext(
new KeyValueKeySelector(), signatureNodeList.item(i));
final XMLSignature signature = xmlSignatureFactory.unmarshalXMLSignature(
validateContext);
if(!signature.validate(validateContext))
return false;
}