* HostProtectionException.cs: New class in Fx 2.0.
* HostSecurityManager.cs: New class in Fx 2.0.
* HostSecurityManagerFlags.cs: New enum in Fx 2.0.
* SecurityContext.cs: New class in Fx 2.0.
* SecurityContextSwitcher.cs: New structure in Fx 2.0.
svn path=/trunk/mcs/; revision=31127
+2004-07-14 Sebastien Pouliot <sebastien@ximian.com>
+
+ * HostProtectionException.cs: New class in Fx 2.0.
+ * HostSecurityManager.cs: New class in Fx 2.0.
+ * HostSecurityManagerFlags.cs: New enum in Fx 2.0.
+ * SecurityContext.cs: New class in Fx 2.0.
+ * SecurityContextSwitcher.cs: New structure in Fx 2.0.
+
2004-06-15 Gert Driesen <drieseng@users.sourceforge.net>
* XmlSyntaxException.cs: added missing serialization ctor
--- /dev/null
+//
+// System.Security.HostProtectionException class
+//
+// Author:
+// Sebastien Pouliot <sebastien@ximian.com>
+//
+// Copyright (C) 2004 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
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if NET_2_0
+
+using System;
+using System.Runtime.InteropServices;
+using System.Runtime.Serialization;
+using System.Security.Permissions;
+
+namespace System.Security {
+
+ [Serializable]
+ public class HostProtectionException : SystemException, _Exception {
+
+ private HostProtectionResource _inaccessible;
+ private HostProtectionResource _protected;
+ private HostProtectionResource _demanded;
+
+ public HostProtectionException (string message, HostProtectionResource inaccessibleResources,
+ HostProtectionResource protectedResources, HostProtectionResource demandedRessources)
+ : base (message)
+ {
+ }
+
+ protected HostProtectionException (SerializationInfo info, StreamingContext context)
+ {
+ GetObjectData (info, context);
+ }
+
+ 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]
+ public override void GetObjectData (SerializationInfo info, StreamingContext context)
+ {
+ if (info == null)
+ throw new ArgumentNullException ("info");
+ }
+
+ [MonoTODO]
+ public override string ToString ()
+ {
+ return base.ToString ();
+ }
+ }
+}
+
+#endif
--- /dev/null
+//
+// System.Security.HostSecurityManager class
+//
+// Author:
+// Sebastien Pouliot <sebastien@ximian.com>
+//
+// Copyright (C) 2004 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
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if NET_2_0
+
+using System;
+using System.Reflection;
+using System.Security.Policy;
+
+namespace System.Security {
+
+ [Serializable]
+ public class HostSecurityManager {
+
+ public HostSecurityManager ()
+ {
+ }
+
+ public virtual PolicyLevel DomainPolicy {
+ get { return null; }
+ }
+
+ public virtual HostSecurityManagerFlags Flags {
+ get { return HostSecurityManagerFlags.AllFlags; }
+ }
+
+ public virtual PermissionSet RefusedSet {
+ get { return null; }
+ }
+
+ public virtual bool DetermineApplicationTrust (ActivationContext activationContext, TrustManagerContext context)
+ {
+ if (activationContext == null)
+ throw new ArgumentNullException ("activationContext");
+ return true;
+ }
+
+ public virtual Evidence ProvideAssemblyEvidence (Assembly loadedAssembly, Evidence evidence)
+ {
+ return evidence;
+ }
+ }
+}
+
+#endif
--- /dev/null
+//
+// System.Security.HostSecurityManagerFlags enumeration
+//
+// Author:
+// Sebastien Pouliot <sebastien@ximian.com>
+//
+// Copyright (C) 2004 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
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if NET_2_0
+
+using System;
+
+namespace System.Security {
+
+ [Flags]
+ [Serializable]
+ public enum HostSecurityManagerFlags {
+ None = 0,
+ HostRefusedSet = 1,
+ HostPolicyLevel = 2,
+ HostAssemblyEvidence = 4,
+ HostDetermineApplicationTrust = 8,
+ AllFlags = HostAssemblyEvidence | HostDetermineApplicationTrust | HostPolicyLevel | HostRefusedSet
+ }
+}
+
+#endif
--- /dev/null
+//
+// System.Security.SecurityContext class
+//
+// Author:
+// Sebastien Pouliot <sebastien@ximian.com>
+//
+// Copyright (C) 2004 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
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// 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.Principal;
+using System.Threading;
+
+namespace System.Security {
+
+ [MonoTODO ("need to determine internals")]
+ [ComVisible (false)]
+ public sealed class SecurityContext {
+
+ static private bool _flowSuppressed;
+ static private bool _windowsIdentityFlowSuppressed;
+
+ private bool _usedForSetSecurityContext;
+ private WindowsIdentity _winid;
+ private CompressedStack _stack;
+
+ internal SecurityContext ()
+ {
+ _usedForSetSecurityContext = false;
+ }
+
+ // copy constructor
+ internal SecurityContext (SecurityContext sc)
+ {
+ _usedForSetSecurityContext = sc._usedForSetSecurityContext;
+ _winid = sc._winid;
+ _stack = sc._stack.CreateCopy ();
+ }
+
+ public SecurityContext CreateCopy ()
+ {
+ if (_usedForSetSecurityContext) {
+ throw new InvalidOperationException (Locale.GetText (
+ "SecurityContext used for SetSecurityContext"));
+ }
+ return new SecurityContext (this);
+ }
+
+// LAMESPEC: documented but not implemented (not shown by corcompare)
+#if false
+ public override bool Equals (object obj)
+ {
+ return false;
+ }
+
+ public override int GetHashCode ()
+ {
+ return 0;
+ }
+
+ public void Undo ()
+ {
+ }
+#endif
+ // static methods
+
+ static public SecurityContext Capture ()
+ {
+ return new SecurityContext ();
+ }
+
+ static public bool IsFlowSuppressed ()
+ {
+ return _flowSuppressed;
+ }
+
+ static public bool IsWindowsIdentityFlowSuppressed ()
+ {
+ return _windowsIdentityFlowSuppressed;
+ }
+
+ static public void RestoreFlow ()
+ {
+ _flowSuppressed = false;
+ }
+
+ 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._usedForSetSecurityContext = true;
+ return new SecurityContextSwitcher ();
+ }
+
+ static public AsyncFlowControl SuppressFlow ()
+ {
+ _flowSuppressed = true;
+ return new AsyncFlowControl ();
+ }
+
+ static public AsyncFlowControl SuppressFlowWindowsIdentity ()
+ {
+ _windowsIdentityFlowSuppressed = true;
+ return new AsyncFlowControl ();
+ }
+ }
+}
+
+#endif
--- /dev/null
+//
+// System.Security.SecurityContextSwitcher structure
+//
+// Author:
+// Sebastien Pouliot <sebastien@ximian.com>
+//
+// Copyright (C) 2004 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
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if NET_2_0
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace System.Security {
+
+ [MonoTODO ("need to determine internals")]
+ [ComVisibleAttribute (false)]
+ public struct SecurityContextSwitcher : IDisposable {
+
+ private bool _undo;
+
+ public override bool Equals (object obj)
+ {
+ return false;
+ }
+
+ public override int GetHashCode ()
+ {
+ return 0;
+ }
+
+ public void Undo ()
+ {
+ _undo = true;
+ }
+
+ void IDisposable.Dispose ()
+ {
+ if (!_undo)
+ Undo ();
+ }
+
+// LAMESPEC: documented but not implemented (not shown by corcompare)
+#if false
+ public static bool op_Equality (SecurityContextSwitcher c1, SecurityContextSwitcher c2)
+ {
+ return false;
+ }
+
+ public static bool op_Inequality (SecurityContextSwitcher c1, SecurityContextSwitcher c2)
+ {
+ return false;
+ }
+#endif
+ }
+}
+
+#endif