2 // XmlDsigXPathTransform.cs -
3 // XmlDsigXPathTransform implementation for XML Signature
4 // http://www.w3.org/TR/1999/REC-xpath-19991116
7 // Sebastien Pouliot (spouliot@motus.com)
9 // (C) 2002 Motus Technologies Inc. (http://www.motus.com)
13 using System.Security.Cryptography;
17 namespace System.Security.Cryptography.Xml {
19 // www.w3.org/TR/xmldsig-core/
20 // see Section 6.6.3 of the XMLDSIG specification
21 public class XmlDsigXPathTransform : Transform {
23 private XmlNodeList xnl;
24 private XmlNodeList xpathNodes;
26 public XmlDsigXPathTransform ()
30 public override Type[] InputTypes {
34 // this way the result is cached if called multiple time
36 input[0] = typeof (System.IO.Stream);
37 input[1] = typeof (System.Xml.XmlDocument);
38 input[2] = typeof (System.Xml.XmlNodeList);
45 public override Type[] OutputTypes {
49 // this way the result is cached if called multiple time
50 output = new Type [1];
51 output[0] = typeof (System.IO.Stream);
58 protected override XmlNodeList GetInnerXml ()
63 public override object GetOutput ()
68 public override object GetOutput (Type type)
70 if (type != typeof (XmlNodeList))
71 throw new ArgumentException ("type");
75 public override void LoadInnerXml (XmlNodeList nodeList)
78 throw new CryptographicException ("nodeList");
82 public override void LoadInput (object obj)
85 // possible input: Stream, XmlDocument, and XmlNodeList
87 XmlDocument doc = new XmlDocument ();
88 doc.Load (obj as Stream);
90 else if (obj is XmlDocument) {
92 else if (obj is XmlNodeList) {
93 xnl = (XmlNodeList) obj;
97 string xpath = xn.InnerXml;
98 // only possible output: XmlNodeList
99 xpathNodes = xnl[0].SelectNodes (xpath);