2 // XmlDsigExcC14NTransform.cs - XmlDsigExcC14NTransform implementation for XML Encryption
5 // Tim Coleman (tim@timcoleman.com)
7 // Copyright (C) Tim Coleman, 2004
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36 namespace System
.Security
.Cryptography
.Xml
{
37 public class XmlDsigExcC14NTransform
: Transform
{
41 XmlCanonicalizer canonicalizer
;
43 string inclusiveNamespacesPrefixList
;
50 public XmlDsigExcC14NTransform ()
52 Algorithm
= XmlSignature
.AlgorithmNamespaces
.XmlDsigExcC14NTransform
;
53 canonicalizer
= new XmlCanonicalizer (true, false);
56 public XmlDsigExcC14NTransform (bool includeComments
)
58 this.includeComments
= includeComments
;
59 canonicalizer
= new XmlCanonicalizer (true, includeComments
);
62 [MonoTODO ("What does inclusiveNamespacesPrefixList mean?")]
63 public XmlDsigExcC14NTransform (string inclusiveNamespacesPrefixList
)
65 this.inclusiveNamespacesPrefixList
= inclusiveNamespacesPrefixList
;
68 [MonoTODO ("What does inclusiveNamespacesPrefixList mean?")]
69 public XmlDsigExcC14NTransform (bool includeComments
, string inclusiveNamespacesPrefixList
)
71 this.inclusiveNamespacesPrefixList
= inclusiveNamespacesPrefixList
;
72 this.includeComments
= includeComments
;
75 #endregion // Constructors
79 public string InclusiveNamespacesPrefixList
{
80 get { return inclusiveNamespacesPrefixList; }
81 set { inclusiveNamespacesPrefixList = value; }
84 public override Type
[] InputTypes
{
85 get { return new Type [3] {typeof (System.IO.Stream), typeof (System.Xml.XmlDocument), typeof (System.Xml.XmlNodeList)}
; }
88 public override Type
[] OutputTypes
{
89 get { return new Type [1] {typeof (System.IO.Stream)}
; }
92 #endregion // Properties
96 public override byte[] GetDigestedOutput (HashAlgorithm hash
)
98 return hash
.ComputeHash ((Stream
) GetOutput());
101 protected override XmlNodeList
GetInnerXml ()
106 public override object GetOutput ()
110 if (inputObj
is Stream
) {
111 XmlDocument doc
= new XmlDocument ();
112 doc
.PreserveWhitespace
= true; // REALLY IMPORTANT
113 doc
.Load (inputObj
as Stream
);
114 s
= canonicalizer
.Canonicalize (doc
);
116 else if (inputObj
is XmlDocument
)
117 s
= canonicalizer
.Canonicalize (inputObj
as XmlDocument
);
118 else if (inputObj
is XmlNodeList
)
119 s
= canonicalizer
.Canonicalize (inputObj
as XmlNodeList
);
121 // note: there is no default are other types won't throw an exception
126 public override object GetOutput (Type type
)
128 if (type
== Type
.GetType ("Stream"))
130 throw new ArgumentException ("type");
133 public override void LoadInnerXml (XmlNodeList nodeList
)
137 public override void LoadInput (object obj
)
142 #endregion // Methods