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)
8 // Atsushi Enomoto (atsushi@ximian.com)
10 // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
11 // (C) 2004 Novell Inc.
18 namespace System.Security.Cryptography.Xml
21 public class XmlDsigXsltTransform : Transform
24 private Type [] input;
25 private Type [] output;
26 private bool comments;
27 private XmlNodeList xnl;
28 private XmlDocument inputDoc;
30 public XmlDsigXsltTransform () : this (false)
34 public XmlDsigXsltTransform (bool includeComments)
36 comments = includeComments;
37 Algorithm = "http://www.w3.org/TR/1999/REC-xslt-19991116";
40 public override Type [] InputTypes {
44 // this way the result is cached if called multiple time
46 input [0] = typeof (System.IO.Stream);
47 input [1] = typeof (System.Xml.XmlDocument);
48 input [2] = typeof (System.Xml.XmlNodeList);
55 public override Type [] OutputTypes {
59 // this way the result is cached if called multiple time
60 output = new Type [1];
61 output [0] = typeof (System.IO.Stream);
68 protected override XmlNodeList GetInnerXml ()
73 public override object GetOutput ()
75 XslTransform xsl = new XslTransform ();
76 XmlDocument doc = new XmlDocument ();
78 doc.XmlResolver = GetResolver ();
80 foreach (XmlNode n in xnl)
81 doc.AppendChild (doc.ImportNode (n, true));
84 MemoryStream stream = null;
86 stream = new MemoryStream ();
87 // only possible output: Stream
88 xsl.Transform (inputDoc, null, stream);
90 stream.Seek (0, SeekOrigin.Begin);
94 public override object GetOutput (Type type)
96 if (type != Type.GetType ("System.IO.Stream"))
97 throw new ArgumentException ("type");
101 public override void LoadInnerXml (XmlNodeList nodeList)
103 if (nodeList == null)
104 throw new CryptographicException ("nodeList");
108 public override void LoadInput (object obj)
110 // possible input: Stream, XmlDocument, and XmlNodeList
112 inputDoc = new XmlDocument ();
113 inputDoc.Load (obj as Stream);
115 else if (obj is XmlDocument) {
116 inputDoc= obj as XmlDocument;
118 else if (obj is XmlNodeList) {
119 inputDoc = new XmlDocument ();
120 XmlNodeList nl = (XmlNodeList) obj;
121 for (int i = 0; i < nl.Count; i++)
122 inputDoc.AppendChild (inputDoc.ImportNode (nl [i], true));