KeyInfoName.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. //
  2. // KeyInfoName.cs - KeyInfoName implementation for XML Signature
  3. //
  4. // Author:
  5. // Sebastien Pouliot ([email protected])
  6. //
  7. // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
  8. //
  9. using System.Text;
  10. using System.Xml;
  11. namespace System.Security.Cryptography.Xml {
  12. public class KeyInfoName : KeyInfoClause {
  13. static private string xmldsig = "http://www.w3.org/2000/09/xmldsig#";
  14. private string Name;
  15. public KeyInfoName() {}
  16. public string Value {
  17. get { return Name; }
  18. set { Name = value; }
  19. }
  20. public override XmlElement GetXml ()
  21. {
  22. StringBuilder sb = new StringBuilder ();
  23. sb.Append ("<KeyName xmlns=\"");
  24. sb.Append (xmldsig);
  25. sb.Append ("\">");
  26. sb.Append (Name);
  27. sb.Append ("</KeyName>");
  28. XmlDocument doc = new XmlDocument ();
  29. doc.LoadXml(sb.ToString ());
  30. return doc.DocumentElement;
  31. }
  32. public override void LoadXml (XmlElement value)
  33. {
  34. if (value == null)
  35. throw new ArgumentNullException ();
  36. if ((value.LocalName == "KeyName") && (value.NamespaceURI == xmldsig))
  37. Name = value.InnerXml;
  38. else
  39. Name = null;
  40. }
  41. }
  42. }