2 // XmlDsigExcC14NTransform.cs:
3 // Handles WS-Security XmlDsigExcC14NTransform
6 // Sebastien Pouliot <sebastien@ximian.com>
7 // Aleksey Sanin (aleksey@aleksey.com)
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)
16 using System
.Security
.Cryptography
.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";
29 private Type
[] output
;
30 private XmlCanonicalizer canonicalizer
;
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
{
65 // this way the result is cached if called multiple time
67 input
[0] = typeof (System
.IO
.Stream
);
68 input
[1] = typeof (System
.Xml
.XmlDocument
);
69 input
[2] = typeof (System
.Xml
.XmlNodeList
);
76 public override Type
[] OutputTypes
{
80 // this way the result is cached if called multiple time
81 output
= new Type
[1];
82 output
[0] = typeof (System
.IO
.Stream
);
88 protected override XmlNodeList
GetInnerXml ()
90 return null; // THIS IS DOCUMENTED AS SUCH
93 public override object GetOutput ()
98 public override object GetOutput (Type type
)
100 if (type
!= typeof (Stream
))
101 throw new ArgumentException ("type");
105 public override void LoadInnerXml (XmlNodeList nodeList
)
107 // documented as not changing the state of the transform
110 public override void LoadInput (object obj
)
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