diff options
-rw-r--r-- | mcs/class/corlib/System.Reflection/Assembly.cs | 6 | ||||
-rw-r--r-- | mcs/class/corlib/System.Security/SecurityContext.cs | 9 | ||||
-rw-r--r-- | mcs/class/corlib/System.Security/SecurityException.cs | 4 | ||||
-rw-r--r-- | mcs/class/corlib/System.Security/SecurityManager.cs | 2 | ||||
-rw-r--r-- | mcs/class/corlib/System.Security/SecurityManager_mobile.cs | 251 | ||||
-rw-r--r-- | mcs/class/corlib/System/AppDomain.cs | 6 | ||||
-rw-r--r-- | mcs/class/corlib/corlib.dll.sources | 1 |
7 files changed, 276 insertions, 3 deletions
diff --git a/mcs/class/corlib/System.Reflection/Assembly.cs b/mcs/class/corlib/System.Reflection/Assembly.cs index d6dc774bd5e..cb241a662b4 100644 --- a/mcs/class/corlib/System.Reflection/Assembly.cs +++ b/mcs/class/corlib/System.Reflection/Assembly.cs @@ -159,6 +159,9 @@ namespace System.Reflection { // note: the security runtime requires evidences but may be unable to do so... internal Evidence UnprotectedGetEvidence () { +#if MOBILE + return null; +#else // if the host (runtime) hasn't provided it's own evidence... if (_evidence == null) { // ... we will provide our own @@ -167,6 +170,7 @@ namespace System.Reflection { } } return _evidence; +#endif } [MethodImplAttribute (MethodImplOptions.InternalCall)] @@ -797,7 +801,7 @@ namespace System.Reflection { return other._mono_assembly == _mono_assembly; } -#if !MOONLIGHT +#if !NET_2_1 // Code Access Security internal void Resolve () diff --git a/mcs/class/corlib/System.Security/SecurityContext.cs b/mcs/class/corlib/System.Security/SecurityContext.cs index cd84c88a2af..eec9b9480ba 100644 --- a/mcs/class/corlib/System.Security/SecurityContext.cs +++ b/mcs/class/corlib/System.Security/SecurityContext.cs @@ -52,9 +52,11 @@ namespace System.Security { internal SecurityContext (SecurityContext sc) { _capture = true; +#if !MOBILE _winid = sc._winid; if (sc._stack != null) _stack = sc._stack.CreateCopy (); +#endif } public SecurityContext CreateCopy () @@ -75,8 +77,10 @@ namespace System.Security { SecurityContext capture = new SecurityContext (); capture._capture = true; +#if !MOBILE capture._winid = WindowsIdentity.GetCurrentToken (); capture._stack = CompressedStack.Capture (); +#endif return capture; } @@ -140,7 +144,9 @@ namespace System.Security { throw new InvalidOperationException (Locale.GetText ( "Null SecurityContext")); } - +#if MOBILE + callback (state); +#else SecurityContext sc = Thread.CurrentThread.ExecutionContext.SecurityContext; IPrincipal original = Thread.CurrentPrincipal; try { @@ -159,6 +165,7 @@ namespace System.Security { if ((original != null) && (sc.IdentityToken != IntPtr.Zero)) Thread.CurrentPrincipal = original; } +#endif } [SecurityPermission (SecurityAction.LinkDemand, Infrastructure = true)] diff --git a/mcs/class/corlib/System.Security/SecurityException.cs b/mcs/class/corlib/System.Security/SecurityException.cs index 5320a22c000..fdf3c7b794e 100644 --- a/mcs/class/corlib/System.Security/SecurityException.cs +++ b/mcs/class/corlib/System.Security/SecurityException.cs @@ -245,6 +245,9 @@ namespace System.Security { public override string ToString () { +#if MOBILE + return base.ToString (); +#else StringBuilder sb = new StringBuilder (base.ToString ()); try { if (permissionType != null) { @@ -285,6 +288,7 @@ namespace System.Security { // some informations can't be displayed } return sb.ToString (); +#endif } } } diff --git a/mcs/class/corlib/System.Security/SecurityManager.cs b/mcs/class/corlib/System.Security/SecurityManager.cs index 52053fbd3cf..68642461eb6 100644 --- a/mcs/class/corlib/System.Security/SecurityManager.cs +++ b/mcs/class/corlib/System.Security/SecurityManager.cs @@ -29,7 +29,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -#if !MOONLIGHT +#if !NET_2_1 using System.Collections; using System.Diagnostics; diff --git a/mcs/class/corlib/System.Security/SecurityManager_mobile.cs b/mcs/class/corlib/System.Security/SecurityManager_mobile.cs new file mode 100644 index 00000000000..ebda6ccbe7d --- /dev/null +++ b/mcs/class/corlib/System.Security/SecurityManager_mobile.cs @@ -0,0 +1,251 @@ +// +// System.Security.SecurityManager.cs +// +// Authors: +// Nick Drochak(ndrochak@gol.com) +// Sebastien Pouliot <sebastien@ximian.com> +// +// (C) Nick Drochak +// Portions (C) 2004 Motus Technologies Inc. (http://www.motus.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 +// "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 MOBILE + +using System.Collections; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Security.Permissions; +using System.Security.Policy; + +namespace System.Security { + + // Must match MonoDeclSecurityActions in /mono/metadata/reflection.h + internal struct RuntimeDeclSecurityActions { + public RuntimeDeclSecurityEntry cas; + public RuntimeDeclSecurityEntry noncas; + public RuntimeDeclSecurityEntry choice; + } + + [ComVisible (true)] + public static class SecurityManager { + + // properties + +#if NET_4_0 + [Obsolete] +#endif + public static bool CheckExecutionRights { + get { return true; } + set { ; } + } + + [Obsolete ("The security manager cannot be turned off on MS runtime")] + public static bool SecurityEnabled { + get { return true; } + set { ; } + } + + internal static bool HasElevatedPermissions { + get { return true; } + } + + internal static bool CheckElevatedPermissions () + { + return true; + } + + internal static void EnsureElevatedPermissions () + { + } + + // methods + + [StrongNameIdentityPermission (SecurityAction.LinkDemand, PublicKey = "0x00000000000000000400000000000000")] + public static void GetZoneAndOrigin (out ArrayList zone, out ArrayList origin) + { + zone = new ArrayList (); + origin = new ArrayList (); + } + +#if NET_4_0 + [Obsolete] +#endif + public static bool IsGranted (IPermission perm) + { + return true; + } + +#if NET_4_0 + [Obsolete] +#endif + [SecurityPermission (SecurityAction.Demand, ControlPolicy = true)] + public static PolicyLevel LoadPolicyLevelFromFile (string path, PolicyLevelType type) + { + throw new NotSupportedException (); + } + +#if NET_4_0 + [Obsolete] +#endif + [SecurityPermission (SecurityAction.Demand, ControlPolicy = true)] + public static PolicyLevel LoadPolicyLevelFromString (string str, PolicyLevelType type) + { + throw new NotSupportedException (); + } + +#if NET_4_0 + [Obsolete] +#endif + [SecurityPermission (SecurityAction.Demand, ControlPolicy = true)] + public static IEnumerator PolicyHierarchy () + { + throw new NotSupportedException (); + } + +#if NET_4_0 + [Obsolete] +#endif + public static PermissionSet ResolvePolicy (Evidence evidence) + { + throw new NotSupportedException (); + } + +#if NET_4_0 + [Obsolete] +#endif + public static PermissionSet ResolvePolicy (Evidence[] evidences) + { + throw new NotSupportedException (); + } + +#if NET_4_0 + [Obsolete] +#endif + public static PermissionSet ResolveSystemPolicy (Evidence evidence) + { + throw new NotSupportedException (); + } + +#if NET_4_0 + [Obsolete] +#endif + public static PermissionSet ResolvePolicy (Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, out PermissionSet denied) + { + throw new NotSupportedException (); + } + +#if NET_4_0 + [Obsolete] +#endif + public static IEnumerator ResolvePolicyGroups (Evidence evidence) + { + throw new NotSupportedException (); + } + +#if NET_4_0 + [Obsolete] +#endif + [SecurityPermission (SecurityAction.Demand, ControlPolicy = true)] + public static void SavePolicy () + { + throw new NotSupportedException (); + } + +#if NET_4_0 + [Obsolete] +#endif + [SecurityPermission (SecurityAction.Demand, ControlPolicy = true)] + public static void SavePolicyLevel (PolicyLevel level) + { + throw new NotSupportedException (); + } + + // private/internal stuff + + internal static bool ResolvePolicyLevel (ref PermissionSet ps, PolicyLevel pl, Evidence evidence) + { + throw new NotSupportedException (); + } + + internal static void ResolveIdentityPermissions (PermissionSet ps, Evidence evidence) + { + throw new NotSupportedException (); + } + + internal static PolicyLevel ResolvingPolicyLevel { + get { return null; } + set { ; } + } + + internal static IPermission CheckPermissionSet (Assembly a, PermissionSet ps, bool noncas) + { + return null; + } + + internal static IPermission CheckPermissionSet (AppDomain ad, PermissionSet ps) + { + return null; + } + + internal static PermissionSet Decode (IntPtr permissions, int length) + { + throw new NotSupportedException (); + } + + internal static PermissionSet Decode (byte[] encodedPermissions) + { + throw new NotSupportedException (); + } + + internal static void ReflectedLinkDemandInvoke (MethodBase mb) + { + throw new NotSupportedException (); + } + + internal static bool ReflectedLinkDemandQuery (MethodBase mb) + { + throw new NotSupportedException (); + } + +#if NET_4_0 + public static PermissionSet GetStandardSandbox (Evidence evidence) + { + if (evidence == null) + throw new ArgumentNullException ("evidence"); + + throw new NotImplementedException (); + } + + public static bool CurrentThreadRequiresSecurityContextCapture () + { + throw new NotImplementedException (); + } +#endif + } +} + +#endif
\ No newline at end of file diff --git a/mcs/class/corlib/System/AppDomain.cs b/mcs/class/corlib/System/AppDomain.cs index eb2d545df37..64bd0634764 100644 --- a/mcs/class/corlib/System/AppDomain.cs +++ b/mcs/class/corlib/System/AppDomain.cs @@ -127,10 +127,12 @@ namespace System { public string BaseDirectory { get { string path = SetupInformationNoCopy.ApplicationBase; +#if !NET_2_1 if (SecurityManager.SecurityEnabled && (path != null) && (path.Length > 0)) { // we cannot divulge local file informations new FileIOPermission (FileIOPermissionAccess.PathDiscovery, path).Demand (); } +#endif return path; } } @@ -138,10 +140,12 @@ namespace System { public string RelativeSearchPath { get { string path = SetupInformationNoCopy.PrivateBinPath; +#if !NET_2_1 if (SecurityManager.SecurityEnabled && (path != null) && (path.Length > 0)) { // we cannot divulge local file informations new FileIOPermission (FileIOPermissionAccess.PathDiscovery, path).Demand (); } +#endif return path; } } @@ -153,10 +157,12 @@ namespace System { return null; string path = Path.Combine (setup.DynamicBase, setup.ApplicationName); +#if !NET_2_1 if (SecurityManager.SecurityEnabled && (path != null) && (path.Length > 0)) { // we cannot divulge local file informations new FileIOPermission (FileIOPermissionAccess.PathDiscovery, path).Demand (); } +#endif return path; } } diff --git a/mcs/class/corlib/corlib.dll.sources b/mcs/class/corlib/corlib.dll.sources index 3c664544b7d..f89e7dee951 100644 --- a/mcs/class/corlib/corlib.dll.sources +++ b/mcs/class/corlib/corlib.dll.sources @@ -1147,6 +1147,7 @@ System.Security/SecurityFrame.cs System.Security/SecurityException.cs System.Security/SecurityManager.cs System.Security/SecurityManager_2_1.cs +System.Security/SecurityManager_mobile.cs System.Security/SecurityRuleSet.cs System.Security/SecurityRulesAttribute.cs System.Security/SecuritySafeCriticalAttribute.cs |