Fix null sessions in HttpContextWrapper.Session
[mono.git] / mcs / class / corlib / System.Security.Policy / Hash.cs
index 0402bb01f84f40efae6c406d8c303c010e189b5a..b135cca778d547cdda0cc65bf86a59ff2ba072fe 100644 (file)
@@ -29,6 +29,8 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
+#if !MOONLIGHT
+
 using System.IO;
 using System.Reflection;
 using System.Runtime.InteropServices;
@@ -40,13 +42,12 @@ using System.Text;
 namespace System.Security.Policy {
 
 [Serializable]
-#if NET_2_0
 [ComVisible (true)]
-#else
-[MonoTODO ("(1.x) This doesn't match the MS version perfectly.")]
-// but it does seems to works exactly like Fx 2.0 beta 1 (and beta2 too) !?!?!
+public sealed class Hash :
+#if NET_4_0
+               EvidenceBase,
 #endif
-public sealed class Hash : ISerializable, IBuiltInEvidence {
+               ISerializable, IBuiltInEvidence {
 
        private Assembly assembly;
        private byte[] data;
@@ -83,12 +84,10 @@ public sealed class Hash : ISerializable, IBuiltInEvidence {
                        // Case 2: we don't have a MD5 value precalculated so we either
                        // (a): have an assembly reference - and can calculate the hash; or
                        // (b): have been initialized with a static MD5 value (FX 2.0)
-#if NET_2_0
                        if ((assembly == null) && (_sha1 != null)) {
                                string msg = Locale.GetText ("No assembly data. This instance was initialized with an MSHA1 digest value.");
                                throw new SecurityException (msg);
                        }
-#endif
                        // fully named to avoid conflit between MD5 property and class name
                        HashAlgorithm hash = System.Security.Cryptography.MD5.Create ();
                        _md5 = GenerateHash (hash);
@@ -105,12 +104,10 @@ public sealed class Hash : ISerializable, IBuiltInEvidence {
                        // Case 2: we don't have a SHA1 value precalculated so we either
                        // (a): have an assembly reference - and can calculate the hash; or
                        // (b): have been initialized with a static MD5 value (FX 2.0)
-#if NET_2_0
                        if ((assembly == null) && (_md5 != null)) {
                                string msg = Locale.GetText ("No assembly data. This instance was initialized with an MD5 digest value.");
                                throw new SecurityException (msg);
                        }
-#endif
                        // fully named to avoid conflit between SHA1 property and class name
                        HashAlgorithm hash = System.Security.Cryptography.SHA1.Create ();
                        _sha1 = GenerateHash (hash);
@@ -158,12 +155,10 @@ public sealed class Hash : ISerializable, IBuiltInEvidence {
        [FileIOPermission (SecurityAction.Assert, Unrestricted = true)]
        private byte[] GetData () 
        {
-#if NET_2_0
                if ((assembly == null) && (data == null)) {
                        string msg = Locale.GetText ("No assembly data.");
                        throw new SecurityException (msg);
                }
-#endif
                if (null == data) {
                        // TODO (Pre-Fx-2.0) we mustn't hash the complete assembly!
                        // ---- Look at ToString (MS version) for what to hash (and what not to)
@@ -196,7 +191,6 @@ public sealed class Hash : ISerializable, IBuiltInEvidence {
                return 0;
        }
 
-#if NET_2_0
        static public Hash CreateMD5 (byte[] md5)
        {
                if (md5 == null)
@@ -214,7 +208,9 @@ public sealed class Hash : ISerializable, IBuiltInEvidence {
                h._sha1 = sha1;
                return h;
        }
-#endif
 }
 
 }
+
+#endif
+