2003-03-02 Sebastien Pouliot <spouliot@videotron.ca>
[mono.git] / mcs / class / System.Security / System.Security.Cryptography.Xml / KeyInfoRetrievalMethod.cs
1 //
2 // KeyInfoRetrievalMethod.cs - KeyInfoRetrievalMethod implementation for XML Signature
3 //
4 // Author:
5 //      Sebastien Pouliot (spouliot@motus.com)
6 //
7 // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
8 //
9
10 using System.Xml;
11
12 namespace System.Security.Cryptography.Xml {
13
14         public class KeyInfoRetrievalMethod : KeyInfoClause {
15
16                 private string URI;
17
18                 public KeyInfoRetrievalMethod () {}
19
20                 public KeyInfoRetrievalMethod (string strUri) 
21                 {
22                         URI = strUri;
23                 }
24
25                 public string Uri {
26                         get { return URI; }
27                         set { URI = value; }
28                 }
29
30                 public override XmlElement GetXml () 
31                 {
32                         XmlDocument document = new XmlDocument ();
33                         XmlElement xel = document.CreateElement (XmlSignature.ElementNames.RetrievalMethod, XmlSignature.NamespaceURI);
34                         if (URI != null)
35                                 xel.SetAttribute (XmlSignature.AttributeNames.URI, URI);
36                         return xel;
37                 }
38
39                 public override void LoadXml (XmlElement value) 
40                 {
41                         if (value == null)
42                                 throw new ArgumentNullException ();
43
44                         if ((value.LocalName != XmlSignature.ElementNames.RetrievalMethod) || (value.NamespaceURI != XmlSignature.NamespaceURI))
45                                 URI = ""; // not null - so we return URI="" as attribute !!!
46                         else
47                                 URI = value.Attributes [XmlSignature.AttributeNames.URI].Value;
48                 }
49         }
50 }