[corlib] Fixes security tests failures
[mono.git] / mcs / class / System.Security / System.Security.Cryptography.Xml / XmlDsigXsltTransform.cs
index 278f22c147288027fc3c64673c35fc077ecd9694..d039bf16730b0ec0dfde53f6aeb7d047353e9c5e 100644 (file)
@@ -55,19 +55,16 @@ namespace System.Security.Cryptography.Xml
                public XmlDsigXsltTransform (bool includeComments) 
                {
                        comments = includeComments;
-                       Algorithm = "http://www.w3.org/TR/1999/REC-xslt-19991116";
+                       Algorithm = XmlSignature.AlgorithmNamespaces.XmlDsigXsltTransform;
                }
 
                public override Type [] InputTypes {
                        get {
                                if (input == null) {
-                                       lock (this) {
-                                               // this way the result is cached if called multiple time
-                                               input = new Type [3];
-                                               input [0] = typeof (System.IO.Stream);
-                                               input [1] = typeof (System.Xml.XmlDocument);
-                                               input [2] = typeof (System.Xml.XmlNodeList);
-                                       }
+                                       input = new Type [3];
+                                       input [0] = typeof (System.IO.Stream);
+                                       input [1] = typeof (System.Xml.XmlDocument);
+                                       input [2] = typeof (System.Xml.XmlNodeList);
                                }
                                return input;
                        }
@@ -76,11 +73,8 @@ namespace System.Security.Cryptography.Xml
                public override Type [] OutputTypes {
                        get {
                                if (output == null) {
-                                       lock (this) {
-                                               // this way the result is cached if called multiple time
-                                               output = new Type [1];
-                                               output [0] = typeof (System.IO.Stream);
-                                       }
+                                       output = new Type [1];
+                                       output [0] = typeof (System.IO.Stream);
                                }
                                return output;
                        }
@@ -93,37 +87,24 @@ namespace System.Security.Cryptography.Xml
 
                public override object GetOutput () 
                {
-#if NET_2_0
                        if (xnl == null)
                                throw new ArgumentNullException ("LoadInnerXml before transformation.");
-#endif
+
                        XmlResolver resolver = GetResolver ();
 
                        XslTransform xsl = new XslTransform ();
                        XmlDocument doc = new XmlDocument ();
-#if NET_1_1
                        doc.XmlResolver = resolver;
-#endif
                        foreach (XmlNode n in xnl)
                                doc.AppendChild (doc.ImportNode (n, true));
-#if NET_1_1
                        xsl.Load (doc, resolver);
-#else
-                       xsl.Load (doc);
-#endif
 
                        if (inputDoc == null)
-#if NET_2_0
                                throw new ArgumentNullException ("LoadInput before transformation.");
-#else
-                               throw new NullReferenceException ("LoadInput before transformation.");
-#endif
 
                        MemoryStream stream = new MemoryStream ();
                        // only possible output: Stream
-#if NET_1_1
                        xsl.XmlResolver = resolver;
-#endif
                        xsl.Transform (inputDoc, null, stream);
 
                        stream.Seek (0, SeekOrigin.Begin);
@@ -132,7 +113,7 @@ namespace System.Security.Cryptography.Xml
 
                public override object GetOutput (Type type) 
                {
-                       if (type != Type.GetType ("System.IO.Stream"))
+                       if (type != typeof (Stream))
                                throw new ArgumentException ("type");
                        return GetOutput ();
                }
@@ -147,24 +128,25 @@ namespace System.Security.Cryptography.Xml
                public override void LoadInput (object obj) 
                {
                        // possible input: Stream, XmlDocument, and XmlNodeList
-                       if (obj is Stream) {
+                       Stream s = (obj as Stream);
+                       if (s != null) {
                                inputDoc = new XmlDocument ();
-#if NET_1_1
                                inputDoc.XmlResolver = GetResolver ();
-#endif
 //                             inputDoc.Load (obj as Stream);
-                               inputDoc.Load (new XmlSignatureStreamReader (
-                                       new StreamReader (obj as Stream)));
+                               inputDoc.Load (new XmlSignatureStreamReader (new StreamReader (s)));
+                               return;
                        }
-                       else if (obj is XmlDocument) {
-                               inputDoc= obj as XmlDocument;
+
+                       XmlDocument xd = (obj as XmlDocument);
+                       if (xd != null) {
+                               inputDoc = xd;
+                               return;
                        }
-                       else if (obj is XmlNodeList) {
+
+                       XmlNodeList nl = (obj as XmlNodeList);
+                       if (nl != null) {
                                inputDoc = new XmlDocument ();
-#if NET_1_1
                                inputDoc.XmlResolver = GetResolver ();
-#endif
-                               XmlNodeList nl = (XmlNodeList) obj;
                                for (int i = 0; i < nl.Count; i++)
                                        inputDoc.AppendChild (inputDoc.ImportNode (nl [i], true));
                        }