public void Validate_ValidSignedXml_NotThrows(string exampleXmlFileName, string elementId)
        {
            var data    = NUnitTestHelper.GetInputFile(exampleXmlFileName);
            var service = new GostXadesBesService();

            service.ValidateSignature(data, elementId);
        }
        public void Validate_InvalidSignedXml_ThrowsInvalidOperationException(string exampleXmlFileName, string elementId, string expectedExceptionMessage)
        {
            var data    = NUnitTestHelper.GetInputFile(exampleXmlFileName);
            var service = new GostXadesBesService();
            var ex      = Assert.Throws <InvalidOperationException>(() => service.ValidateSignature(data, elementId));

            Assert.AreEqual(expectedExceptionMessage, ex.Message);
        }
        public void Sign_ValidXml_NotThrows(string exampleXmlFileName, string elementId)
        {
            var data    = NUnitTestHelper.GetInputFile(exampleXmlFileName);
            var service = new GostXadesBesService();

            var signedData = service.Sign(data, elementId, CertificateThumbprint, CertificatePassword);

            service.ValidateSignature(signedData, elementId);
        }
Esempio n. 4
0
        protected static void Validate(XmlDocument xml, string elementId)
        {
            var xadesService = new GostXadesBesService();

            if (string.IsNullOrEmpty(elementId))
            {
                var rootNode   = xml.DocumentElement;
                var rootNodeId = GetRootId(rootNode);
                if (!string.IsNullOrEmpty(rootNodeId))
                {
                    Warning(string.Format("Не задан элемент для проверки подписи. Используется элемент {0} с Id {1}", rootNode.Name, rootNodeId));
                    elementId = rootNodeId;
                }
                else
                {
                    throw new ArgumentException("Не задан Id элемента для проверки подписи и корневой элемент не имеет Id");
                }
            }
            xadesService.ValidateSignature(xml.OuterXml, elementId);
        }