context.setProperty(AttachmentContentSignatureTransform.ATTACHMENT_CALLBACKHANDLER,
data.getAttachmentCallbackHandler());
try {
XMLSignature xmlSignature = signatureFactory.unmarshalXMLSignature(context);
checkBSPCompliance(xmlSignature, data.getBSPEnforcer());
// Check for compliance against the defined AlgorithmSuite
AlgorithmSuite algorithmSuite = data.getAlgorithmSuite();
if (algorithmSuite != null) {
AlgorithmSuiteValidator algorithmSuiteValidator = new
AlgorithmSuiteValidator(algorithmSuite);
algorithmSuiteValidator.checkSignatureAlgorithms(xmlSignature);
}
// Test for replay attacks
testMessageReplay(elem, xmlSignature.getSignatureValue().getValue(), data, wsDocInfo);
setElementsOnContext(xmlSignature, (DOMValidateContext)context, wsDocInfo, elem.getOwnerDocument());
boolean signatureOk = xmlSignature.validate(context);
if (signatureOk) {
return xmlSignature;
}
//
// Log the exact signature error
//
if (LOG.isDebugEnabled()) {
LOG.debug("XML Signature verification has failed");
boolean signatureValidationCheck =
xmlSignature.getSignatureValue().validate(context);
LOG.debug("Signature Validation check: " + signatureValidationCheck);
java.util.Iterator<?> referenceIterator =
xmlSignature.getSignedInfo().getReferences().iterator();
while (referenceIterator.hasNext()) {
Reference reference = (Reference)referenceIterator.next();
boolean referenceValidationCheck = reference.validate(context);
String id = reference.getId();
if (id == null) {