2 // XmlDsigEnvelopedSignatureTransform.cs -
3 // Enveloped Signature Transform implementation for XML Signature
4 // http://www.w3.org/TR/1999/REC-xslt-19991116
7 // Sebastien Pouliot (spouliot@motus.com)
9 // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
16 namespace System.Security.Cryptography.Xml {
19 public class XmlDsigXsltTransform : Transform {
22 private Type[] output;
23 private bool comments;
24 private XmlNodeList xnl;
25 private CryptoStream cs;
27 public XmlDsigXsltTransform () : this (false) {}
29 public XmlDsigXsltTransform (bool includeComments)
31 comments = includeComments;
32 Algorithm = "http://www.w3.org/TR/1999/REC-xslt-19991116";
35 public override Type[] InputTypes {
39 // this way the result is cached if called multiple time
41 input[0] = typeof (System.IO.Stream);
42 input[1] = typeof (System.Xml.XmlDocument);
43 input[2] = typeof (System.Xml.XmlNodeList);
50 public override Type[] OutputTypes {
54 // this way the result is cached if called multiple time
55 output = new Type [1];
56 output[0] = typeof (System.IO.Stream);
63 protected override XmlNodeList GetInnerXml ()
68 [MonoTODO("Missing some action - see InvalidXslt test")]
69 public override object GetOutput ()
74 public override object GetOutput (Type type)
76 if (type != Type.GetType ("System.IO.Stream"))
77 throw new ArgumentException ("type");
81 public override void LoadInnerXml (XmlNodeList nodeList)
84 throw new CryptographicException ("nodeList");
89 public override void LoadInput (object obj)
91 XslTransform xsl = new XslTransform ();
92 XmlDocument doc = new XmlDocument ();
93 doc.XmlResolver = GetResolver ();
96 // possible input: Stream, XmlDocument, and XmlNodeList
98 doc.Load (obj as Stream);
101 else if (obj is XmlDocument) {
102 xsl.Load (obj as XmlDocument);
104 else if (obj is XmlNodeList) {
105 // Is it valid operation?
109 stream = new MemoryStream ();
110 // only possible output: Stream
111 xsl.Transform (doc, null, stream);
115 cs = new CryptoStream (stream, new FromBase64Transform (), CryptoStreamMode.Read);
118 // note: there is no default are other types won't throw an exception