summaryrefslogtreecommitdiff
path: root/src/mscorlib/src/System/Security/Util
diff options
context:
space:
mode:
Diffstat (limited to 'src/mscorlib/src/System/Security/Util')
-rw-r--r--src/mscorlib/src/System/Security/Util/Config.cs48
-rw-r--r--src/mscorlib/src/System/Security/Util/Hex.cs2
-rw-r--r--src/mscorlib/src/System/Security/Util/StringExpressionSet.cs41
-rw-r--r--src/mscorlib/src/System/Security/Util/TokenBasedSet.cs32
-rw-r--r--src/mscorlib/src/System/Security/Util/URLString.cs17
-rw-r--r--src/mscorlib/src/System/Security/Util/XMLUtil.cs272
6 files changed, 27 insertions, 385 deletions
diff --git a/src/mscorlib/src/System/Security/Util/Config.cs b/src/mscorlib/src/System/Security/Util/Config.cs
index 988a39a9d6..afc9b8c336 100644
--- a/src/mscorlib/src/System/Security/Util/Config.cs
+++ b/src/mscorlib/src/System/Security/Util/Config.cs
@@ -37,7 +37,6 @@ namespace System.Security.Util {
private static volatile string m_machineConfig;
private static volatile string m_userConfig;
- [System.Security.SecurityCritical] // auto-generated
private static void GetFileLocales()
{
if (m_machineConfig == null)
@@ -56,7 +55,6 @@ namespace System.Security.Util {
internal static string MachineDirectory
{
- [System.Security.SecurityCritical] // auto-generated
get
{
GetFileLocales();
@@ -66,7 +64,6 @@ namespace System.Security.Util {
internal static string UserDirectory
{
- [System.Security.SecurityCritical] // auto-generated
get
{
GetFileLocales();
@@ -74,57 +71,12 @@ namespace System.Security.Util {
}
}
-#if FEATURE_CAS_POLICY
- [System.Security.SecurityCritical] // auto-generated
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
- internal static extern int SaveDataByte(string path, [In] byte[] data, int length);
-
- [System.Security.SecurityCritical] // auto-generated
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
- internal static extern bool RecoverData(ConfigId id);
-
- [System.Security.SecurityCritical] // auto-generated
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
- internal static extern void SetQuickCache(ConfigId id, QuickCacheEntryType quickCacheFlags);
-
- [System.Security.SecurityCritical] // auto-generated
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
- private static extern bool GetCacheEntry(ConfigId id, int numKey, [In] byte[] key, int keyLength, ObjectHandleOnStack retData);
-
- [System.Security.SecurityCritical] // auto-generated
- internal static bool GetCacheEntry(ConfigId id, int numKey, byte[] key, out byte[] data)
- {
- byte[] retData = null;
- bool ret = GetCacheEntry(id, numKey, key, key.Length, JitHelpers.GetObjectHandleOnStack(ref retData));
-
- data = retData;
- return ret;
- }
-
- [System.Security.SecurityCritical] // auto-generated
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
- private static extern void AddCacheEntry(ConfigId id, int numKey, [In] byte[] key, int keyLength, byte[] data, int dataLength);
-
- [System.Security.SecurityCritical] // auto-generated
- internal static void AddCacheEntry(ConfigId id, int numKey, byte[] key, byte[] data)
- {
- AddCacheEntry(id, numKey, key, key.Length, data, data.Length);
- }
-
- [System.Security.SecurityCritical] // auto-generated
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
- internal static extern void ResetCacheData(ConfigId id);
-#endif
-
- [System.Security.SecurityCritical] // auto-generated
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
private static extern void GetMachineDirectory(StringHandleOnStack retDirectory);
- [System.Security.SecurityCritical] // auto-generated
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
private static extern void GetUserDirectory(StringHandleOnStack retDirectory);
- [System.Security.SecurityCritical] // auto-generated
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
internal static extern bool WriteToEventLog(string message);
}
diff --git a/src/mscorlib/src/System/Security/Util/Hex.cs b/src/mscorlib/src/System/Security/Util/Hex.cs
index 709744f2a2..4ca1cf678b 100644
--- a/src/mscorlib/src/System/Security/Util/Hex.cs
+++ b/src/mscorlib/src/System/Security/Util/Hex.cs
@@ -73,7 +73,7 @@ namespace System.Security.Util
public static byte[] DecodeHexString(String hexString)
{
if (hexString == null)
- throw new ArgumentNullException( "hexString" );
+ throw new ArgumentNullException( nameof(hexString) );
Contract.EndContractBlock();
bool spaceSkippingMode = false;
diff --git a/src/mscorlib/src/System/Security/Util/StringExpressionSet.cs b/src/mscorlib/src/System/Security/Util/StringExpressionSet.cs
index 19937f5ae6..8a12235106 100644
--- a/src/mscorlib/src/System/Security/Util/StringExpressionSet.cs
+++ b/src/mscorlib/src/System/Security/Util/StringExpressionSet.cs
@@ -12,6 +12,7 @@ namespace System.Security.Util {
using System.Globalization;
using System.Runtime.Versioning;
using System.IO;
+ using System.Diagnostics;
using System.Diagnostics.Contracts;
[Serializable]
@@ -26,12 +27,9 @@ namespace System.Security.Util {
// 2. Ensuring that the partial trust code has permission to see full path data
// 3. Not using this set for paths (eg EnvironmentStringExpressionSet)
//
- [SecurityCritical]
protected ArrayList m_list;
protected bool m_ignoreCase;
- [SecurityCritical]
protected String m_expressions;
- [SecurityCritical]
protected String[] m_expressionsArray;
protected bool m_throwOnRelative;
@@ -61,7 +59,6 @@ namespace System.Security.Util {
{
}
- [System.Security.SecuritySafeCritical] // auto-generated
public StringExpressionSet( bool ignoreCase, String str, bool throwOnRelative )
{
m_list = null;
@@ -78,7 +75,6 @@ namespace System.Security.Util {
return new StringExpressionSet();
}
- [SecuritySafeCritical]
public virtual StringExpressionSet Copy()
{
// SafeCritical: just copying this value around, not leaking it
@@ -118,11 +114,10 @@ namespace System.Security.Util {
return StaticProcessSingleString(str);
}
- [System.Security.SecurityCritical] // auto-generated
public void AddExpressions( String str )
{
if (str == null)
- throw new ArgumentNullException( "str" );
+ throw new ArgumentNullException( nameof(str) );
Contract.EndContractBlock();
if (str.Length == 0)
return;
@@ -165,7 +160,7 @@ namespace System.Security.Util {
{
if (m_throwOnRelative)
{
- if (Path.IsRelative(temp))
+ if (PathInternal.IsPartiallyQualified(temp))
{
throw new ArgumentException( Environment.GetResourceString( "Argument_AbsolutePathRequired" ) );
}
@@ -181,16 +176,14 @@ namespace System.Security.Util {
Reduce();
}
- [System.Security.SecurityCritical] // auto-generated
public void AddExpressions( String[] str, bool checkForDuplicates, bool needFullPath )
{
AddExpressions(CreateListFromExpressions(str, needFullPath), checkForDuplicates);
}
- [System.Security.SecurityCritical] // auto-generated
public void AddExpressions( ArrayList exprArrayList, bool checkForDuplicates)
{
- Contract.Assert( m_throwOnRelative, "This should only be called when throw on relative is set" );
+ Debug.Assert( m_throwOnRelative, "This should only be called when throw on relative is set" );
m_expressionsArray = null;
m_expressions = null;
@@ -205,19 +198,18 @@ namespace System.Security.Util {
}
- [System.Security.SecurityCritical] // auto-generated
internal static ArrayList CreateListFromExpressions(String[] str, bool needFullPath)
{
if (str == null)
{
- throw new ArgumentNullException( "str" );
+ throw new ArgumentNullException( nameof(str) );
}
Contract.EndContractBlock();
ArrayList retArrayList = new ArrayList();
for (int index = 0; index < str.Length; ++index)
{
if (str[index] == null)
- throw new ArgumentNullException( "str" );
+ throw new ArgumentNullException( nameof(str) );
// Replace alternate directory separators
String oneString = StaticProcessWholeString( str[index] );
@@ -249,7 +241,6 @@ namespace System.Security.Util {
return retArrayList;
}
- [System.Security.SecurityCritical] // auto-generated
protected void CheckList()
{
if (m_list == null && m_expressions != null)
@@ -303,7 +294,6 @@ namespace System.Security.Util {
}
- [System.Security.SecurityCritical] // auto-generated
protected void CreateList()
{
String[] expressionsArray = Split( m_expressions );
@@ -325,7 +315,7 @@ namespace System.Security.Util {
{
if (m_throwOnRelative)
{
- if (Path.IsRelative(temp))
+ if (PathInternal.IsPartiallyQualified(temp))
{
throw new ArgumentException( Environment.GetResourceString( "Argument_AbsolutePathRequired" ) );
}
@@ -339,7 +329,6 @@ namespace System.Security.Util {
}
}
- [SecuritySafeCritical]
public bool IsEmpty()
{
// SafeCritical: we're just showing that the expressions are empty, the sensitive portion is their
@@ -354,7 +343,6 @@ namespace System.Security.Util {
}
}
- [System.Security.SecurityCritical] // auto-generated
public bool IsSubsetOf( StringExpressionSet ses )
{
if (this.IsEmpty())
@@ -376,7 +364,6 @@ namespace System.Security.Util {
return true;
}
- [System.Security.SecurityCritical] // auto-generated
public bool IsSubsetOfPathDiscovery( StringExpressionSet ses )
{
if (this.IsEmpty())
@@ -399,7 +386,6 @@ namespace System.Security.Util {
}
- [System.Security.SecurityCritical] // auto-generated
public StringExpressionSet Union( StringExpressionSet ses )
{
// If either set is empty, the union represents a copy of the other.
@@ -434,7 +420,6 @@ namespace System.Security.Util {
}
- [System.Security.SecurityCritical] // auto-generated
public StringExpressionSet Intersect( StringExpressionSet ses )
{
// If either set is empty, the intersection is empty
@@ -477,7 +462,6 @@ namespace System.Security.Util {
return intersectSet;
}
- [SecuritySafeCritical]
protected void GenerateString()
{
// SafeCritical - moves critical data around, but doesn't expose it out
@@ -522,7 +506,6 @@ namespace System.Security.Util {
// expressions contain paths that were canonicalized and expanded from the input that would cause
// information disclosure, so we instead only expose this out to trusted code that can ensure they
// either don't leak the information or required full path information.
- [SecurityCritical]
public string UnsafeToString()
{
CheckList();
@@ -534,7 +517,6 @@ namespace System.Security.Util {
return m_expressions;
}
- [SecurityCritical]
public String[] UnsafeToStringArray()
{
if (m_expressionsArray == null && m_list != null)
@@ -550,7 +532,6 @@ namespace System.Security.Util {
// protected static helper functions
//-------------------------------
- [SecurityCritical]
private bool StringSubsetStringExpression( String left, StringExpressionSet right, bool ignoreCase )
{
for (int index = 0; index < right.m_list.Count; ++index)
@@ -563,7 +544,6 @@ namespace System.Security.Util {
return false;
}
- [SecurityCritical]
private static bool StringSubsetStringExpressionPathDiscovery( String left, StringExpressionSet right, bool ignoreCase )
{
for (int index = 0; index < right.m_list.Count; ++index)
@@ -661,7 +641,6 @@ namespace System.Security.Util {
// protected helper functions
//-------------------------------
- [SecuritySafeCritical]
protected void AddSingleExpressionNoDuplicates( String expression )
{
// SafeCritical: We're not exposing out the string sets, just allowing modification of them
@@ -691,7 +670,6 @@ namespace System.Security.Util {
this.m_list.Add( expression );
}
- [System.Security.SecurityCritical] // auto-generated
protected void Reduce()
{
CheckList();
@@ -726,23 +704,20 @@ namespace System.Security.Util {
}
}
- [System.Security.SecurityCritical] // auto-generated
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
internal static extern void GetLongPathName( String path, StringHandleOnStack retLongPath );
- [System.Security.SecurityCritical] // auto-generated
internal static String CanonicalizePath( String path )
{
return CanonicalizePath( path, true );
}
- [System.Security.SecurityCritical] // auto-generated
internal static string CanonicalizePath(string path, bool needFullPath)
{
if (needFullPath)
{
- string newPath = Path.GetFullPathInternal(path);
+ string newPath = Path.GetFullPath(path);
if (path.EndsWith(m_directorySeparator + ".", StringComparison.Ordinal))
{
if (newPath.EndsWith(m_directorySeparator))
diff --git a/src/mscorlib/src/System/Security/Util/TokenBasedSet.cs b/src/mscorlib/src/System/Security/Util/TokenBasedSet.cs
index 590a909662..8589fa7c42 100644
--- a/src/mscorlib/src/System/Security/Util/TokenBasedSet.cs
+++ b/src/mscorlib/src/System/Security/Util/TokenBasedSet.cs
@@ -9,6 +9,7 @@ namespace System.Security.Util
using System.Security.Permissions;
using System.Runtime.Serialization;
using System.Threading;
+ using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Diagnostics.CodeAnalysis;
@@ -368,31 +369,17 @@ namespace System.Security.Util
{
Object thisObj = this.GetItem( i );
IPermission thisPerm = thisObj as IPermission;
-#if FEATURE_CAS_POLICY
- ISecurityElementFactory thisElem = thisObj as ISecurityElementFactory;
-#endif // FEATURE_CAS_POLICY
Object otherObj = (other != null)?other.GetItem( i ):null;
IPermission otherPerm = otherObj as IPermission;
-#if FEATURE_CAS_POLICY
- ISecurityElementFactory otherElem = otherObj as ISecurityElementFactory;
-#endif // FEATURE_CAS_POLICY
if (thisObj == null && otherObj == null)
continue;
-
-
+
if (thisObj == null)
{
-#if FEATURE_CAS_POLICY
- if (otherElem != null)
- {
- otherPerm = PermissionSet.CreatePerm(otherElem, false);
- }
-#endif // FEATURE_CAS_POLICY
-
PermissionToken token = PermissionToken.GetToken(otherPerm);
-
+
if (token == null)
{
throw new SerializationException(Environment.GetResourceString("Serialization_InsufficientState"));
@@ -402,13 +389,6 @@ namespace System.Security.Util
}
else if (otherObj == null)
{
-#if FEATURE_CAS_POLICY
- if (thisElem != null)
- {
- thisPerm = PermissionSet.CreatePerm(thisElem, false);
- }
-#endif // FEATURE_CAS_POLICY
-
PermissionToken token = PermissionToken.GetToken(thisPerm);
if (token == null)
{
@@ -418,7 +398,7 @@ namespace System.Security.Util
}
else
{
- Contract.Assert( (thisObj == null || otherObj == null), "Permission cannot be in both TokenBasedSets" );
+ Debug.Assert( (thisObj == null || otherObj == null), "Permission cannot be in both TokenBasedSets" );
}
}
return unionSet;
@@ -434,10 +414,6 @@ namespace System.Security.Util
if (obj != null)
{
IPermission perm = obj as IPermission;
-#if FEATURE_CAS_POLICY
- if (perm == null)
- perm = PermissionSet.CreatePerm(obj, ignoreTypeLoadFailures);
-#endif // FEATURE_CAS_POLICY
PermissionToken token = PermissionToken.GetToken(perm);
if (perm == null || token == null)
diff --git a/src/mscorlib/src/System/Security/Util/URLString.cs b/src/mscorlib/src/System/Security/Util/URLString.cs
index 51ae24cf4a..83f9ce483f 100644
--- a/src/mscorlib/src/System/Security/Util/URLString.cs
+++ b/src/mscorlib/src/System/Security/Util/URLString.cs
@@ -484,10 +484,11 @@ namespace System.Security.Util {
private static void CheckPathTooLong(StringBuilder path)
{
if (path.Length >= (
-#if FEATURE_PATHCOMPAT
- AppContextSwitches.BlockLongPaths ? PathInternal.MaxShortPath :
-#endif
+#if PLATFORM_UNIX
+ Interop.Sys.MaxPath))
+#else
PathInternal.MaxLongPath))
+#endif
{
throw new PathTooLongException(Environment.GetResourceString("IO.PathTooLong"));
}
@@ -513,7 +514,7 @@ namespace System.Security.Util {
// file:/home/johndoe/here
// file:../johndoe/here
// file:~/johndoe/here
- String temp = url;
+ String temp = url;
int nbSlashes = 0;
while(nbSlashes<temp.Length && '/'==temp[nbSlashes])
nbSlashes++;
@@ -533,7 +534,7 @@ namespace System.Security.Util {
{
String temp = url;
-#if !PLATFORM_UNIX
+#if !PLATFORM_UNIX
int index = temp.IndexOf( '/');
if (index != -1 &&
@@ -651,7 +652,7 @@ namespace System.Security.Util {
}
else
{
-#if !PLATFORM_UNIX
+#if !PLATFORM_UNIX
String site = temp.Substring( 0, index );
m_localSite = null;
m_siteString = new SiteString( site );
@@ -680,7 +681,7 @@ namespace System.Security.Util {
{
if (url == null)
{
- throw new ArgumentNullException( "url" );
+ throw new ArgumentNullException( nameof(url) );
}
Contract.EndContractBlock();
@@ -1127,7 +1128,6 @@ namespace System.Security.Util {
}
#if !PLATFORM_UNIX
- [System.Security.SecuritySafeCritical] // auto-generated
internal URLString SpecialNormalizeUrl()
{
// Under WinXP, file protocol urls can be mapped to
@@ -1177,7 +1177,6 @@ namespace System.Security.Util {
}
}
- [System.Security.SecurityCritical] // auto-generated
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
private static extern void GetDeviceName( String driveLetter, StringHandleOnStack retDeviceName );
diff --git a/src/mscorlib/src/System/Security/Util/XMLUtil.cs b/src/mscorlib/src/System/Security/Util/XMLUtil.cs
index df8f0c4670..3a1aaa3b09 100644
--- a/src/mscorlib/src/System/Security/Util/XMLUtil.cs
+++ b/src/mscorlib/src/System/Security/Util/XMLUtil.cs
@@ -25,6 +25,7 @@ namespace System.Security.Util {
using System.Threading;
using System.Globalization;
using System.Reflection;
+ using System.Diagnostics;
using System.Diagnostics.Contracts;
internal static class XMLUtil
@@ -35,12 +36,7 @@ namespace System.Security.Util {
//
private const String BuiltInPermission = "System.Security.Permissions.";
-#if FEATURE_CAS_POLICY
- private const String BuiltInMembershipCondition = "System.Security.Policy.";
- private const String BuiltInCodeGroup = "System.Security.Policy.";
- private const String BuiltInApplicationSecurityManager = "System.Security.Policy.";
- private static readonly char[] sepChar = {',', ' '};
-#endif
+
public static SecurityElement
NewPermissionElement (IPermission ip)
{
@@ -66,7 +62,7 @@ namespace System.Security.Util {
if ( typename == null )
typename = type.FullName;
- Contract.Assert( type.FullName.Equals( typename ), "Incorrect class name passed! Was : " + typename + " Shoule be: " + type.FullName);
+ Debug.Assert( type.FullName.Equals( typename ), "Incorrect class name passed! Was : " + typename + " Shoule be: " + type.FullName);
element.AddAttribute( "class", typename + ", " + type.Module.Assembly.FullName.Replace( '\"', '\'' ) );
}
@@ -110,7 +106,6 @@ namespace System.Security.Util {
assemblyVersion = an.Version.ToString();
return true;
}
- [System.Security.SecurityCritical] // auto-generated
private static bool
ParseElementForObjectCreation( SecurityElement el,
String requiredNamespace,
@@ -175,29 +170,6 @@ namespace System.Security.Util {
return false;
}
-#if FEATURE_CAS_POLICY
- public static String SecurityObjectToXmlString(Object ob)
- {
- if(ob == null)
- return "";
- PermissionSet pset = ob as PermissionSet;
- if(pset != null)
- return pset.ToXml().ToString();
- return ((IPermission)ob).ToXml().ToString();
- }
-
- [System.Security.SecurityCritical] // auto-generated
- public static Object XmlStringToSecurityObject(String s)
- {
- if(s == null)
- return null;
- if(s.Length < 1)
- return null;
- return SecurityElement.FromString(s).ToSecurityObject();
- }
-#endif // FEATURE_CAS_POLICY
-
- [SecuritySafeCritical]
public static IPermission
CreatePermission (SecurityElement el, PermissionState permState, bool ignoreTypeLoadFailures)
{
@@ -235,9 +207,6 @@ namespace System.Security.Util {
// UnsafeForHostPermission
// HostProtectionPermission
// StrongNameIdentityPermission
-#if !FEATURE_CORECLR
- // IsolatedStorageFilePermission
-#endif
// RegistryPermission
// PublisherIdentityPermission
@@ -274,15 +243,6 @@ namespace System.Security.Util {
else
goto USEREFLECTION;
}
-
-#if !FEATURE_CORECLR
- case 19:
- // PrincipalPermission
- if (String.Compare(className, classNameStart, "PrincipalPermission", 0, classNameLength, StringComparison.Ordinal) == 0)
- return new PrincipalPermission( permState );
- else
- goto USEREFLECTION;
-#endif // !FEATURE_CORECLR
case 20:
// ReflectionPermission
// FileDialogPermission
@@ -326,8 +286,6 @@ namespace System.Security.Util {
else
goto USEREFLECTION;
}
-
-
case 22:
// SiteIdentityPermission
// ZoneIdentityPermission
@@ -353,42 +311,22 @@ namespace System.Security.Util {
else
goto USEREFLECTION;
}
-
-
case 24:
// HostProtectionPermission
if (String.Compare(className, classNameStart, "HostProtectionPermission", 0, classNameLength, StringComparison.Ordinal) == 0)
return new HostProtectionPermission( permState );
else
goto USEREFLECTION;
-
-#if FEATURE_X509 && FEATURE_CAS_POLICY
- case 27:
- // PublisherIdentityPermission
- if (String.Compare(className, classNameStart, "PublisherIdentityPermission", 0, classNameLength, StringComparison.Ordinal) == 0)
- return new PublisherIdentityPermission( permState );
- else
- goto USEREFLECTION;
-#endif // FEATURE_X509 && FEATURE_CAS_POLICY
-
case 28:
// StrongNameIdentityPermission
if (String.Compare(className, classNameStart, "StrongNameIdentityPermission", 0, classNameLength, StringComparison.Ordinal) == 0)
return new StrongNameIdentityPermission( permState );
else
goto USEREFLECTION;
-#if !FEATURE_CORECLR
- case 29:
- // IsolatedStorageFilePermission
- if (String.Compare(className, classNameStart, "IsolatedStorageFilePermission", 0, classNameLength, StringComparison.Ordinal) == 0)
- return new IsolatedStorageFilePermission( permState );
- else
- goto USEREFLECTION;
-#endif
default:
goto USEREFLECTION;
}
-
+
USEREFLECTION:
Object[] objs = new Object[1];
@@ -409,204 +347,6 @@ USEREFLECTION:
return perm;
}
-#if FEATURE_CAS_POLICY
-#pragma warning disable 618 // CodeGroups are obsolete
- [System.Security.SecuritySafeCritical] // auto-generated
- public static CodeGroup
- CreateCodeGroup (SecurityElement el)
- {
- if (el == null || !el.Tag.Equals("CodeGroup"))
- throw new ArgumentException( String.Format( CultureInfo.CurrentCulture, Environment.GetResourceString( "Argument_WrongElementType" ), "<CodeGroup>" ) ) ;
- Contract.EndContractBlock();
-
- String className;
- int classNameLength;
- int classNameStart;
-
- if (!ParseElementForObjectCreation( el,
- BuiltInCodeGroup,
- out className,
- out classNameStart,
- out classNameLength ))
- {
- goto USEREFLECTION;
- }
-
- switch (classNameLength)
- {
- case 12:
- // NetCodeGroup
- if (String.Compare(className, classNameStart, "NetCodeGroup", 0, classNameLength, StringComparison.Ordinal) == 0)
- return new NetCodeGroup();
- else
- goto USEREFLECTION;
-
- case 13:
- // FileCodeGroup
- if (String.Compare(className, classNameStart, "FileCodeGroup", 0, classNameLength, StringComparison.Ordinal) == 0)
- return new FileCodeGroup();
- else
- goto USEREFLECTION;
- case 14:
- // UnionCodeGroup
- if (String.Compare(className, classNameStart, "UnionCodeGroup", 0, classNameLength, StringComparison.Ordinal) == 0)
- return new UnionCodeGroup();
- else
- goto USEREFLECTION;
-
- case 19:
- // FirstMatchCodeGroup
- if (String.Compare(className, classNameStart, "FirstMatchCodeGroup", 0, classNameLength, StringComparison.Ordinal) == 0)
- return new FirstMatchCodeGroup();
- else
- goto USEREFLECTION;
-
- default:
- goto USEREFLECTION;
- }
-
-USEREFLECTION:
- Type groupClass = null;
- CodeGroup group = null;
-
- new ReflectionPermission(ReflectionPermissionFlag.MemberAccess).Assert();
- groupClass = GetClassFromElement(el, true);
- if (groupClass == null)
- return null;
- if (!(typeof(CodeGroup).IsAssignableFrom(groupClass)))
- throw new ArgumentException( Environment.GetResourceString("Argument_NotACodeGroupType") );
-
- group = (CodeGroup) Activator.CreateInstance(groupClass, true);
-
- Contract.Assert( groupClass.Module.Assembly != Assembly.GetExecutingAssembly(),
- "This path should not get called for mscorlib based classes" );
-
- return group;
- }
-#pragma warning restore 618
-
- [System.Security.SecurityCritical] // auto-generated
- internal static IMembershipCondition
- CreateMembershipCondition( SecurityElement el )
- {
- if (el == null || !el.Tag.Equals("IMembershipCondition"))
- throw new ArgumentException( String.Format( CultureInfo.CurrentCulture, Environment.GetResourceString( "Argument_WrongElementType" ), "<IMembershipCondition>" ) ) ;
- Contract.EndContractBlock();
-
- String className;
- int classNameStart;
- int classNameLength;
-
- if (!ParseElementForObjectCreation( el,
- BuiltInMembershipCondition,
- out className,
- out classNameStart,
- out classNameLength ))
- {
- goto USEREFLECTION;
- }
-
- // We have a built in membership condition, figure out which it is.
-
- // Here's the list of built in membership conditions as of 9/17/2002
- // System.Security.Policy.AllMembershipCondition
- // System.Security.Policy.URLMembershipCondition
- // System.Security.Policy.SHA1MembershipCondition
- // System.Security.Policy.SiteMembershipCondition
- // System.Security.Policy.ZoneMembershipCondition
- // System.Security.Policy.PublisherMembershipCondition
- // System.Security.Policy.StrongNameMembershipCondition
- // System.Security.Policy.ApplicationMembershipCondition
- // System.Security.Policy.DomainApplicationMembershipCondition
- // System.Security.Policy.ApplicationDirectoryMembershipCondition
-
- switch (classNameLength)
- {
- case 22:
- // AllMembershipCondition
- // URLMembershipCondition
- if (className[classNameStart] == 'A')
- {
- if (String.Compare(className, classNameStart, "AllMembershipCondition", 0, classNameLength, StringComparison.Ordinal) == 0)
- return new AllMembershipCondition();
- else
- goto USEREFLECTION;
- }
- else
- {
- if (String.Compare(className, classNameStart, "UrlMembershipCondition", 0, classNameLength, StringComparison.Ordinal) == 0)
- return new UrlMembershipCondition();
- else
- goto USEREFLECTION;
- }
-
- case 23:
- // HashMembershipCondition
- // SiteMembershipCondition
- // ZoneMembershipCondition
- if (className[classNameStart] == 'H')
- {
- if (String.Compare(className, classNameStart, "HashMembershipCondition", 0, classNameLength, StringComparison.Ordinal) == 0)
- return new HashMembershipCondition();
- else
- goto USEREFLECTION;
- }
- else if (className[classNameStart] == 'S')
- {
- if (String.Compare(className, classNameStart, "SiteMembershipCondition", 0, classNameLength, StringComparison.Ordinal) == 0)
- return new SiteMembershipCondition();
- else
- goto USEREFLECTION;
- }
- else
- {
- if (String.Compare(className, classNameStart, "ZoneMembershipCondition", 0, classNameLength, StringComparison.Ordinal) == 0)
- return new ZoneMembershipCondition();
- else
- goto USEREFLECTION;
- }
-
- case 28:
- // PublisherMembershipCondition
- if (String.Compare(className, classNameStart, "PublisherMembershipCondition", 0, classNameLength, StringComparison.Ordinal) == 0)
- return new PublisherMembershipCondition();
- else
- goto USEREFLECTION;
-
- case 29:
- // StrongNameMembershipCondition
- if (String.Compare(className, classNameStart, "StrongNameMembershipCondition", 0, classNameLength, StringComparison.Ordinal) == 0)
- return new StrongNameMembershipCondition();
- else
- goto USEREFLECTION;
-
- case 39:
- // ApplicationDirectoryMembershipCondition
- if (String.Compare(className, classNameStart, "ApplicationDirectoryMembershipCondition", 0, classNameLength, StringComparison.Ordinal) == 0)
- return new ApplicationDirectoryMembershipCondition();
- else
- goto USEREFLECTION;
-
- default:
- goto USEREFLECTION;
- }
-
-USEREFLECTION:
- Type condClass = null;
- IMembershipCondition cond = null;
-
- new ReflectionPermission(ReflectionPermissionFlag.MemberAccess).Assert();
- condClass = GetClassFromElement(el, true);
- if (condClass == null)
- return null;
- if (!(typeof(IMembershipCondition).IsAssignableFrom(condClass)))
- throw new ArgumentException( Environment.GetResourceString("Argument_NotAMembershipCondition") );
-
- cond = (IMembershipCondition) Activator.CreateInstance(condClass, true);
-
- return cond;
- }
-#endif //#if FEATURE_CAS_POLICY
internal static Type
GetClassFromElement (SecurityElement el, bool ignoreTypeLoadFailures)
{
@@ -624,7 +364,7 @@ USEREFLECTION:
{
try
{
- return Type.GetType(className, false, false);
+ return Type.GetType(className, false, false);
}
catch (SecurityException)
{
@@ -632,7 +372,7 @@ USEREFLECTION:
}
}
else
- return Type.GetType(className, true, false);
+ return Type.GetType(className, true, false);
}
public static bool