コード例 #1
0
        /// <summary>
        /// Sign using the given <paramref name="signingStrategy"/>
        /// </summary>
        /// <param name="signingStrategy"></param>
        internal void Sign(SignStrategy signingStrategy)
        {
            if (signingStrategy == null)
            {
                throw new ArgumentNullException(nameof(signingStrategy));
            }

            _signature = signingStrategy.SignDocument();

            IsSigned = true;
        }
コード例 #2
0
        public void ThenSignStrategySignsCorrectlyAS4Message()
        {
            // Arrange
            SignStrategy signingStrategy = CreateSignStrategyForSigning();

            // Act
            Signature signature = signingStrategy.SignDocument();

            XmlNode signatureElement = signature.GetXml();

            Assert.Equal("Signature", signatureElement.LocalName);

            XmlNodeList signedInfoReferences = signatureElement.SelectEbmsNodes("/dsig:SignedInfo/dsig:Reference");

            Assert.True(
                signedInfoReferences.Count == 2,
                "The required 2 <Reference/> elements are not present under the <SignedInfo/> element in the <Signature/>");

            XmlNodeList keyInfoReferences = signatureElement.SelectEbmsNodes("/dsig:KeyInfo/wsse:SecurityTokenReference/wsse:Reference");

            Assert.True(
                keyInfoReferences.Count == 1,
                "The required 1 <Reference/> element is not present under the <KeyInfo/> element in the <Signature/>");
        }