2 // XmlDsigBase64Transform.cs - Base64 Transform implementation for XML Signature
5 // Sebastien Pouliot <sebastien@ximian.com>
7 // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
8 // (C) 2004 Novell (http://www.novell.com)
12 using System.Security.Cryptography;
16 namespace System.Security.Cryptography.Xml {
18 // http://www.w3.org/2000/09/xmldsig#base64
19 public class XmlDsigBase64Transform : Transform {
21 private CryptoStream cs;
23 public XmlDsigBase64Transform ()
25 Algorithm = "http://www.w3.org/2000/09/xmldsig#base64";
28 public override Type[] InputTypes {
30 Type[] input = new Type [3];
31 input[0] = typeof (System.IO.Stream);
32 input[1] = typeof (System.Xml.XmlDocument);
33 input[2] = typeof (System.Xml.XmlNodeList);
38 public override Type[] OutputTypes {
40 Type[] output = new Type [1];
41 output[0] = typeof (System.IO.Stream);
46 protected override XmlNodeList GetInnerXml ()
48 return null; // THIS IS DOCUMENTED AS SUCH
51 public override object GetOutput ()
56 public override object GetOutput (Type type)
58 if (type != typeof (System.IO.Stream))
59 throw new ArgumentException ("type");
63 public override void LoadInnerXml (XmlNodeList nodeList)
65 // documented as not changing the state of the transform
68 [MonoTODO("There's still one unit test failing")]
69 public override void LoadInput (object obj)
71 XmlNodeList xnl = null;
75 stream = (obj as Stream);
76 else if (obj is XmlDocument)
77 xnl = (obj as XmlDocument).ChildNodes;
78 else if (obj is XmlNodeList)
79 xnl = (XmlNodeList) obj;
82 stream = new MemoryStream ();
83 StreamWriter sw = new StreamWriter (stream);
84 foreach (XmlNode xn in xnl) {
86 sw.Write (xn.InnerText);
89 // ready to be re-used
94 cs = new CryptoStream (stream, new FromBase64Transform (), CryptoStreamMode.Read);
95 // note: there is no default are other types won't throw an exception