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