KeyInfoRetrievalMethod.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. //
  2. // KeyInfoRetrievalMethod.cs - KeyInfoRetrievalMethod implementation for XML Signature
  3. //
  4. // Author:
  5. // Sebastien Pouliot ([email protected])
  6. //
  7. // (C) 2002 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 KeyInfoRetrievalMethod : KeyInfoClause {
  13. protected string URI;
  14. public KeyInfoRetrievalMethod () {}
  15. public KeyInfoRetrievalMethod (string strUri)
  16. {
  17. URI = strUri;
  18. }
  19. public string Uri {
  20. get { return URI; }
  21. set { URI = value; }
  22. }
  23. public override XmlElement GetXml ()
  24. {
  25. StringBuilder sb = new StringBuilder ();
  26. sb.Append ("<RetrievalElement ");
  27. if (URI != null) {
  28. sb.Append ("URI=\"");
  29. sb.Append (URI);
  30. sb.Append ("\" ");
  31. }
  32. sb.Append ("xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />");
  33. XmlDocument doc = new XmlDocument ();
  34. doc.LoadXml(sb.ToString ());
  35. return doc.DocumentElement;
  36. }
  37. public override void LoadXml (XmlElement value)
  38. {
  39. if (value == null)
  40. throw new ArgumentNullException ();
  41. if ((value.LocalName == "RetrievalElement") && (value.NamespaceURI == "http://www.w3.org/2000/09/xmldsig#")) {
  42. URI = value.Attributes["URI"].Value;
  43. }
  44. else
  45. URI = ""; // not null - so we return URI="" as attribute !!!
  46. }
  47. }
  48. }