Author: spouliot
Date: 2005-04-28 08:09:31 -0400 (Thu, 28 Apr 2005)
New Revision: 43714

Modified:
   trunk/mcs/class/corlib/System.Security/ChangeLog
   trunk/mcs/class/corlib/System.Security/HostProtectionException.cs
   trunk/mcs/class/corlib/System.Security/PermissionSetCollection.cs
   trunk/mcs/class/corlib/System.Security/SecurityContext.cs
   trunk/mcs/class/corlib/System.Security/SecurityCriticalAttribute.cs
   trunk/mcs/class/corlib/System.Security/SecurityException.cs
   trunk/mcs/class/corlib/System.Security/SecurityTransparentAttribute.cs
   
trunk/mcs/class/corlib/System.Security/SuppressUnmanagedCodeSecurityAttribute.cs
Log:
2005-04-28  Sebastien Pouliot  <[EMAIL PROTECTED]>

        * PermissionSetCollection.cs: Updated wrt beta2. Seems this will be
        removed before 2.0 final.
        * HostProtectionException.cs: Updated wrt beta2. Added TODO as it 
        isn't support by the runtime.
        * SecurityContext.cs: Updated wrt beta2. Class is now internal in 
        NET_1_1 to allow the compressed stack propagation to other threads.
        * SecurityCriticalAttribute.cs: Added support for property Scope.
        * SecurityException.cs: Removed PermitOnlySetInstance property to 
        match beta2.
        * SecurityTransparentAttribute.cs: Fixed AttributeUsage. Added TODO
        as it isn't support by the runtime.
        * SuppressUnmanagedCodeSecurityAttribute.cs: Added delegates to usage
        in NET_2_0.



Modified: trunk/mcs/class/corlib/System.Security/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/System.Security/ChangeLog    2005-04-28 11:37:01 UTC 
(rev 43713)
+++ trunk/mcs/class/corlib/System.Security/ChangeLog    2005-04-28 12:09:31 UTC 
(rev 43714)
@@ -1,3 +1,19 @@
+2005-04-28  Sebastien Pouliot  <[EMAIL PROTECTED]>
+
+       * PermissionSetCollection.cs: Updated wrt beta2. Seems this will be
+       removed before 2.0 final.
+       * HostProtectionException.cs: Updated wrt beta2. Added TODO as it 
+       isn't support by the runtime.
+       * SecurityContext.cs: Updated wrt beta2. Class is now internal in 
+       NET_1_1 to allow the compressed stack propagation to other threads.
+       * SecurityCriticalAttribute.cs: Added support for property Scope.
+       * SecurityException.cs: Removed PermitOnlySetInstance property to 
+       match beta2.
+       * SecurityTransparentAttribute.cs: Fixed AttributeUsage. Added TODO
+       as it isn't support by the runtime.
+       * SuppressUnmanagedCodeSecurityAttribute.cs: Added delegates to usage
+       in NET_2_0.
+
 2005-04-27  Sebastien Pouliot  <[EMAIL PROTECTED]>
 
        * SecurityCriticalScope.cs: New. Enum introduced in 2.0 beta2.

Modified: trunk/mcs/class/corlib/System.Security/HostProtectionException.cs
===================================================================
--- trunk/mcs/class/corlib/System.Security/HostProtectionException.cs   
2005-04-28 11:37:01 UTC (rev 43713)
+++ trunk/mcs/class/corlib/System.Security/HostProtectionException.cs   
2005-04-28 12:09:31 UTC (rev 43714)
@@ -4,7 +4,7 @@
 // Author:
 //     Sebastien Pouliot  <[EMAIL PROTECTED]>
 //
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -28,7 +28,6 @@
 
 #if NET_2_0
 
-using System;
 using System.Runtime.InteropServices;
 using System.Runtime.Serialization;
 using System.Security.Permissions;
@@ -36,18 +35,32 @@
 namespace System.Security {
 
        [Serializable]
-       public class HostProtectionException : SystemException, _Exception {
+       [ComVisible (true)]
+       [MonoTODO ("Not supported in the runtime")]
+       public class HostProtectionException : SystemException {
 
-               private HostProtectionResource _inaccessible;
                private HostProtectionResource _protected;
                private HostProtectionResource _demanded;
 
-               public HostProtectionException (string message, 
HostProtectionResource inaccessibleResources, 
-                       HostProtectionResource protectedResources, 
HostProtectionResource demandedRessources)
+               public HostProtectionException ()
+               {
+               }
+
+               public HostProtectionException (string message)
                        : base (message)
                {
                }
 
+               public HostProtectionException (string message, Exception e)
+                       : base (message, e)
+               {
+               }
+
+               public HostProtectionException (string message, 
HostProtectionResource protectedResources, HostProtectionResource 
demandedRessources)
+                       : base (message)
+               {
+               }
+
                protected HostProtectionException (SerializationInfo info, 
StreamingContext context)
                {
                        GetObjectData (info, context);
@@ -55,17 +68,10 @@
 
                public HostProtectionResource DemandedResources {
                        get { return _demanded; }
-                       set { _demanded = value; }
                }
 
-               public HostProtectionResource InaccessibleResources {
-                       get { return _inaccessible; }
-                       set { _inaccessible = value; }
-               }
-
                public HostProtectionResource ProtectedResources {
                        get { return _protected; }
-                       set { _protected = value; }
                }
 
                [MonoTODO]

Modified: trunk/mcs/class/corlib/System.Security/PermissionSetCollection.cs
===================================================================
--- trunk/mcs/class/corlib/System.Security/PermissionSetCollection.cs   
2005-04-28 11:37:01 UTC (rev 43713)
+++ trunk/mcs/class/corlib/System.Security/PermissionSetCollection.cs   
2005-04-28 12:09:31 UTC (rev 43714)
@@ -29,11 +29,14 @@
 #if NET_2_0
 
 using System.Collections;
+using System.Runtime.InteropServices;
 using System.Security.Permissions;
 
 namespace System.Security {
 
        [Serializable]
+       [ComVisible (true)]
+       [Obsolete ("seems the *Choice actions won't survive")]
        public sealed class PermissionSetCollection : ICollection, IEnumerable {
 
                private static string tagName = "PermissionSetCollection";
@@ -56,7 +59,6 @@
 
                public IList PermissionSets {
                        get { return _list; }
-                       set { _list = value; }
                }
 
                public object SyncRoot {

Modified: trunk/mcs/class/corlib/System.Security/SecurityContext.cs
===================================================================
--- trunk/mcs/class/corlib/System.Security/SecurityContext.cs   2005-04-28 
11:37:01 UTC (rev 43713)
+++ trunk/mcs/class/corlib/System.Security/SecurityContext.cs   2005-04-28 
12:09:31 UTC (rev 43714)
@@ -4,7 +4,7 @@
 // Author:
 //     Sebastien Pouliot  <[EMAIL PROTECTED]>
 //
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -26,117 +26,144 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_2_0
-
-using System;
 using System.Runtime.InteropServices;
+using System.Security.Permissions;
 using System.Security.Principal;
 using System.Threading;
 
 namespace System.Security {
 
-       [MonoTODO ("need to determine internals")]
-       [ComVisible (false)]
+#if NET_2_0
        public sealed class SecurityContext {
-
-               static private bool _flowSuppressed;
-               static private bool _windowsIdentityFlowSuppressed;
-
-               private bool _usedForSetSecurityContext;
+#else
+       internal sealed class SecurityContext {
+#endif
+               private bool _capture;
                private WindowsIdentity _winid;
                private CompressedStack _stack;
+               private bool _suppressFlowWindowsIdentity;
+               private bool _suppressFlow;
 
                internal SecurityContext ()
                {
-                       _usedForSetSecurityContext = false;
                }
 
                // copy constructor
                internal SecurityContext (SecurityContext sc)
                {
-                       _usedForSetSecurityContext = 
sc._usedForSetSecurityContext;
+                       _capture = true;
                        _winid = sc._winid;
-                       _stack = sc._stack.CreateCopy ();
+                       if (sc._stack != null)
+                               _stack = sc._stack.CreateCopy ();
                }
 
                public SecurityContext CreateCopy ()
                {
-                       if (_usedForSetSecurityContext) {
-                               throw new InvalidOperationException 
(Locale.GetText (
-                                       "SecurityContext used for 
SetSecurityContext"));
-                       }
+                       if (!_capture)
+                               throw new InvalidOperationException ();
+
                        return new SecurityContext (this);
                }
 
-// LAMESPEC: documented but not implemented (not shown by corcompare)
-#if false
-               public override bool Equals (object obj)
+               // static methods
+
+               static public SecurityContext Capture ()
                {
-                       return false;
+                       SecurityContext sc = 
Thread.CurrentThread.ExecutionContext.SecurityContext;
+                       if (sc.FlowSuppressed)
+                               return null;
+
+                       SecurityContext capture = new SecurityContext ();
+                       capture._capture = true;
+                       capture._winid = WindowsIdentity.GetCurrent ();
+                       capture._stack = CompressedStack.Capture ();
+                       return capture;
                }
 
-               public override int GetHashCode ()
-               {
-                       return 0;
+               // internal stuff
+
+               internal bool FlowSuppressed {
+                       get { return _suppressFlow; }
+                       set { _suppressFlow = value; }
                }
 
-               public void Undo ()
-               {
+               internal bool WindowsIdentityFlowSuppressed {
+                       get { return _suppressFlowWindowsIdentity; }
+                       set { _suppressFlowWindowsIdentity = value; }
                }
-#endif
-               // static methods
 
-               static public SecurityContext Capture ()
-               {
-                       return new SecurityContext ();
+               internal CompressedStack CompressedStack {
+                       get { return _stack; }
+                       set { _stack = value; }
                }
 
+               internal WindowsIdentity WindowsIdentity {
+                       get { return _winid; }
+                       set { _winid = value; }
+               }
+
+#if NET_2_0
+               // Suppressing the SecurityContext flow wasn't required before 
2.0
+
                static public bool IsFlowSuppressed ()
                {
-                       return _flowSuppressed;
+                       return 
Thread.CurrentThread.ExecutionContext.SecurityContext.FlowSuppressed;
                } 
 
                static public bool IsWindowsIdentityFlowSuppressed ()
                {
-                       return _windowsIdentityFlowSuppressed;
+                       return 
Thread.CurrentThread.ExecutionContext.SecurityContext.WindowsIdentityFlowSuppressed;
                }
 
                static public void RestoreFlow ()
                {
-                       _flowSuppressed = false;
+                       SecurityContext sc = 
Thread.CurrentThread.ExecutionContext.SecurityContext;
+                       // if nothing is suppressed then throw
+                       if (!sc.FlowSuppressed && 
!sc.WindowsIdentityFlowSuppressed)
+                               throw new InvalidOperationException ();
+
+                       sc.FlowSuppressed = false;
+                       sc.WindowsIdentityFlowSuppressed = false;
                }
 
+               [SecurityPermission (SecurityAction.LinkDemand, Infrastructure 
= true)]
                static public void Run (SecurityContext securityContext, 
ContextCallback callBack, object state)
                {
                        if (securityContext == null) {
                                throw new InvalidOperationException 
(Locale.GetText (
                                        "Null SecurityContext"));
                        }
-               }
 
-               static public SecurityContextSwitcher SetSecurityContext 
(SecurityContext securityContext)
-               {
-                       if (securityContext == null) {
-                               throw new InvalidOperationException 
(Locale.GetText (
-                                       "Null SecurityContext"));
+                       SecurityContext sc = 
Thread.CurrentThread.ExecutionContext.SecurityContext;
+                       IPrincipal original = Thread.CurrentPrincipal;
+                       try {
+                               if (sc.WindowsIdentity != null)
+                                       Thread.CurrentPrincipal = new 
WindowsPrincipal (sc.WindowsIdentity);
+
+                               CompressedStack.Run 
(securityContext.CompressedStack, callBack, state);
                        }
-
-                       securityContext._usedForSetSecurityContext = true;
-                       return new SecurityContextSwitcher ();
+                       finally {
+                               if ((original != null) && (sc.WindowsIdentity 
!= null))
+                                       Thread.CurrentPrincipal = original;
+                       }
                }
 
+               [SecurityPermission (SecurityAction.LinkDemand, Infrastructure 
= true)]
                static public AsyncFlowControl SuppressFlow ()
                {
-                       _flowSuppressed = true;
-                       return new AsyncFlowControl ();
+                       Thread t = Thread.CurrentThread;
+                       // suppress both flows
+                       t.ExecutionContext.SecurityContext.FlowSuppressed = 
true;
+                       
t.ExecutionContext.SecurityContext.WindowsIdentityFlowSuppressed = true;
+                       return new AsyncFlowControl (t, 
AsyncFlowControlType.Security);
                }
 
                static public AsyncFlowControl SuppressFlowWindowsIdentity ()
                {
-                       _windowsIdentityFlowSuppressed = true;
-                       return new AsyncFlowControl ();
+                       Thread t = Thread.CurrentThread;
+                       
t.ExecutionContext.SecurityContext.WindowsIdentityFlowSuppressed = true;
+                       return new AsyncFlowControl (t, 
AsyncFlowControlType.Security);
                }
+#endif
        }
 }
-
-#endif

Modified: trunk/mcs/class/corlib/System.Security/SecurityCriticalAttribute.cs
===================================================================
--- trunk/mcs/class/corlib/System.Security/SecurityCriticalAttribute.cs 
2005-04-28 11:37:01 UTC (rev 43713)
+++ trunk/mcs/class/corlib/System.Security/SecurityCriticalAttribute.cs 
2005-04-28 12:09:31 UTC (rev 43714)
@@ -28,19 +28,40 @@
 
 #if NET_2_0
 
-using System.Runtime.InteropServices;
-
 namespace System.Security {
 
-       [AttributeUsage (AttributeTargets.Assembly | AttributeTargets.Class | 
AttributeTargets.Method | AttributeTargets.Interface,
+       [AttributeUsage (AttributeTargets.Assembly | AttributeTargets.Module | 
AttributeTargets.Class | AttributeTargets.Struct |
+               AttributeTargets.Enum | AttributeTargets.Constructor | 
AttributeTargets.Method | AttributeTargets.Property |
+               AttributeTargets.Field | AttributeTargets.Event | 
AttributeTargets.Interface | AttributeTargets.Delegate,
                AllowMultiple=false, Inherited=false)]
-       [ComVisible (false)]
+       [MonoTODO ("Not supported by the runtime")]
        public sealed class SecurityCriticalAttribute : Attribute {
 
+               private SecurityCriticalScope _scope;
+
                public SecurityCriticalAttribute ()
                        : base ()
                {
+                       _scope = SecurityCriticalScope.Explicit;
                }
+
+               public SecurityCriticalAttribute (SecurityCriticalScope scope)
+                       : base ()
+               {
+                       switch (scope) {
+                       case SecurityCriticalScope.Everything:
+                               _scope = SecurityCriticalScope.Everything;
+                               break;
+                       default:
+                               // that includes all bad enums values
+                               _scope = SecurityCriticalScope.Explicit;
+                               break;
+                       }
+               }
+
+               public SecurityCriticalScope Scope {
+                       get { return _scope; }
+               }
        }
 }
 

Modified: trunk/mcs/class/corlib/System.Security/SecurityException.cs
===================================================================
--- trunk/mcs/class/corlib/System.Security/SecurityException.cs 2005-04-28 
11:37:01 UTC (rev 43713)
+++ trunk/mcs/class/corlib/System.Security/SecurityException.cs 2005-04-28 
12:09:31 UTC (rev 43714)
@@ -41,10 +41,9 @@
 
        [Serializable]
 #if NET_2_0
-       public class SecurityException : SystemException, _Exception {
-#else
-       public class SecurityException : SystemException {
+       [ComVisible (true)]
 #endif
+       public class SecurityException : SystemException {
                // Fields
                string permissionState;
                Type permissionType;
@@ -91,14 +90,7 @@
                        set { _method = value; }
                }
 
-               [Obsolete]
                [ComVisible (false)]
-               public IPermission PermissionThatFailed {
-                       get { return _permfailed; }
-                       set { _permfailed = value; }
-               }
-
-               [ComVisible (false)]
                public object PermitOnlySetInstance {
                        [SecurityPermission (SecurityAction.Demand, 
ControlEvidence=true, ControlPolicy=true)]
                        get { return _permitset; }

Modified: trunk/mcs/class/corlib/System.Security/SecurityTransparentAttribute.cs
===================================================================
--- trunk/mcs/class/corlib/System.Security/SecurityTransparentAttribute.cs      
2005-04-28 11:37:01 UTC (rev 43713)
+++ trunk/mcs/class/corlib/System.Security/SecurityTransparentAttribute.cs      
2005-04-28 12:09:31 UTC (rev 43714)
@@ -28,13 +28,10 @@
 
 #if NET_2_0
 
-using System.Runtime.InteropServices;
-
 namespace System.Security {
 
-       [AttributeUsage (AttributeTargets.Assembly | AttributeTargets.Class | 
AttributeTargets.Method | AttributeTargets.Interface,
-               AllowMultiple=false, Inherited=false)]
-       [ComVisible (false)]
+       [AttributeUsage (AttributeTargets.Assembly, AllowMultiple=false, 
Inherited=false)]
+       [MonoTODO ("Not supported by the runtime")]
        public sealed class SecurityTransparentAttribute : Attribute {
 
                public SecurityTransparentAttribute ()

Modified: 
trunk/mcs/class/corlib/System.Security/SuppressUnmanagedCodeSecurityAttribute.cs
===================================================================
--- 
trunk/mcs/class/corlib/System.Security/SuppressUnmanagedCodeSecurityAttribute.cs
    2005-04-28 11:37:01 UTC (rev 43713)
+++ 
trunk/mcs/class/corlib/System.Security/SuppressUnmanagedCodeSecurityAttribute.cs
    2005-04-28 12:09:31 UTC (rev 43714)
@@ -5,7 +5,7 @@
 //   Nick Drochak([EMAIL PROTECTED])
 //
 // (C) Nick Drochak
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -27,10 +27,19 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
+using System.Runtime.InteropServices;
+
 namespace System.Security {
 
+#if NET_2_0
+       [AttributeUsage (AttributeTargets.Class | AttributeTargets.Method | 
+               AttributeTargets.Interface | AttributeTargets.Delegate, 
+               AllowMultiple=true, Inherited=false)]
+       [ComVisible (true)]
+#else
        [AttributeUsage (AttributeTargets.Class | AttributeTargets.Method |
                         AttributeTargets.Interface, AllowMultiple=true, 
Inherited=false)]
+#endif
        public sealed class SuppressUnmanagedCodeSecurityAttribute : Attribute {
        }
 }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to