2 // XmlDsigExcC14NTransform.cs:
\r
3 // Handles WS-Security XmlDsigExcC14NTransform
\r
6 // Sebastien Pouliot <sebastien@ximian.com>
\r
7 // Aleksey Sanin (aleksey@aleksey.com)
\r
9 // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
\r
10 // (C) 2003 Aleksey Sanin (aleksey@aleksey.com)
\r
11 // (C) 2004 Novell (http://www.novell.com)
\r
16 using System.Security.Cryptography.Xml;
\r
21 namespace Microsoft.Web.Services.Security {
\r
23 public class XmlDsigExcC14NTransform : Transform {
\r
25 public const string XmlDsigExcC14NTransformUrl = "http://www.w3.org/2001/10/xml-exc-c14n#";
\r
26 public const string XmlDsigExcC14NWithCommentsTransformUrl = "http://www.w3.org/2001/10/xml-exc-c14n#WithComments";
\r
28 private Type[] input;
\r
29 private Type[] output;
\r
30 private XmlCanonicalizer canonicalizer;
\r
32 private string prefixList;
\r
33 private bool comments;
\r
35 public XmlDsigExcC14NTransform () : this (false)
\r
39 public XmlDsigExcC14NTransform (bool includeComments)
\r
41 comments = includeComments;
\r
42 canonicalizer = new XmlCanonicalizer (includeComments, true);
\r
45 public XmlDsigExcC14NTransform (string inclusiveNamespacesPrefixList)
\r
46 : this (false, inclusiveNamespacesPrefixList)
\r
50 public XmlDsigExcC14NTransform (bool includeComments, string inclusiveNamespacesPrefixList)
\r
51 : this (includeComments)
\r
53 prefixList = inclusiveNamespacesPrefixList;
\r
56 public string InclusiveNamespacesPrefixList {
\r
57 get { return prefixList; }
\r
58 set { prefixList = value; }
\r
61 public override Type[] InputTypes {
\r
63 if (input == null) {
\r
65 // this way the result is cached if called multiple time
\r
66 input = new Type [3];
\r
67 input[0] = typeof (System.IO.Stream);
\r
68 input[1] = typeof (System.Xml.XmlDocument);
\r
69 input[2] = typeof (System.Xml.XmlNodeList);
\r
76 public override Type[] OutputTypes {
\r
78 if (output == null) {
\r
80 // this way the result is cached if called multiple time
\r
81 output = new Type [1];
\r
82 output[0] = typeof (System.IO.Stream);
\r
88 protected override XmlNodeList GetInnerXml ()
\r
90 return null; // THIS IS DOCUMENTED AS SUCH
\r
93 public override object GetOutput ()
\r
98 public override object GetOutput (Type type)
\r
100 if (type != typeof (Stream))
\r
101 throw new ArgumentException ("type");
\r
102 return GetOutput ();
\r
105 public override void LoadInnerXml (XmlNodeList nodeList)
\r
107 // documented as not changing the state of the transform
\r
110 public override void LoadInput (object obj)
\r
112 if (obj is Stream) {
\r
113 s = (obj as Stream);
\r
114 XmlDocument doc = new XmlDocument ();
\r
115 doc.PreserveWhitespace = true; // REALLY IMPORTANT
\r
116 doc.Load (obj as Stream);
\r
117 s = canonicalizer.Canonicalize (doc);
\r
118 } else if (obj is XmlDocument)
\r
119 s = canonicalizer.Canonicalize ((obj as XmlDocument));
\r
120 else if (obj is XmlNodeList)
\r
121 s = canonicalizer.Canonicalize ((obj as XmlNodeList));
\r
122 // note: there is no default are other types won't throw an exception
\r