private void VerifyBusinessSignatureReferences() { var withId = new SignedXmlWithId(document); if (signedElementIds.Count != 1) { throw new SignatureException("Wrong number of references found for " + SignatureType + ", found " + signedElementIds.Count + " expected 1."); } var signedElement = withId.GetIdElement(document, signedElementIds.First()); if (signedElement == null) { throw new SignatureException("Could not locate signed element"); } if (signedElement.NamespaceURI != manager.LookupNamespace("bc")) { throw new SignatureException("Wrong ns of signed element"); } var name = signedElement.LocalName; if (name != "paymentMessage" && name != "paymentResponse" && name != "corporateMessage" && name != "corporateException") { throw new SignatureException("Wrong name of signed element"); } }
private void VerifyWsSecuritySignatureReferences() { var withId = new SignedXmlWithId(document); if (signedElementIds.Count != 2) { throw new SignatureException("Wrong number of references found for " + SignatureType + ", found " + signedElementIds.Count + " expected 2."); } var serviceHeaderSigned = false; var bodySigned = false; foreach (var signedElementId in signedElementIds) { var signedElement = withId.GetIdElement(document, signedElementId); if (signedElement == null) { throw new SignatureException("Could not locate signed element"); } if (signedElement.LocalName == "serviceHeader" && signedElement.NamespaceURI == manager.LookupNamespace("bc")) { serviceHeaderSigned = true; } if (signedElement.LocalName == "Body" && signedElement.NamespaceURI == manager.LookupNamespace("soap")) { bodySigned = true; } } if (!serviceHeaderSigned) { throw new SignatureException("WS-Security signature does not sign serviceHeader"); } if (!bodySigned) { throw new SignatureException("WS-Security signature does not sign body"); } }