KeyInfoRetrievalMethod.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. //
  2. // KeyInfoRetrievalMethod.cs - KeyInfoRetrievalMethod implementation for XML Signature
  3. //
  4. // Author:
  5. // Sebastien Pouliot ([email protected])
  6. // Tim Coleman ([email protected])
  7. //
  8. // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
  9. // Copyright (C) Tim Coleman, 2004
  10. //
  11. using System.Xml;
  12. namespace System.Security.Cryptography.Xml {
  13. public class KeyInfoRetrievalMethod : KeyInfoClause {
  14. private string URI;
  15. #if NET_1_2
  16. string type;
  17. #endif
  18. public KeyInfoRetrievalMethod () {}
  19. public KeyInfoRetrievalMethod (string strUri)
  20. {
  21. URI = strUri;
  22. }
  23. #if NET_1_2
  24. public KeyInfoRetrievalMethod (string strUri, string strType)
  25. : this (strUri)
  26. {
  27. Type = strType;
  28. }
  29. public string Type {
  30. get { return type; }
  31. set { type = value; }
  32. }
  33. #endif
  34. public string Uri {
  35. get { return URI; }
  36. set { URI = value; }
  37. }
  38. public override XmlElement GetXml ()
  39. {
  40. XmlDocument document = new XmlDocument ();
  41. XmlElement xel = document.CreateElement (XmlSignature.ElementNames.RetrievalMethod, XmlSignature.NamespaceURI);
  42. if (URI != null)
  43. xel.SetAttribute (XmlSignature.AttributeNames.URI, URI);
  44. #if NET_1_2
  45. if (Type != null)
  46. xel.SetAttribute (XmlSignature.AttributeNames.Type, Type);
  47. #endif
  48. return xel;
  49. }
  50. public override void LoadXml (XmlElement value)
  51. {
  52. if (value == null)
  53. throw new ArgumentNullException ();
  54. if ((value.LocalName != XmlSignature.ElementNames.RetrievalMethod) || (value.NamespaceURI != XmlSignature.NamespaceURI)) {
  55. URI = ""; // not null - so we return URI="" as attribute !!!
  56. } else {
  57. URI = value.Attributes [XmlSignature.AttributeNames.URI].Value;
  58. #if NET_1_2
  59. if (value.HasAttribute (XmlSignature.AttributeNames.Type))
  60. Type = value.Attributes [XmlSignature.AttributeNames.Type].Value;
  61. #endif
  62. }
  63. }
  64. }
  65. }