2 // XmlDsigC14NTransform.cs - C14N Transform implementation for XML Signature
3 // http://www.w3.org/TR/xml-c14n
6 // Sebastien Pouliot (spouliot@motus.com)
8 // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
15 namespace System.Security.Cryptography.Xml {
18 public class XmlDsigC14NTransform : Transform {
21 private Type[] output;
22 private bool comments;
25 public XmlDsigC14NTransform ()
27 Algorithm = "http://www.w3.org/TR/2001/REC-xml-c14n-20010315";
31 public XmlDsigC14NTransform (bool includeComments)
33 comments = includeComments;
36 public override Type[] InputTypes {
40 // this way the result is cached if called multiple time
42 input[0] = typeof (System.IO.Stream);
43 input[1] = typeof (System.Xml.XmlDocument);
44 input[2] = typeof (System.Xml.XmlNodeList);
51 public override Type[] OutputTypes {
55 // this way the result is cached if called multiple time
56 output = new Type [1];
57 output[0] = typeof (System.IO.Stream);
64 protected override XmlNodeList GetInnerXml ()
66 return null; // THIS IS DOCUMENTED AS SUCH
69 public override object GetOutput ()
74 public override object GetOutput (Type type)
76 if (type == Type.GetType ("Stream"))
78 throw new ArgumentException ("type");
81 public override void LoadInnerXml (XmlNodeList nodeList)
83 // documented as not changing the state of the transform
86 public override void LoadInput (object obj)
88 XmlNodeList xnl = null;
92 else if (obj is XmlDocument)
93 xnl = (obj as XmlDocument).ChildNodes;
94 else if (obj is XmlNodeList)
95 xnl = (XmlNodeList) obj;
98 StringBuilder sb = new StringBuilder ();
99 foreach (XmlNode xn in xnl)
100 sb.Append (xn.InnerText);
102 UTF8Encoding utf8 = new UTF8Encoding ();
103 byte[] data = utf8.GetBytes (sb.ToString ());
104 s = new MemoryStream (data);
107 // note: there is no default are other types won't throw an exception