XMLSignature xmlSig = buildSignature(signature);
Key validationKey = SecurityHelper.extractVerificationKey(validationCredential);
if (validationKey == null) {
log.debug("Supplied credential contained no key suitable for signature validation");
throw new ValidationException("No key available to validate signature");
}
log.debug("Validating signature with signature algorithm URI: {}", signature.getSignatureAlgorithm());
log.debug("Validation credential key algorithm '{}', key instance class '{}'",
validationKey.getAlgorithm(), validationKey.getClass().getName());
try {
if (xmlSig.checkSignatureValue(validationKey)) {
log.debug("Signature validated with key from supplied credential");
return;
}
} catch (XMLSignatureException e) {
throw new ValidationException("Unable to evaluate key against signature", e);
}
log.debug("Signature did not validate against the credential's key");
throw new ValidationException("Signature did not validate against the credential's key");
}