Skip to content

Commit 04c7473

Browse files
author
Ron Petrusha
authored
Corrected XmlDocument variable name (#566)
* Corrected variable name * Update snippets/csharp/VS_Snippets_CLR/HowToVerifyXMLDocumentRSA/cs/sample.cs Co-Authored-By: rpetrusha <ronpet@microsoft.com> * Corrected case of Key
1 parent 2d08bfd commit 04c7473

File tree

2 files changed

+17
-29
lines changed
  • snippets
    • csharp/VS_Snippets_CLR/HowToVerifyXMLDocumentRSA/cs
    • visualbasic/VS_Snippets_CLR/HowToVerifyXMLDocumentRSA/vb

2 files changed

+17
-29
lines changed

snippets/csharp/VS_Snippets_CLR/HowToVerifyXMLDocumentRSA/cs/sample.cs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,29 +54,26 @@ public static void Main(String[] args)
5454
}
5555
}
5656

57-
58-
59-
6057
// Verify the signature of an XML file against an asymmetric
6158
// algorithm and return the result.
62-
public static Boolean VerifyXml(XmlDocument Doc, RSA Key)
59+
public static Boolean VerifyXml(XmlDocument xmlDoc, RSA key)
6360
{
6461
// Check arguments.
65-
if (Doc == null)
66-
throw new ArgumentException("Doc");
67-
if (Key == null)
68-
throw new ArgumentException("Key");
62+
if (xmlDoc == null)
63+
throw new ArgumentException("xmlDoc");
64+
if (key == null)
65+
throw new ArgumentException("key");
6966

7067
// Create a new SignedXml object and pass it
7168
// the XML document class.
7269
// <snippet5>
73-
SignedXml signedXml = new SignedXml(Doc);
70+
SignedXml signedXml = new SignedXml(xmlDoc);
7471
// </snippet5>
7572

7673
// Find the "Signature" node and create a new
7774
// XmlNodeList object.
7875
// <snippet6>
79-
XmlNodeList nodeList = Doc.GetElementsByTagName("Signature");
76+
XmlNodeList nodeList = xmlDoc.GetElementsByTagName("Signature");
8077
// </snippet6>
8178

8279
// Throw an exception if no signature was found.
@@ -100,8 +97,8 @@ public static Boolean VerifyXml(XmlDocument Doc, RSA Key)
10097

10198
// Check the signature and return the result.
10299
// <snippet8>
103-
return signedXml.CheckSignature(Key);
100+
return signedXml.CheckSignature(key);
104101
// </snippet8>
105102
}
106103
}
107-
// </snippet1>
104+
// </snippet1>

snippets/visualbasic/VS_Snippets_CLR/HowToVerifyXMLDocumentRSA/vb/sample.vb

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@ Imports System.Security.Cryptography
44
Imports System.Security.Cryptography.Xml
55
Imports System.Xml
66

7-
8-
97
Module VerifyXML
10-
11-
128
Sub Main(ByVal args() As String)
139
Try
1410
' Create a new CspParameters object to specify
@@ -44,32 +40,27 @@ Module VerifyXML
4440
Catch e As Exception
4541
Console.WriteLine(e.Message)
4642
End Try
47-
4843
End Sub
4944

50-
51-
52-
53-
5445
' Verify the signature of an XML file against an asymmetric
5546
' algorithm and return the result.
56-
Function VerifyXml(ByVal Doc As XmlDocument, ByVal Key As RSA) As [Boolean]
47+
Function VerifyXml(ByVal xmlDoc As XmlDocument, ByVal key As RSA) As [Boolean]
5748
' Check arguments.
58-
If Doc Is Nothing Then
59-
Throw New ArgumentException("Doc")
49+
If xmlDoc Is Nothing Then
50+
Throw New ArgumentException("xmlDoc")
6051
End If
61-
If Key Is Nothing Then
62-
Throw New ArgumentException("Key")
52+
If key Is Nothing Then
53+
Throw New ArgumentException("key")
6354
End If
6455
' Create a new SignedXml object and pass it
6556
' the XML document class.
6657
' <snippet5>
67-
Dim signedXml As New SignedXml(Doc)
58+
Dim signedXml As New SignedXml(xmlDoc)
6859
' </snippet5>
6960
' Find the "Signature" node and create a new
7061
' XmlNodeList object.
7162
' <snippet6>
72-
Dim nodeList As XmlNodeList = Doc.GetElementsByTagName("Signature")
63+
Dim nodeList As XmlNodeList = xmlDoc.GetElementsByTagName("Signature")
7364
' </snippet6>
7465
' Throw an exception if no signature was found.
7566
If nodeList.Count <= 0 Then
@@ -89,7 +80,7 @@ Module VerifyXML
8980
' </snippet7>
9081
' Check the signature and return the result.
9182
' <snippet8>
92-
Return signedXml.CheckSignature(Key)
83+
Return signedXml.CheckSignature(key)
9384
' </snippet8>
9485
End Function
9586
End Module

0 commit comments

Comments
 (0)