This commit is contained in:
niko
2026-06-04 11:42:34 +02:00
parent f39ba70a9f
commit e720b98cd1
7488 changed files with 2493818 additions and 0 deletions
@@ -0,0 +1,93 @@
using System;
using System.Runtime.InteropServices;
namespace System.Security.Policy
{
/// <summary>Represents a membership condition that matches all code. This class cannot be inherited.</summary>
// Token: 0x02000579 RID: 1401
[ComVisible(true)]
[Serializable]
public sealed class AllMembershipCondition : IConstantMembershipCondition, IMembershipCondition, ISecurityEncodable, ISecurityPolicyEncodable
{
/// <summary>Determines whether the specified evidence satisfies the membership condition.</summary>
/// <returns>Always true.</returns>
/// <param name="evidence">The evidence set against which to make the test. </param>
// Token: 0x06003333 RID: 13107 RVA: 0x000B0354 File Offset: 0x000AE554
public bool Check(Evidence evidence)
{
return true;
}
/// <summary>Creates an equivalent copy of the membership condition.</summary>
/// <returns>A new, identical copy of the current membership condition.</returns>
// Token: 0x06003334 RID: 13108 RVA: 0x000B0358 File Offset: 0x000AE558
public IMembershipCondition Copy()
{
return new AllMembershipCondition();
}
/// <summary>Determines whether the specified membership condition is an <see cref="T:System.Security.Policy.AllMembershipCondition" />.</summary>
/// <returns>true if the specified membership condition is an <see cref="T:System.Security.Policy.AllMembershipCondition" />; otherwise, false.</returns>
/// <param name="o">The object to compare to <see cref="T:System.Security.Policy.AllMembershipCondition" />. </param>
// Token: 0x06003335 RID: 13109 RVA: 0x000B0360 File Offset: 0x000AE560
public override bool Equals(object o)
{
return o is AllMembershipCondition;
}
/// <summary>Reconstructs a security object with a specified state from an XML encoding.</summary>
/// <param name="e">The XML encoding to use to reconstruct the security object. </param>
// Token: 0x06003336 RID: 13110 RVA: 0x000B036C File Offset: 0x000AE56C
public void FromXml(SecurityElement e)
{
this.FromXml(e, null);
}
/// <summary>Reconstructs a security object with a specified state from an XML encoding.</summary>
/// <param name="e">The XML encoding to use to reconstruct the security object. </param>
/// <param name="level">The policy level context used to resolve named permission set references. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="e" /> parameter is null. </exception>
/// <exception cref="T:System.ArgumentException">The <paramref name="e" /> parameter is not a valid membership condition element. </exception>
// Token: 0x06003337 RID: 13111 RVA: 0x000B0378 File Offset: 0x000AE578
public void FromXml(SecurityElement e, PolicyLevel level)
{
MembershipConditionHelper.CheckSecurityElement(e, "e", this.version, this.version);
}
/// <summary>Gets the hash code for the current membership condition.</summary>
/// <returns>The hash code for the current membership condition.</returns>
// Token: 0x06003338 RID: 13112 RVA: 0x000B0394 File Offset: 0x000AE594
public override int GetHashCode()
{
return typeof(AllMembershipCondition).GetHashCode();
}
/// <summary>Creates and returns a string representation of the membership condition.</summary>
/// <returns>A representation of the membership condition.</returns>
// Token: 0x06003339 RID: 13113 RVA: 0x000B03A8 File Offset: 0x000AE5A8
public override string ToString()
{
return "All code";
}
/// <summary>Creates an XML encoding of the security object and its current state.</summary>
/// <returns>An XML encoding of the security object, including any state information.</returns>
// Token: 0x0600333A RID: 13114 RVA: 0x000B03B0 File Offset: 0x000AE5B0
public SecurityElement ToXml()
{
return this.ToXml(null);
}
/// <summary>Creates an XML encoding of the security object and its current state with the specified <see cref="T:System.Security.Policy.PolicyLevel" />.</summary>
/// <returns>An XML encoding of the security object, including any state information.</returns>
/// <param name="level">The policy level context for resolving named permission set references. </param>
// Token: 0x0600333B RID: 13115 RVA: 0x000B03BC File Offset: 0x000AE5BC
public SecurityElement ToXml(PolicyLevel level)
{
return MembershipConditionHelper.Element(typeof(AllMembershipCondition), this.version);
}
// Token: 0x04001501 RID: 5377
private readonly int version = 1;
}
}
@@ -0,0 +1,118 @@
using System;
using System.IO;
using System.Runtime.InteropServices;
namespace System.Security.Policy
{
/// <summary>Provides the application directory as evidence for policy evaluation. This class cannot be inherited.</summary>
// Token: 0x0200057A RID: 1402
[ComVisible(true)]
[Serializable]
public sealed class ApplicationDirectory : IBuiltInEvidence
{
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Policy.ApplicationDirectory" /> class.</summary>
/// <param name="name">The path of the application directory. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="name" /> parameter is null. </exception>
// Token: 0x0600333C RID: 13116 RVA: 0x000B03E0 File Offset: 0x000AE5E0
public ApplicationDirectory(string name)
{
if (name == null)
{
throw new ArgumentNullException("name");
}
if (name.Length < 1)
{
throw new FormatException(Locale.GetText("Empty"));
}
this.directory = name;
}
// Token: 0x0600333D RID: 13117 RVA: 0x000B0428 File Offset: 0x000AE628
int IBuiltInEvidence.GetRequiredSize(bool verbose)
{
return ((!verbose) ? 1 : 3) + this.directory.Length;
}
// Token: 0x0600333E RID: 13118 RVA: 0x000B0444 File Offset: 0x000AE644
[MonoTODO("IBuiltInEvidence")]
int IBuiltInEvidence.InitFromBuffer(char[] buffer, int position)
{
return 0;
}
// Token: 0x0600333F RID: 13119 RVA: 0x000B0448 File Offset: 0x000AE648
[MonoTODO("IBuiltInEvidence")]
int IBuiltInEvidence.OutputToBuffer(char[] buffer, int position, bool verbose)
{
return 0;
}
/// <summary>Gets the path of the application directory.</summary>
/// <returns>The path of the application directory.</returns>
// Token: 0x17000A0E RID: 2574
// (get) Token: 0x06003340 RID: 13120 RVA: 0x000B044C File Offset: 0x000AE64C
public string Directory
{
get
{
return this.directory;
}
}
/// <summary>Creates a new copy of the <see cref="T:System.Security.Policy.ApplicationDirectory" />.</summary>
/// <returns>A new, identical copy of the <see cref="T:System.Security.Policy.ApplicationDirectory" />.</returns>
// Token: 0x06003341 RID: 13121 RVA: 0x000B0454 File Offset: 0x000AE654
public object Copy()
{
return new ApplicationDirectory(this.Directory);
}
/// <summary>Determines whether instances of the same type of an evidence object are equivalent.</summary>
/// <returns>true if the two instances are equivalent; otherwise, false.</returns>
/// <param name="o">An object of same type as the current evidence object. </param>
// Token: 0x06003342 RID: 13122 RVA: 0x000B0464 File Offset: 0x000AE664
public override bool Equals(object o)
{
ApplicationDirectory applicationDirectory = o as ApplicationDirectory;
if (applicationDirectory != null)
{
this.ThrowOnInvalid(applicationDirectory.directory);
return this.directory == applicationDirectory.directory;
}
return false;
}
/// <summary>Gets the hash code of the current application directory.</summary>
/// <returns>The hash code of the current application directory.</returns>
// Token: 0x06003343 RID: 13123 RVA: 0x000B04A0 File Offset: 0x000AE6A0
public override int GetHashCode()
{
return this.Directory.GetHashCode();
}
/// <summary>Gets a string representation of the state of the <see cref="T:System.Security.Policy.ApplicationDirectory" /> evidence object.</summary>
/// <returns>A representation of the state of the <see cref="T:System.Security.Policy.ApplicationDirectory" /> evidence object.</returns>
// Token: 0x06003344 RID: 13124 RVA: 0x000B04B0 File Offset: 0x000AE6B0
public override string ToString()
{
this.ThrowOnInvalid(this.Directory);
SecurityElement securityElement = new SecurityElement("System.Security.Policy.ApplicationDirectory");
securityElement.AddAttribute("version", "1");
securityElement.AddChild(new SecurityElement("Directory", this.directory));
return securityElement.ToString();
}
// Token: 0x06003345 RID: 13125 RVA: 0x000B0500 File Offset: 0x000AE700
private void ThrowOnInvalid(string appdir)
{
if (appdir.IndexOfAny(Path.InvalidPathChars) != -1)
{
string text = Locale.GetText("Invalid character(s) in directory {0}");
throw new ArgumentException(string.Format(text, appdir), "other");
}
}
// Token: 0x04001502 RID: 5378
private string directory;
}
}
@@ -0,0 +1,127 @@
using System;
using System.Collections;
using System.Globalization;
using System.Reflection;
using System.Runtime.InteropServices;
using Mono.Security;
namespace System.Security.Policy
{
/// <summary>Determines whether an assembly belongs to a code group by testing its application directory. This class cannot be inherited.</summary>
// Token: 0x0200057B RID: 1403
[ComVisible(true)]
[Serializable]
public sealed class ApplicationDirectoryMembershipCondition : IConstantMembershipCondition, IMembershipCondition, ISecurityEncodable, ISecurityPolicyEncodable
{
/// <summary>Determines whether the membership condition is satisfied by the specified evidence.</summary>
/// <returns>true if the specified evidence satisfies the membership condition; otherwise, false.</returns>
/// <param name="evidence">The evidence set against which to make the test. </param>
// Token: 0x06003347 RID: 13127 RVA: 0x000B054C File Offset: 0x000AE74C
public bool Check(Evidence evidence)
{
if (evidence == null)
{
return false;
}
string codeBase = Assembly.GetCallingAssembly().CodeBase;
Uri uri = new Uri(codeBase);
Url url = new Url(codeBase);
bool flag = false;
bool flag2 = false;
IEnumerator hostEnumerator = evidence.GetHostEnumerator();
while (hostEnumerator.MoveNext())
{
object obj = hostEnumerator.Current;
if (!flag && obj is ApplicationDirectory)
{
ApplicationDirectory applicationDirectory = obj as ApplicationDirectory;
string directory = applicationDirectory.Directory;
flag = string.Compare(directory, 0, uri.ToString(), 0, directory.Length, true, CultureInfo.InvariantCulture) == 0;
}
else if (!flag2 && obj is Url)
{
flag2 = url.Equals(obj);
}
if (flag && flag2)
{
return true;
}
}
return false;
}
/// <summary>Creates an equivalent copy of the membership condition.</summary>
/// <returns>A new, identical copy of the current membership condition.</returns>
// Token: 0x06003348 RID: 13128 RVA: 0x000B0618 File Offset: 0x000AE818
public IMembershipCondition Copy()
{
return new ApplicationDirectoryMembershipCondition();
}
/// <summary>Determines whether the specified membership condition is an <see cref="T:System.Security.Policy.ApplicationDirectoryMembershipCondition" />.</summary>
/// <returns>true if the specified membership condition is an <see cref="T:System.Security.Policy.ApplicationDirectoryMembershipCondition" />; otherwise, false.</returns>
/// <param name="o">The object to compare to <see cref="T:System.Security.Policy.ApplicationDirectoryMembershipCondition" />. </param>
// Token: 0x06003349 RID: 13129 RVA: 0x000B0620 File Offset: 0x000AE820
public override bool Equals(object o)
{
return o is ApplicationDirectoryMembershipCondition;
}
/// <summary>Reconstructs a security object with a specified state from an XML encoding.</summary>
/// <param name="e">The XML encoding to use to reconstruct the security object. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="e" /> parameter is null. </exception>
/// <exception cref="T:System.ArgumentException">The <paramref name="e" /> parameter is not a valid application directory membership condition element. </exception>
// Token: 0x0600334A RID: 13130 RVA: 0x000B062C File Offset: 0x000AE82C
public void FromXml(SecurityElement e)
{
this.FromXml(e, null);
}
/// <summary>Reconstructs a security object with a specified state from an XML encoding.</summary>
/// <param name="e">The XML encoding to use to reconstruct the security object. </param>
/// <param name="level">The policy level context, used to resolve named permission set references. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="e" /> parameter is null. </exception>
/// <exception cref="T:System.ArgumentException">The <paramref name="e" /> parameter is not a valid application directory membership condition element. </exception>
// Token: 0x0600334B RID: 13131 RVA: 0x000B0638 File Offset: 0x000AE838
public void FromXml(SecurityElement e, PolicyLevel level)
{
MembershipConditionHelper.CheckSecurityElement(e, "e", this.version, this.version);
}
/// <summary>Gets the hash code for the current membership condition.</summary>
/// <returns>The hash code for the current membership condition.</returns>
// Token: 0x0600334C RID: 13132 RVA: 0x000B0654 File Offset: 0x000AE854
public override int GetHashCode()
{
return typeof(ApplicationDirectoryMembershipCondition).GetHashCode();
}
/// <summary>Creates and returns a string representation of the membership condition.</summary>
/// <returns>A string representation of the state of the membership condition.</returns>
// Token: 0x0600334D RID: 13133 RVA: 0x000B0668 File Offset: 0x000AE868
public override string ToString()
{
return "ApplicationDirectory";
}
/// <summary>Creates an XML encoding of the security object and its current state.</summary>
/// <returns>An XML encoding of the security object, including any state information.</returns>
// Token: 0x0600334E RID: 13134 RVA: 0x000B0670 File Offset: 0x000AE870
public SecurityElement ToXml()
{
return this.ToXml(null);
}
/// <summary>Creates an XML encoding of the security object and its current state with the specified <see cref="T:System.Security.Policy.PolicyLevel" />.</summary>
/// <returns>An XML encoding of the security object, including any state information.</returns>
/// <param name="level">The policy level context for resolving named permission set references. </param>
// Token: 0x0600334F RID: 13135 RVA: 0x000B067C File Offset: 0x000AE87C
public SecurityElement ToXml(PolicyLevel level)
{
return MembershipConditionHelper.Element(typeof(ApplicationDirectoryMembershipCondition), this.version);
}
// Token: 0x04001503 RID: 5379
private readonly int version = 1;
}
}
@@ -0,0 +1,140 @@
using System;
using System.Runtime.InteropServices;
using System.Security.Permissions;
namespace System.Security.Policy
{
/// <summary>Holds the security evidence for an application. This class cannot be inherited.</summary>
// Token: 0x0200057C RID: 1404
[ComVisible(true)]
public sealed class ApplicationSecurityInfo
{
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Policy.ApplicationSecurityInfo" /> class using the provided activation context. </summary>
/// <param name="activationContext">An <see cref="T:System.ActivationContext" /> object that uniquely identifies the target application.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="activationContext" /> is null. </exception>
// Token: 0x06003350 RID: 13136 RVA: 0x000B06A0 File Offset: 0x000AE8A0
public ApplicationSecurityInfo(ActivationContext activationContext)
{
if (activationContext == null)
{
throw new ArgumentNullException("activationContext");
}
this._context = activationContext;
}
/// <summary>Gets or sets the evidence for the application.</summary>
/// <returns>An <see cref="T:System.Security.Policy.Evidence" /> object for the application.</returns>
/// <exception cref="T:System.ArgumentNullException">
/// <see cref="P:System.Security.Policy.ApplicationSecurityInfo.ApplicationEvidence" /> is set to null. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="ControlEvidence" />
/// </PermissionSet>
// Token: 0x17000A0F RID: 2575
// (get) Token: 0x06003351 RID: 13137 RVA: 0x000B06C0 File Offset: 0x000AE8C0
// (set) Token: 0x06003352 RID: 13138 RVA: 0x000B06C8 File Offset: 0x000AE8C8
public Evidence ApplicationEvidence
{
get
{
return this._evidence;
}
set
{
if (value == null)
{
throw new ArgumentNullException("ApplicationEvidence");
}
this._evidence = value;
}
}
/// <summary>Gets or sets the application identity information.</summary>
/// <returns>An <see cref="T:System.ApplicationId" /> object.</returns>
/// <exception cref="T:System.ArgumentNullException">
/// <see cref="P:System.Security.Policy.ApplicationSecurityInfo.ApplicationId" /> is set to null.</exception>
// Token: 0x17000A10 RID: 2576
// (get) Token: 0x06003353 RID: 13139 RVA: 0x000B06E4 File Offset: 0x000AE8E4
// (set) Token: 0x06003354 RID: 13140 RVA: 0x000B06EC File Offset: 0x000AE8EC
public ApplicationId ApplicationId
{
get
{
return this._appid;
}
set
{
if (value == null)
{
throw new ArgumentNullException("ApplicationId");
}
this._appid = value;
}
}
/// <summary>Gets or sets the default permission set.</summary>
/// <returns>A <see cref="T:System.Security.PermissionSet" /> object representing the default permissions for the application. The default is a <see cref="T:System.Security.PermissionSet" /> with a permission state of <see cref="F:System.Security.Permissions.PermissionState.None" /></returns>
/// <exception cref="T:System.ArgumentNullException">
/// <see cref="P:System.Security.Policy.ApplicationSecurityInfo.DefaultRequestSet" /> is set to null. </exception>
// Token: 0x17000A11 RID: 2577
// (get) Token: 0x06003355 RID: 13141 RVA: 0x000B0708 File Offset: 0x000AE908
// (set) Token: 0x06003356 RID: 13142 RVA: 0x000B0724 File Offset: 0x000AE924
public PermissionSet DefaultRequestSet
{
get
{
if (this._defaultSet == null)
{
return new PermissionSet(PermissionState.None);
}
return this._defaultSet;
}
set
{
if (value == null)
{
throw new ArgumentNullException("DefaultRequestSet");
}
this._defaultSet = value;
}
}
/// <summary>Gets or sets the top element in the application, which is described in the deployment identity.</summary>
/// <returns>An <see cref="T:System.ApplicationId" /> object describing the top element of the application.</returns>
/// <exception cref="T:System.ArgumentNullException">
/// <see cref="P:System.Security.Policy.ApplicationSecurityInfo.DeploymentId" /> is set to null. </exception>
// Token: 0x17000A12 RID: 2578
// (get) Token: 0x06003357 RID: 13143 RVA: 0x000B0740 File Offset: 0x000AE940
// (set) Token: 0x06003358 RID: 13144 RVA: 0x000B0748 File Offset: 0x000AE948
public ApplicationId DeploymentId
{
get
{
return this._deployid;
}
set
{
if (value == null)
{
throw new ArgumentNullException("DeploymentId");
}
this._deployid = value;
}
}
// Token: 0x04001504 RID: 5380
private ActivationContext _context;
// Token: 0x04001505 RID: 5381
private Evidence _evidence;
// Token: 0x04001506 RID: 5382
private ApplicationId _appid;
// Token: 0x04001507 RID: 5383
private PermissionSet _defaultSet;
// Token: 0x04001508 RID: 5384
private ApplicationId _deployid;
}
}
@@ -0,0 +1,75 @@
using System;
using System.Runtime.InteropServices;
namespace System.Security.Policy
{
/// <summary>Manages trust decisions for manifest activated applications. </summary>
// Token: 0x0200057D RID: 1405
[ComVisible(true)]
public static class ApplicationSecurityManager
{
/// <summary>Gets or sets the current application trust manager.</summary>
/// <returns>An <see cref="T:System.Security.Policy.IApplicationTrustManager" /> that represents the current trust manager.</returns>
/// <exception cref="T:System.Security.Policy.PolicyException">The policy on this application does not have a trust manager.</exception>
// Token: 0x17000A13 RID: 2579
// (get) Token: 0x06003359 RID: 13145 RVA: 0x000B0764 File Offset: 0x000AE964
public static IApplicationTrustManager ApplicationTrustManager
{
get
{
if (ApplicationSecurityManager._appTrustManager == null)
{
ApplicationSecurityManager._appTrustManager = new MonoTrustManager();
}
return ApplicationSecurityManager._appTrustManager;
}
}
/// <summary>Gets an application trust collection that contains the cached trust decisions for the user.</summary>
/// <returns>An <see cref="T:System.Security.Policy.ApplicationTrustCollection" /> that contains the cached trust decisions for the user.</returns>
// Token: 0x17000A14 RID: 2580
// (get) Token: 0x0600335A RID: 13146 RVA: 0x000B0780 File Offset: 0x000AE980
public static ApplicationTrustCollection UserApplicationTrusts
{
get
{
if (ApplicationSecurityManager._userAppTrusts == null)
{
ApplicationSecurityManager._userAppTrusts = new ApplicationTrustCollection();
}
return ApplicationSecurityManager._userAppTrusts;
}
}
/// <summary>Determines whether the user approves the specified application to execute with the requested permission set.</summary>
/// <returns>true to execute the specified application; otherwise, false.</returns>
/// <param name="activationContext">An <see cref="T:System.ActivationContext" /> identifying the activation context for the application.</param>
/// <param name="context">A <see cref="T:System.Security.Policy.TrustManagerContext" /> identifying the trust manager context for the application.</param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="activationContext" /> parameter is null.</exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Read="*AllFiles*" PathDiscovery="*AllFiles*" />
/// <IPermission class="System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="MemberAccess" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="ControlEvidence, ControlPolicy" />
/// </PermissionSet>
// Token: 0x0600335B RID: 13147 RVA: 0x000B079C File Offset: 0x000AE99C
[MonoTODO("Missing application manifest support")]
public static bool DetermineApplicationTrust(ActivationContext activationContext, TrustManagerContext context)
{
if (activationContext == null)
{
throw new NullReferenceException("activationContext");
}
ApplicationTrust applicationTrust = ApplicationSecurityManager.ApplicationTrustManager.DetermineApplicationTrust(activationContext, context);
return applicationTrust.IsApplicationTrustedToRun;
}
// Token: 0x04001509 RID: 5385
private const string config = "ApplicationTrust.config";
// Token: 0x0400150A RID: 5386
private static IApplicationTrustManager _appTrustManager;
// Token: 0x0400150B RID: 5387
private static ApplicationTrustCollection _userAppTrusts;
}
}
@@ -0,0 +1,293 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.Serialization.Formatters.Binary;
using System.Security.Permissions;
using Mono.Security.Cryptography;
namespace System.Security.Policy
{
/// <summary>Encapsulates security decisions about an application. This class cannot be inherited.</summary>
// Token: 0x0200057E RID: 1406
[ComVisible(true)]
[Serializable]
public sealed class ApplicationTrust : ISecurityEncodable
{
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Policy.ApplicationTrust" /> class.</summary>
// Token: 0x0600335C RID: 13148 RVA: 0x000B07D0 File Offset: 0x000AE9D0
public ApplicationTrust()
{
this.fullTrustAssemblies = new List<StrongName>(0);
}
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Policy.ApplicationTrust" /> class with an <see cref="T:System.ApplicationIdentity" />. </summary>
/// <param name="applicationIdentity">An <see cref="T:System.ApplicationIdentity" /> that uniquely identifies an application.</param>
// Token: 0x0600335D RID: 13149 RVA: 0x000B07E4 File Offset: 0x000AE9E4
public ApplicationTrust(ApplicationIdentity applicationIdentity)
: this()
{
if (applicationIdentity == null)
{
throw new ArgumentNullException("applicationIdentity");
}
this._appid = applicationIdentity;
}
// Token: 0x0600335E RID: 13150 RVA: 0x000B0804 File Offset: 0x000AEA04
internal ApplicationTrust(PermissionSet defaultGrantSet, IEnumerable<StrongName> fullTrustAssemblies)
{
if (defaultGrantSet == null)
{
throw new ArgumentNullException("defaultGrantSet");
}
this._defaultPolicy = new PolicyStatement(defaultGrantSet);
if (fullTrustAssemblies == null)
{
throw new ArgumentNullException("fullTrustAssemblies");
}
this.fullTrustAssemblies = new List<StrongName>();
foreach (StrongName strongName in fullTrustAssemblies)
{
if (strongName == null)
{
throw new ArgumentException("fullTrustAssemblies contains an assembly that does not have a StrongName");
}
this.fullTrustAssemblies.Add((StrongName)strongName.Copy());
}
}
/// <summary>Gets or sets the application identity for the application trust object.</summary>
/// <returns>An <see cref="T:System.ApplicationIdentity" /> for the application trust object.</returns>
/// <exception cref="T:System.ArgumentNullException">
/// <see cref="T:System.ApplicationIdentity" /> cannot be set because it has a value of null.</exception>
// Token: 0x17000A15 RID: 2581
// (get) Token: 0x0600335F RID: 13151 RVA: 0x000B08C4 File Offset: 0x000AEAC4
// (set) Token: 0x06003360 RID: 13152 RVA: 0x000B08CC File Offset: 0x000AEACC
public ApplicationIdentity ApplicationIdentity
{
get
{
return this._appid;
}
set
{
if (value == null)
{
throw new ArgumentNullException("ApplicationIdentity");
}
this._appid = value;
}
}
/// <summary>Gets or sets the policy statement defining the default grant set.</summary>
/// <returns>A <see cref="T:System.Security.Policy.PolicyStatement" /> describing the default grants.</returns>
// Token: 0x17000A16 RID: 2582
// (get) Token: 0x06003361 RID: 13153 RVA: 0x000B08E8 File Offset: 0x000AEAE8
// (set) Token: 0x06003362 RID: 13154 RVA: 0x000B0908 File Offset: 0x000AEB08
public PolicyStatement DefaultGrantSet
{
get
{
if (this._defaultPolicy == null)
{
this._defaultPolicy = this.GetDefaultGrantSet();
}
return this._defaultPolicy;
}
set
{
this._defaultPolicy = value;
}
}
/// <summary>Gets or sets extra security information about the application.</summary>
/// <returns>An object containing additional security information about the application.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x17000A17 RID: 2583
// (get) Token: 0x06003363 RID: 13155 RVA: 0x000B0914 File Offset: 0x000AEB14
// (set) Token: 0x06003364 RID: 13156 RVA: 0x000B091C File Offset: 0x000AEB1C
public object ExtraInfo
{
get
{
return this._xtranfo;
}
set
{
this._xtranfo = value;
}
}
/// <summary>Gets or sets a value indicating whether the application has the required permission grants and is trusted to run.</summary>
/// <returns>true if the application is trusted to run; otherwise, false. The default is false.</returns>
// Token: 0x17000A18 RID: 2584
// (get) Token: 0x06003365 RID: 13157 RVA: 0x000B0928 File Offset: 0x000AEB28
// (set) Token: 0x06003366 RID: 13158 RVA: 0x000B0930 File Offset: 0x000AEB30
public bool IsApplicationTrustedToRun
{
get
{
return this._trustrun;
}
set
{
this._trustrun = value;
}
}
/// <summary>Gets or sets a value indicating whether application trust information is persisted.</summary>
/// <returns>true if application trust information is persisted; otherwise, false. The default is false.</returns>
// Token: 0x17000A19 RID: 2585
// (get) Token: 0x06003367 RID: 13159 RVA: 0x000B093C File Offset: 0x000AEB3C
// (set) Token: 0x06003368 RID: 13160 RVA: 0x000B0944 File Offset: 0x000AEB44
public bool Persist
{
get
{
return this._persist;
}
set
{
this._persist = value;
}
}
/// <summary>Reconstructs an <see cref="T:System.Security.Policy.ApplicationTrust" /> object with a given state from an XML encoding.</summary>
/// <param name="element">The XML encoding to use to reconstruct the <see cref="T:System.Security.Policy.ApplicationTrust" /> object. </param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="element" /> is null. </exception>
/// <exception cref="T:System.ArgumentException">The XML encoding used for <paramref name="element" /> is invalid.</exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
/// </PermissionSet>
// Token: 0x06003369 RID: 13161 RVA: 0x000B0950 File Offset: 0x000AEB50
public void FromXml(SecurityElement element)
{
if (element == null)
{
throw new ArgumentNullException("element");
}
if (element.Tag != "ApplicationTrust")
{
throw new ArgumentException("element");
}
string text = element.Attribute("FullName");
if (text != null)
{
this._appid = new ApplicationIdentity(text);
}
else
{
this._appid = null;
}
this._defaultPolicy = null;
SecurityElement securityElement = element.SearchForChildByTag("DefaultGrant");
if (securityElement != null)
{
for (int i = 0; i < securityElement.Children.Count; i++)
{
SecurityElement securityElement2 = securityElement.Children[i] as SecurityElement;
if (securityElement2.Tag == "PolicyStatement")
{
this.DefaultGrantSet.FromXml(securityElement2, null);
break;
}
}
}
if (!bool.TryParse(element.Attribute("TrustedToRun"), out this._trustrun))
{
this._trustrun = false;
}
if (!bool.TryParse(element.Attribute("Persist"), out this._persist))
{
this._persist = false;
}
this._xtranfo = null;
SecurityElement securityElement3 = element.SearchForChildByTag("ExtraInfo");
if (securityElement3 != null)
{
text = securityElement3.Attribute("Data");
if (text != null)
{
byte[] array = CryptoConvert.FromHex(text);
using (MemoryStream memoryStream = new MemoryStream(array))
{
BinaryFormatter binaryFormatter = new BinaryFormatter();
this._xtranfo = binaryFormatter.Deserialize(memoryStream);
}
}
}
}
/// <summary>Creates an XML encoding of the <see cref="T:System.Security.Policy.ApplicationTrust" /> object and its current state.</summary>
/// <returns>An XML encoding of the security object, including any state information.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Read="*AllFiles*" PathDiscovery="*AllFiles*" />
/// <IPermission class="System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="MemberAccess" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x0600336A RID: 13162 RVA: 0x000B0AF0 File Offset: 0x000AECF0
public SecurityElement ToXml()
{
SecurityElement securityElement = new SecurityElement("ApplicationTrust");
securityElement.AddAttribute("version", "1");
if (this._appid != null)
{
securityElement.AddAttribute("FullName", this._appid.FullName);
}
if (this._trustrun)
{
securityElement.AddAttribute("TrustedToRun", "true");
}
if (this._persist)
{
securityElement.AddAttribute("Persist", "true");
}
SecurityElement securityElement2 = new SecurityElement("DefaultGrant");
securityElement2.AddChild(this.DefaultGrantSet.ToXml());
securityElement.AddChild(securityElement2);
if (this._xtranfo != null)
{
byte[] array = null;
using (MemoryStream memoryStream = new MemoryStream())
{
BinaryFormatter binaryFormatter = new BinaryFormatter();
binaryFormatter.Serialize(memoryStream, this._xtranfo);
array = memoryStream.ToArray();
}
SecurityElement securityElement3 = new SecurityElement("ExtraInfo");
securityElement3.AddAttribute("Data", CryptoConvert.ToHex(array));
securityElement.AddChild(securityElement3);
}
return securityElement;
}
// Token: 0x0600336B RID: 13163 RVA: 0x000B0C18 File Offset: 0x000AEE18
private PolicyStatement GetDefaultGrantSet()
{
PermissionSet permissionSet = new PermissionSet(PermissionState.None);
return new PolicyStatement(permissionSet);
}
// Token: 0x0400150C RID: 5388
private ApplicationIdentity _appid;
// Token: 0x0400150D RID: 5389
private PolicyStatement _defaultPolicy;
// Token: 0x0400150E RID: 5390
private object _xtranfo;
// Token: 0x0400150F RID: 5391
private bool _trustrun;
// Token: 0x04001510 RID: 5392
private bool _persist;
// Token: 0x04001511 RID: 5393
private IList<StrongName> fullTrustAssemblies;
}
}
@@ -0,0 +1,365 @@
using System;
using System.Collections;
using System.Runtime.InteropServices;
namespace System.Security.Policy
{
/// <summary>Represents a collection of <see cref="T:System.Security.Policy.ApplicationTrust" /> objects. This class cannot be inherited. </summary>
// Token: 0x0200057F RID: 1407
[ComVisible(true)]
public sealed class ApplicationTrustCollection : IEnumerable, ICollection
{
// Token: 0x0600336C RID: 13164 RVA: 0x000B0C34 File Offset: 0x000AEE34
internal ApplicationTrustCollection()
{
this._list = new ArrayList();
}
/// <summary>Copies the elements of the <see cref="T:System.Collections.ICollection" /> to the specified <see cref="T:System.Array" />, starting at the specified <see cref="T:System.Array" /> index.</summary>
/// <param name="array">The one-dimensional <see cref="T:System.Array" /> that is the destination of the elements copied from the <see cref="T:System.Collections.ICollection" />. The <see cref="T:System.Array" /> must have zero-based indexing. </param>
/// <param name="index">The zero-based index in <paramref name="array" /> at which copying begins. </param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="array" /> is null. </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="index" /> is less than zero. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="array" /> is multidimensional.-or- The number of elements in the source <see cref="T:System.Collections.ICollection" /> is greater than the available space from <paramref name="index" /> to the end of the destination <paramref name="array" />. </exception>
// Token: 0x0600336D RID: 13165 RVA: 0x000B0C48 File Offset: 0x000AEE48
void ICollection.CopyTo(Array array, int index)
{
this._list.CopyTo(array, index);
}
/// <summary>Returns an enumerator that iterates through the collection.</summary>
/// <returns>An <see cref="T:System.Collections.IEnumerator" /> that can be used to iterate through the collection.</returns>
// Token: 0x0600336E RID: 13166 RVA: 0x000B0C58 File Offset: 0x000AEE58
IEnumerator IEnumerable.GetEnumerator()
{
return new ApplicationTrustEnumerator(this);
}
/// <summary>Gets the number of items contained in the collection.</summary>
/// <returns>The number of items contained in the collection.</returns>
// Token: 0x17000A1A RID: 2586
// (get) Token: 0x0600336F RID: 13167 RVA: 0x000B0C60 File Offset: 0x000AEE60
public int Count
{
get
{
return this._list.Count;
}
}
/// <summary>Gets a value indicating whether access to the collection is synchronized (thread safe).</summary>
/// <returns>false in all cases.</returns>
// Token: 0x17000A1B RID: 2587
// (get) Token: 0x06003370 RID: 13168 RVA: 0x000B0C70 File Offset: 0x000AEE70
public bool IsSynchronized
{
get
{
return false;
}
}
/// <summary>Gets an object that can be used to synchronize access to the collection.</summary>
/// <returns>The object to use to synchronize access to the collection.</returns>
// Token: 0x17000A1C RID: 2588
// (get) Token: 0x06003371 RID: 13169 RVA: 0x000B0C74 File Offset: 0x000AEE74
public object SyncRoot
{
get
{
return this;
}
}
/// <summary>Gets the <see cref="T:System.Security.Policy.ApplicationTrust" /> object located at the specified index in the collection.</summary>
/// <returns>The <see cref="T:System.Security.Policy.ApplicationTrust" /> object at the specified index in the collection.</returns>
/// <param name="index">The zero-based index of the object within the collection.</param>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="index" /> is greater than or equal to the count of objects in the collection. </exception>
/// <exception cref="T:System.InvalidOperationException">
/// <paramref name="index" /> is negative. </exception>
// Token: 0x17000A1D RID: 2589
public ApplicationTrust this[int index]
{
get
{
return (ApplicationTrust)this._list[index];
}
}
/// <summary>Gets the <see cref="T:System.Security.Policy.ApplicationTrust" /> object for the specified application.</summary>
/// <returns>The <see cref="T:System.Security.Policy.ApplicationTrust" /> object for the specified application, or null if the object cannot be found.</returns>
/// <param name="appFullName">The full name of the application.</param>
// Token: 0x17000A1E RID: 2590
public ApplicationTrust this[string appFullName]
{
get
{
for (int i = 0; i < this._list.Count; i++)
{
ApplicationTrust applicationTrust = this._list[i] as ApplicationTrust;
if (applicationTrust.ApplicationIdentity.FullName == appFullName)
{
return applicationTrust;
}
}
return null;
}
}
/// <summary>Adds an element to the collection.</summary>
/// <returns>The index at which the new element was inserted.</returns>
/// <param name="trust">The <see cref="T:System.Security.Policy.ApplicationTrust" /> object to add.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="trust" /> is null.</exception>
/// <exception cref="T:System.ArgumentException">The <see cref="P:System.Security.Policy.ApplicationTrust.ApplicationIdentity" /> property of the <see cref="T:System.Security.Policy.ApplicationTrust" /> specified in <paramref name="trust" /> is null.</exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Read="*AllFiles*" PathDiscovery="*AllFiles*" />
/// <IPermission class="System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="MemberAccess" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence, ControlPolicy" />
/// </PermissionSet>
// Token: 0x06003374 RID: 13172 RVA: 0x000B0CE0 File Offset: 0x000AEEE0
public int Add(ApplicationTrust trust)
{
if (trust == null)
{
throw new ArgumentNullException("trust");
}
if (trust.ApplicationIdentity == null)
{
throw new ArgumentException(Locale.GetText("ApplicationTrust.ApplicationIdentity can't be null."), "trust");
}
return this._list.Add(trust);
}
/// <summary>Copies the elements of the specified <see cref="T:System.Security.Policy.ApplicationTrust" /> array to the end of the collection.</summary>
/// <param name="trusts">An array of type <see cref="T:System.Security.Policy.ApplicationTrust" /> containing the objects to add to the collection.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="trusts" /> is null. </exception>
/// <exception cref="T:System.ArgumentException">The <see cref="P:System.Security.Policy.ApplicationTrust.ApplicationIdentity" /> property of an <see cref="T:System.Security.Policy.ApplicationTrust" /> specified in <paramref name="trust" /> is null.</exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Read="*AllFiles*" PathDiscovery="*AllFiles*" />
/// <IPermission class="System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="MemberAccess" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence, ControlPolicy" />
/// </PermissionSet>
// Token: 0x06003375 RID: 13173 RVA: 0x000B0D20 File Offset: 0x000AEF20
public void AddRange(ApplicationTrust[] trusts)
{
if (trusts == null)
{
throw new ArgumentNullException("trusts");
}
foreach (ApplicationTrust applicationTrust in trusts)
{
if (applicationTrust.ApplicationIdentity == null)
{
throw new ArgumentException(Locale.GetText("ApplicationTrust.ApplicationIdentity can't be null."), "trust");
}
this._list.Add(applicationTrust);
}
}
/// <summary>Copies the elements of the specified <see cref="T:System.Security.Policy.ApplicationTrustCollection" /> to the end of the collection.</summary>
/// <param name="trusts">A <see cref="T:System.Security.Policy.ApplicationTrustCollection" /> containing the objects to add to the collection.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="trusts" /> is null. </exception>
/// <exception cref="T:System.ArgumentException">The <see cref="P:System.Security.Policy.ApplicationTrust.ApplicationIdentity" /> property of an <see cref="T:System.Security.Policy.ApplicationTrust" /> specified in <paramref name="trust" /> is null.</exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Read="*AllFiles*" PathDiscovery="*AllFiles*" />
/// <IPermission class="System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="MemberAccess" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence, ControlPolicy" />
/// </PermissionSet>
// Token: 0x06003376 RID: 13174 RVA: 0x000B0D88 File Offset: 0x000AEF88
public void AddRange(ApplicationTrustCollection trusts)
{
if (trusts == null)
{
throw new ArgumentNullException("trusts");
}
foreach (ApplicationTrust applicationTrust in trusts)
{
if (applicationTrust.ApplicationIdentity == null)
{
throw new ArgumentException(Locale.GetText("ApplicationTrust.ApplicationIdentity can't be null."), "trust");
}
this._list.Add(applicationTrust);
}
}
/// <summary>Removes all the application trusts from the collection.</summary>
/// <exception cref="T:System.ArgumentException">The <see cref="P:System.Security.Policy.ApplicationTrust.ApplicationIdentity" /> property of an item in the collection is null.</exception>
// Token: 0x06003377 RID: 13175 RVA: 0x000B0DF4 File Offset: 0x000AEFF4
public void Clear()
{
this._list.Clear();
}
/// <summary>Copies the entire collection to a compatible one-dimensional array, starting at the specified index of the target array.</summary>
/// <param name="array">The one-dimensional array of type <see cref="T:System.Security.Policy.ApplicationTrust" /> that is the destination of the elements copied from the current collection. </param>
/// <param name="index">The zero-based index in <paramref name="array" /> at which copying begins. </param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="array" /> is null. </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="index" /> is less than the lower bound of <paramref name="array" />. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="array" /> is multidimensional.-or- The number of elements in the <see cref="T:System.Security.Policy.ApplicationTrustCollection" /> is greater than the available space from <paramref name="index" /> to the end of the destination <paramref name="array" />. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="ControlPolicy" />
/// </PermissionSet>
// Token: 0x06003378 RID: 13176 RVA: 0x000B0E04 File Offset: 0x000AF004
public void CopyTo(ApplicationTrust[] array, int index)
{
this._list.CopyTo(array, index);
}
/// <summary>Gets the application trusts in the collection that match the specified application identity.</summary>
/// <returns>An <see cref="T:System.Security.Policy.ApplicationTrustCollection" /> containing all matching <see cref="T:System.Security.Policy.ApplicationTrust" /> objects.</returns>
/// <param name="applicationIdentity">An <see cref="T:System.ApplicationIdentity" /> object describing the application to find.</param>
/// <param name="versionMatch">One of the <see cref="T:System.Security.Policy.ApplicationVersionMatch" /> values. </param>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Read="*AllFiles*" PathDiscovery="*AllFiles*" />
/// <IPermission class="System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="MemberAccess" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence, ControlPolicy" />
/// </PermissionSet>
// Token: 0x06003379 RID: 13177 RVA: 0x000B0E14 File Offset: 0x000AF014
public ApplicationTrustCollection Find(ApplicationIdentity applicationIdentity, ApplicationVersionMatch versionMatch)
{
if (applicationIdentity == null)
{
throw new ArgumentNullException("applicationIdentity");
}
string text = applicationIdentity.FullName;
if (versionMatch != ApplicationVersionMatch.MatchExactVersion)
{
if (versionMatch != ApplicationVersionMatch.MatchAllVersions)
{
throw new ArgumentException("versionMatch");
}
int num = text.IndexOf(", Version=");
if (num >= 0)
{
text = text.Substring(0, num);
}
}
ApplicationTrustCollection applicationTrustCollection = new ApplicationTrustCollection();
foreach (object obj in this._list)
{
ApplicationTrust applicationTrust = (ApplicationTrust)obj;
if (applicationTrust.ApplicationIdentity.FullName.StartsWith(text))
{
applicationTrustCollection.Add(applicationTrust);
}
}
return applicationTrustCollection;
}
/// <summary>Returns an object that can be used to iterate over the collection.</summary>
/// <returns>An <see cref="T:System.Security.Policy.ApplicationTrustEnumerator" /> that can be used to iterate over the collection.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="ControlPolicy" />
/// </PermissionSet>
// Token: 0x0600337A RID: 13178 RVA: 0x000B0F08 File Offset: 0x000AF108
public ApplicationTrustEnumerator GetEnumerator()
{
return new ApplicationTrustEnumerator(this);
}
/// <summary>Removes the specified application trust from the collection.</summary>
/// <param name="trust">The <see cref="T:System.Security.Policy.ApplicationTrust" /> object to remove.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="trust" /> is null.</exception>
/// <exception cref="T:System.ArgumentException">The <see cref="P:System.Security.Policy.ApplicationTrust.ApplicationIdentity" /> property of the <see cref="T:System.Security.Policy.ApplicationTrust" /> object specified by <paramref name="trust" /> is null.</exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence, ControlPolicy" />
/// </PermissionSet>
// Token: 0x0600337B RID: 13179 RVA: 0x000B0F10 File Offset: 0x000AF110
public void Remove(ApplicationTrust trust)
{
if (trust == null)
{
throw new ArgumentNullException("trust");
}
if (trust.ApplicationIdentity == null)
{
throw new ArgumentException(Locale.GetText("ApplicationTrust.ApplicationIdentity can't be null."), "trust");
}
this.RemoveAllInstances(trust);
}
/// <summary>Removes all application trust objects that match the specified criteria from the collection.</summary>
/// <param name="applicationIdentity">The <see cref="T:System.ApplicationIdentity" /> of the <see cref="T:System.Security.Policy.ApplicationTrust" /> object to be removed.</param>
/// <param name="versionMatch">One of the <see cref="T:System.Security.Policy.ApplicationVersionMatch" /> values.</param>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Read="*AllFiles*" PathDiscovery="*AllFiles*" />
/// <IPermission class="System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="MemberAccess" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence, ControlPolicy" />
/// </PermissionSet>
// Token: 0x0600337C RID: 13180 RVA: 0x000B0F58 File Offset: 0x000AF158
public void Remove(ApplicationIdentity applicationIdentity, ApplicationVersionMatch versionMatch)
{
ApplicationTrustCollection applicationTrustCollection = this.Find(applicationIdentity, versionMatch);
foreach (ApplicationTrust applicationTrust in applicationTrustCollection)
{
this.RemoveAllInstances(applicationTrust);
}
}
/// <summary>Removes the application trust objects in the specified array from the collection.</summary>
/// <param name="trusts">A one-dimensional array of type <see cref="T:System.Security.Policy.ApplicationTrust" /> that contains items to be removed from the current collection. </param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="trusts" /> is null. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence, ControlPolicy" />
/// </PermissionSet>
// Token: 0x0600337D RID: 13181 RVA: 0x000B0F94 File Offset: 0x000AF194
public void RemoveRange(ApplicationTrust[] trusts)
{
if (trusts == null)
{
throw new ArgumentNullException("trusts");
}
foreach (ApplicationTrust applicationTrust in trusts)
{
this.RemoveAllInstances(applicationTrust);
}
}
/// <summary>Removes the application trust objects in the specified collection from the collection.</summary>
/// <param name="trusts">An <see cref="T:System.Security.Policy.ApplicationTrustCollection" /> that contains items to be removed from the currentcollection.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="trusts" /> is null. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence, ControlPolicy" />
/// </PermissionSet>
// Token: 0x0600337E RID: 13182 RVA: 0x000B0FD4 File Offset: 0x000AF1D4
public void RemoveRange(ApplicationTrustCollection trusts)
{
if (trusts == null)
{
throw new ArgumentNullException("trusts");
}
foreach (ApplicationTrust applicationTrust in trusts)
{
this.RemoveAllInstances(applicationTrust);
}
}
// Token: 0x0600337F RID: 13183 RVA: 0x000B1018 File Offset: 0x000AF218
internal void RemoveAllInstances(ApplicationTrust trust)
{
for (int i = this._list.Count - 1; i >= 0; i--)
{
if (trust.Equals(this._list[i]))
{
this._list.RemoveAt(i);
}
}
}
// Token: 0x04001512 RID: 5394
private ArrayList _list;
}
}
@@ -0,0 +1,63 @@
using System;
using System.Collections;
using System.Runtime.InteropServices;
namespace System.Security.Policy
{
/// <summary>Represents the enumerator for <see cref="T:System.Security.Policy.ApplicationTrust" /> objects in the <see cref="T:System.Security.Policy.ApplicationTrustCollection" /> collection.</summary>
// Token: 0x02000580 RID: 1408
[ComVisible(true)]
public sealed class ApplicationTrustEnumerator : IEnumerator
{
// Token: 0x06003380 RID: 13184 RVA: 0x000B1068 File Offset: 0x000AF268
internal ApplicationTrustEnumerator(ApplicationTrustCollection collection)
{
this.e = collection.GetEnumerator();
}
/// <summary>Gets the current <see cref="T:System.Object" /> in the <see cref="T:System.Security.Policy.ApplicationTrustCollection" /> collection.</summary>
/// <returns>The current <see cref="T:System.Object" /> in the <see cref="T:System.Security.Policy.ApplicationTrustCollection" />.</returns>
// Token: 0x17000A1F RID: 2591
// (get) Token: 0x06003381 RID: 13185 RVA: 0x000B107C File Offset: 0x000AF27C
object IEnumerator.Current
{
get
{
return this.e.Current;
}
}
/// <summary>Gets the current <see cref="T:System.Security.Policy.ApplicationTrust" /> object in the <see cref="T:System.Security.Policy.ApplicationTrustCollection" /> collection.</summary>
/// <returns>The current <see cref="T:System.Security.Policy.ApplicationTrust" /> in the <see cref="T:System.Security.Policy.ApplicationTrustCollection" />.</returns>
// Token: 0x17000A20 RID: 2592
// (get) Token: 0x06003382 RID: 13186 RVA: 0x000B108C File Offset: 0x000AF28C
public ApplicationTrust Current
{
get
{
return (ApplicationTrust)this.e.Current;
}
}
/// <summary>Moves to the next element in the <see cref="T:System.Security.Policy.ApplicationTrustCollection" /> collection.</summary>
/// <returns>true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
/// </PermissionSet>
// Token: 0x06003383 RID: 13187 RVA: 0x000B10A0 File Offset: 0x000AF2A0
public bool MoveNext()
{
return this.e.MoveNext();
}
/// <summary>Resets the enumerator to the beginning of the <see cref="T:System.Security.Policy.ApplicationTrustCollection" /> collection.</summary>
// Token: 0x06003384 RID: 13188 RVA: 0x000B10B0 File Offset: 0x000AF2B0
public void Reset()
{
this.e.Reset();
}
// Token: 0x04001513 RID: 5395
private IEnumerator e;
}
}
@@ -0,0 +1,18 @@
using System;
using System.Runtime.InteropServices;
namespace System.Security.Policy
{
/// <summary>Specifies how to match versions when locating application trusts in a collection.</summary>
// Token: 0x02000581 RID: 1409
[ComVisible(true)]
public enum ApplicationVersionMatch
{
/// <summary>Match on the exact version.</summary>
// Token: 0x04001515 RID: 5397
MatchExactVersion,
/// <summary>Match on all versions.</summary>
// Token: 0x04001516 RID: 5398
MatchAllVersions
}
}
@@ -0,0 +1,117 @@
using System;
using System.Runtime.InteropServices;
namespace System.Security.Policy
{
/// <summary>Specifies the network resource access that is granted to code.</summary>
// Token: 0x02000582 RID: 1410
[ComVisible(true)]
[Serializable]
public class CodeConnectAccess
{
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Policy.CodeConnectAccess" /> class. </summary>
/// <param name="allowScheme">The URI scheme represented by the current instance.</param>
/// <param name="allowPort">The port represented by the current instance.</param>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="allowScheme" /> is null.-or-<paramref name="allowScheme" /> is an empty string ("").-or-<paramref name="allowScheme" /> contains characters that are not permitted in schemes.-or-<paramref name="allowPort" /> is less than 0.-or-<paramref name="allowPort" /> is greater than 65,535.</exception>
// Token: 0x06003385 RID: 13189 RVA: 0x000B10C0 File Offset: 0x000AF2C0
[MonoTODO("(2.0) validations incomplete")]
public CodeConnectAccess(string allowScheme, int allowPort)
{
if (allowScheme == null || allowScheme.Length == 0)
{
throw new ArgumentOutOfRangeException("allowScheme");
}
if (allowPort < 0 || allowPort > 65535)
{
throw new ArgumentOutOfRangeException("allowPort");
}
this._scheme = allowScheme;
this._port = allowPort;
}
/// <summary>Gets the port represented by the current instance.</summary>
/// <returns>A <see cref="T:System.Int32" /> value that identifies a computer port used in conjunction with the <see cref="P:System.Security.Policy.CodeConnectAccess.Scheme" /> property.</returns>
// Token: 0x17000A21 RID: 2593
// (get) Token: 0x06003387 RID: 13191 RVA: 0x000B114C File Offset: 0x000AF34C
public int Port
{
get
{
return this._port;
}
}
/// <summary>Gets the URI scheme represented by the current instance.</summary>
/// <returns>A <see cref="T:System.String" /> that identifies a URI scheme, converted to lowercase.</returns>
// Token: 0x17000A22 RID: 2594
// (get) Token: 0x06003388 RID: 13192 RVA: 0x000B1154 File Offset: 0x000AF354
public string Scheme
{
get
{
return this._scheme;
}
}
/// <summary>Returns a value indicating whether two <see cref="T:System.Security.Policy.CodeConnectAccess" /> objects represent the same scheme and port.</summary>
/// <returns>true if the two objects represent the same scheme and port; otherwise, false.</returns>
/// <param name="o">The object to compare to the current <see cref="T:System.Security.Policy.CodeConnectAccess" /> object.</param>
// Token: 0x06003389 RID: 13193 RVA: 0x000B115C File Offset: 0x000AF35C
public override bool Equals(object o)
{
CodeConnectAccess codeConnectAccess = o as CodeConnectAccess;
return codeConnectAccess != null && this._scheme == codeConnectAccess._scheme && this._port == codeConnectAccess._port;
}
// Token: 0x0600338A RID: 13194 RVA: 0x000B11A0 File Offset: 0x000AF3A0
public override int GetHashCode()
{
return this._scheme.GetHashCode() ^ this._port;
}
/// <summary>Returns a <see cref="T:System.Security.Policy.CodeConnectAccess" /> instance that represents access to the specified port using any scheme.</summary>
/// <returns>A <see cref="T:System.Security.Policy.CodeConnectAccess" /> instance for the specified port.</returns>
/// <param name="allowPort">The port represented by the returned instance.</param>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="allowPort" /> is less than 0.-or-<paramref name="allowPort" /> is greater than 65,535.</exception>
// Token: 0x0600338B RID: 13195 RVA: 0x000B11B4 File Offset: 0x000AF3B4
public static CodeConnectAccess CreateAnySchemeAccess(int allowPort)
{
return new CodeConnectAccess(CodeConnectAccess.AnyScheme, allowPort);
}
/// <summary>Returns a <see cref="T:System.Security.Policy.CodeConnectAccess" /> instance that represents access to the specified port using the code's scheme of origin.</summary>
/// <returns>A <see cref="T:System.Security.Policy.CodeConnectAccess" /> instance for the specified port.</returns>
/// <param name="allowPort">The port represented by the returned instance.</param>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="allowPort" /> is less than 0.-or-<paramref name="allowPort" /> is greater than 65,535.</exception>
// Token: 0x0600338C RID: 13196 RVA: 0x000B11C4 File Offset: 0x000AF3C4
public static CodeConnectAccess CreateOriginSchemeAccess(int allowPort)
{
return new CodeConnectAccess(CodeConnectAccess.OriginScheme, allowPort);
}
/// <summary>Contains the string value that represents the scheme wildcard.</summary>
// Token: 0x04001517 RID: 5399
public static readonly string AnyScheme = "*";
/// <summary>Contains the value used to represent the default port.</summary>
// Token: 0x04001518 RID: 5400
public static readonly int DefaultPort = -3;
/// <summary>Contains the value used to represent the port value in the URI where code originated.</summary>
// Token: 0x04001519 RID: 5401
public static readonly int OriginPort = -4;
/// <summary>Contains the value used to represent the scheme in the URL where the code originated.</summary>
// Token: 0x0400151A RID: 5402
public static readonly string OriginScheme = "$origin";
// Token: 0x0400151B RID: 5403
private string _scheme;
// Token: 0x0400151C RID: 5404
private int _port;
}
}
@@ -0,0 +1,472 @@
using System;
using System.Collections;
using System.Runtime.InteropServices;
using System.Security.Permissions;
namespace System.Security.Policy
{
/// <summary>Represents the abstract base class from which all implementations of code groups must derive.</summary>
// Token: 0x02000583 RID: 1411
[ComVisible(true)]
[Serializable]
public abstract class CodeGroup
{
/// <summary>Initializes a new instance of <see cref="T:System.Security.Policy.CodeGroup" />.</summary>
/// <param name="membershipCondition">A membership condition that tests evidence to determine whether this code group applies policy. </param>
/// <param name="policy">The policy statement for the code group in the form of a permission set and attributes to grant code that matches the membership condition. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="membershipCondition" /> parameter is null. </exception>
/// <exception cref="T:System.ArgumentException">The type of the <paramref name="membershipCondition" /> parameter is not valid.-or- The type of the <paramref name="policy" /> parameter is not valid. </exception>
// Token: 0x0600338D RID: 13197 RVA: 0x000B11D4 File Offset: 0x000AF3D4
protected CodeGroup(IMembershipCondition membershipCondition, PolicyStatement policy)
{
if (membershipCondition == null)
{
throw new ArgumentNullException("membershipCondition");
}
if (policy != null)
{
this.m_policy = policy.Copy();
}
this.m_membershipCondition = membershipCondition.Copy();
}
// Token: 0x0600338E RID: 13198 RVA: 0x000B1224 File Offset: 0x000AF424
internal CodeGroup(SecurityElement e, PolicyLevel level)
{
this.FromXml(e, level);
}
/// <summary>When overridden in a derived class, makes a deep copy of the current code group.</summary>
/// <returns>An equivalent copy of the current code group, including its membership conditions and child code groups.</returns>
// Token: 0x0600338F RID: 13199
public abstract CodeGroup Copy();
/// <summary>When overridden in a derived class, gets the merge logic for the code group.</summary>
/// <returns>A description of the merge logic for the code group.</returns>
// Token: 0x17000A23 RID: 2595
// (get) Token: 0x06003390 RID: 13200
public abstract string MergeLogic { get; }
/// <summary>When overridden in a derived class, resolves policy for the code group and its descendants for a set of evidence.</summary>
/// <returns>A policy statement that consists of the permissions granted by the code group with optional attributes, or null if the code group does not apply (the membership condition does not match the specified evidence).</returns>
/// <param name="evidence">The evidence for the assembly. </param>
// Token: 0x06003391 RID: 13201
public abstract PolicyStatement Resolve(Evidence evidence);
/// <summary>When overridden in a derived class, resolves matching code groups.</summary>
/// <returns>A <see cref="T:System.Security.Policy.CodeGroup" /> that is the root of the tree of matching code groups.</returns>
/// <param name="evidence">The evidence for the assembly. </param>
// Token: 0x06003392 RID: 13202
public abstract CodeGroup ResolveMatchingCodeGroups(Evidence evidence);
/// <summary>Gets or sets the policy statement associated with the code group.</summary>
/// <returns>The policy statement for the code group.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x17000A24 RID: 2596
// (get) Token: 0x06003393 RID: 13203 RVA: 0x000B1240 File Offset: 0x000AF440
// (set) Token: 0x06003394 RID: 13204 RVA: 0x000B1248 File Offset: 0x000AF448
public PolicyStatement PolicyStatement
{
get
{
return this.m_policy;
}
set
{
this.m_policy = value;
}
}
/// <summary>Gets or sets the description of the code group.</summary>
/// <returns>The description of the code group.</returns>
// Token: 0x17000A25 RID: 2597
// (get) Token: 0x06003395 RID: 13205 RVA: 0x000B1254 File Offset: 0x000AF454
// (set) Token: 0x06003396 RID: 13206 RVA: 0x000B125C File Offset: 0x000AF45C
public string Description
{
get
{
return this.m_description;
}
set
{
this.m_description = value;
}
}
/// <summary>Gets or sets the code group's membership condition.</summary>
/// <returns>The membership condition that determines to which evidence the code group is applicable.</returns>
/// <exception cref="T:System.ArgumentNullException">An attempt is made to set this parameter to null. </exception>
// Token: 0x17000A26 RID: 2598
// (get) Token: 0x06003397 RID: 13207 RVA: 0x000B1268 File Offset: 0x000AF468
// (set) Token: 0x06003398 RID: 13208 RVA: 0x000B1270 File Offset: 0x000AF470
public IMembershipCondition MembershipCondition
{
get
{
return this.m_membershipCondition;
}
set
{
if (value == null)
{
throw new ArgumentException("value");
}
this.m_membershipCondition = value;
}
}
/// <summary>Gets or sets the name of the code group.</summary>
/// <returns>The name of the code group.</returns>
// Token: 0x17000A27 RID: 2599
// (get) Token: 0x06003399 RID: 13209 RVA: 0x000B128C File Offset: 0x000AF48C
// (set) Token: 0x0600339A RID: 13210 RVA: 0x000B1294 File Offset: 0x000AF494
public string Name
{
get
{
return this.m_name;
}
set
{
this.m_name = value;
}
}
/// <summary>Gets or sets an ordered list of the child code groups of a code group.</summary>
/// <returns>A list of child code groups.</returns>
/// <exception cref="T:System.ArgumentNullException">An attempt is made to set this property to null. </exception>
/// <exception cref="T:System.ArgumentException">An attempt is made to set this property with a list of children that are not <see cref="T:System.Security.Policy.CodeGroup" /> objects.</exception>
// Token: 0x17000A28 RID: 2600
// (get) Token: 0x0600339B RID: 13211 RVA: 0x000B12A0 File Offset: 0x000AF4A0
// (set) Token: 0x0600339C RID: 13212 RVA: 0x000B12A8 File Offset: 0x000AF4A8
public IList Children
{
get
{
return this.m_children;
}
set
{
if (value == null)
{
throw new ArgumentNullException("value");
}
this.m_children = new ArrayList(value);
}
}
/// <summary>Gets a string representation of the attributes of the policy statement for the code group.</summary>
/// <returns>A string representation of the attributes of the policy statement for the code group.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x17000A29 RID: 2601
// (get) Token: 0x0600339D RID: 13213 RVA: 0x000B12C8 File Offset: 0x000AF4C8
public virtual string AttributeString
{
get
{
if (this.m_policy != null)
{
return this.m_policy.AttributeString;
}
return null;
}
}
/// <summary>Gets the name of the named permission set for the code group.</summary>
/// <returns>The name of a named permission set of the policy level.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x17000A2A RID: 2602
// (get) Token: 0x0600339E RID: 13214 RVA: 0x000B12E4 File Offset: 0x000AF4E4
public virtual string PermissionSetName
{
get
{
if (this.m_policy == null)
{
return null;
}
if (this.m_policy.PermissionSet is NamedPermissionSet)
{
return ((NamedPermissionSet)this.m_policy.PermissionSet).Name;
}
return null;
}
}
/// <summary>Adds a child code group to the current code group.</summary>
/// <param name="group">The code group to be added as a child. This new child code group is added to the end of the list. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="group" /> parameter is null. </exception>
/// <exception cref="T:System.ArgumentException">The <paramref name="group" /> parameter is not a valid code group. </exception>
// Token: 0x0600339F RID: 13215 RVA: 0x000B132C File Offset: 0x000AF52C
public void AddChild(CodeGroup group)
{
if (group == null)
{
throw new ArgumentNullException("group");
}
this.m_children.Add(group.Copy());
}
/// <summary>Determines whether the specified code group is equivalent to the current code group.</summary>
/// <returns>true if the specified code group is equivalent to the current code group; otherwise, false.</returns>
/// <param name="o">The code group to compare with the current code group. </param>
// Token: 0x060033A0 RID: 13216 RVA: 0x000B1354 File Offset: 0x000AF554
public override bool Equals(object o)
{
CodeGroup codeGroup = o as CodeGroup;
return codeGroup != null && this.Equals(codeGroup, false);
}
/// <summary>Determines whether the specified code group is equivalent to the current code group, checking the child code groups as well, if specified.</summary>
/// <returns>true if the specified code group is equivalent to the current code group; otherwise, false.</returns>
/// <param name="cg">The code group to compare with the current code group. </param>
/// <param name="compareChildren">true to compare child code groups, as well; otherwise, false. </param>
// Token: 0x060033A1 RID: 13217 RVA: 0x000B1378 File Offset: 0x000AF578
public bool Equals(CodeGroup cg, bool compareChildren)
{
if (cg.Name != this.Name)
{
return false;
}
if (cg.Description != this.Description)
{
return false;
}
if (!cg.MembershipCondition.Equals(this.m_membershipCondition))
{
return false;
}
if (compareChildren)
{
int count = cg.Children.Count;
if (this.Children.Count != count)
{
return false;
}
for (int i = 0; i < count; i++)
{
if (!((CodeGroup)this.Children[i]).Equals((CodeGroup)cg.Children[i], false))
{
return false;
}
}
}
return true;
}
/// <summary>Removes the specified child code group.</summary>
/// <param name="group">The code group to be removed as a child. </param>
/// <exception cref="T:System.ArgumentException">The <paramref name="group" /> parameter is not an immediate child code group of the current code group. </exception>
// Token: 0x060033A2 RID: 13218 RVA: 0x000B1434 File Offset: 0x000AF634
public void RemoveChild(CodeGroup group)
{
if (group != null)
{
this.m_children.Remove(group);
}
}
/// <summary>Gets the hash code of the current code group.</summary>
/// <returns>The hash code of the current code group.</returns>
// Token: 0x060033A3 RID: 13219 RVA: 0x000B1448 File Offset: 0x000AF648
public override int GetHashCode()
{
int num = this.m_membershipCondition.GetHashCode();
if (this.m_policy != null)
{
num += this.m_policy.GetHashCode();
}
return num;
}
/// <summary>Reconstructs a security object with a given state from an XML encoding.</summary>
/// <param name="e">The XML encoding to use to reconstruct the security object. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="e" /> parameter is null. </exception>
// Token: 0x060033A4 RID: 13220 RVA: 0x000B147C File Offset: 0x000AF67C
public void FromXml(SecurityElement e)
{
this.FromXml(e, null);
}
/// <summary>Reconstructs a security object with a given state and policy level from an XML encoding.</summary>
/// <param name="e">The XML encoding to use to reconstruct the security object. </param>
/// <param name="level">The policy level within which the code group exists. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="e" /> parameter is null. </exception>
// Token: 0x060033A5 RID: 13221 RVA: 0x000B1488 File Offset: 0x000AF688
public void FromXml(SecurityElement e, PolicyLevel level)
{
if (e == null)
{
throw new ArgumentNullException("e");
}
string text = e.Attribute("PermissionSetName");
PermissionSet permissionSet;
if (text != null && level != null)
{
permissionSet = level.GetNamedPermissionSet(text);
}
else
{
SecurityElement securityElement = e.SearchForChildByTag("PermissionSet");
if (securityElement != null)
{
Type type = Type.GetType(securityElement.Attribute("class"));
permissionSet = (PermissionSet)Activator.CreateInstance(type, true);
permissionSet.FromXml(securityElement);
}
else
{
permissionSet = new PermissionSet(new PermissionSet(PermissionState.None));
}
}
this.m_policy = new PolicyStatement(permissionSet);
this.m_children.Clear();
if (e.Children != null && e.Children.Count > 0)
{
foreach (object obj in e.Children)
{
SecurityElement securityElement2 = (SecurityElement)obj;
if (securityElement2.Tag == "CodeGroup")
{
this.AddChild(CodeGroup.CreateFromXml(securityElement2, level));
}
}
}
this.m_membershipCondition = null;
SecurityElement securityElement3 = e.SearchForChildByTag("IMembershipCondition");
if (securityElement3 != null)
{
string text2 = securityElement3.Attribute("class");
Type type2 = Type.GetType(text2);
if (type2 == null)
{
type2 = Type.GetType("System.Security.Policy." + text2);
}
this.m_membershipCondition = (IMembershipCondition)Activator.CreateInstance(type2, true);
this.m_membershipCondition.FromXml(securityElement3, level);
}
this.m_name = e.Attribute("Name");
this.m_description = e.Attribute("Description");
this.ParseXml(e, level);
}
/// <summary>When overridden in a derived class, reconstructs properties and internal state specific to a derived code group from the specified <see cref="T:System.Security.SecurityElement" />.</summary>
/// <param name="e">The XML encoding to use to reconstruct the security object. </param>
/// <param name="level">The policy level within which the code group exists. </param>
// Token: 0x060033A6 RID: 13222 RVA: 0x000B1668 File Offset: 0x000AF868
protected virtual void ParseXml(SecurityElement e, PolicyLevel level)
{
}
/// <summary>Creates an XML encoding of the security object and its current state.</summary>
/// <returns>An XML encoding of the security object, including any state information.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="ControlEvidence" />
/// </PermissionSet>
// Token: 0x060033A7 RID: 13223 RVA: 0x000B166C File Offset: 0x000AF86C
public SecurityElement ToXml()
{
return this.ToXml(null);
}
/// <summary>Creates an XML encoding of the security object, its current state, and the policy level within which the code exists.</summary>
/// <returns>An XML encoding of the security object, including any state information.</returns>
/// <param name="level">The policy level within which the code group exists. </param>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="ControlEvidence" />
/// </PermissionSet>
// Token: 0x060033A8 RID: 13224 RVA: 0x000B1678 File Offset: 0x000AF878
public SecurityElement ToXml(PolicyLevel level)
{
SecurityElement securityElement = new SecurityElement("CodeGroup");
securityElement.AddAttribute("class", base.GetType().AssemblyQualifiedName);
securityElement.AddAttribute("version", "1");
if (this.Name != null)
{
securityElement.AddAttribute("Name", this.Name);
}
if (this.Description != null)
{
securityElement.AddAttribute("Description", this.Description);
}
if (this.MembershipCondition != null)
{
securityElement.AddChild(this.MembershipCondition.ToXml());
}
if (this.PolicyStatement != null && this.PolicyStatement.PermissionSet != null)
{
securityElement.AddChild(this.PolicyStatement.PermissionSet.ToXml());
}
foreach (object obj in this.Children)
{
CodeGroup codeGroup = (CodeGroup)obj;
securityElement.AddChild(codeGroup.ToXml());
}
this.CreateXml(securityElement, level);
return securityElement;
}
/// <summary>When overridden in a derived class, serializes properties and internal state specific to a derived code group and adds the serialization to the specified <see cref="T:System.Security.SecurityElement" />.</summary>
/// <param name="element">The XML encoding to which to add the serialization. </param>
/// <param name="level">The policy level within which the code group exists. </param>
// Token: 0x060033A9 RID: 13225 RVA: 0x000B17AC File Offset: 0x000AF9AC
protected virtual void CreateXml(SecurityElement element, PolicyLevel level)
{
}
// Token: 0x060033AA RID: 13226 RVA: 0x000B17B0 File Offset: 0x000AF9B0
internal static CodeGroup CreateFromXml(SecurityElement se, PolicyLevel level)
{
string text = se.Attribute("class");
string text2 = text;
int num = text2.IndexOf(",");
if (num > 0)
{
text2 = text2.Substring(0, num);
}
num = text2.LastIndexOf(".");
if (num > 0)
{
text2 = text2.Substring(num + 1);
}
string text3 = text2;
switch (text3)
{
case "FileCodeGroup":
return new FileCodeGroup(se, level);
case "FirstMatchCodeGroup":
return new FirstMatchCodeGroup(se, level);
case "NetCodeGroup":
return new NetCodeGroup(se, level);
case "UnionCodeGroup":
return new UnionCodeGroup(se, level);
}
Type type = Type.GetType(text);
CodeGroup codeGroup = (CodeGroup)Activator.CreateInstance(type, true);
codeGroup.FromXml(se, level);
return codeGroup;
}
// Token: 0x0400151D RID: 5405
private PolicyStatement m_policy;
// Token: 0x0400151E RID: 5406
private IMembershipCondition m_membershipCondition;
// Token: 0x0400151F RID: 5407
private string m_description;
// Token: 0x04001520 RID: 5408
private string m_name;
// Token: 0x04001521 RID: 5409
private ArrayList m_children = new ArrayList();
}
}
@@ -0,0 +1,435 @@
using System;
using System.Collections.Generic;
using System.Security.Permissions;
namespace System.Security.Policy
{
// Token: 0x02000584 RID: 1412
internal static class DefaultPolicies
{
// Token: 0x060033AB RID: 13227 RVA: 0x000B18CC File Offset: 0x000AFACC
// Note: this type is marked as 'beforefieldinit'.
static DefaultPolicies()
{
byte[] array = new byte[16];
array[8] = 4;
DefaultPolicies._ecmaKey = array;
DefaultPolicies._msFinalKey = new byte[]
{
0, 36, 0, 0, 4, 128, 0, 0, 148, 0,
0, 0, 6, 2, 0, 0, 0, 36, 0, 0,
82, 83, 65, 49, 0, 4, 0, 0, 1, 0,
1, 0, 7, 209, 250, 87, 196, 174, 217, 240,
163, 46, 132, 170, 15, 174, 253, 13, 233, 232,
253, 106, 236, 143, 135, 251, 3, 118, 108, 131,
76, 153, 146, 30, 178, 59, 231, 154, 217, 213,
220, 193, 221, 154, 210, 54, 19, 33, 2, 144,
11, 114, 60, 249, 128, 149, 127, 196, 225, 119,
16, 143, 198, 7, 119, 79, 41, 232, 50, 14,
146, 234, 5, 236, 228, 232, 33, 192, 165, 239,
232, 241, 100, 92, 76, 12, 147, 193, 171, 153,
40, 93, 98, 44, 170, 101, 44, 29, 250, 214,
61, 116, 93, 111, 45, 229, 241, 126, 94, 175,
15, 196, 150, 61, 38, 28, 138, 18, 67, 101,
24, 32, 109, 192, 147, 52, 77, 90, 210, 147
};
}
// Token: 0x060033AC RID: 13228 RVA: 0x000B1904 File Offset: 0x000AFB04
public static PermissionSet GetSpecialPermissionSet(string name)
{
if (name == null)
{
throw new ArgumentNullException("name");
}
switch (name)
{
case "FullTrust":
return DefaultPolicies.FullTrust;
case "LocalIntranet":
return DefaultPolicies.LocalIntranet;
case "Internet":
return DefaultPolicies.Internet;
case "SkipVerification":
return DefaultPolicies.SkipVerification;
case "Execution":
return DefaultPolicies.Execution;
case "Nothing":
return DefaultPolicies.Nothing;
case "Everything":
return DefaultPolicies.Everything;
}
return null;
}
// Token: 0x17000A2B RID: 2603
// (get) Token: 0x060033AD RID: 13229 RVA: 0x000B19FC File Offset: 0x000AFBFC
public static PermissionSet FullTrust
{
get
{
if (DefaultPolicies._fullTrust == null)
{
DefaultPolicies._fullTrust = DefaultPolicies.BuildFullTrust();
}
return DefaultPolicies._fullTrust;
}
}
// Token: 0x17000A2C RID: 2604
// (get) Token: 0x060033AE RID: 13230 RVA: 0x000B1A18 File Offset: 0x000AFC18
public static PermissionSet LocalIntranet
{
get
{
if (DefaultPolicies._localIntranet == null)
{
DefaultPolicies._localIntranet = DefaultPolicies.BuildLocalIntranet();
}
return DefaultPolicies._localIntranet;
}
}
// Token: 0x17000A2D RID: 2605
// (get) Token: 0x060033AF RID: 13231 RVA: 0x000B1A34 File Offset: 0x000AFC34
public static PermissionSet Internet
{
get
{
if (DefaultPolicies._internet == null)
{
DefaultPolicies._internet = DefaultPolicies.BuildInternet();
}
return DefaultPolicies._internet;
}
}
// Token: 0x17000A2E RID: 2606
// (get) Token: 0x060033B0 RID: 13232 RVA: 0x000B1A50 File Offset: 0x000AFC50
public static PermissionSet SkipVerification
{
get
{
if (DefaultPolicies._skipVerification == null)
{
DefaultPolicies._skipVerification = DefaultPolicies.BuildSkipVerification();
}
return DefaultPolicies._skipVerification;
}
}
// Token: 0x17000A2F RID: 2607
// (get) Token: 0x060033B1 RID: 13233 RVA: 0x000B1A6C File Offset: 0x000AFC6C
public static PermissionSet Execution
{
get
{
if (DefaultPolicies._execution == null)
{
DefaultPolicies._execution = DefaultPolicies.BuildExecution();
}
return DefaultPolicies._execution;
}
}
// Token: 0x17000A30 RID: 2608
// (get) Token: 0x060033B2 RID: 13234 RVA: 0x000B1A88 File Offset: 0x000AFC88
public static PermissionSet Nothing
{
get
{
if (DefaultPolicies._nothing == null)
{
DefaultPolicies._nothing = DefaultPolicies.BuildNothing();
}
return DefaultPolicies._nothing;
}
}
// Token: 0x17000A31 RID: 2609
// (get) Token: 0x060033B3 RID: 13235 RVA: 0x000B1AA4 File Offset: 0x000AFCA4
public static PermissionSet Everything
{
get
{
if (DefaultPolicies._everything == null)
{
DefaultPolicies._everything = DefaultPolicies.BuildEverything();
}
return DefaultPolicies._everything;
}
}
// Token: 0x060033B4 RID: 13236 RVA: 0x000B1AC0 File Offset: 0x000AFCC0
public static StrongNameMembershipCondition FullTrustMembership(string name, DefaultPolicies.Key key)
{
StrongNamePublicKeyBlob strongNamePublicKeyBlob = null;
if (key != DefaultPolicies.Key.Ecma)
{
if (key == DefaultPolicies.Key.MsFinal)
{
if (DefaultPolicies._msFinal == null)
{
DefaultPolicies._msFinal = new StrongNamePublicKeyBlob(DefaultPolicies._msFinalKey);
}
strongNamePublicKeyBlob = DefaultPolicies._msFinal;
}
}
else
{
if (DefaultPolicies._ecma == null)
{
DefaultPolicies._ecma = new StrongNamePublicKeyBlob(DefaultPolicies._ecmaKey);
}
strongNamePublicKeyBlob = DefaultPolicies._ecma;
}
if (DefaultPolicies._fxVersion == null)
{
DefaultPolicies._fxVersion = new Version("2.0.0.0");
}
return new StrongNameMembershipCondition(strongNamePublicKeyBlob, name, DefaultPolicies._fxVersion);
}
// Token: 0x060033B5 RID: 13237 RVA: 0x000B1B58 File Offset: 0x000AFD58
private static NamedPermissionSet BuildFullTrust()
{
return new NamedPermissionSet("FullTrust", PermissionState.Unrestricted);
}
// Token: 0x060033B6 RID: 13238 RVA: 0x000B1B68 File Offset: 0x000AFD68
private static NamedPermissionSet BuildLocalIntranet()
{
NamedPermissionSet namedPermissionSet = new NamedPermissionSet("LocalIntranet", PermissionState.None);
namedPermissionSet.AddPermission(new EnvironmentPermission(EnvironmentPermissionAccess.Read, "USERNAME;USER"));
namedPermissionSet.AddPermission(new FileDialogPermission(PermissionState.Unrestricted));
namedPermissionSet.AddPermission(new IsolatedStorageFilePermission(PermissionState.None)
{
UsageAllowed = IsolatedStorageContainment.AssemblyIsolationByUser,
UserQuota = long.MaxValue
});
namedPermissionSet.AddPermission(new ReflectionPermission(ReflectionPermissionFlag.ReflectionEmit));
SecurityPermissionFlag securityPermissionFlag = SecurityPermissionFlag.Assertion | SecurityPermissionFlag.Execution;
namedPermissionSet.AddPermission(new SecurityPermission(securityPermissionFlag));
namedPermissionSet.AddPermission(new UIPermission(PermissionState.Unrestricted));
namedPermissionSet.AddPermission(PermissionBuilder.Create("System.Net.DnsPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", PermissionState.Unrestricted));
namedPermissionSet.AddPermission(PermissionBuilder.Create(DefaultPolicies.PrintingPermission("SafePrinting")));
return namedPermissionSet;
}
// Token: 0x060033B7 RID: 13239 RVA: 0x000B1C1C File Offset: 0x000AFE1C
private static NamedPermissionSet BuildInternet()
{
NamedPermissionSet namedPermissionSet = new NamedPermissionSet("Internet", PermissionState.None);
namedPermissionSet.AddPermission(new FileDialogPermission(FileDialogPermissionAccess.Open));
namedPermissionSet.AddPermission(new IsolatedStorageFilePermission(PermissionState.None)
{
UsageAllowed = IsolatedStorageContainment.DomainIsolationByUser,
UserQuota = 512000L
});
namedPermissionSet.AddPermission(new SecurityPermission(SecurityPermissionFlag.Execution));
namedPermissionSet.AddPermission(new UIPermission(UIPermissionWindow.SafeTopLevelWindows, UIPermissionClipboard.OwnClipboard));
namedPermissionSet.AddPermission(PermissionBuilder.Create(DefaultPolicies.PrintingPermission("SafePrinting")));
return namedPermissionSet;
}
// Token: 0x060033B8 RID: 13240 RVA: 0x000B1C98 File Offset: 0x000AFE98
private static NamedPermissionSet BuildSkipVerification()
{
NamedPermissionSet namedPermissionSet = new NamedPermissionSet("SkipVerification", PermissionState.None);
namedPermissionSet.AddPermission(new SecurityPermission(SecurityPermissionFlag.SkipVerification));
return namedPermissionSet;
}
// Token: 0x060033B9 RID: 13241 RVA: 0x000B1CC0 File Offset: 0x000AFEC0
private static NamedPermissionSet BuildExecution()
{
NamedPermissionSet namedPermissionSet = new NamedPermissionSet("Execution", PermissionState.None);
namedPermissionSet.AddPermission(new SecurityPermission(SecurityPermissionFlag.Execution));
return namedPermissionSet;
}
// Token: 0x060033BA RID: 13242 RVA: 0x000B1CE8 File Offset: 0x000AFEE8
private static NamedPermissionSet BuildNothing()
{
return new NamedPermissionSet("Nothing", PermissionState.None);
}
// Token: 0x060033BB RID: 13243 RVA: 0x000B1CF8 File Offset: 0x000AFEF8
private static NamedPermissionSet BuildEverything()
{
NamedPermissionSet namedPermissionSet = new NamedPermissionSet("Everything", PermissionState.None);
namedPermissionSet.AddPermission(new EnvironmentPermission(PermissionState.Unrestricted));
namedPermissionSet.AddPermission(new FileDialogPermission(PermissionState.Unrestricted));
namedPermissionSet.AddPermission(new FileIOPermission(PermissionState.Unrestricted));
namedPermissionSet.AddPermission(new IsolatedStorageFilePermission(PermissionState.Unrestricted));
namedPermissionSet.AddPermission(new ReflectionPermission(PermissionState.Unrestricted));
namedPermissionSet.AddPermission(new RegistryPermission(PermissionState.Unrestricted));
namedPermissionSet.AddPermission(new KeyContainerPermission(PermissionState.Unrestricted));
SecurityPermissionFlag securityPermissionFlag = SecurityPermissionFlag.AllFlags;
securityPermissionFlag &= ~SecurityPermissionFlag.SkipVerification;
namedPermissionSet.AddPermission(new SecurityPermission(securityPermissionFlag));
namedPermissionSet.AddPermission(new UIPermission(PermissionState.Unrestricted));
namedPermissionSet.AddPermission(PermissionBuilder.Create("System.Net.DnsPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", PermissionState.Unrestricted));
namedPermissionSet.AddPermission(PermissionBuilder.Create("System.Drawing.Printing.PrintingPermission, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", PermissionState.Unrestricted));
namedPermissionSet.AddPermission(PermissionBuilder.Create("System.Diagnostics.EventLogPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", PermissionState.Unrestricted));
namedPermissionSet.AddPermission(PermissionBuilder.Create("System.Net.SocketPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", PermissionState.Unrestricted));
namedPermissionSet.AddPermission(PermissionBuilder.Create("System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", PermissionState.Unrestricted));
namedPermissionSet.AddPermission(PermissionBuilder.Create("System.Diagnostics.PerformanceCounterPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", PermissionState.Unrestricted));
namedPermissionSet.AddPermission(PermissionBuilder.Create("System.DirectoryServices.DirectoryServicesPermission, System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", PermissionState.Unrestricted));
namedPermissionSet.AddPermission(PermissionBuilder.Create("System.Messaging.MessageQueuePermission, System.Messaging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", PermissionState.Unrestricted));
namedPermissionSet.AddPermission(PermissionBuilder.Create("System.ServiceProcess.ServiceControllerPermission, System.ServiceProcess, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", PermissionState.Unrestricted));
namedPermissionSet.AddPermission(PermissionBuilder.Create("System.Data.OleDb.OleDbPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", PermissionState.Unrestricted));
namedPermissionSet.AddPermission(PermissionBuilder.Create("System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", PermissionState.Unrestricted));
return namedPermissionSet;
}
// Token: 0x060033BC RID: 13244 RVA: 0x000B1E58 File Offset: 0x000B0058
private static SecurityElement PrintingPermission(string level)
{
SecurityElement securityElement = new SecurityElement("IPermission");
securityElement.AddAttribute("class", "System.Drawing.Printing.PrintingPermission, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
securityElement.AddAttribute("version", "1");
securityElement.AddAttribute("Level", level);
return securityElement;
}
// Token: 0x04001523 RID: 5411
private const string DnsPermissionClass = "System.Net.DnsPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
// Token: 0x04001524 RID: 5412
private const string EventLogPermissionClass = "System.Diagnostics.EventLogPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
// Token: 0x04001525 RID: 5413
private const string PrintingPermissionClass = "System.Drawing.Printing.PrintingPermission, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
// Token: 0x04001526 RID: 5414
private const string SocketPermissionClass = "System.Net.SocketPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
// Token: 0x04001527 RID: 5415
private const string WebPermissionClass = "System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
// Token: 0x04001528 RID: 5416
private const string PerformanceCounterPermissionClass = "System.Diagnostics.PerformanceCounterPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
// Token: 0x04001529 RID: 5417
private const string DirectoryServicesPermissionClass = "System.DirectoryServices.DirectoryServicesPermission, System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
// Token: 0x0400152A RID: 5418
private const string MessageQueuePermissionClass = "System.Messaging.MessageQueuePermission, System.Messaging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
// Token: 0x0400152B RID: 5419
private const string ServiceControllerPermissionClass = "System.ServiceProcess.ServiceControllerPermission, System.ServiceProcess, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
// Token: 0x0400152C RID: 5420
private const string OleDbPermissionClass = "System.Data.OleDb.OleDbPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
// Token: 0x0400152D RID: 5421
private const string SqlClientPermissionClass = "System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
// Token: 0x0400152E RID: 5422
private const string DataProtectionPermissionClass = "System.Security.Permissions.DataProtectionPermission, System.Security, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
// Token: 0x0400152F RID: 5423
private const string StorePermissionClass = "System.Security.Permissions.StorePermission, System.Security, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
// Token: 0x04001530 RID: 5424
private static Version _fxVersion;
// Token: 0x04001531 RID: 5425
private static byte[] _ecmaKey;
// Token: 0x04001532 RID: 5426
private static StrongNamePublicKeyBlob _ecma;
// Token: 0x04001533 RID: 5427
private static byte[] _msFinalKey;
// Token: 0x04001534 RID: 5428
private static StrongNamePublicKeyBlob _msFinal;
// Token: 0x04001535 RID: 5429
private static NamedPermissionSet _fullTrust;
// Token: 0x04001536 RID: 5430
private static NamedPermissionSet _localIntranet;
// Token: 0x04001537 RID: 5431
private static NamedPermissionSet _internet;
// Token: 0x04001538 RID: 5432
private static NamedPermissionSet _skipVerification;
// Token: 0x04001539 RID: 5433
private static NamedPermissionSet _execution;
// Token: 0x0400153A RID: 5434
private static NamedPermissionSet _nothing;
// Token: 0x0400153B RID: 5435
private static NamedPermissionSet _everything;
// Token: 0x02000585 RID: 1413
public static class ReservedNames
{
// Token: 0x060033BD RID: 13245 RVA: 0x000B1EA0 File Offset: 0x000B00A0
public static bool IsReserved(string name)
{
if (name != null)
{
if (DefaultPolicies.ReservedNames.<>f__switch$map2C == null)
{
DefaultPolicies.ReservedNames.<>f__switch$map2C = new Dictionary<string, int>(7)
{
{ "FullTrust", 0 },
{ "LocalIntranet", 0 },
{ "Internet", 0 },
{ "SkipVerification", 0 },
{ "Execution", 0 },
{ "Nothing", 0 },
{ "Everything", 0 }
};
}
int num;
if (DefaultPolicies.ReservedNames.<>f__switch$map2C.TryGetValue(name, out num))
{
if (num == 0)
{
return true;
}
}
}
return false;
}
// Token: 0x0400153D RID: 5437
public const string FullTrust = "FullTrust";
// Token: 0x0400153E RID: 5438
public const string LocalIntranet = "LocalIntranet";
// Token: 0x0400153F RID: 5439
public const string Internet = "Internet";
// Token: 0x04001540 RID: 5440
public const string SkipVerification = "SkipVerification";
// Token: 0x04001541 RID: 5441
public const string Execution = "Execution";
// Token: 0x04001542 RID: 5442
public const string Nothing = "Nothing";
// Token: 0x04001543 RID: 5443
public const string Everything = "Everything";
}
// Token: 0x02000586 RID: 1414
public enum Key
{
// Token: 0x04001546 RID: 5446
Ecma,
// Token: 0x04001547 RID: 5447
MsFinal
}
}
}
+485
View File
@@ -0,0 +1,485 @@
using System;
using System.Collections;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security.Permissions;
namespace System.Security.Policy
{
/// <summary>Defines the set of information that constitutes input to security policy decisions. This class cannot be inherited.</summary>
// Token: 0x02000587 RID: 1415
[ComVisible(true)]
[MonoTODO("Serialization format not compatible with .NET")]
[Serializable]
public sealed class Evidence : IEnumerable, ICollection
{
/// <summary>Initializes a new empty instance of the <see cref="T:System.Security.Policy.Evidence" /> class.</summary>
// Token: 0x060033BE RID: 13246 RVA: 0x000B1F40 File Offset: 0x000B0140
public Evidence()
{
}
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Policy.Evidence" /> class from a shallow copy of an existing one.</summary>
/// <param name="evidence">The <see cref="T:System.Security.Policy.Evidence" /> instance from which to create the new instance. This instance is not deep copied. </param>
/// <exception cref="T:System.ArgumentException">The <paramref name="evidence" /> parameter is not a valid instance of <see cref="T:System.Security.Policy.Evidence" />. </exception>
// Token: 0x060033BF RID: 13247 RVA: 0x000B1F48 File Offset: 0x000B0148
public Evidence(Evidence evidence)
{
if (evidence != null)
{
this.Merge(evidence);
}
}
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Policy.Evidence" /> class from multiple sets of host and assembly evidence.</summary>
/// <param name="hostEvidence">The host evidence from which to create the new instance. </param>
/// <param name="assemblyEvidence">The assembly evidence from which to create the new instance. </param>
// Token: 0x060033C0 RID: 13248 RVA: 0x000B1F60 File Offset: 0x000B0160
public Evidence(object[] hostEvidence, object[] assemblyEvidence)
{
if (hostEvidence != null)
{
this.HostEvidenceList.AddRange(hostEvidence);
}
if (assemblyEvidence != null)
{
this.AssemblyEvidenceList.AddRange(assemblyEvidence);
}
}
/// <summary>Gets the number of evidence objects in the evidence set.</summary>
/// <returns>The number of evidence objects in the evidence set.</returns>
// Token: 0x17000A32 RID: 2610
// (get) Token: 0x060033C1 RID: 13249 RVA: 0x000B1F98 File Offset: 0x000B0198
public int Count
{
get
{
int num = 0;
if (this.hostEvidenceList != null)
{
num += this.hostEvidenceList.Count;
}
if (this.assemblyEvidenceList != null)
{
num += this.assemblyEvidenceList.Count;
}
return num;
}
}
/// <summary>Gets a value indicating whether the evidence set is read-only.</summary>
/// <returns>Always false because read-only evidence sets are not supported.</returns>
// Token: 0x17000A33 RID: 2611
// (get) Token: 0x060033C2 RID: 13250 RVA: 0x000B1FDC File Offset: 0x000B01DC
public bool IsReadOnly
{
get
{
return false;
}
}
/// <summary>Gets a value indicating whether the evidence set is thread-safe.</summary>
/// <returns>Always false because thread-safe evidence sets are not supported.</returns>
// Token: 0x17000A34 RID: 2612
// (get) Token: 0x060033C3 RID: 13251 RVA: 0x000B1FE0 File Offset: 0x000B01E0
public bool IsSynchronized
{
get
{
return false;
}
}
/// <summary>Gets or sets a value indicating whether the evidence is locked.</summary>
/// <returns>true if the evidence is locked; otherwise, false. The default is false.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="ControlEvidence" />
/// </PermissionSet>
// Token: 0x17000A35 RID: 2613
// (get) Token: 0x060033C4 RID: 13252 RVA: 0x000B1FE4 File Offset: 0x000B01E4
// (set) Token: 0x060033C5 RID: 13253 RVA: 0x000B1FEC File Offset: 0x000B01EC
public bool Locked
{
get
{
return this._locked;
}
set
{
this._locked = value;
}
}
/// <summary>Gets the synchronization root.</summary>
/// <returns>Always this (Me in Visual Basic) because synchronization of evidence sets is not supported.</returns>
// Token: 0x17000A36 RID: 2614
// (get) Token: 0x060033C6 RID: 13254 RVA: 0x000B1FF8 File Offset: 0x000B01F8
public object SyncRoot
{
get
{
return this;
}
}
// Token: 0x17000A37 RID: 2615
// (get) Token: 0x060033C7 RID: 13255 RVA: 0x000B1FFC File Offset: 0x000B01FC
internal ArrayList HostEvidenceList
{
get
{
if (this.hostEvidenceList == null)
{
this.hostEvidenceList = ArrayList.Synchronized(new ArrayList());
}
return this.hostEvidenceList;
}
}
// Token: 0x17000A38 RID: 2616
// (get) Token: 0x060033C8 RID: 13256 RVA: 0x000B2020 File Offset: 0x000B0220
internal ArrayList AssemblyEvidenceList
{
get
{
if (this.assemblyEvidenceList == null)
{
this.assemblyEvidenceList = ArrayList.Synchronized(new ArrayList());
}
return this.assemblyEvidenceList;
}
}
/// <summary>Adds the specified assembly evidence to the evidence set.</summary>
/// <param name="id">Any evidence object. </param>
// Token: 0x060033C9 RID: 13257 RVA: 0x000B2044 File Offset: 0x000B0244
public void AddAssembly(object id)
{
this.AssemblyEvidenceList.Add(id);
this._hashCode = 0;
}
/// <summary>Adds the specified evidence supplied by the host to the evidence set.</summary>
/// <param name="id">Any evidence object. </param>
/// <exception cref="T:System.Security.SecurityException">
/// <see cref="P:System.Security.Policy.Evidence.Locked" /> is true and the code that calls this method does not have <see cref="F:System.Security.Permissions.SecurityPermissionFlag.ControlEvidence" />. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="ControlEvidence" />
/// </PermissionSet>
// Token: 0x060033CA RID: 13258 RVA: 0x000B205C File Offset: 0x000B025C
public void AddHost(object id)
{
if (this._locked && SecurityManager.SecurityEnabled)
{
new SecurityPermission(SecurityPermissionFlag.ControlEvidence).Demand();
}
this.HostEvidenceList.Add(id);
this._hashCode = 0;
}
/// <summary>Removes the host and assembly evidence from the evidence set.</summary>
// Token: 0x060033CB RID: 13259 RVA: 0x000B20A0 File Offset: 0x000B02A0
[ComVisible(false)]
public void Clear()
{
if (this.hostEvidenceList != null)
{
this.hostEvidenceList.Clear();
}
if (this.assemblyEvidenceList != null)
{
this.assemblyEvidenceList.Clear();
}
this._hashCode = 0;
}
/// <summary>Copies evidence objects to an <see cref="T:System.Array" />.</summary>
/// <param name="array">The target array to which to copy evidence objects. </param>
/// <param name="index">The zero-based position in the array to which to begin copying evidence objects. </param>
// Token: 0x060033CC RID: 13260 RVA: 0x000B20D8 File Offset: 0x000B02D8
public void CopyTo(Array array, int index)
{
int num = 0;
if (this.hostEvidenceList != null)
{
num = this.hostEvidenceList.Count;
if (num > 0)
{
this.hostEvidenceList.CopyTo(array, index);
}
}
if (this.assemblyEvidenceList != null && this.assemblyEvidenceList.Count > 0)
{
this.assemblyEvidenceList.CopyTo(array, index + num);
}
}
/// <summary>Determines whether the specified <see cref="T:System.Security.Policy.Evidence" /> object is equal to the current <see cref="T:System.Security.Policy.Evidence" />.</summary>
/// <returns>true if the specified <see cref="T:System.Security.Policy.Evidence" /> object is equal to the current <see cref="T:System.Security.Policy.Evidence" />; otherwise, false.</returns>
/// <param name="obj">The <see cref="T:System.Security.Policy.Evidence" /> object to compare with the current <see cref="T:System.Security.Policy.Evidence" />. </param>
// Token: 0x060033CD RID: 13261 RVA: 0x000B2140 File Offset: 0x000B0340
[ComVisible(false)]
public override bool Equals(object obj)
{
if (obj == null)
{
return false;
}
Evidence evidence = obj as Evidence;
if (evidence == null)
{
return false;
}
if (this.HostEvidenceList.Count != evidence.HostEvidenceList.Count)
{
return false;
}
if (this.AssemblyEvidenceList.Count != evidence.AssemblyEvidenceList.Count)
{
return false;
}
for (int i = 0; i < this.hostEvidenceList.Count; i++)
{
bool flag = false;
int j = 0;
while (j < evidence.hostEvidenceList.Count)
{
if (this.hostEvidenceList[i].Equals(evidence.hostEvidenceList[j]))
{
flag = true;
break;
}
i++;
}
if (!flag)
{
return false;
}
}
for (int k = 0; k < this.assemblyEvidenceList.Count; k++)
{
bool flag2 = false;
int l = 0;
while (l < evidence.assemblyEvidenceList.Count)
{
if (this.assemblyEvidenceList[k].Equals(evidence.assemblyEvidenceList[l]))
{
flag2 = true;
break;
}
k++;
}
if (!flag2)
{
return false;
}
}
return true;
}
/// <summary>Enumerates all evidence in the set, both that provided by the host and that provided by the assembly.</summary>
/// <returns>An enumerator for evidence added by both the <see cref="M:System.Security.Policy.Evidence.AddHost(System.Object)" /> method and the <see cref="M:System.Security.Policy.Evidence.AddAssembly(System.Object)" /> method.</returns>
// Token: 0x060033CE RID: 13262 RVA: 0x000B2284 File Offset: 0x000B0484
public IEnumerator GetEnumerator()
{
IEnumerator enumerator = null;
if (this.hostEvidenceList != null)
{
enumerator = this.hostEvidenceList.GetEnumerator();
}
IEnumerator enumerator2 = null;
if (this.assemblyEvidenceList != null)
{
enumerator2 = this.assemblyEvidenceList.GetEnumerator();
}
return new Evidence.EvidenceEnumerator(enumerator, enumerator2);
}
/// <summary>Enumerates evidence provided by the assembly.</summary>
/// <returns>An enumerator for evidence added by the <see cref="M:System.Security.Policy.Evidence.AddAssembly(System.Object)" /> method.</returns>
// Token: 0x060033CF RID: 13263 RVA: 0x000B22CC File Offset: 0x000B04CC
public IEnumerator GetAssemblyEnumerator()
{
return this.AssemblyEvidenceList.GetEnumerator();
}
/// <summary>Gets a hash code for the <see cref="T:System.Security.Policy.Evidence" /> object that is suitable for use in hashing algorithms and data structures such as a hash table.</summary>
/// <returns>A hash code for the current <see cref="T:System.Security.Policy.Evidence" /> object.</returns>
// Token: 0x060033D0 RID: 13264 RVA: 0x000B22DC File Offset: 0x000B04DC
[ComVisible(false)]
public override int GetHashCode()
{
if (this._hashCode == 0)
{
if (this.hostEvidenceList != null)
{
for (int i = 0; i < this.hostEvidenceList.Count; i++)
{
this._hashCode ^= this.hostEvidenceList[i].GetHashCode();
}
}
if (this.assemblyEvidenceList != null)
{
for (int j = 0; j < this.assemblyEvidenceList.Count; j++)
{
this._hashCode ^= this.assemblyEvidenceList[j].GetHashCode();
}
}
}
return this._hashCode;
}
/// <summary>Enumerates evidence supplied by the host.</summary>
/// <returns>An enumerator for evidence added by the <see cref="M:System.Security.Policy.Evidence.AddHost(System.Object)" /> method.</returns>
// Token: 0x060033D1 RID: 13265 RVA: 0x000B2384 File Offset: 0x000B0584
public IEnumerator GetHostEnumerator()
{
return this.HostEvidenceList.GetEnumerator();
}
/// <summary>Merges the specified evidence set into the current evidence set.</summary>
/// <param name="evidence">The evidence set to be merged into the current evidence set. </param>
/// <exception cref="T:System.ArgumentException">The <paramref name="evidence" /> parameter is not a valid instance of <see cref="T:System.Security.Policy.Evidence" />. </exception>
/// <exception cref="T:System.Security.SecurityException">
/// <see cref="P:System.Security.Policy.Evidence.Locked" /> is true, the code that calls this method does not have <see cref="F:System.Security.Permissions.SecurityPermissionFlag.ControlEvidence" />, and the <paramref name="evidence" /> parameter has a host list that is not empty. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="ControlEvidence" />
/// </PermissionSet>
// Token: 0x060033D2 RID: 13266 RVA: 0x000B2394 File Offset: 0x000B0594
public void Merge(Evidence evidence)
{
if (evidence != null && evidence.Count > 0)
{
if (evidence.hostEvidenceList != null)
{
foreach (object obj in evidence.hostEvidenceList)
{
this.AddHost(obj);
}
}
if (evidence.assemblyEvidenceList != null)
{
foreach (object obj2 in evidence.assemblyEvidenceList)
{
this.AddAssembly(obj2);
}
}
this._hashCode = 0;
}
}
/// <summary>Removes the evidence for a given type from the host and assembly enumerations.</summary>
/// <param name="t">The <see cref="T:System.Type" /> of the evidence to be removed. </param>
// Token: 0x060033D3 RID: 13267 RVA: 0x000B248C File Offset: 0x000B068C
[ComVisible(false)]
public void RemoveType(Type t)
{
for (int i = this.hostEvidenceList.Count; i >= 0; i--)
{
if (this.hostEvidenceList.GetType() == t)
{
this.hostEvidenceList.RemoveAt(i);
this._hashCode = 0;
}
}
for (int j = this.assemblyEvidenceList.Count; j >= 0; j--)
{
if (this.assemblyEvidenceList.GetType() == t)
{
this.assemblyEvidenceList.RemoveAt(j);
this._hashCode = 0;
}
}
}
// Token: 0x060033D4 RID: 13268
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern bool IsAuthenticodePresent(Assembly a);
// Token: 0x060033D5 RID: 13269 RVA: 0x000B251C File Offset: 0x000B071C
internal static Evidence GetDefaultHostEvidence(Assembly a)
{
return new Evidence();
}
// Token: 0x04001548 RID: 5448
private bool _locked;
// Token: 0x04001549 RID: 5449
private ArrayList hostEvidenceList;
// Token: 0x0400154A RID: 5450
private ArrayList assemblyEvidenceList;
// Token: 0x0400154B RID: 5451
private int _hashCode;
// Token: 0x02000588 RID: 1416
private class EvidenceEnumerator : IEnumerator
{
// Token: 0x060033D6 RID: 13270 RVA: 0x000B2524 File Offset: 0x000B0724
public EvidenceEnumerator(IEnumerator hostenum, IEnumerator assemblyenum)
{
this.hostEnum = hostenum;
this.assemblyEnum = assemblyenum;
this.currentEnum = this.hostEnum;
}
// Token: 0x060033D7 RID: 13271 RVA: 0x000B2554 File Offset: 0x000B0754
public bool MoveNext()
{
if (this.currentEnum == null)
{
return false;
}
bool flag = this.currentEnum.MoveNext();
if (!flag && this.hostEnum == this.currentEnum && this.assemblyEnum != null)
{
this.currentEnum = this.assemblyEnum;
flag = this.assemblyEnum.MoveNext();
}
return flag;
}
// Token: 0x060033D8 RID: 13272 RVA: 0x000B25B8 File Offset: 0x000B07B8
public void Reset()
{
if (this.hostEnum != null)
{
this.hostEnum.Reset();
this.currentEnum = this.hostEnum;
}
else
{
this.currentEnum = this.assemblyEnum;
}
if (this.assemblyEnum != null)
{
this.assemblyEnum.Reset();
}
}
// Token: 0x17000A39 RID: 2617
// (get) Token: 0x060033D9 RID: 13273 RVA: 0x000B2610 File Offset: 0x000B0810
public object Current
{
get
{
return this.currentEnum.Current;
}
}
// Token: 0x0400154C RID: 5452
private IEnumerator currentEnum;
// Token: 0x0400154D RID: 5453
private IEnumerator hostEnum;
// Token: 0x0400154E RID: 5454
private IEnumerator assemblyEnum;
}
}
}
@@ -0,0 +1,204 @@
using System;
using System.Runtime.InteropServices;
using System.Security.Permissions;
namespace System.Security.Policy
{
/// <summary>Grants permission to manipulate files located in the code assemblies to code assemblies that match the membership condition. This class cannot be inherited.</summary>
// Token: 0x02000589 RID: 1417
[ComVisible(true)]
[Serializable]
public sealed class FileCodeGroup : CodeGroup
{
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Policy.FileCodeGroup" /> class.</summary>
/// <param name="membershipCondition">A membership condition that tests evidence to determine whether this code group applies policy. </param>
/// <param name="access">One of the <see cref="T:System.Security.Permissions.FileIOPermissionAccess" /> values. This value is used to construct the <see cref="T:System.Security.Permissions.FileIOPermission" /> that is granted. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="membershipCondition" /> parameter is null. </exception>
/// <exception cref="T:System.ArgumentException">The type of the <paramref name="membershipCondition" /> parameter is not valid.-or- The type of the <paramref name="access" /> parameter is not valid. </exception>
// Token: 0x060033DA RID: 13274 RVA: 0x000B2620 File Offset: 0x000B0820
public FileCodeGroup(IMembershipCondition membershipCondition, FileIOPermissionAccess access)
: base(membershipCondition, null)
{
this.m_access = access;
}
// Token: 0x060033DB RID: 13275 RVA: 0x000B2634 File Offset: 0x000B0834
internal FileCodeGroup(SecurityElement e, PolicyLevel level)
: base(e, level)
{
}
/// <summary>Makes a deep copy of the current code group.</summary>
/// <returns>An equivalent copy of the current code group, including its membership conditions and child code groups.</returns>
// Token: 0x060033DC RID: 13276 RVA: 0x000B2640 File Offset: 0x000B0840
public override CodeGroup Copy()
{
FileCodeGroup fileCodeGroup = new FileCodeGroup(base.MembershipCondition, this.m_access);
fileCodeGroup.Name = base.Name;
fileCodeGroup.Description = base.Description;
foreach (object obj in base.Children)
{
CodeGroup codeGroup = (CodeGroup)obj;
fileCodeGroup.AddChild(codeGroup.Copy());
}
return fileCodeGroup;
}
/// <summary>Gets the merge logic.</summary>
/// <returns>The string "Union".</returns>
// Token: 0x17000A3A RID: 2618
// (get) Token: 0x060033DD RID: 13277 RVA: 0x000B26E0 File Offset: 0x000B08E0
public override string MergeLogic
{
get
{
return "Union";
}
}
/// <summary>Resolves policy for the code group and its descendants for a set of evidence.</summary>
/// <returns>A policy statement consisting of the permissions granted by the code group with optional attributes, or null if the code group does not apply (the membership condition does not match the specified evidence).</returns>
/// <param name="evidence">The evidence for the assembly. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="evidence" /> parameter is null. </exception>
/// <exception cref="T:System.Security.Policy.PolicyException">The current policy is null.-or- More than one code group (including the parent code group and all child code groups) is marked <see cref="F:System.Security.Policy.PolicyStatementAttribute.Exclusive" />. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" PathDiscovery="*AllFiles*" />
/// </PermissionSet>
// Token: 0x060033DE RID: 13278 RVA: 0x000B26E8 File Offset: 0x000B08E8
public override PolicyStatement Resolve(Evidence evidence)
{
if (evidence == null)
{
throw new ArgumentNullException("evidence");
}
if (!base.MembershipCondition.Check(evidence))
{
return null;
}
PermissionSet permissionSet = null;
if (base.PolicyStatement == null)
{
permissionSet = new PermissionSet(PermissionState.None);
}
else
{
permissionSet = base.PolicyStatement.PermissionSet.Copy();
}
if (base.Children.Count > 0)
{
foreach (object obj in base.Children)
{
CodeGroup codeGroup = (CodeGroup)obj;
PolicyStatement policyStatement = codeGroup.Resolve(evidence);
if (policyStatement != null)
{
permissionSet = permissionSet.Union(policyStatement.PermissionSet);
}
}
}
PolicyStatement policyStatement2;
if (base.PolicyStatement != null)
{
policyStatement2 = base.PolicyStatement.Copy();
}
else
{
policyStatement2 = PolicyStatement.Empty();
}
policyStatement2.PermissionSet = permissionSet;
return policyStatement2;
}
/// <summary>Resolves matching code groups.</summary>
/// <returns>A <see cref="T:System.Security.Policy.CodeGroup" /> that is the root of the tree of matching code groups.</returns>
/// <param name="evidence">The evidence for the assembly. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="evidence" /> parameter is null. </exception>
// Token: 0x060033DF RID: 13279 RVA: 0x000B2800 File Offset: 0x000B0A00
public override CodeGroup ResolveMatchingCodeGroups(Evidence evidence)
{
if (evidence == null)
{
throw new ArgumentNullException("evidence");
}
if (!base.MembershipCondition.Check(evidence))
{
return null;
}
FileCodeGroup fileCodeGroup = new FileCodeGroup(base.MembershipCondition, this.m_access);
foreach (object obj in base.Children)
{
CodeGroup codeGroup = (CodeGroup)obj;
CodeGroup codeGroup2 = codeGroup.ResolveMatchingCodeGroups(evidence);
if (codeGroup2 != null)
{
fileCodeGroup.AddChild(codeGroup2);
}
}
return fileCodeGroup;
}
/// <summary>Gets a string representation of the attributes of the policy statement for the code group.</summary>
/// <returns>Always null.</returns>
// Token: 0x17000A3B RID: 2619
// (get) Token: 0x060033E0 RID: 13280 RVA: 0x000B28B8 File Offset: 0x000B0AB8
public override string AttributeString
{
get
{
return null;
}
}
/// <summary>Gets the name of the named permission set for the code group.</summary>
/// <returns>The concatenatation of the string "Same directory FileIO - " and the access type.</returns>
// Token: 0x17000A3C RID: 2620
// (get) Token: 0x060033E1 RID: 13281 RVA: 0x000B28BC File Offset: 0x000B0ABC
public override string PermissionSetName
{
get
{
return "Same directory FileIO - " + this.m_access.ToString();
}
}
/// <summary>Determines whether the specified code group is equivalent to the current code group.</summary>
/// <returns>true if the specified code group is equivalent to the current code group; otherwise, false.</returns>
/// <param name="o">The code group to compare with the current code group. </param>
// Token: 0x060033E2 RID: 13282 RVA: 0x000B28D8 File Offset: 0x000B0AD8
public override bool Equals(object o)
{
return o is FileCodeGroup && this.m_access == ((FileCodeGroup)o).m_access && base.Equals((CodeGroup)o, false);
}
/// <summary>Gets the hash code of the current code group.</summary>
/// <returns>The hash code of the current code group.</returns>
// Token: 0x060033E3 RID: 13283 RVA: 0x000B2918 File Offset: 0x000B0B18
public override int GetHashCode()
{
return this.m_access.GetHashCode();
}
// Token: 0x060033E4 RID: 13284 RVA: 0x000B292C File Offset: 0x000B0B2C
protected override void ParseXml(SecurityElement e, PolicyLevel level)
{
string text = e.Attribute("Access");
if (text != null)
{
this.m_access = (FileIOPermissionAccess)((int)Enum.Parse(typeof(FileIOPermissionAccess), text, true));
}
else
{
this.m_access = FileIOPermissionAccess.NoAccess;
}
}
// Token: 0x060033E5 RID: 13285 RVA: 0x000B2974 File Offset: 0x000B0B74
protected override void CreateXml(SecurityElement element, PolicyLevel level)
{
element.AddAttribute("Access", this.m_access.ToString());
}
// Token: 0x0400154F RID: 5455
private FileIOPermissionAccess m_access;
}
}
@@ -0,0 +1,124 @@
using System;
using System.Runtime.InteropServices;
namespace System.Security.Policy
{
/// <summary>Allows security policy to be defined by the union of the policy statement of a code group and that of the first child code group that matches. This class cannot be inherited.</summary>
// Token: 0x0200058A RID: 1418
[ComVisible(true)]
[Serializable]
public sealed class FirstMatchCodeGroup : CodeGroup
{
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Policy.FirstMatchCodeGroup" /> class.</summary>
/// <param name="membershipCondition">A membership condition that tests evidence to determine whether this code group applies policy. </param>
/// <param name="policy">The policy statement for the code group in the form of a permission set and attributes to grant code that matches the membership condition. </param>
/// <exception cref="T:System.ArgumentException">The type of the <paramref name="membershipCondition" /> parameter is not valid.-or- The type of the <paramref name="policy" /> parameter is not valid. </exception>
// Token: 0x060033E6 RID: 13286 RVA: 0x000B2994 File Offset: 0x000B0B94
public FirstMatchCodeGroup(IMembershipCondition membershipCondition, PolicyStatement policy)
: base(membershipCondition, policy)
{
}
// Token: 0x060033E7 RID: 13287 RVA: 0x000B29A0 File Offset: 0x000B0BA0
internal FirstMatchCodeGroup(SecurityElement e, PolicyLevel level)
: base(e, level)
{
}
/// <summary>Gets the merge logic.</summary>
/// <returns>The string "First Match".</returns>
// Token: 0x17000A3D RID: 2621
// (get) Token: 0x060033E8 RID: 13288 RVA: 0x000B29AC File Offset: 0x000B0BAC
public override string MergeLogic
{
get
{
return "First Match";
}
}
/// <summary>Makes a deep copy of the code group.</summary>
/// <returns>An equivalent copy of the code group, including its membership conditions and child code groups.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x060033E9 RID: 13289 RVA: 0x000B29B4 File Offset: 0x000B0BB4
public override CodeGroup Copy()
{
FirstMatchCodeGroup firstMatchCodeGroup = this.CopyNoChildren();
foreach (object obj in base.Children)
{
CodeGroup codeGroup = (CodeGroup)obj;
firstMatchCodeGroup.AddChild(codeGroup.Copy());
}
return firstMatchCodeGroup;
}
/// <summary>Resolves policy for the code group and its descendants for a set of evidence.</summary>
/// <returns>A policy statement consisting of the permissions granted by the code group with optional attributes, or null if the code group does not apply (the membership condition does not match the specified evidence).</returns>
/// <param name="evidence">The evidence for the assembly. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="evidence" /> parameter is null. </exception>
/// <exception cref="T:System.Security.Policy.PolicyException">More than one code group (including the parent code group and any child code groups) is marked <see cref="F:System.Security.Policy.PolicyStatementAttribute.Exclusive" />. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x060033EA RID: 13290 RVA: 0x000B2A30 File Offset: 0x000B0C30
public override PolicyStatement Resolve(Evidence evidence)
{
if (evidence == null)
{
throw new ArgumentNullException("evidence");
}
if (!base.MembershipCondition.Check(evidence))
{
return null;
}
foreach (object obj in base.Children)
{
CodeGroup codeGroup = (CodeGroup)obj;
PolicyStatement policyStatement = codeGroup.Resolve(evidence);
if (policyStatement != null)
{
return policyStatement;
}
}
return base.PolicyStatement;
}
/// <summary>Resolves matching code groups.</summary>
/// <returns>A <see cref="T:System.Security.Policy.CodeGroup" /> that is the root of the tree of matching code groups.</returns>
/// <param name="evidence">The evidence for the assembly. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="evidence" /> parameter is null. </exception>
// Token: 0x060033EB RID: 13291 RVA: 0x000B2ADC File Offset: 0x000B0CDC
public override CodeGroup ResolveMatchingCodeGroups(Evidence evidence)
{
if (evidence == null)
{
throw new ArgumentNullException("evidence");
}
if (!base.MembershipCondition.Check(evidence))
{
return null;
}
foreach (object obj in base.Children)
{
CodeGroup codeGroup = (CodeGroup)obj;
if (codeGroup.Resolve(evidence) != null)
{
return codeGroup.Copy();
}
}
return this.CopyNoChildren();
}
// Token: 0x060033EC RID: 13292 RVA: 0x000B2B88 File Offset: 0x000B0D88
private FirstMatchCodeGroup CopyNoChildren()
{
return new FirstMatchCodeGroup(base.MembershipCondition, base.PolicyStatement)
{
Name = base.Name,
Description = base.Description
};
}
}
}
@@ -0,0 +1,76 @@
using System;
using System.Runtime.InteropServices;
using System.Security.Permissions;
namespace System.Security.Policy
{
/// <summary>Confirms that a code assembly originates in the global assembly cache (GAC) as evidence for policy evaluation. This class cannot be inherited.</summary>
// Token: 0x0200058B RID: 1419
[ComVisible(true)]
[Serializable]
public sealed class GacInstalled : IBuiltInEvidence, IIdentityPermissionFactory
{
// Token: 0x060033EE RID: 13294 RVA: 0x000B2BC8 File Offset: 0x000B0DC8
int IBuiltInEvidence.GetRequiredSize(bool verbose)
{
return 1;
}
// Token: 0x060033EF RID: 13295 RVA: 0x000B2BCC File Offset: 0x000B0DCC
int IBuiltInEvidence.InitFromBuffer(char[] buffer, int position)
{
return position;
}
// Token: 0x060033F0 RID: 13296 RVA: 0x000B2BD0 File Offset: 0x000B0DD0
int IBuiltInEvidence.OutputToBuffer(char[] buffer, int position, bool verbose)
{
buffer[position] = '\t';
return position + 1;
}
/// <summary>Creates an equivalent copy of the current object.</summary>
/// <returns>A new <see cref="T:System.Security.Policy.GacInstalled" /> object.</returns>
// Token: 0x060033F1 RID: 13297 RVA: 0x000B2BDC File Offset: 0x000B0DDC
public object Copy()
{
return new GacInstalled();
}
/// <summary>Creates a new identity permission that corresponds to the current object.</summary>
/// <returns>A new <see cref="T:System.Security.Permissions.GacIdentityPermission" />.</returns>
/// <param name="evidence">The <see cref="T:System.Security.Policy.Evidence" /> from which to construct the identity permission. </param>
// Token: 0x060033F2 RID: 13298 RVA: 0x000B2BE4 File Offset: 0x000B0DE4
public IPermission CreateIdentityPermission(Evidence evidence)
{
return new GacIdentityPermission();
}
/// <summary>Indicates whether the current object is equivalent to the specified object.</summary>
/// <returns>true if <paramref name="o" /> is a <see cref="T:System.Security.Policy.GacInstalled" /> object; otherwise, false.</returns>
/// <param name="o">The object to compare with the current object. </param>
// Token: 0x060033F3 RID: 13299 RVA: 0x000B2BEC File Offset: 0x000B0DEC
public override bool Equals(object o)
{
return o != null && o is GacInstalled;
}
/// <summary>Returns a hash code for the current object.</summary>
/// <returns>0 (zero).</returns>
// Token: 0x060033F4 RID: 13300 RVA: 0x000B2C00 File Offset: 0x000B0E00
public override int GetHashCode()
{
return 0;
}
/// <summary>Returns a string representation of the current object.</summary>
/// <returns>A string representation of the current object.</returns>
// Token: 0x060033F5 RID: 13301 RVA: 0x000B2C04 File Offset: 0x000B0E04
public override string ToString()
{
SecurityElement securityElement = new SecurityElement(base.GetType().FullName);
securityElement.AddAttribute("version", "1");
return securityElement.ToString();
}
}
}
@@ -0,0 +1,112 @@
using System;
using System.Collections;
using System.Runtime.InteropServices;
namespace System.Security.Policy
{
/// <summary>Determines whether an assembly belongs to a code group by testing its global assembly cache membership. This class cannot be inherited.</summary>
// Token: 0x0200058C RID: 1420
[ComVisible(true)]
[Serializable]
public sealed class GacMembershipCondition : IConstantMembershipCondition, IMembershipCondition, ISecurityEncodable, ISecurityPolicyEncodable
{
/// <summary>Indicates whether the specified evidence satisfies the membership condition.</summary>
/// <returns>true if the specified evidence satisfies the membership condition; otherwise, false.</returns>
/// <param name="evidence">The <see cref="T:System.Security.Policy.Evidence" /> against which to make the test. </param>
// Token: 0x060033F7 RID: 13303 RVA: 0x000B2C48 File Offset: 0x000B0E48
public bool Check(Evidence evidence)
{
if (evidence == null)
{
return false;
}
IEnumerator hostEnumerator = evidence.GetHostEnumerator();
while (hostEnumerator.MoveNext())
{
if (hostEnumerator.Current is GacInstalled)
{
return true;
}
}
return false;
}
/// <summary>Creates an equivalent copy of the membership condition.</summary>
/// <returns>A new <see cref="T:System.Security.Policy.GacMembershipCondition" /> object.</returns>
// Token: 0x060033F8 RID: 13304 RVA: 0x000B2C88 File Offset: 0x000B0E88
public IMembershipCondition Copy()
{
return new GacMembershipCondition();
}
/// <summary>Indicates whether the current object is equivalent to the specified object.</summary>
/// <returns>true if <paramref name="o" /> is a <see cref="T:System.Security.Policy.GacMembershipCondition" />; otherwise, false.</returns>
/// <param name="o">The object to compare with the current object. </param>
// Token: 0x060033F9 RID: 13305 RVA: 0x000B2C90 File Offset: 0x000B0E90
public override bool Equals(object o)
{
return o != null && o is GacMembershipCondition;
}
/// <summary>Uses the specified XML encoding to reconstruct a security object.</summary>
/// <param name="e">The <see cref="T:System.Security.SecurityElement" /> that contains the XML encoding to use to reconstruct the security object. </param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="e" /> is null. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="e" /> is not a valid membership condition element. </exception>
// Token: 0x060033FA RID: 13306 RVA: 0x000B2CA4 File Offset: 0x000B0EA4
public void FromXml(SecurityElement e)
{
this.FromXml(e, null);
}
/// <summary>Uses the specified XML encoding to reconstruct a security object, using the specified policy level context.</summary>
/// <param name="e">The <see cref="T:System.Security.SecurityElement" /> that contains the XML encoding to use to reconstruct the security object. </param>
/// <param name="level">The <see cref="T:System.Security.Policy.PolicyLevel" /> context for resolving <see cref="T:System.Security.NamedPermissionSet" /> references. </param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="e" /> is null. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="e" /> is not a valid membership condition element. </exception>
// Token: 0x060033FB RID: 13307 RVA: 0x000B2CB0 File Offset: 0x000B0EB0
public void FromXml(SecurityElement e, PolicyLevel level)
{
MembershipConditionHelper.CheckSecurityElement(e, "e", this.version, this.version);
}
/// <summary>Gets a hash code for the current membership condition.</summary>
/// <returns>0 (zero).</returns>
// Token: 0x060033FC RID: 13308 RVA: 0x000B2CCC File Offset: 0x000B0ECC
public override int GetHashCode()
{
return 0;
}
/// <summary>Returns a string representation of the membership condition.</summary>
/// <returns>A string representation of the membership condition.</returns>
// Token: 0x060033FD RID: 13309 RVA: 0x000B2CD0 File Offset: 0x000B0ED0
public override string ToString()
{
return "GAC";
}
/// <summary>Creates an XML encoding of the security object and its current state.</summary>
/// <returns>A <see cref="T:System.Security.SecurityElement" /> that contains the XML encoding of the security object, including any state information.</returns>
// Token: 0x060033FE RID: 13310 RVA: 0x000B2CD8 File Offset: 0x000B0ED8
public SecurityElement ToXml()
{
return this.ToXml(null);
}
/// <summary>Creates an XML encoding of the security object and its current state, using the specified policy level context.</summary>
/// <returns>A <see cref="T:System.Security.SecurityElement" /> that contains the XML encoding of the security object, including any state information.</returns>
/// <param name="level">The <see cref="T:System.Security.Policy.PolicyLevel" /> context for resolving <see cref="T:System.Security.NamedPermissionSet" /> references. </param>
// Token: 0x060033FF RID: 13311 RVA: 0x000B2CE4 File Offset: 0x000B0EE4
public SecurityElement ToXml(PolicyLevel level)
{
return MembershipConditionHelper.Element(typeof(GacMembershipCondition), this.version);
}
// Token: 0x04001550 RID: 5456
private readonly int version = 1;
}
}
+222
View File
@@ -0,0 +1,222 @@
using System;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Security.Cryptography;
using System.Text;
namespace System.Security.Policy
{
/// <summary>Provides evidence about the hash value for an assembly. This class cannot be inherited.</summary>
// Token: 0x0200058D RID: 1421
[ComVisible(true)]
[Serializable]
public sealed class Hash : ISerializable, IBuiltInEvidence
{
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Policy.Hash" /> class.</summary>
/// <param name="assembly">The <see cref="T:System.Reflection.Assembly" /> for which to compute the hash value. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="assembly" /> parameter is null. </exception>
// Token: 0x06003400 RID: 13312 RVA: 0x000B2D08 File Offset: 0x000B0F08
public Hash(Assembly assembly)
{
if (assembly == null)
{
throw new ArgumentNullException("assembly");
}
this.assembly = assembly;
}
// Token: 0x06003401 RID: 13313 RVA: 0x000B2D28 File Offset: 0x000B0F28
internal Hash()
{
}
// Token: 0x06003402 RID: 13314 RVA: 0x000B2D30 File Offset: 0x000B0F30
internal Hash(SerializationInfo info, StreamingContext context)
{
this.data = (byte[])info.GetValue("RawData", typeof(byte[]));
}
// Token: 0x06003403 RID: 13315 RVA: 0x000B2D64 File Offset: 0x000B0F64
int IBuiltInEvidence.GetRequiredSize(bool verbose)
{
return (!verbose) ? 0 : 5;
}
// Token: 0x06003404 RID: 13316 RVA: 0x000B2D74 File Offset: 0x000B0F74
[MonoTODO("IBuiltInEvidence")]
int IBuiltInEvidence.InitFromBuffer(char[] buffer, int position)
{
return 0;
}
// Token: 0x06003405 RID: 13317 RVA: 0x000B2D78 File Offset: 0x000B0F78
[MonoTODO("IBuiltInEvidence")]
int IBuiltInEvidence.OutputToBuffer(char[] buffer, int position, bool verbose)
{
return 0;
}
/// <summary>Gets the <see cref="T:System.Security.Cryptography.MD5" /> hash value for the assembly.</summary>
/// <returns>A byte array that represents the <see cref="T:System.Security.Cryptography.MD5" /> hash value for the assembly.</returns>
// Token: 0x17000A3E RID: 2622
// (get) Token: 0x06003406 RID: 13318 RVA: 0x000B2D7C File Offset: 0x000B0F7C
public byte[] MD5
{
get
{
if (this._md5 != null)
{
return this._md5;
}
if (this.assembly == null && this._sha1 != null)
{
string text = Locale.GetText("No assembly data. This instance was initialized with an MSHA1 digest value.");
throw new SecurityException(text);
}
HashAlgorithm hashAlgorithm = global::System.Security.Cryptography.MD5.Create();
this._md5 = this.GenerateHash(hashAlgorithm);
return this._md5;
}
}
/// <summary>Gets the <see cref="T:System.Security.Cryptography.SHA1" /> hash value for the assembly.</summary>
/// <returns>A byte array that represents the <see cref="T:System.Security.Cryptography.SHA1" /> hash value for the assembly.</returns>
// Token: 0x17000A3F RID: 2623
// (get) Token: 0x06003407 RID: 13319 RVA: 0x000B2DDC File Offset: 0x000B0FDC
public byte[] SHA1
{
get
{
if (this._sha1 != null)
{
return this._sha1;
}
if (this.assembly == null && this._md5 != null)
{
string text = Locale.GetText("No assembly data. This instance was initialized with an MD5 digest value.");
throw new SecurityException(text);
}
HashAlgorithm hashAlgorithm = global::System.Security.Cryptography.SHA1.Create();
this._sha1 = this.GenerateHash(hashAlgorithm);
return this._sha1;
}
}
/// <summary>Computes the hash value for the assembly using the specified hash algorithm.</summary>
/// <returns>A byte array that represents the hash value for the assembly.</returns>
/// <param name="hashAlg">The hash algorithm to use to compute the hash value for the assembly. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="hashAlg" /> parameter is null. </exception>
/// <exception cref="T:System.Security.SecurityException">The hash value for the assembly cannot be generated.</exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// <IPermission class="System.Security.Permissions.KeyContainerPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x06003408 RID: 13320 RVA: 0x000B2E3C File Offset: 0x000B103C
public byte[] GenerateHash(HashAlgorithm hashAlg)
{
if (hashAlg == null)
{
throw new ArgumentNullException("hashAlg");
}
return hashAlg.ComputeHash(this.GetData());
}
/// <summary>Gets the <see cref="T:System.Runtime.Serialization.SerializationInfo" /> object with the parameter name and additional exception information.</summary>
/// <param name="info">The object that holds the serialized object data. </param>
/// <param name="context">The contextual information about the source or destination. </param>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x06003409 RID: 13321 RVA: 0x000B2E5C File Offset: 0x000B105C
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
if (info == null)
{
throw new ArgumentNullException("info");
}
info.AddValue("RawData", this.GetData());
}
/// <summary>Returns a string representation of the current <see cref="T:System.Security.Policy.Hash" />.</summary>
/// <returns>A representation of the current <see cref="T:System.Security.Policy.Hash" />.</returns>
// Token: 0x0600340A RID: 13322 RVA: 0x000B2E8C File Offset: 0x000B108C
public override string ToString()
{
SecurityElement securityElement = new SecurityElement(base.GetType().FullName);
securityElement.AddAttribute("version", "1");
StringBuilder stringBuilder = new StringBuilder();
byte[] array = this.GetData();
for (int i = 0; i < array.Length; i++)
{
stringBuilder.Append(array[i].ToString("X2"));
}
securityElement.AddChild(new SecurityElement("RawData", stringBuilder.ToString()));
return securityElement.ToString();
}
// Token: 0x0600340B RID: 13323 RVA: 0x000B2F10 File Offset: 0x000B1110
private byte[] GetData()
{
if (this.assembly == null && this.data == null)
{
string text = Locale.GetText("No assembly data.");
throw new SecurityException(text);
}
if (this.data == null)
{
FileStream fileStream = new FileStream(this.assembly.Location, FileMode.Open, FileAccess.Read);
this.data = new byte[fileStream.Length];
fileStream.Read(this.data, 0, (int)fileStream.Length);
}
return this.data;
}
/// <summary>Creates a <see cref="T:System.Security.Policy.Hash" /> object containing an <see cref="T:System.Security.Cryptography.MD5" /> hash value.</summary>
/// <returns>A <see cref="T:System.Security.Policy.Hash" /> object containing the hash value provided by the <paramref name="md5" /> parameter.</returns>
/// <param name="md5">A byte array containing an <see cref="T:System.Security.Cryptography.MD5" /> hash value.</param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="md5" /> parameter is null. </exception>
// Token: 0x0600340C RID: 13324 RVA: 0x000B2F90 File Offset: 0x000B1190
public static Hash CreateMD5(byte[] md5)
{
if (md5 == null)
{
throw new ArgumentNullException("md5");
}
return new Hash
{
_md5 = md5
};
}
/// <summary>Creates a <see cref="T:System.Security.Policy.Hash" /> object containing an <see cref="T:System.Security.Cryptography.SHA1" /> hash value.</summary>
/// <returns>A <see cref="T:System.Security.Policy.Hash" /> object containing the hash value provided by the <paramref name="sha1" /> parameter.</returns>
/// <param name="sha1">A byte array containing a <see cref="T:System.Security.Cryptography.SHA1" /> hash value.</param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="sha1" /> parameter is null. </exception>
// Token: 0x0600340D RID: 13325 RVA: 0x000B2FBC File Offset: 0x000B11BC
public static Hash CreateSHA1(byte[] sha1)
{
if (sha1 == null)
{
throw new ArgumentNullException("sha1");
}
return new Hash
{
_sha1 = sha1
};
}
// Token: 0x04001551 RID: 5457
private Assembly assembly;
// Token: 0x04001552 RID: 5458
private byte[] data;
// Token: 0x04001553 RID: 5459
internal byte[] _md5;
// Token: 0x04001554 RID: 5460
internal byte[] _sha1;
}
}
@@ -0,0 +1,274 @@
using System;
using System.Collections;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Security.Cryptography;
using Mono.Security.Cryptography;
namespace System.Security.Policy
{
/// <summary>Determines whether an assembly belongs to a code group by testing its hash value. This class cannot be inherited.</summary>
// Token: 0x0200058E RID: 1422
[ComVisible(true)]
[Serializable]
public sealed class HashMembershipCondition : ISerializable, IDeserializationCallback, IMembershipCondition, ISecurityEncodable, ISecurityPolicyEncodable
{
// Token: 0x0600340E RID: 13326 RVA: 0x000B2FE8 File Offset: 0x000B11E8
internal HashMembershipCondition()
{
}
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Policy.HashMembershipCondition" /> class with the hash algorithm and hash value that determine membership.</summary>
/// <param name="hashAlg">The hash algorithm to use to compute the hash value for the assembly. </param>
/// <param name="value">The hash value for which to test. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="hashAlg" /> parameter is null.-or- The <paramref name="value" /> parameter is null. </exception>
/// <exception cref="T:System.ArgumentException">The <paramref name="hashAlg" /> parameter is not a valid hash algorithm. </exception>
// Token: 0x0600340F RID: 13327 RVA: 0x000B2FF8 File Offset: 0x000B11F8
public HashMembershipCondition(HashAlgorithm hashAlg, byte[] value)
{
if (hashAlg == null)
{
throw new ArgumentNullException("hashAlg");
}
if (value == null)
{
throw new ArgumentNullException("value");
}
this.hash_algorithm = hashAlg;
this.hash_value = (byte[])value.Clone();
}
/// <summary>Runs when the entire object graph has been deserialized.</summary>
/// <param name="sender">The object that initiated the callback. The functionality for this parameter is not currently implemented.</param>
// Token: 0x06003410 RID: 13328 RVA: 0x000B304C File Offset: 0x000B124C
[MonoTODO("fx 2.0")]
void IDeserializationCallback.OnDeserialization(object sender)
{
}
/// <summary>Populates a <see cref="T:System.Runtime.Serialization.SerializationInfo" /> with the data needed to serialize the target object.</summary>
/// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo" /> to populate with data. </param>
/// <param name="context">The destination <see cref="T:System.Runtime.Serialization.StreamingContext" /> for this serialization. </param>
// Token: 0x06003411 RID: 13329 RVA: 0x000B3050 File Offset: 0x000B1250
[MonoTODO("fx 2.0")]
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
{
}
/// <summary>Gets or sets the hash algorithm to use for the membership condition.</summary>
/// <returns>The hash algorithm to use for the membership condition.</returns>
/// <exception cref="T:System.ArgumentNullException">An attempt is made to set <see cref="P:System.Security.Policy.HashMembershipCondition.HashAlgorithm" /> to null. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x17000A40 RID: 2624
// (get) Token: 0x06003412 RID: 13330 RVA: 0x000B3054 File Offset: 0x000B1254
// (set) Token: 0x06003413 RID: 13331 RVA: 0x000B3074 File Offset: 0x000B1274
public HashAlgorithm HashAlgorithm
{
get
{
if (this.hash_algorithm == null)
{
this.hash_algorithm = new SHA1Managed();
}
return this.hash_algorithm;
}
set
{
if (value == null)
{
throw new ArgumentNullException("HashAlgorithm");
}
this.hash_algorithm = value;
}
}
/// <summary>Gets or sets the hash value for which the membership condition tests.</summary>
/// <returns>The hash value for which the membership condition tests.</returns>
/// <exception cref="T:System.ArgumentNullException">An attempt is made to set <see cref="P:System.Security.Policy.HashMembershipCondition.HashValue" /> to null. </exception>
// Token: 0x17000A41 RID: 2625
// (get) Token: 0x06003414 RID: 13332 RVA: 0x000B3090 File Offset: 0x000B1290
// (set) Token: 0x06003415 RID: 13333 RVA: 0x000B30C0 File Offset: 0x000B12C0
public byte[] HashValue
{
get
{
if (this.hash_value == null)
{
throw new ArgumentException(Locale.GetText("No HashValue available."));
}
return (byte[])this.hash_value.Clone();
}
set
{
if (value == null)
{
throw new ArgumentNullException("HashValue");
}
this.hash_value = (byte[])value.Clone();
}
}
/// <summary>Determines whether the specified evidence satisfies the membership condition.</summary>
/// <returns>true if the specified evidence satisfies the membership condition; otherwise, false.</returns>
/// <param name="evidence">The evidence set against which to make the test. </param>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// <IPermission class="System.Security.Permissions.KeyContainerPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x06003416 RID: 13334 RVA: 0x000B30F0 File Offset: 0x000B12F0
public bool Check(Evidence evidence)
{
if (evidence == null)
{
return false;
}
IEnumerator hostEnumerator = evidence.GetHostEnumerator();
while (hostEnumerator.MoveNext())
{
object obj = hostEnumerator.Current;
Hash hash = obj as Hash;
if (hash != null)
{
if (this.Compare(this.hash_value, hash.GenerateHash(this.hash_algorithm)))
{
return true;
}
break;
}
}
return false;
}
/// <summary>Creates an equivalent copy of the membership condition.</summary>
/// <returns>A new, identical copy of the current membership condition.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x06003417 RID: 13335 RVA: 0x000B3158 File Offset: 0x000B1358
public IMembershipCondition Copy()
{
return new HashMembershipCondition(this.hash_algorithm, this.hash_value);
}
/// <summary>Determines whether the <see cref="P:System.Security.Policy.HashMembershipCondition.HashValue" /> and the <see cref="P:System.Security.Policy.HashMembershipCondition.HashAlgorithm" /> from the specified object are equivalent to the <see cref="P:System.Security.Policy.HashMembershipCondition.HashValue" /> and <see cref="P:System.Security.Policy.HashMembershipCondition.HashAlgorithm" /> contained in the current <see cref="T:System.Security.Policy.HashMembershipCondition" />.</summary>
/// <returns>true if the <see cref="P:System.Security.Policy.HashMembershipCondition.HashValue" /> and <see cref="P:System.Security.Policy.HashMembershipCondition.HashAlgorithm" /> from the specified object is equivalent to the <see cref="P:System.Security.Policy.HashMembershipCondition.HashValue" /> and <see cref="P:System.Security.Policy.HashMembershipCondition.HashAlgorithm" /> contained in the current <see cref="T:System.Security.Policy.HashMembershipCondition" />; otherwise, false.</returns>
/// <param name="o">The object to compare to the current <see cref="T:System.Security.Policy.HashMembershipCondition" />. </param>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x06003418 RID: 13336 RVA: 0x000B316C File Offset: 0x000B136C
public override bool Equals(object o)
{
HashMembershipCondition hashMembershipCondition = o as HashMembershipCondition;
return hashMembershipCondition != null && hashMembershipCondition.HashAlgorithm == this.hash_algorithm && this.Compare(this.hash_value, hashMembershipCondition.hash_value);
}
/// <summary>Creates an XML encoding of the security object and its current state.</summary>
/// <returns>An XML encoding of the security object, including any state information.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x06003419 RID: 13337 RVA: 0x000B31B0 File Offset: 0x000B13B0
public SecurityElement ToXml()
{
return this.ToXml(null);
}
/// <summary>Creates an XML encoding of the security object and its current state with the specified <see cref="T:System.Security.Policy.PolicyLevel" />.</summary>
/// <returns>An XML encoding of the security object, including any state information.</returns>
/// <param name="level">The policy level context for resolving named permission set references. </param>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x0600341A RID: 13338 RVA: 0x000B31BC File Offset: 0x000B13BC
public SecurityElement ToXml(PolicyLevel level)
{
SecurityElement securityElement = MembershipConditionHelper.Element(typeof(HashMembershipCondition), this.version);
securityElement.AddAttribute("HashValue", CryptoConvert.ToHex(this.HashValue));
securityElement.AddAttribute("HashAlgorithm", this.hash_algorithm.GetType().FullName);
return securityElement;
}
/// <summary>Reconstructs a security object with a specified state from an XML encoding.</summary>
/// <param name="e">The XML encoding to use to reconstruct the security object. </param>
// Token: 0x0600341B RID: 13339 RVA: 0x000B3214 File Offset: 0x000B1414
public void FromXml(SecurityElement e)
{
this.FromXml(e, null);
}
/// <summary>Reconstructs a security object with a specified state from an XML encoding.</summary>
/// <param name="e">The XML encoding to use to reconstruct the security object. </param>
/// <param name="level">The policy level context, used to resolve named permission set references. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="e" /> parameter is null. </exception>
/// <exception cref="T:System.ArgumentException">The <paramref name="e" /> parameter is not a valid membership condition element. </exception>
// Token: 0x0600341C RID: 13340 RVA: 0x000B3220 File Offset: 0x000B1420
public void FromXml(SecurityElement e, PolicyLevel level)
{
MembershipConditionHelper.CheckSecurityElement(e, "e", this.version, this.version);
this.hash_value = CryptoConvert.FromHex(e.Attribute("HashValue"));
string text = e.Attribute("HashAlgorithm");
this.hash_algorithm = ((text != null) ? HashAlgorithm.Create(text) : null);
}
/// <summary>Gets the hash code for the current membership condition.</summary>
/// <returns>The hash code for the current membership condition.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x0600341D RID: 13341 RVA: 0x000B3280 File Offset: 0x000B1480
public override int GetHashCode()
{
int num = this.hash_algorithm.GetType().GetHashCode();
if (this.hash_value != null)
{
foreach (byte b in this.hash_value)
{
num ^= (int)b;
}
}
return num;
}
/// <summary>Creates and returns a string representation of the membership condition.</summary>
/// <returns>A string representation of the state of the membership condition.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x0600341E RID: 13342 RVA: 0x000B32D0 File Offset: 0x000B14D0
public override string ToString()
{
Type type = this.HashAlgorithm.GetType();
return string.Format("Hash - {0} {1} = {2}", type.FullName, type.Assembly, CryptoConvert.ToHex(this.HashValue));
}
// Token: 0x0600341F RID: 13343 RVA: 0x000B330C File Offset: 0x000B150C
private bool Compare(byte[] expected, byte[] actual)
{
if (expected.Length != actual.Length)
{
return false;
}
int num = expected.Length;
for (int i = 0; i < num; i++)
{
if (expected[i] != actual[i])
{
return false;
}
}
return true;
}
// Token: 0x04001555 RID: 5461
private readonly int version = 1;
// Token: 0x04001556 RID: 5462
private HashAlgorithm hash_algorithm;
// Token: 0x04001557 RID: 5463
private byte[] hash_value;
}
}
@@ -0,0 +1,18 @@
using System;
using System.Runtime.InteropServices;
namespace System.Security.Policy
{
/// <summary>Determines whether an application should be executed and which set of permissions should be granted to the application.</summary>
// Token: 0x0200058F RID: 1423
[ComVisible(true)]
public interface IApplicationTrustManager : ISecurityEncodable
{
/// <summary>Determines whether an application should be executed and which set of permissions should be granted to the application.</summary>
/// <returns>An <see cref="T:System.Security.Policy.ApplicationTrust" />.</returns>
/// <param name="activationContext">An <see cref="T:System.ActivationContext" /> identifying the activation context for the application.</param>
/// <param name="context">A <see cref="T:System.Security.Policy.TrustManagerContext" /> identifying the trust manager context for the application.</param>
// Token: 0x06003420 RID: 13344
ApplicationTrust DetermineApplicationTrust(ActivationContext activationContext, TrustManagerContext context);
}
}
@@ -0,0 +1,17 @@
using System;
namespace System.Security.Policy
{
// Token: 0x02000590 RID: 1424
internal interface IBuiltInEvidence
{
// Token: 0x06003421 RID: 13345
int GetRequiredSize(bool verbose);
// Token: 0x06003422 RID: 13346
int InitFromBuffer(char[] buffer, int position);
// Token: 0x06003423 RID: 13347
int OutputToBuffer(char[] buffer, int position, bool verbose);
}
}
@@ -0,0 +1,9 @@
using System;
namespace System.Security.Policy
{
// Token: 0x02000591 RID: 1425
internal interface IConstantMembershipCondition
{
}
}
@@ -0,0 +1,17 @@
using System;
using System.Runtime.InteropServices;
namespace System.Security.Policy
{
/// <summary>Defines the method that creates a new identity permission.</summary>
// Token: 0x02000592 RID: 1426
[ComVisible(true)]
public interface IIdentityPermissionFactory
{
/// <summary>Creates a new identity permission for the specified evidence.</summary>
/// <returns>The new identity permission.</returns>
/// <param name="evidence">The evidence from which to create the new identity permission. </param>
// Token: 0x06003424 RID: 13348
IPermission CreateIdentityPermission(Evidence evidence);
}
}
@@ -0,0 +1,33 @@
using System;
using System.Runtime.InteropServices;
namespace System.Security.Policy
{
/// <summary>Defines the test to determine whether a code assembly is a member of a code group.</summary>
// Token: 0x02000593 RID: 1427
[ComVisible(true)]
public interface IMembershipCondition : ISecurityEncodable, ISecurityPolicyEncodable
{
/// <summary>Determines whether the specified evidence satisfies the membership condition.</summary>
/// <returns>true if the specified evidence satisfies the membership condition; otherwise, false.</returns>
/// <param name="evidence">The evidence set against which to make the test. </param>
// Token: 0x06003425 RID: 13349
bool Check(Evidence evidence);
/// <summary>Creates an equivalent copy of the membership condition.</summary>
/// <returns>A new, identical copy of the current membership condition.</returns>
// Token: 0x06003426 RID: 13350
IMembershipCondition Copy();
/// <summary>Determines whether the specified <see cref="T:System.Object" /> is equal to the current <see cref="T:System.Object" />.</summary>
/// <returns>true if the specified <see cref="T:System.Object" /> is equal to the current <see cref="T:System.Object" />; otherwise, false.</returns>
/// <param name="obj">The <see cref="T:System.Object" /> to compare with the current <see cref="T:System.Object" />. </param>
// Token: 0x06003427 RID: 13351
bool Equals(object obj);
/// <summary>Creates and returns a string representation of the membership condition.</summary>
/// <returns>A string representation of the state of the current membership condition.</returns>
// Token: 0x06003428 RID: 13352
string ToString();
}
}
@@ -0,0 +1,50 @@
using System;
namespace System.Security.Policy
{
// Token: 0x02000594 RID: 1428
internal sealed class MembershipConditionHelper
{
// Token: 0x0600342B RID: 13355 RVA: 0x000B3360 File Offset: 0x000B1560
internal static int CheckSecurityElement(SecurityElement se, string parameterName, int minimumVersion, int maximumVersion)
{
if (se == null)
{
throw new ArgumentNullException(parameterName);
}
if (se.Tag != MembershipConditionHelper.XmlTag)
{
string text = string.Format(Locale.GetText("Invalid tag {0}, expected {1}."), se.Tag, MembershipConditionHelper.XmlTag);
throw new ArgumentException(text, parameterName);
}
int num = minimumVersion;
string text2 = se.Attribute("version");
if (text2 != null)
{
try
{
num = int.Parse(text2);
}
catch (Exception ex)
{
string text3 = Locale.GetText("Couldn't parse version from '{0}'.");
text3 = string.Format(text3, text2);
throw new ArgumentException(text3, parameterName, ex);
}
}
return num;
}
// Token: 0x0600342C RID: 13356 RVA: 0x000B3418 File Offset: 0x000B1618
internal static SecurityElement Element(Type type, int version)
{
SecurityElement securityElement = new SecurityElement(MembershipConditionHelper.XmlTag);
securityElement.AddAttribute("class", type.FullName + ", " + type.Assembly.ToString().Replace('"', '\''));
securityElement.AddAttribute("version", version.ToString());
return securityElement;
}
// Token: 0x04001558 RID: 5464
private static readonly string XmlTag = "IMembershipCondition";
}
}
@@ -0,0 +1,43 @@
using System;
namespace System.Security.Policy
{
// Token: 0x02000595 RID: 1429
internal class MonoTrustManager : IApplicationTrustManager, ISecurityEncodable
{
// Token: 0x0600342E RID: 13358 RVA: 0x000B347C File Offset: 0x000B167C
public ApplicationTrust DetermineApplicationTrust(ActivationContext activationContext, TrustManagerContext context)
{
if (activationContext == null)
{
throw new ArgumentNullException("activationContext");
}
return null;
}
// Token: 0x0600342F RID: 13359 RVA: 0x000B3490 File Offset: 0x000B1690
public void FromXml(SecurityElement e)
{
if (e == null)
{
throw new ArgumentNullException("e");
}
if (e.Tag != "IApplicationTrustManager")
{
throw new ArgumentException("e", Locale.GetText("Invalid XML tag."));
}
}
// Token: 0x06003430 RID: 13360 RVA: 0x000B34D0 File Offset: 0x000B16D0
public SecurityElement ToXml()
{
SecurityElement securityElement = new SecurityElement("IApplicationTrustManager");
securityElement.AddAttribute("class", typeof(MonoTrustManager).AssemblyQualifiedName);
securityElement.AddAttribute("version", "1");
return securityElement;
}
// Token: 0x04001559 RID: 5465
private const string tag = "IApplicationTrustManager";
}
}
@@ -0,0 +1,318 @@
using System;
using System.Collections;
using System.Runtime.InteropServices;
using System.Security.Permissions;
namespace System.Security.Policy
{
/// <summary>Grants Web permission to the site from which the assembly was downloaded. This class cannot be inherited.</summary>
// Token: 0x02000596 RID: 1430
[ComVisible(true)]
[Serializable]
public sealed class NetCodeGroup : CodeGroup
{
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Policy.NetCodeGroup" /> class.</summary>
/// <param name="membershipCondition">A membership condition that tests evidence to determine whether this code group applies code access security policy. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="membershipCondition" /> parameter is null. </exception>
/// <exception cref="T:System.ArgumentException">The type of the <paramref name="membershipCondition" /> parameter is not valid. </exception>
// Token: 0x06003431 RID: 13361 RVA: 0x000B3514 File Offset: 0x000B1714
public NetCodeGroup(IMembershipCondition membershipCondition)
: base(membershipCondition, null)
{
}
// Token: 0x06003432 RID: 13362 RVA: 0x000B352C File Offset: 0x000B172C
internal NetCodeGroup(SecurityElement e, PolicyLevel level)
: base(e, level)
{
}
/// <summary>Gets a string representation of the attributes of the policy statement for the code group.</summary>
/// <returns>Always null.</returns>
// Token: 0x17000A42 RID: 2626
// (get) Token: 0x06003434 RID: 13364 RVA: 0x000B355C File Offset: 0x000B175C
public override string AttributeString
{
get
{
return null;
}
}
/// <summary>Gets the logic to use for merging groups.</summary>
/// <returns>The string "Union".</returns>
// Token: 0x17000A43 RID: 2627
// (get) Token: 0x06003435 RID: 13365 RVA: 0x000B3560 File Offset: 0x000B1760
public override string MergeLogic
{
get
{
return "Union";
}
}
/// <summary>Gets the name of the <see cref="T:System.Security.NamedPermissionSet" /> for the code group.</summary>
/// <returns>Always the string "Same site Web."</returns>
// Token: 0x17000A44 RID: 2628
// (get) Token: 0x06003436 RID: 13366 RVA: 0x000B3568 File Offset: 0x000B1768
public override string PermissionSetName
{
get
{
return "Same site Web";
}
}
/// <summary>Adds the specified connection access to the current code group.</summary>
/// <param name="originScheme">A <see cref="T:System.String" /> containing the scheme to match against the code's scheme.</param>
/// <param name="connectAccess">A <see cref="T:System.Security.Policy.CodeConnectAccess" /> that specifies the scheme and port code can use to connect back to its origin server.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="originScheme" /> is null.</exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="originScheme" /> contains characters that are not permitted in schemes.-or-<paramref name="originScheme" /> = <see cref="F:System.Security.Policy.NetCodeGroup.AbsentOriginScheme" /> and <paramref name="connectAccess" /> specifies <see cref="F:System.Security.Policy.CodeConnectAccess.OriginScheme" /> as its scheme.</exception>
// Token: 0x06003437 RID: 13367 RVA: 0x000B3570 File Offset: 0x000B1770
[MonoTODO("(2.0) missing validations")]
public void AddConnectAccess(string originScheme, CodeConnectAccess connectAccess)
{
if (originScheme == null)
{
throw new ArgumentException("originScheme");
}
if (originScheme == NetCodeGroup.AbsentOriginScheme && connectAccess.Scheme == CodeConnectAccess.OriginScheme)
{
throw new ArgumentOutOfRangeException("connectAccess", Locale.GetText("Schema == CodeConnectAccess.OriginScheme"));
}
if (this._rules.ContainsKey(originScheme))
{
if (connectAccess != null)
{
CodeConnectAccess[] array = (CodeConnectAccess[])this._rules[originScheme];
CodeConnectAccess[] array2 = new CodeConnectAccess[array.Length + 1];
Array.Copy(array, 0, array2, 0, array.Length);
array2[array.Length] = connectAccess;
this._rules[originScheme] = array2;
}
}
else
{
CodeConnectAccess[] array3 = new CodeConnectAccess[] { connectAccess };
this._rules.Add(originScheme, array3);
}
}
/// <summary>Makes a deep copy of the current code group.</summary>
/// <returns>An equivalent copy of the current code group, including its membership conditions and child code groups.</returns>
// Token: 0x06003438 RID: 13368 RVA: 0x000B3638 File Offset: 0x000B1838
public override CodeGroup Copy()
{
NetCodeGroup netCodeGroup = new NetCodeGroup(base.MembershipCondition);
netCodeGroup.Name = base.Name;
netCodeGroup.Description = base.Description;
netCodeGroup.PolicyStatement = base.PolicyStatement;
foreach (object obj in base.Children)
{
CodeGroup codeGroup = (CodeGroup)obj;
netCodeGroup.AddChild(codeGroup.Copy());
}
return netCodeGroup;
}
// Token: 0x06003439 RID: 13369 RVA: 0x000B36E0 File Offset: 0x000B18E0
private bool Equals(CodeConnectAccess[] rules1, CodeConnectAccess[] rules2)
{
for (int i = 0; i < rules1.Length; i++)
{
bool flag = false;
for (int j = 0; j < rules2.Length; j++)
{
if (rules1[i].Equals(rules2[j]))
{
flag = true;
break;
}
}
if (!flag)
{
return false;
}
}
return true;
}
/// <summary>Determines whether the specified code group is equivalent to the current code group.</summary>
/// <returns>true if the specified code group is equivalent to the current code group; otherwise, false.</returns>
/// <param name="o">The <see cref="T:System.Security.Policy.NetCodeGroup" /> object to compare with the current code group.</param>
// Token: 0x0600343A RID: 13370 RVA: 0x000B3738 File Offset: 0x000B1938
public override bool Equals(object o)
{
if (!base.Equals(o))
{
return false;
}
NetCodeGroup netCodeGroup = o as NetCodeGroup;
if (netCodeGroup == null)
{
return false;
}
foreach (object obj in this._rules)
{
DictionaryEntry dictionaryEntry = (DictionaryEntry)obj;
CodeConnectAccess[] array = (CodeConnectAccess[])netCodeGroup._rules[dictionaryEntry.Key];
bool flag;
if (array != null)
{
flag = this.Equals((CodeConnectAccess[])dictionaryEntry.Value, array);
}
else
{
flag = dictionaryEntry.Value == null;
}
if (!flag)
{
return false;
}
}
return true;
}
/// <summary>Gets the connection access information for the current code group.</summary>
/// <returns>A <see cref="T:System.Collections.DictionaryEntry" /> array containing connection access information.</returns>
// Token: 0x0600343B RID: 13371 RVA: 0x000B381C File Offset: 0x000B1A1C
public DictionaryEntry[] GetConnectAccessRules()
{
DictionaryEntry[] array = new DictionaryEntry[this._rules.Count];
this._rules.CopyTo(array, 0);
return array;
}
/// <returns>The hash code of the current code group.</returns>
// Token: 0x0600343C RID: 13372 RVA: 0x000B3848 File Offset: 0x000B1A48
public override int GetHashCode()
{
if (this._hashcode == 0)
{
this._hashcode = base.GetHashCode();
foreach (object obj in this._rules)
{
CodeConnectAccess[] array = (CodeConnectAccess[])((DictionaryEntry)obj).Value;
if (array != null)
{
foreach (CodeConnectAccess codeConnectAccess in array)
{
this._hashcode ^= codeConnectAccess.GetHashCode();
}
}
}
}
return this._hashcode;
}
/// <summary>Resolves policy for the code group and its descendants for a set of evidence.</summary>
/// <returns>A <see cref="T:System.Security.Policy.PolicyStatement" /> that consists of the permissions granted by the code group with optional attributes, or null if the code group does not apply (the membership condition does not match the specified evidence).</returns>
/// <param name="evidence">The <see cref="T:System.Security.Policy.Evidence" /> for the assembly. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="evidence" /> parameter is null. </exception>
/// <exception cref="T:System.Security.Policy.PolicyException">More than one code group (including the parent code group and any child code groups) is marked <see cref="F:System.Security.Policy.PolicyStatementAttribute.Exclusive" />. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="ControlEvidence" />
/// </PermissionSet>
// Token: 0x0600343D RID: 13373 RVA: 0x000B3918 File Offset: 0x000B1B18
public override PolicyStatement Resolve(Evidence evidence)
{
if (evidence == null)
{
throw new ArgumentNullException("evidence");
}
if (!base.MembershipCondition.Check(evidence))
{
return null;
}
PermissionSet permissionSet = null;
if (base.PolicyStatement == null)
{
permissionSet = new PermissionSet(PermissionState.None);
}
else
{
permissionSet = base.PolicyStatement.PermissionSet.Copy();
}
if (base.Children.Count > 0)
{
foreach (object obj in base.Children)
{
CodeGroup codeGroup = (CodeGroup)obj;
PolicyStatement policyStatement = codeGroup.Resolve(evidence);
if (policyStatement != null)
{
permissionSet = permissionSet.Union(policyStatement.PermissionSet);
}
}
}
PolicyStatement policyStatement2 = base.PolicyStatement.Copy();
policyStatement2.PermissionSet = permissionSet;
return policyStatement2;
}
/// <summary>Removes all connection access information for the current code group.</summary>
// Token: 0x0600343E RID: 13374 RVA: 0x000B3A14 File Offset: 0x000B1C14
public void ResetConnectAccess()
{
this._rules.Clear();
}
/// <summary>Resolves matching code groups.</summary>
/// <returns>A <see cref="T:System.Security.Policy.CodeGroup" />.</returns>
/// <param name="evidence">The <see cref="T:System.Security.Policy.Evidence" /> for the assembly. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="evidence" /> parameter is null. </exception>
// Token: 0x0600343F RID: 13375 RVA: 0x000B3A24 File Offset: 0x000B1C24
public override CodeGroup ResolveMatchingCodeGroups(Evidence evidence)
{
if (evidence == null)
{
throw new ArgumentNullException("evidence");
}
CodeGroup codeGroup = null;
if (base.MembershipCondition.Check(evidence))
{
codeGroup = this.Copy();
foreach (object obj in base.Children)
{
CodeGroup codeGroup2 = (CodeGroup)obj;
CodeGroup codeGroup3 = codeGroup2.ResolveMatchingCodeGroups(evidence);
if (codeGroup3 != null)
{
codeGroup.AddChild(codeGroup3);
}
}
}
return codeGroup;
}
// Token: 0x06003440 RID: 13376 RVA: 0x000B3AD8 File Offset: 0x000B1CD8
[MonoTODO("(2.0) Add new stuff (CodeConnectAccess) into XML")]
protected override void CreateXml(SecurityElement element, PolicyLevel level)
{
base.CreateXml(element, level);
}
// Token: 0x06003441 RID: 13377 RVA: 0x000B3AE4 File Offset: 0x000B1CE4
[MonoTODO("(2.0) Parse new stuff (CodeConnectAccess) from XML")]
protected override void ParseXml(SecurityElement e, PolicyLevel level)
{
base.ParseXml(e, level);
}
/// <summary>Contains a value used to specify connection access for code with an unknown or unrecognized origin scheme.</summary>
// Token: 0x0400155A RID: 5466
public static readonly string AbsentOriginScheme = string.Empty;
/// <summary>Contains a value used to specify any other unspecified origin scheme.</summary>
// Token: 0x0400155B RID: 5467
public static readonly string AnyOtherOriginScheme = "*";
// Token: 0x0400155C RID: 5468
private Hashtable _rules = new Hashtable();
// Token: 0x0400155D RID: 5469
private int _hashcode;
}
}
@@ -0,0 +1,153 @@
using System;
using System.Runtime.InteropServices;
namespace System.Security.Policy
{
/// <summary>Defines evidence that represents permission requests. This class cannot be inherited.</summary>
// Token: 0x02000597 RID: 1431
[ComVisible(true)]
[Serializable]
public sealed class PermissionRequestEvidence : IBuiltInEvidence
{
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Policy.PermissionRequestEvidence" /> class with the permission request of a code assembly.</summary>
/// <param name="request">The minimum permissions the code requires to run. </param>
/// <param name="optional">The permissions the code can use if they are granted, but that are not required. </param>
/// <param name="denied">The permissions the code explicitly asks not to be granted. </param>
// Token: 0x06003442 RID: 13378 RVA: 0x000B3AF0 File Offset: 0x000B1CF0
public PermissionRequestEvidence(PermissionSet request, PermissionSet optional, PermissionSet denied)
{
if (request != null)
{
this.requested = new PermissionSet(request);
}
if (optional != null)
{
this.optional = new PermissionSet(optional);
}
if (denied != null)
{
this.denied = new PermissionSet(denied);
}
}
// Token: 0x06003443 RID: 13379 RVA: 0x000B3B3C File Offset: 0x000B1D3C
int IBuiltInEvidence.GetRequiredSize(bool verbose)
{
int num = ((!verbose) ? 1 : 3);
if (this.requested != null)
{
int num2 = this.requested.ToXml().ToString().Length + ((!verbose) ? 0 : 5);
num += num2;
}
if (this.optional != null)
{
int num3 = this.optional.ToXml().ToString().Length + ((!verbose) ? 0 : 5);
num += num3;
}
if (this.denied != null)
{
int num4 = this.denied.ToXml().ToString().Length + ((!verbose) ? 0 : 5);
num += num4;
}
return num;
}
// Token: 0x06003444 RID: 13380 RVA: 0x000B3BF4 File Offset: 0x000B1DF4
[MonoTODO("IBuiltInEvidence")]
int IBuiltInEvidence.InitFromBuffer(char[] buffer, int position)
{
return 0;
}
// Token: 0x06003445 RID: 13381 RVA: 0x000B3BF8 File Offset: 0x000B1DF8
[MonoTODO("IBuiltInEvidence")]
int IBuiltInEvidence.OutputToBuffer(char[] buffer, int position, bool verbose)
{
return 0;
}
/// <summary>Gets the permissions the code explicitly asks not to be granted.</summary>
/// <returns>The permissions the code explicitly asks not to be granted.</returns>
// Token: 0x17000A45 RID: 2629
// (get) Token: 0x06003446 RID: 13382 RVA: 0x000B3BFC File Offset: 0x000B1DFC
public PermissionSet DeniedPermissions
{
get
{
return this.denied;
}
}
/// <summary>Gets the permissions the code can use if they are granted, but are not required.</summary>
/// <returns>The permissions the code can use if they are granted, but are not required.</returns>
// Token: 0x17000A46 RID: 2630
// (get) Token: 0x06003447 RID: 13383 RVA: 0x000B3C04 File Offset: 0x000B1E04
public PermissionSet OptionalPermissions
{
get
{
return this.optional;
}
}
/// <summary>Gets the minimum permissions the code requires to run.</summary>
/// <returns>The minimum permissions the code requires to run.</returns>
// Token: 0x17000A47 RID: 2631
// (get) Token: 0x06003448 RID: 13384 RVA: 0x000B3C0C File Offset: 0x000B1E0C
public PermissionSet RequestedPermissions
{
get
{
return this.requested;
}
}
/// <summary>Creates an equivalent copy of the current <see cref="T:System.Security.Policy.PermissionRequestEvidence" />.</summary>
/// <returns>An equivalent copy of the current <see cref="T:System.Security.Policy.PermissionRequestEvidence" />.</returns>
// Token: 0x06003449 RID: 13385 RVA: 0x000B3C14 File Offset: 0x000B1E14
public PermissionRequestEvidence Copy()
{
return new PermissionRequestEvidence(this.requested, this.optional, this.denied);
}
/// <summary>Gets a string representation of the state of the <see cref="T:System.Security.Policy.PermissionRequestEvidence" />.</summary>
/// <returns>A representation of the state of the <see cref="T:System.Security.Policy.PermissionRequestEvidence" />.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x0600344A RID: 13386 RVA: 0x000B3C30 File Offset: 0x000B1E30
public override string ToString()
{
SecurityElement securityElement = new SecurityElement("System.Security.Policy.PermissionRequestEvidence");
securityElement.AddAttribute("version", "1");
if (this.requested != null)
{
SecurityElement securityElement2 = new SecurityElement("Request");
securityElement2.AddChild(this.requested.ToXml());
securityElement.AddChild(securityElement2);
}
if (this.optional != null)
{
SecurityElement securityElement3 = new SecurityElement("Optional");
securityElement3.AddChild(this.optional.ToXml());
securityElement.AddChild(securityElement3);
}
if (this.denied != null)
{
SecurityElement securityElement4 = new SecurityElement("Denied");
securityElement4.AddChild(this.denied.ToXml());
securityElement.AddChild(securityElement4);
}
return securityElement.ToString();
}
// Token: 0x0400155E RID: 5470
private PermissionSet requested;
// Token: 0x0400155F RID: 5471
private PermissionSet optional;
// Token: 0x04001560 RID: 5472
private PermissionSet denied;
}
}
@@ -0,0 +1,46 @@
using System;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
namespace System.Security.Policy
{
/// <summary>The exception that is thrown when policy forbids code to run.</summary>
// Token: 0x02000598 RID: 1432
[ComVisible(true)]
[Serializable]
public class PolicyException : SystemException, _Exception
{
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Policy.PolicyException" /> class with default properties.</summary>
// Token: 0x0600344B RID: 13387 RVA: 0x000B3CE8 File Offset: 0x000B1EE8
public PolicyException()
: base(Locale.GetText("Cannot run because of policy."))
{
}
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Policy.PolicyException" /> class with a specified error message.</summary>
/// <param name="message">The error message that explains the reason for the exception. </param>
// Token: 0x0600344C RID: 13388 RVA: 0x000B3CFC File Offset: 0x000B1EFC
public PolicyException(string message)
: base(message)
{
}
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Policy.PolicyException" /> class with serialized data.</summary>
/// <param name="info">The object that holds the serialized object data. </param>
/// <param name="context">The contextual information about the source or destination. </param>
// Token: 0x0600344D RID: 13389 RVA: 0x000B3D08 File Offset: 0x000B1F08
protected PolicyException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Policy.PolicyException" /> class with a specified error message and a reference to the inner exception that is the cause of this exception.</summary>
/// <param name="message">The error message that explains the reason for the exception. </param>
/// <param name="exception">The exception that is the cause of the current exception. If the <paramref name="exception" /> parameter is not null, the current exception is raised in a catch block that handles the inner exception. </param>
// Token: 0x0600344E RID: 13390 RVA: 0x000B3D14 File Offset: 0x000B1F14
public PolicyException(string message, Exception exception)
: base(message, exception)
{
}
}
}
@@ -0,0 +1,811 @@
using System;
using System.Collections;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using Mono.Xml;
namespace System.Security.Policy
{
/// <summary>Represents the security policy levels for the common language runtime. This class cannot be inherited.</summary>
// Token: 0x02000599 RID: 1433
[ComVisible(true)]
[Serializable]
public sealed class PolicyLevel
{
// Token: 0x0600344F RID: 13391 RVA: 0x000B3D20 File Offset: 0x000B1F20
internal PolicyLevel(string label, PolicyLevelType type)
{
this.label = label;
this._type = type;
this.full_trust_assemblies = new ArrayList();
this.named_permission_sets = new ArrayList();
}
// Token: 0x06003450 RID: 13392 RVA: 0x000B3D58 File Offset: 0x000B1F58
internal void LoadFromFile(string filename)
{
try
{
if (!File.Exists(filename))
{
string text = filename + ".default";
if (File.Exists(text))
{
File.Copy(text, filename);
}
}
if (File.Exists(filename))
{
using (StreamReader streamReader = File.OpenText(filename))
{
this.xml = this.FromString(streamReader.ReadToEnd());
}
try
{
SecurityManager.ResolvingPolicyLevel = this;
this.FromXml(this.xml);
}
finally
{
SecurityManager.ResolvingPolicyLevel = this;
}
}
else
{
this.CreateDefaultFullTrustAssemblies();
this.CreateDefaultNamedPermissionSets();
this.CreateDefaultLevel(this._type);
this.Save();
}
}
catch
{
}
finally
{
this._location = filename;
}
}
// Token: 0x06003451 RID: 13393 RVA: 0x000B3E7C File Offset: 0x000B207C
internal void LoadFromString(string xml)
{
this.FromXml(this.FromString(xml));
}
// Token: 0x06003452 RID: 13394 RVA: 0x000B3E8C File Offset: 0x000B208C
private SecurityElement FromString(string xml)
{
SecurityParser securityParser = new SecurityParser();
securityParser.LoadXml(xml);
SecurityElement securityElement = securityParser.ToXml();
if (securityElement.Tag != "configuration")
{
throw new ArgumentException(Locale.GetText("missing <configuration> root element"));
}
SecurityElement securityElement2 = (SecurityElement)securityElement.Children[0];
if (securityElement2.Tag != "mscorlib")
{
throw new ArgumentException(Locale.GetText("missing <mscorlib> tag"));
}
SecurityElement securityElement3 = (SecurityElement)securityElement2.Children[0];
if (securityElement3.Tag != "security")
{
throw new ArgumentException(Locale.GetText("missing <security> tag"));
}
SecurityElement securityElement4 = (SecurityElement)securityElement3.Children[0];
if (securityElement4.Tag != "policy")
{
throw new ArgumentException(Locale.GetText("missing <policy> tag"));
}
return (SecurityElement)securityElement4.Children[0];
}
/// <summary>Gets a list of <see cref="T:System.Security.Policy.StrongNameMembershipCondition" /> objects used to determine whether an assembly is a member of the group of assemblies used to evaluate security policy.</summary>
/// <returns>A list of <see cref="T:System.Security.Policy.StrongNameMembershipCondition" /> objects used to determine whether an assembly is a member of the group of assemblies used to evaluate security policy. These assemblies are granted full trust during security policy evaluation of assemblies not in the list.</returns>
// Token: 0x17000A48 RID: 2632
// (get) Token: 0x06003453 RID: 13395 RVA: 0x000B3F90 File Offset: 0x000B2190
[Obsolete("All GACed assemblies are now fully trusted and all permissions now succeed on fully trusted code.")]
public IList FullTrustAssemblies
{
get
{
return this.full_trust_assemblies;
}
}
/// <summary>Gets a descriptive label for the policy level.</summary>
/// <returns>The label associated with the policy level.</returns>
// Token: 0x17000A49 RID: 2633
// (get) Token: 0x06003454 RID: 13396 RVA: 0x000B3F98 File Offset: 0x000B2198
public string Label
{
get
{
return this.label;
}
}
/// <summary>Gets a list of named permission sets defined for the policy level.</summary>
/// <returns>A list of named permission sets defined for the policy level.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x17000A4A RID: 2634
// (get) Token: 0x06003455 RID: 13397 RVA: 0x000B3FA0 File Offset: 0x000B21A0
public IList NamedPermissionSets
{
get
{
return this.named_permission_sets;
}
}
/// <summary>Gets or sets the root code group for the policy level.</summary>
/// <returns>The <see cref="T:System.Security.Policy.CodeGroup" /> that is the root of the tree of policy level code groups.</returns>
/// <exception cref="T:System.ArgumentNullException">The value for <see cref="P:System.Security.Policy.PolicyLevel.RootCodeGroup" /> is null.</exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="ControlEvidence, ControlPolicy" />
/// </PermissionSet>
// Token: 0x17000A4B RID: 2635
// (get) Token: 0x06003456 RID: 13398 RVA: 0x000B3FA8 File Offset: 0x000B21A8
// (set) Token: 0x06003457 RID: 13399 RVA: 0x000B3FB0 File Offset: 0x000B21B0
public CodeGroup RootCodeGroup
{
get
{
return this.root_code_group;
}
set
{
if (value == null)
{
throw new ArgumentNullException("value");
}
this.root_code_group = value;
}
}
/// <summary>Gets the path where the policy file is stored.</summary>
/// <returns>The path where the policy file is stored, or null if the <see cref="T:System.Security.Policy.PolicyLevel" /> does not have a storage location.</returns>
// Token: 0x17000A4C RID: 2636
// (get) Token: 0x06003458 RID: 13400 RVA: 0x000B3FCC File Offset: 0x000B21CC
public string StoreLocation
{
get
{
return this._location;
}
}
/// <summary>Gets the type of the policy level.</summary>
/// <returns>One of the <see cref="T:System.Security.PolicyLevelType" /> values.</returns>
// Token: 0x17000A4D RID: 2637
// (get) Token: 0x06003459 RID: 13401 RVA: 0x000B3FD4 File Offset: 0x000B21D4
[ComVisible(false)]
public PolicyLevelType Type
{
get
{
return this._type;
}
}
/// <summary>Adds a <see cref="T:System.Security.Policy.StrongNameMembershipCondition" /> corresponding to the specified <see cref="T:System.Security.Policy.StrongName" /> to the list of <see cref="T:System.Security.Policy.StrongNameMembershipCondition" /> objects used to determine whether an assembly is a member of the group of assemblies that should not be evaluated.</summary>
/// <param name="sn">The <see cref="T:System.Security.Policy.StrongName" /> used to create the <see cref="T:System.Security.Policy.StrongNameMembershipCondition" /> to add to the list of <see cref="T:System.Security.Policy.StrongNameMembershipCondition" /> objects used to determine whether an assembly is a member of the group of assemblies that should not be evaluated. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="sn" /> parameter is null. </exception>
/// <exception cref="T:System.ArgumentException">The <see cref="T:System.Security.Policy.StrongName" /> specified by the <paramref name="sn" /> parameter already has full trust. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="ControlEvidence" />
/// </PermissionSet>
// Token: 0x0600345A RID: 13402 RVA: 0x000B3FDC File Offset: 0x000B21DC
[Obsolete("All GACed assemblies are now fully trusted and all permissions now succeed on fully trusted code.")]
public void AddFullTrustAssembly(StrongName sn)
{
if (sn == null)
{
throw new ArgumentNullException("sn");
}
StrongNameMembershipCondition strongNameMembershipCondition = new StrongNameMembershipCondition(sn.PublicKey, sn.Name, sn.Version);
this.AddFullTrustAssembly(strongNameMembershipCondition);
}
/// <summary>Adds the specified <see cref="T:System.Security.Policy.StrongNameMembershipCondition" /> to the list of <see cref="T:System.Security.Policy.StrongNameMembershipCondition" /> objects used to determine whether an assembly is a member of the group of assemblies that should not be evaluated.</summary>
/// <param name="snMC">The <see cref="T:System.Security.Policy.StrongNameMembershipCondition" /> to add to the list of <see cref="T:System.Security.Policy.StrongNameMembershipCondition" /> objects used to determine whether an assembly is a member of the group of assemblies that should not be evaluated. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="snMC" /> parameter is null. </exception>
/// <exception cref="T:System.ArgumentException">The <see cref="T:System.Security.Policy.StrongNameMembershipCondition" /> specified by the <paramref name="snMC" /> parameter already has full trust. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="ControlEvidence" />
/// </PermissionSet>
// Token: 0x0600345B RID: 13403 RVA: 0x000B401C File Offset: 0x000B221C
[Obsolete("All GACed assemblies are now fully trusted and all permissions now succeed on fully trusted code.")]
public void AddFullTrustAssembly(StrongNameMembershipCondition snMC)
{
if (snMC == null)
{
throw new ArgumentNullException("snMC");
}
foreach (object obj in this.full_trust_assemblies)
{
StrongNameMembershipCondition strongNameMembershipCondition = (StrongNameMembershipCondition)obj;
if (strongNameMembershipCondition.Equals(snMC))
{
throw new ArgumentException(Locale.GetText("sn already has full trust."));
}
}
this.full_trust_assemblies.Add(snMC);
}
/// <summary>Adds a <see cref="T:System.Security.NamedPermissionSet" /> to the current policy level.</summary>
/// <param name="permSet">The <see cref="T:System.Security.NamedPermissionSet" /> to add to the current policy level. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="permSet" /> parameter is null. </exception>
/// <exception cref="T:System.ArgumentException">The <paramref name="permSet" /> parameter has the same name as an existing <see cref="T:System.Security.NamedPermissionSet" /> in the <see cref="T:System.Security.Policy.PolicyLevel" />. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="ControlEvidence" />
/// </PermissionSet>
// Token: 0x0600345C RID: 13404 RVA: 0x000B40C0 File Offset: 0x000B22C0
public void AddNamedPermissionSet(NamedPermissionSet permSet)
{
if (permSet == null)
{
throw new ArgumentNullException("permSet");
}
foreach (object obj in this.named_permission_sets)
{
NamedPermissionSet namedPermissionSet = (NamedPermissionSet)obj;
if (permSet.Name == namedPermissionSet.Name)
{
throw new ArgumentException(Locale.GetText("This NamedPermissionSet is the same an existing NamedPermissionSet."));
}
}
this.named_permission_sets.Add(permSet.Copy());
}
/// <summary>Replaces a <see cref="T:System.Security.NamedPermissionSet" /> in the current policy level with the specified <see cref="T:System.Security.PermissionSet" />.</summary>
/// <returns>A copy of the <see cref="T:System.Security.NamedPermissionSet" /> that was replaced.</returns>
/// <param name="name">The name of the <see cref="T:System.Security.NamedPermissionSet" /> to replace. </param>
/// <param name="pSet">The <see cref="T:System.Security.PermissionSet" /> that replaces the <see cref="T:System.Security.NamedPermissionSet" /> specified by the <paramref name="name" /> parameter. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="name" /> parameter is null.-or- The <paramref name="pSet" /> parameter is null. </exception>
/// <exception cref="T:System.ArgumentException">The <paramref name="name" /> parameter is equal to the name of a reserved permission set.-or- The <see cref="T:System.Security.PermissionSet" /> specified by the <paramref name="pSet" /> parameter cannot be found. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="ControlEvidence" />
/// </PermissionSet>
// Token: 0x0600345D RID: 13405 RVA: 0x000B4174 File Offset: 0x000B2374
public NamedPermissionSet ChangeNamedPermissionSet(string name, PermissionSet pSet)
{
if (name == null)
{
throw new ArgumentNullException("name");
}
if (pSet == null)
{
throw new ArgumentNullException("pSet");
}
if (DefaultPolicies.ReservedNames.IsReserved(name))
{
throw new ArgumentException(Locale.GetText("Reserved name"));
}
foreach (object obj in this.named_permission_sets)
{
NamedPermissionSet namedPermissionSet = (NamedPermissionSet)obj;
if (name == namedPermissionSet.Name)
{
this.named_permission_sets.Remove(namedPermissionSet);
this.AddNamedPermissionSet(new NamedPermissionSet(name, pSet));
return namedPermissionSet;
}
}
throw new ArgumentException(Locale.GetText("PermissionSet not found"));
}
/// <summary>Creates a new policy level for use at the application domain policy level.</summary>
/// <returns>The newly created <see cref="T:System.Security.Policy.PolicyLevel" />.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x0600345E RID: 13406 RVA: 0x000B425C File Offset: 0x000B245C
public static PolicyLevel CreateAppDomainLevel()
{
UnionCodeGroup unionCodeGroup = new UnionCodeGroup(new AllMembershipCondition(), new PolicyStatement(DefaultPolicies.FullTrust));
unionCodeGroup.Name = "All_Code";
PolicyLevel policyLevel = new PolicyLevel("AppDomain", PolicyLevelType.AppDomain);
policyLevel.RootCodeGroup = unionCodeGroup;
policyLevel.Reset();
return policyLevel;
}
/// <summary>Reconstructs a security object with a given state from an XML encoding.</summary>
/// <param name="e">The XML encoding to use to reconstruct the security object. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="e" /> parameter is null. </exception>
/// <exception cref="T:System.ArgumentException">The <see cref="T:System.Security.SecurityElement" /> specified by the <paramref name="e" /> parameter is invalid. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x0600345F RID: 13407 RVA: 0x000B42A4 File Offset: 0x000B24A4
public void FromXml(SecurityElement e)
{
if (e == null)
{
throw new ArgumentNullException("e");
}
SecurityElement securityElement = e.SearchForChildByTag("SecurityClasses");
if (securityElement != null && securityElement.Children != null && securityElement.Children.Count > 0)
{
this.fullNames = new Hashtable(securityElement.Children.Count);
foreach (object obj in securityElement.Children)
{
SecurityElement securityElement2 = (SecurityElement)obj;
this.fullNames.Add(securityElement2.Attributes["Name"], securityElement2.Attributes["Description"]);
}
}
SecurityElement securityElement3 = e.SearchForChildByTag("FullTrustAssemblies");
if (securityElement3 != null && securityElement3.Children != null && securityElement3.Children.Count > 0)
{
this.full_trust_assemblies.Clear();
foreach (object obj2 in securityElement3.Children)
{
SecurityElement securityElement4 = (SecurityElement)obj2;
if (securityElement4.Tag != "IMembershipCondition")
{
throw new ArgumentException(Locale.GetText("Invalid XML"));
}
string text = securityElement4.Attribute("class");
if (text.IndexOf("StrongNameMembershipCondition") < 0)
{
throw new ArgumentException(Locale.GetText("Invalid XML - must be StrongNameMembershipCondition"));
}
this.full_trust_assemblies.Add(new StrongNameMembershipCondition(securityElement4));
}
}
SecurityElement securityElement5 = e.SearchForChildByTag("CodeGroup");
if (securityElement5 != null && securityElement5.Children != null && securityElement5.Children.Count > 0)
{
this.root_code_group = CodeGroup.CreateFromXml(securityElement5, this);
SecurityElement securityElement6 = e.SearchForChildByTag("NamedPermissionSets");
if (securityElement6 != null && securityElement6.Children != null && securityElement6.Children.Count > 0)
{
this.named_permission_sets.Clear();
foreach (object obj3 in securityElement6.Children)
{
SecurityElement securityElement7 = (SecurityElement)obj3;
NamedPermissionSet namedPermissionSet = new NamedPermissionSet();
namedPermissionSet.Resolver = this;
namedPermissionSet.FromXml(securityElement7);
this.named_permission_sets.Add(namedPermissionSet);
}
}
return;
}
throw new ArgumentException(Locale.GetText("Missing Root CodeGroup"));
}
/// <summary>Returns the <see cref="T:System.Security.NamedPermissionSet" /> in the current policy level with the specified name.</summary>
/// <returns>The <see cref="T:System.Security.NamedPermissionSet" /> in the current policy level with the specified name, if found; otherwise, null.</returns>
/// <param name="name">The name of the <see cref="T:System.Security.NamedPermissionSet" /> to find. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="name" /> parameter is null. </exception>
// Token: 0x06003460 RID: 13408 RVA: 0x000B45A8 File Offset: 0x000B27A8
public NamedPermissionSet GetNamedPermissionSet(string name)
{
if (name == null)
{
throw new ArgumentNullException("name");
}
foreach (object obj in this.named_permission_sets)
{
NamedPermissionSet namedPermissionSet = (NamedPermissionSet)obj;
if (namedPermissionSet.Name == name)
{
return (NamedPermissionSet)namedPermissionSet.Copy();
}
}
return null;
}
/// <summary>Replaces the configuration file for this <see cref="T:System.Security.Policy.PolicyLevel" /> with the last backup (reflecting the state of policy prior to the last time it was saved) and returns it to the state of the last save.</summary>
/// <exception cref="T:System.Security.Policy.PolicyException">The policy level does not have a valid configuration file. </exception>
// Token: 0x06003461 RID: 13409 RVA: 0x000B4648 File Offset: 0x000B2848
public void Recover()
{
if (this._location == null)
{
string text = Locale.GetText("Only file based policies may be recovered.");
throw new PolicyException(text);
}
string text2 = this._location + ".backup";
if (!File.Exists(text2))
{
string text3 = Locale.GetText("No policy backup exists.");
throw new PolicyException(text3);
}
try
{
File.Copy(text2, this._location, true);
}
catch (Exception ex)
{
string text4 = Locale.GetText("Couldn't replace the policy file with it's backup.");
throw new PolicyException(text4, ex);
}
}
/// <summary>Removes an assembly with the specified <see cref="T:System.Security.Policy.StrongName" /> from the list of assemblies the policy level uses to evaluate policy.</summary>
/// <param name="sn">The <see cref="T:System.Security.Policy.StrongName" /> of the assembly to remove from the list of assemblies used to evaluate policy. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="sn" /> parameter is null. </exception>
/// <exception cref="T:System.ArgumentException">The assembly with the <see cref="T:System.Security.Policy.StrongName" /> specified by the <paramref name="sn" /> parameter does not have full trust. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="ControlEvidence" />
/// </PermissionSet>
// Token: 0x06003462 RID: 13410 RVA: 0x000B46EC File Offset: 0x000B28EC
[Obsolete("All GACed assemblies are now fully trusted and all permissions now succeed on fully trusted code.")]
public void RemoveFullTrustAssembly(StrongName sn)
{
if (sn == null)
{
throw new ArgumentNullException("sn");
}
StrongNameMembershipCondition strongNameMembershipCondition = new StrongNameMembershipCondition(sn.PublicKey, sn.Name, sn.Version);
this.RemoveFullTrustAssembly(strongNameMembershipCondition);
}
/// <summary>Removes an assembly with the specified <see cref="T:System.Security.Policy.StrongNameMembershipCondition" /> from the list of assemblies the policy level uses to evaluate policy.</summary>
/// <param name="snMC">The <see cref="T:System.Security.Policy.StrongNameMembershipCondition" /> of the assembly to remove from the list of assemblies used to evaluate policy. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="snMC" /> parameter is null. </exception>
/// <exception cref="T:System.ArgumentException">The <see cref="T:System.Security.Policy.StrongNameMembershipCondition" /> specified by the <paramref name="snMC" /> parameter does not have full trust. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="ControlEvidence" />
/// </PermissionSet>
// Token: 0x06003463 RID: 13411 RVA: 0x000B472C File Offset: 0x000B292C
[Obsolete("All GACed assemblies are now fully trusted and all permissions now succeed on fully trusted code.")]
public void RemoveFullTrustAssembly(StrongNameMembershipCondition snMC)
{
if (snMC == null)
{
throw new ArgumentNullException("snMC");
}
if (((IList)this.full_trust_assemblies).Contains(snMC))
{
((IList)this.full_trust_assemblies).Remove(snMC);
return;
}
throw new ArgumentException(Locale.GetText("sn does not have full trust."));
}
/// <summary>Removes the specified <see cref="T:System.Security.NamedPermissionSet" /> from the current policy level.</summary>
/// <returns>The <see cref="T:System.Security.NamedPermissionSet" /> that was removed.</returns>
/// <param name="permSet">The <see cref="T:System.Security.NamedPermissionSet" /> to remove from the current policy level. </param>
/// <exception cref="T:System.ArgumentException">The <see cref="T:System.Security.NamedPermissionSet" /> specified by the <paramref name="permSet" /> parameter was not found. </exception>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="permSet" /> parameter is null. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="ControlEvidence" />
/// </PermissionSet>
// Token: 0x06003464 RID: 13412 RVA: 0x000B477C File Offset: 0x000B297C
public NamedPermissionSet RemoveNamedPermissionSet(NamedPermissionSet permSet)
{
if (permSet == null)
{
throw new ArgumentNullException("permSet");
}
return this.RemoveNamedPermissionSet(permSet.Name);
}
/// <summary>Removes the <see cref="T:System.Security.NamedPermissionSet" /> with the specified name from the current policy level.</summary>
/// <returns>The <see cref="T:System.Security.NamedPermissionSet" /> that was removed.</returns>
/// <param name="name">The name of the <see cref="T:System.Security.NamedPermissionSet" /> to remove. </param>
/// <exception cref="T:System.ArgumentException">The <paramref name="name" /> parameter is equal to the name of a reserved permission set.-or- A <see cref="T:System.Security.NamedPermissionSet" /> with the specified name cannot be found. </exception>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="name" /> parameter is null. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="ControlEvidence" />
/// </PermissionSet>
// Token: 0x06003465 RID: 13413 RVA: 0x000B479C File Offset: 0x000B299C
public NamedPermissionSet RemoveNamedPermissionSet(string name)
{
if (name == null)
{
throw new ArgumentNullException("name");
}
if (DefaultPolicies.ReservedNames.IsReserved(name))
{
throw new ArgumentException(Locale.GetText("Reserved name"));
}
foreach (object obj in this.named_permission_sets)
{
NamedPermissionSet namedPermissionSet = (NamedPermissionSet)obj;
if (name == namedPermissionSet.Name)
{
this.named_permission_sets.Remove(namedPermissionSet);
return namedPermissionSet;
}
}
string text = string.Format(Locale.GetText("Name '{0}' cannot be found."), name);
throw new ArgumentException(text, "name");
}
/// <summary>Returns the current policy level to the default state.</summary>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="MemberAccess" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence, ControlPolicy" />
/// </PermissionSet>
// Token: 0x06003466 RID: 13414 RVA: 0x000B4878 File Offset: 0x000B2A78
public void Reset()
{
if (this.fullNames != null)
{
this.fullNames.Clear();
}
if (this._type != PolicyLevelType.AppDomain)
{
this.full_trust_assemblies.Clear();
this.named_permission_sets.Clear();
if (this._location != null && File.Exists(this._location))
{
try
{
File.Delete(this._location);
}
catch
{
}
}
this.LoadFromFile(this._location);
}
else
{
this.CreateDefaultFullTrustAssemblies();
this.CreateDefaultNamedPermissionSets();
}
}
/// <summary>Resolves policy based on evidence for the policy level, and returns the resulting <see cref="T:System.Security.Policy.PolicyStatement" />.</summary>
/// <returns>The resulting <see cref="T:System.Security.Policy.PolicyStatement" />.</returns>
/// <param name="evidence">The <see cref="T:System.Security.Policy.Evidence" /> used to resolve the <see cref="T:System.Security.Policy.PolicyLevel" />. </param>
/// <exception cref="T:System.Security.Policy.PolicyException">The policy level contains multiple matching code groups marked as exclusive. </exception>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="evidence" /> parameter is null. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x06003467 RID: 13415 RVA: 0x000B4928 File Offset: 0x000B2B28
public PolicyStatement Resolve(Evidence evidence)
{
if (evidence == null)
{
throw new ArgumentNullException("evidence");
}
PolicyStatement policyStatement = this.root_code_group.Resolve(evidence);
return (policyStatement == null) ? PolicyStatement.Empty() : policyStatement;
}
/// <summary>Resolves policy at the policy level and returns the root of a code group tree that matches the evidence.</summary>
/// <returns>A <see cref="T:System.Security.Policy.CodeGroup" /> representing the root of a tree of code groups matching the specified evidence.</returns>
/// <param name="evidence">The <see cref="T:System.Security.Policy.Evidence" /> used to resolve policy. </param>
/// <exception cref="T:System.Security.Policy.PolicyException">The policy level contains multiple matching code groups marked as exclusive. </exception>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="evidence" /> parameter is null. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="ControlEvidence" />
/// </PermissionSet>
// Token: 0x06003468 RID: 13416 RVA: 0x000B4964 File Offset: 0x000B2B64
public CodeGroup ResolveMatchingCodeGroups(Evidence evidence)
{
if (evidence == null)
{
throw new ArgumentNullException("evidence");
}
CodeGroup codeGroup = this.root_code_group.ResolveMatchingCodeGroups(evidence);
return (codeGroup == null) ? null : codeGroup;
}
/// <summary>Creates an XML encoding of the security object and its current state.</summary>
/// <returns>An XML encoding of the security object, including any state information.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="ControlEvidence" />
/// </PermissionSet>
// Token: 0x06003469 RID: 13417 RVA: 0x000B499C File Offset: 0x000B2B9C
public SecurityElement ToXml()
{
Hashtable hashtable = new Hashtable();
if (this.full_trust_assemblies.Count > 0 && !hashtable.Contains("StrongNameMembershipCondition"))
{
hashtable.Add("StrongNameMembershipCondition", typeof(StrongNameMembershipCondition).FullName);
}
SecurityElement securityElement = new SecurityElement("NamedPermissionSets");
foreach (object obj in this.named_permission_sets)
{
NamedPermissionSet namedPermissionSet = (NamedPermissionSet)obj;
SecurityElement securityElement2 = namedPermissionSet.ToXml();
object obj2 = securityElement2.Attributes["class"];
if (!hashtable.Contains(obj2))
{
hashtable.Add(obj2, namedPermissionSet.GetType().FullName);
}
securityElement.AddChild(securityElement2);
}
SecurityElement securityElement3 = new SecurityElement("FullTrustAssemblies");
foreach (object obj3 in this.full_trust_assemblies)
{
StrongNameMembershipCondition strongNameMembershipCondition = (StrongNameMembershipCondition)obj3;
securityElement3.AddChild(strongNameMembershipCondition.ToXml(this));
}
SecurityElement securityElement4 = new SecurityElement("SecurityClasses");
if (hashtable.Count > 0)
{
foreach (object obj4 in hashtable)
{
DictionaryEntry dictionaryEntry = (DictionaryEntry)obj4;
SecurityElement securityElement5 = new SecurityElement("SecurityClass");
securityElement5.AddAttribute("Name", (string)dictionaryEntry.Key);
securityElement5.AddAttribute("Description", (string)dictionaryEntry.Value);
securityElement4.AddChild(securityElement5);
}
}
SecurityElement securityElement6 = new SecurityElement(typeof(PolicyLevel).Name);
securityElement6.AddAttribute("version", "1");
securityElement6.AddChild(securityElement4);
securityElement6.AddChild(securityElement);
if (this.root_code_group != null)
{
securityElement6.AddChild(this.root_code_group.ToXml(this));
}
securityElement6.AddChild(securityElement3);
return securityElement6;
}
// Token: 0x0600346A RID: 13418 RVA: 0x000B4C28 File Offset: 0x000B2E28
internal void Save()
{
if (this._type == PolicyLevelType.AppDomain)
{
throw new PolicyException(Locale.GetText("Can't save AppDomain PolicyLevel"));
}
if (this._location != null)
{
try
{
if (File.Exists(this._location))
{
File.Copy(this._location, this._location + ".backup", true);
}
}
catch (Exception)
{
}
finally
{
using (StreamWriter streamWriter = new StreamWriter(this._location))
{
streamWriter.Write(this.ToXml().ToString());
streamWriter.Close();
}
}
}
}
// Token: 0x0600346B RID: 13419 RVA: 0x000B4D18 File Offset: 0x000B2F18
internal void CreateDefaultLevel(PolicyLevelType type)
{
PolicyStatement policyStatement = new PolicyStatement(DefaultPolicies.FullTrust);
switch (type)
{
case PolicyLevelType.User:
case PolicyLevelType.Enterprise:
case PolicyLevelType.AppDomain:
this.root_code_group = new UnionCodeGroup(new AllMembershipCondition(), policyStatement);
this.root_code_group.Name = "All_Code";
break;
case PolicyLevelType.Machine:
{
PolicyStatement policyStatement2 = new PolicyStatement(DefaultPolicies.Nothing);
this.root_code_group = new UnionCodeGroup(new AllMembershipCondition(), policyStatement2);
this.root_code_group.Name = "All_Code";
UnionCodeGroup unionCodeGroup = new UnionCodeGroup(new ZoneMembershipCondition(SecurityZone.MyComputer), policyStatement);
unionCodeGroup.Name = "My_Computer_Zone";
this.root_code_group.AddChild(unionCodeGroup);
UnionCodeGroup unionCodeGroup2 = new UnionCodeGroup(new ZoneMembershipCondition(SecurityZone.Intranet), new PolicyStatement(DefaultPolicies.LocalIntranet));
unionCodeGroup2.Name = "LocalIntranet_Zone";
this.root_code_group.AddChild(unionCodeGroup2);
PolicyStatement policyStatement3 = new PolicyStatement(DefaultPolicies.Internet);
UnionCodeGroup unionCodeGroup3 = new UnionCodeGroup(new ZoneMembershipCondition(SecurityZone.Internet), policyStatement3);
unionCodeGroup3.Name = "Internet_Zone";
this.root_code_group.AddChild(unionCodeGroup3);
UnionCodeGroup unionCodeGroup4 = new UnionCodeGroup(new ZoneMembershipCondition(SecurityZone.Untrusted), policyStatement2);
unionCodeGroup4.Name = "Restricted_Zone";
this.root_code_group.AddChild(unionCodeGroup4);
UnionCodeGroup unionCodeGroup5 = new UnionCodeGroup(new ZoneMembershipCondition(SecurityZone.Trusted), policyStatement3);
unionCodeGroup5.Name = "Trusted_Zone";
this.root_code_group.AddChild(unionCodeGroup5);
break;
}
}
}
// Token: 0x0600346C RID: 13420 RVA: 0x000B4E7C File Offset: 0x000B307C
internal void CreateDefaultFullTrustAssemblies()
{
this.full_trust_assemblies.Clear();
this.full_trust_assemblies.Add(DefaultPolicies.FullTrustMembership("mscorlib", DefaultPolicies.Key.Ecma));
this.full_trust_assemblies.Add(DefaultPolicies.FullTrustMembership("System", DefaultPolicies.Key.Ecma));
this.full_trust_assemblies.Add(DefaultPolicies.FullTrustMembership("System.Data", DefaultPolicies.Key.Ecma));
this.full_trust_assemblies.Add(DefaultPolicies.FullTrustMembership("System.DirectoryServices", DefaultPolicies.Key.MsFinal));
this.full_trust_assemblies.Add(DefaultPolicies.FullTrustMembership("System.Drawing", DefaultPolicies.Key.MsFinal));
this.full_trust_assemblies.Add(DefaultPolicies.FullTrustMembership("System.Messaging", DefaultPolicies.Key.MsFinal));
this.full_trust_assemblies.Add(DefaultPolicies.FullTrustMembership("System.ServiceProcess", DefaultPolicies.Key.MsFinal));
}
// Token: 0x0600346D RID: 13421 RVA: 0x000B4F38 File Offset: 0x000B3138
internal void CreateDefaultNamedPermissionSets()
{
this.named_permission_sets.Clear();
try
{
SecurityManager.ResolvingPolicyLevel = this;
this.named_permission_sets.Add(DefaultPolicies.LocalIntranet);
this.named_permission_sets.Add(DefaultPolicies.Internet);
this.named_permission_sets.Add(DefaultPolicies.SkipVerification);
this.named_permission_sets.Add(DefaultPolicies.Execution);
this.named_permission_sets.Add(DefaultPolicies.Nothing);
this.named_permission_sets.Add(DefaultPolicies.Everything);
this.named_permission_sets.Add(DefaultPolicies.FullTrust);
}
finally
{
SecurityManager.ResolvingPolicyLevel = null;
}
}
// Token: 0x0600346E RID: 13422 RVA: 0x000B4FF8 File Offset: 0x000B31F8
internal string ResolveClassName(string className)
{
if (this.fullNames != null)
{
object obj = this.fullNames[className];
if (obj != null)
{
return (string)obj;
}
}
return className;
}
// Token: 0x0600346F RID: 13423 RVA: 0x000B502C File Offset: 0x000B322C
internal bool IsFullTrustAssembly(Assembly a)
{
AssemblyName assemblyName = a.UnprotectedGetName();
StrongNamePublicKeyBlob strongNamePublicKeyBlob = new StrongNamePublicKeyBlob(assemblyName.GetPublicKey());
StrongNameMembershipCondition strongNameMembershipCondition = new StrongNameMembershipCondition(strongNamePublicKeyBlob, assemblyName.Name, assemblyName.Version);
foreach (object obj in this.full_trust_assemblies)
{
StrongNameMembershipCondition strongNameMembershipCondition2 = (StrongNameMembershipCondition)obj;
if (strongNameMembershipCondition2.Equals(strongNameMembershipCondition))
{
return true;
}
}
return false;
}
// Token: 0x04001561 RID: 5473
private string label;
// Token: 0x04001562 RID: 5474
private CodeGroup root_code_group;
// Token: 0x04001563 RID: 5475
private ArrayList full_trust_assemblies;
// Token: 0x04001564 RID: 5476
private ArrayList named_permission_sets;
// Token: 0x04001565 RID: 5477
private string _location;
// Token: 0x04001566 RID: 5478
private PolicyLevelType _type;
// Token: 0x04001567 RID: 5479
private Hashtable fullNames;
// Token: 0x04001568 RID: 5480
private SecurityElement xml;
}
}
@@ -0,0 +1,227 @@
using System;
using System.Runtime.InteropServices;
using System.Security.Permissions;
namespace System.Security.Policy
{
/// <summary>Represents the statement of a <see cref="T:System.Security.Policy.CodeGroup" /> describing the permissions and other information that apply to code with a particular set of evidence. This class cannot be inherited.</summary>
// Token: 0x0200059A RID: 1434
[ComVisible(true)]
[Serializable]
public sealed class PolicyStatement : ISecurityEncodable, ISecurityPolicyEncodable
{
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Policy.PolicyStatement" /> class with the specified <see cref="T:System.Security.PermissionSet" />.</summary>
/// <param name="permSet">The <see cref="T:System.Security.PermissionSet" /> with which to initialize the new instance. </param>
// Token: 0x06003470 RID: 13424 RVA: 0x000B50DC File Offset: 0x000B32DC
public PolicyStatement(PermissionSet permSet)
: this(permSet, PolicyStatementAttribute.Nothing)
{
}
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Policy.PolicyStatement" /> class with the specified <see cref="T:System.Security.PermissionSet" /> and attributes.</summary>
/// <param name="permSet">The <see cref="T:System.Security.PermissionSet" /> with which to initialize the new instance. </param>
/// <param name="attributes">A bitwise combination of the <see cref="T:System.Security.Policy.PolicyStatementAttribute" /> values. </param>
// Token: 0x06003471 RID: 13425 RVA: 0x000B50E8 File Offset: 0x000B32E8
public PolicyStatement(PermissionSet permSet, PolicyStatementAttribute attributes)
{
if (permSet != null)
{
this.perms = permSet.Copy();
this.perms.SetReadOnly(true);
}
this.attrs = attributes;
}
/// <summary>Gets or sets the <see cref="T:System.Security.PermissionSet" /> of the policy statement.</summary>
/// <returns>The <see cref="T:System.Security.PermissionSet" /> of the policy statement.</returns>
// Token: 0x17000A4E RID: 2638
// (get) Token: 0x06003472 RID: 13426 RVA: 0x000B5120 File Offset: 0x000B3320
// (set) Token: 0x06003473 RID: 13427 RVA: 0x000B514C File Offset: 0x000B334C
public PermissionSet PermissionSet
{
get
{
if (this.perms == null)
{
this.perms = new PermissionSet(PermissionState.None);
this.perms.SetReadOnly(true);
}
return this.perms;
}
set
{
this.perms = value;
}
}
/// <summary>Gets or sets the attributes of the policy statement.</summary>
/// <returns>The attributes of the policy statement.</returns>
// Token: 0x17000A4F RID: 2639
// (get) Token: 0x06003474 RID: 13428 RVA: 0x000B5158 File Offset: 0x000B3358
// (set) Token: 0x06003475 RID: 13429 RVA: 0x000B5160 File Offset: 0x000B3360
public PolicyStatementAttribute Attributes
{
get
{
return this.attrs;
}
set
{
switch (value)
{
case PolicyStatementAttribute.Nothing:
case PolicyStatementAttribute.Exclusive:
case PolicyStatementAttribute.LevelFinal:
case PolicyStatementAttribute.All:
this.attrs = value;
return;
default:
{
string text = Locale.GetText("Invalid value for {0}.");
throw new ArgumentException(string.Format(text, "PolicyStatementAttribute"));
}
}
}
}
/// <summary>Gets a string representation of the attributes of the policy statement.</summary>
/// <returns>A text string representing the attributes of the policy statement.</returns>
// Token: 0x17000A50 RID: 2640
// (get) Token: 0x06003476 RID: 13430 RVA: 0x000B51B4 File Offset: 0x000B33B4
public string AttributeString
{
get
{
switch (this.attrs)
{
case PolicyStatementAttribute.Exclusive:
return "Exclusive";
case PolicyStatementAttribute.LevelFinal:
return "LevelFinal";
case PolicyStatementAttribute.All:
return "Exclusive LevelFinal";
default:
return string.Empty;
}
}
}
/// <summary>Creates an equivalent copy of the current policy statement.</summary>
/// <returns>A new copy of the <see cref="T:System.Security.Policy.PolicyStatement" /> with <see cref="P:System.Security.Policy.PolicyStatement.PermissionSet" /> and <see cref="P:System.Security.Policy.PolicyStatement.Attributes" /> identical to those of the current <see cref="T:System.Security.Policy.PolicyStatement" />.</returns>
// Token: 0x06003477 RID: 13431 RVA: 0x000B51F8 File Offset: 0x000B33F8
public PolicyStatement Copy()
{
return new PolicyStatement(this.perms, this.attrs);
}
/// <summary>Reconstructs a security object with a given state from an XML encoding.</summary>
/// <param name="et">The XML encoding to use to reconstruct the security object. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="et" /> parameter is null. </exception>
/// <exception cref="T:System.ArgumentException">The <paramref name="et" /> parameter is not a valid <see cref="T:System.Security.Policy.PolicyStatement" /> encoding. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="ControlEvidence" />
/// </PermissionSet>
// Token: 0x06003478 RID: 13432 RVA: 0x000B520C File Offset: 0x000B340C
public void FromXml(SecurityElement et)
{
this.FromXml(et, null);
}
/// <summary>Reconstructs a security object with a given state from an XML encoding.</summary>
/// <param name="et">The XML encoding to use to reconstruct the security object. </param>
/// <param name="level">The <see cref="T:System.Security.Policy.PolicyLevel" /> context for lookup of <see cref="T:System.Security.NamedPermissionSet" /> values. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="et" /> parameter is null. </exception>
/// <exception cref="T:System.ArgumentException">The <paramref name="et" /> parameter is not a valid <see cref="T:System.Security.Policy.PolicyStatement" /> encoding. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="ControlEvidence" />
/// </PermissionSet>
// Token: 0x06003479 RID: 13433 RVA: 0x000B5218 File Offset: 0x000B3418
public void FromXml(SecurityElement et, PolicyLevel level)
{
if (et == null)
{
throw new ArgumentNullException("et");
}
if (et.Tag != "PolicyStatement")
{
throw new ArgumentException(Locale.GetText("Invalid tag."));
}
string text = et.Attribute("Attributes");
if (text != null)
{
this.attrs = (PolicyStatementAttribute)((int)Enum.Parse(typeof(PolicyStatementAttribute), text));
}
SecurityElement securityElement = et.SearchForChildByTag("PermissionSet");
this.PermissionSet.FromXml(securityElement);
}
/// <summary>Creates an XML encoding of the security object and its current state.</summary>
/// <returns>An XML encoding of the security object, including any state information.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x0600347A RID: 13434 RVA: 0x000B52A0 File Offset: 0x000B34A0
public SecurityElement ToXml()
{
return this.ToXml(null);
}
/// <summary>Creates an XML encoding of the security object and its current state.</summary>
/// <returns>An XML encoding of the security object, including any state information.</returns>
/// <param name="level">The <see cref="T:System.Security.Policy.PolicyLevel" /> context for lookup of <see cref="T:System.Security.NamedPermissionSet" /> values. </param>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x0600347B RID: 13435 RVA: 0x000B52AC File Offset: 0x000B34AC
public SecurityElement ToXml(PolicyLevel level)
{
SecurityElement securityElement = new SecurityElement("PolicyStatement");
securityElement.AddAttribute("version", "1");
if (this.attrs != PolicyStatementAttribute.Nothing)
{
securityElement.AddAttribute("Attributes", this.attrs.ToString());
}
securityElement.AddChild(this.PermissionSet.ToXml());
return securityElement;
}
/// <summary>Determines whether the specified <see cref="T:System.Security.Policy.PolicyStatement" /> object is equal to the current <see cref="T:System.Security.Policy.PolicyStatement" />.</summary>
/// <returns>true if the specified <see cref="T:System.Security.Policy.PolicyStatement" /> is equal to the current <see cref="T:System.Security.Policy.PolicyStatement" /> object; otherwise, false.</returns>
/// <param name="obj">The <see cref="T:System.Security.Policy.PolicyStatement" /> object to compare with the current <see cref="T:System.Security.Policy.PolicyStatement" />. </param>
// Token: 0x0600347C RID: 13436 RVA: 0x000B530C File Offset: 0x000B350C
[ComVisible(false)]
public override bool Equals(object obj)
{
if (obj == null)
{
return false;
}
PolicyStatement policyStatement = obj as PolicyStatement;
return policyStatement != null && this.PermissionSet.Equals(obj) && this.attrs == policyStatement.attrs;
}
/// <summary>Gets a hash code for the <see cref="T:System.Security.Policy.PolicyStatement" /> object that is suitable for use in hashing algorithms and data structures such as a hash table.</summary>
/// <returns>A hash code for the current <see cref="T:System.Security.Policy.PolicyStatement" /> object.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x0600347D RID: 13437 RVA: 0x000B5354 File Offset: 0x000B3554
[ComVisible(false)]
public override int GetHashCode()
{
return this.PermissionSet.GetHashCode() ^ (int)this.attrs;
}
// Token: 0x0600347E RID: 13438 RVA: 0x000B5368 File Offset: 0x000B3568
internal static PolicyStatement Empty()
{
return new PolicyStatement(new PermissionSet(PermissionState.None));
}
// Token: 0x04001569 RID: 5481
private PermissionSet perms;
// Token: 0x0400156A RID: 5482
private PolicyStatementAttribute attrs;
}
}
@@ -0,0 +1,26 @@
using System;
using System.Runtime.InteropServices;
namespace System.Security.Policy
{
/// <summary>Defines special attribute flags for security policy on code groups.</summary>
// Token: 0x0200059B RID: 1435
[Flags]
[ComVisible(true)]
[Serializable]
public enum PolicyStatementAttribute
{
/// <summary>No flags are set.</summary>
// Token: 0x0400156C RID: 5484
Nothing = 0,
/// <summary>The exclusive code group flag. When a code group has this flag set, only the permissions associated with that code group are granted to code belonging to the code group. At most, one code group matching a given piece of code can be set as exclusive.</summary>
// Token: 0x0400156D RID: 5485
Exclusive = 1,
/// <summary>The flag representing a policy statement that causes lower policy levels to not be evaluated as part of the resolve operation, effectively allowing the policy level to override lower levels.</summary>
// Token: 0x0400156E RID: 5486
LevelFinal = 2,
/// <summary>All attribute flags are set.</summary>
// Token: 0x0400156F RID: 5487
All = 3
}
}
@@ -0,0 +1,127 @@
using System;
using System.Runtime.InteropServices;
using System.Security.Cryptography.X509Certificates;
using System.Security.Permissions;
namespace System.Security.Policy
{
/// <summary>Provides the Authenticode X.509v3 digital signature of a code assembly as evidence for policy evaluation. This class cannot be inherited.</summary>
// Token: 0x0200059C RID: 1436
[ComVisible(true)]
[Serializable]
public sealed class Publisher : IBuiltInEvidence, IIdentityPermissionFactory
{
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Policy.Publisher" /> class with the Authenticode X.509v3 certificate containing the publisher's public key.</summary>
/// <param name="cert">An <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> that contains the software publisher's public key. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="cert" /> parameter is null. </exception>
// Token: 0x0600347F RID: 13439 RVA: 0x000B5378 File Offset: 0x000B3578
public Publisher(X509Certificate cert)
{
if (cert == null)
{
throw new ArgumentNullException("cert");
}
if (cert.GetHashCode() == 0)
{
throw new ArgumentException("cert");
}
this.m_cert = cert;
}
// Token: 0x06003480 RID: 13440 RVA: 0x000B53BC File Offset: 0x000B35BC
int IBuiltInEvidence.GetRequiredSize(bool verbose)
{
return ((!verbose) ? 1 : 3) + this.m_cert.GetRawCertData().Length;
}
// Token: 0x06003481 RID: 13441 RVA: 0x000B53DC File Offset: 0x000B35DC
[MonoTODO("IBuiltInEvidence")]
int IBuiltInEvidence.InitFromBuffer(char[] buffer, int position)
{
return 0;
}
// Token: 0x06003482 RID: 13442 RVA: 0x000B53E0 File Offset: 0x000B35E0
[MonoTODO("IBuiltInEvidence")]
int IBuiltInEvidence.OutputToBuffer(char[] buffer, int position, bool verbose)
{
return 0;
}
/// <summary>Gets the publisher's Authenticode X.509v3 certificate.</summary>
/// <returns>The publisher's <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" />.</returns>
// Token: 0x17000A51 RID: 2641
// (get) Token: 0x06003483 RID: 13443 RVA: 0x000B53E4 File Offset: 0x000B35E4
public X509Certificate Certificate
{
get
{
if (this.m_cert.GetHashCode() == 0)
{
throw new ArgumentException("m_cert");
}
return this.m_cert;
}
}
/// <summary>Creates an equivalent copy of the <see cref="T:System.Security.Policy.Publisher" />.</summary>
/// <returns>A new, identical copy of the <see cref="T:System.Security.Policy.Publisher" />.</returns>
// Token: 0x06003484 RID: 13444 RVA: 0x000B5408 File Offset: 0x000B3608
public object Copy()
{
return new Publisher(this.m_cert);
}
/// <summary>Creates an identity permission that corresponds to the current instance of the <see cref="T:System.Security.Policy.Publisher" /> class.</summary>
/// <returns>A <see cref="T:System.Security.Permissions.PublisherIdentityPermission" /> for the specified <see cref="T:System.Security.Policy.Publisher" />.</returns>
/// <param name="evidence">The <see cref="T:System.Security.Policy.Evidence" /> from which to construct the identity permission. </param>
// Token: 0x06003485 RID: 13445 RVA: 0x000B5418 File Offset: 0x000B3618
public IPermission CreateIdentityPermission(Evidence evidence)
{
return new PublisherIdentityPermission(this.m_cert);
}
/// <summary>Compares the current <see cref="T:System.Security.Policy.Publisher" /> to the specified object for equivalence.</summary>
/// <returns>true if the two instances of the <see cref="T:System.Security.Policy.Publisher" /> class are equal; otherwise, false.</returns>
/// <param name="o">The <see cref="T:System.Security.Policy.Publisher" /> to test for equivalence with the current object. </param>
/// <exception cref="T:System.ArgumentException">The <paramref name="o" /> parameter is not a <see cref="T:System.Security.Policy.Publisher" /> object. </exception>
// Token: 0x06003486 RID: 13446 RVA: 0x000B5428 File Offset: 0x000B3628
public override bool Equals(object o)
{
Publisher publisher = o as Publisher;
if (publisher == null)
{
throw new ArgumentException("o", Locale.GetText("not a Publisher instance."));
}
return this.m_cert.Equals(publisher.Certificate);
}
/// <summary>Gets the hash code of the current <see cref="P:System.Security.Policy.Publisher.Certificate" />.</summary>
/// <returns>The hash code of the current <see cref="P:System.Security.Policy.Publisher.Certificate" />.</returns>
// Token: 0x06003487 RID: 13447 RVA: 0x000B5468 File Offset: 0x000B3668
public override int GetHashCode()
{
return this.m_cert.GetHashCode();
}
/// <summary>Returns a string representation of the current <see cref="T:System.Security.Policy.Publisher" />.</summary>
/// <returns>A representation of the current <see cref="T:System.Security.Policy.Publisher" />.</returns>
// Token: 0x06003488 RID: 13448 RVA: 0x000B5478 File Offset: 0x000B3678
public override string ToString()
{
SecurityElement securityElement = new SecurityElement("System.Security.Policy.Publisher");
securityElement.AddAttribute("version", "1");
SecurityElement securityElement2 = new SecurityElement("X509v3Certificate");
string rawCertDataString = this.m_cert.GetRawCertDataString();
if (rawCertDataString != null)
{
securityElement2.Text = rawCertDataString;
}
securityElement.AddChild(securityElement2);
return securityElement.ToString();
}
// Token: 0x04001570 RID: 5488
private X509Certificate m_cert;
}
}
@@ -0,0 +1,197 @@
using System;
using System.Collections;
using System.Runtime.InteropServices;
using System.Security.Cryptography.X509Certificates;
using Mono.Security.Cryptography;
namespace System.Security.Policy
{
/// <summary>Determines whether an assembly belongs to a code group by testing its software publisher's Authenticode X.509v3 certificate. This class cannot be inherited.</summary>
// Token: 0x0200059D RID: 1437
[ComVisible(true)]
[Serializable]
public sealed class PublisherMembershipCondition : IConstantMembershipCondition, IMembershipCondition, ISecurityEncodable, ISecurityPolicyEncodable
{
// Token: 0x06003489 RID: 13449 RVA: 0x000B54D4 File Offset: 0x000B36D4
internal PublisherMembershipCondition()
{
}
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Policy.PublisherMembershipCondition" /> class with the Authenticode X.509v3 certificate that determines membership.</summary>
/// <param name="certificate">An <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> that contains the software publisher's public key. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="certificate" /> parameter is null. </exception>
// Token: 0x0600348A RID: 13450 RVA: 0x000B54E4 File Offset: 0x000B36E4
public PublisherMembershipCondition(X509Certificate certificate)
{
if (certificate == null)
{
throw new ArgumentNullException("certificate");
}
if (certificate.GetHashCode() == 0)
{
throw new ArgumentException("certificate");
}
this.x509 = certificate;
}
/// <summary>Gets or sets the Authenticode X.509v3 certificate for which the membership condition tests.</summary>
/// <returns>The <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> for which the membership condition tests.</returns>
/// <exception cref="T:System.ArgumentNullException">The property value is null. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.KeyContainerPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Create" />
/// </PermissionSet>
// Token: 0x17000A52 RID: 2642
// (get) Token: 0x0600348B RID: 13451 RVA: 0x000B5524 File Offset: 0x000B3724
// (set) Token: 0x0600348C RID: 13452 RVA: 0x000B552C File Offset: 0x000B372C
public X509Certificate Certificate
{
get
{
return this.x509;
}
set
{
if (value == null)
{
throw new ArgumentNullException("value");
}
this.x509 = value;
}
}
/// <summary>Determines whether the specified evidence satisfies the membership condition.</summary>
/// <returns>true if the specified evidence satisfies the membership condition; otherwise, false.</returns>
/// <param name="evidence">The <see cref="T:System.Security.Policy.Evidence" /> against which to make the test. </param>
/// <exception cref="T:System.ArgumentNullException">The <see cref="P:System.Security.Policy.PublisherMembershipCondition.Certificate" /> property is null. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.KeyContainerPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Create" />
/// </PermissionSet>
// Token: 0x0600348D RID: 13453 RVA: 0x000B5548 File Offset: 0x000B3748
public bool Check(Evidence evidence)
{
if (evidence == null)
{
return false;
}
IEnumerator hostEnumerator = evidence.GetHostEnumerator();
while (hostEnumerator.MoveNext())
{
if (hostEnumerator.Current is Publisher && this.x509.Equals((hostEnumerator.Current as Publisher).Certificate))
{
return true;
}
}
return false;
}
/// <summary>Creates an equivalent copy of the membership condition.</summary>
/// <returns>A new, identical copy of the current membership condition.</returns>
/// <exception cref="T:System.ArgumentNullException">The <see cref="P:System.Security.Policy.PublisherMembershipCondition.Certificate" /> property is null. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.KeyContainerPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Create" />
/// </PermissionSet>
// Token: 0x0600348E RID: 13454 RVA: 0x000B55A8 File Offset: 0x000B37A8
public IMembershipCondition Copy()
{
return new PublisherMembershipCondition(this.x509);
}
/// <summary>Determines whether the publisher certificate from the specified object is equivalent to the publisher certificate contained in the current <see cref="T:System.Security.Policy.PublisherMembershipCondition" />.</summary>
/// <returns>true if the publisher certificate from the specified object is equivalent to the publisher certificate contained in the current <see cref="T:System.Security.Policy.PublisherMembershipCondition" />; otherwise, false.</returns>
/// <param name="o">The object to compare to the current <see cref="T:System.Security.Policy.PublisherMembershipCondition" />. </param>
/// <exception cref="T:System.ArgumentNullException">The <see cref="P:System.Security.Policy.PublisherMembershipCondition.Certificate" /> property is null. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.KeyContainerPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Create" />
/// </PermissionSet>
// Token: 0x0600348F RID: 13455 RVA: 0x000B55B8 File Offset: 0x000B37B8
public override bool Equals(object o)
{
PublisherMembershipCondition publisherMembershipCondition = o as PublisherMembershipCondition;
return publisherMembershipCondition != null && this.x509.Equals(publisherMembershipCondition.Certificate);
}
/// <summary>Reconstructs a security object with a specified state from an XML encoding.</summary>
/// <param name="e">The XML encoding to use to reconstruct the security object. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="e" /> parameter is null. </exception>
/// <exception cref="T:System.ArgumentException">The <paramref name="e" /> parameter is not a valid membership condition element. </exception>
// Token: 0x06003490 RID: 13456 RVA: 0x000B55E8 File Offset: 0x000B37E8
public void FromXml(SecurityElement e)
{
this.FromXml(e, null);
}
/// <summary>Reconstructs a security object with a specified state from an XML encoding.</summary>
/// <param name="e">The XML encoding to use to reconstruct the security object. </param>
/// <param name="level">The <see cref="T:System.Security.Policy.PolicyLevel" /> context, used to resolve <see cref="T:System.Security.NamedPermissionSet" /> references. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="e" /> parameter is null. </exception>
/// <exception cref="T:System.ArgumentException">The <paramref name="e" /> parameter is not a valid membership condition element. </exception>
// Token: 0x06003491 RID: 13457 RVA: 0x000B55F4 File Offset: 0x000B37F4
public void FromXml(SecurityElement e, PolicyLevel level)
{
MembershipConditionHelper.CheckSecurityElement(e, "e", this.version, this.version);
string text = e.Attribute("X509Certificate");
if (text != null)
{
byte[] array = CryptoConvert.FromHex(text);
this.x509 = new X509Certificate(array);
}
}
/// <summary>Gets the hash code for the current membership condition.</summary>
/// <returns>The hash code for the current membership condition.</returns>
/// <exception cref="T:System.ArgumentNullException">The <see cref="P:System.Security.Policy.PublisherMembershipCondition.Certificate" /> property is null. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.KeyContainerPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Create" />
/// </PermissionSet>
// Token: 0x06003492 RID: 13458 RVA: 0x000B5640 File Offset: 0x000B3840
public override int GetHashCode()
{
return this.x509.GetHashCode();
}
/// <summary>Creates and returns a string representation of the <see cref="T:System.Security.Policy.PublisherMembershipCondition" />.</summary>
/// <returns>A representation of the <see cref="T:System.Security.Policy.PublisherMembershipCondition" />.</returns>
/// <exception cref="T:System.ArgumentNullException">The <see cref="P:System.Security.Policy.PublisherMembershipCondition.Certificate" /> property is null. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.KeyContainerPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Create" />
/// </PermissionSet>
// Token: 0x06003493 RID: 13459 RVA: 0x000B5650 File Offset: 0x000B3850
public override string ToString()
{
return "Publisher - " + this.x509.GetPublicKeyString();
}
/// <summary>Creates an XML encoding of the security object and its current state.</summary>
/// <returns>An XML encoding of the security object, including any state information.</returns>
/// <exception cref="T:System.ArgumentNullException">The <see cref="P:System.Security.Policy.PublisherMembershipCondition.Certificate" /> property is null. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.KeyContainerPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Create" />
/// </PermissionSet>
// Token: 0x06003494 RID: 13460 RVA: 0x000B5668 File Offset: 0x000B3868
public SecurityElement ToXml()
{
return this.ToXml(null);
}
/// <summary>Creates an XML encoding of the security object and its current state with the specified <see cref="T:System.Security.Policy.PolicyLevel" />.</summary>
/// <returns>An XML encoding of the security object, including any state information.</returns>
/// <param name="level">The <see cref="T:System.Security.Policy.PolicyLevel" /> context, which is used to resolve <see cref="T:System.Security.NamedPermissionSet" /> references. </param>
/// <exception cref="T:System.ArgumentNullException">The <see cref="P:System.Security.Policy.PublisherMembershipCondition.Certificate" /> property is null. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.KeyContainerPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Create" />
/// </PermissionSet>
// Token: 0x06003495 RID: 13461 RVA: 0x000B5674 File Offset: 0x000B3874
public SecurityElement ToXml(PolicyLevel level)
{
SecurityElement securityElement = MembershipConditionHelper.Element(typeof(PublisherMembershipCondition), this.version);
securityElement.AddAttribute("X509Certificate", this.x509.GetRawCertDataString());
return securityElement;
}
// Token: 0x04001571 RID: 5489
private readonly int version = 1;
// Token: 0x04001572 RID: 5490
private X509Certificate x509;
}
}
+183
View File
@@ -0,0 +1,183 @@
using System;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using Mono.Security;
namespace System.Security.Policy
{
/// <summary>Provides the Web site from which a code assembly originates as evidence for policy evaluation. This class cannot be inherited.</summary>
// Token: 0x0200059E RID: 1438
[ComVisible(true)]
[Serializable]
public sealed class Site : IBuiltInEvidence, IIdentityPermissionFactory
{
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Policy.Site" /> class with the Web site from which a code assembly originates.</summary>
/// <param name="name">The Web site of origin for the associated code assembly. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="name" /> parameter is null. </exception>
// Token: 0x06003496 RID: 13462 RVA: 0x000B56B0 File Offset: 0x000B38B0
public Site(string name)
{
if (name == null)
{
throw new ArgumentNullException("url");
}
if (!Site.IsValid(name))
{
throw new ArgumentException(Locale.GetText("name is not valid"));
}
this.origin_site = name;
}
// Token: 0x06003497 RID: 13463 RVA: 0x000B56EC File Offset: 0x000B38EC
int IBuiltInEvidence.GetRequiredSize(bool verbose)
{
return ((!verbose) ? 1 : 3) + this.origin_site.Length;
}
// Token: 0x06003498 RID: 13464 RVA: 0x000B5708 File Offset: 0x000B3908
[MonoTODO("IBuiltInEvidence")]
int IBuiltInEvidence.InitFromBuffer(char[] buffer, int position)
{
return 0;
}
// Token: 0x06003499 RID: 13465 RVA: 0x000B570C File Offset: 0x000B390C
[MonoTODO("IBuiltInEvidence")]
int IBuiltInEvidence.OutputToBuffer(char[] buffer, int position, bool verbose)
{
return 0;
}
/// <summary>Creates a new <see cref="T:System.Security.Policy.Site" /> from the specified URL.</summary>
/// <returns>The new <see cref="T:System.Security.Policy.Site" />.</returns>
/// <param name="url">The URL from which to create the new <see cref="T:System.Security.Policy.Site" />. </param>
/// <exception cref="T:System.ArgumentException">The <paramref name="url" /> parameter is not a valid URL. -or-The <paramref name="url" /> parameter is a file name.</exception>
// Token: 0x0600349A RID: 13466 RVA: 0x000B5710 File Offset: 0x000B3910
public static Site CreateFromUrl(string url)
{
if (url == null)
{
throw new ArgumentNullException("url");
}
if (url.Length == 0)
{
throw new FormatException(Locale.GetText("Empty URL."));
}
string text = Site.UrlToSite(url);
if (text == null)
{
string text2 = string.Format(Locale.GetText("Invalid URL '{0}'."), url);
throw new ArgumentException(text2, "url");
}
return new Site(text);
}
/// <summary>Creates an equivalent copy of the <see cref="T:System.Security.Policy.Site" />.</summary>
/// <returns>A new, identical copy of the <see cref="T:System.Security.Policy.Site" />.</returns>
// Token: 0x0600349B RID: 13467 RVA: 0x000B577C File Offset: 0x000B397C
public object Copy()
{
return new Site(this.origin_site);
}
/// <summary>Creates an identity permission that corresponds to the current <see cref="T:System.Security.Policy.Site" />.</summary>
/// <returns>A <see cref="T:System.Security.Permissions.SiteIdentityPermission" /> for the specified <see cref="T:System.Security.Policy.Site" />.</returns>
/// <param name="evidence">The <see cref="T:System.Security.Policy.Evidence" /> from which to construct the identity permission. </param>
// Token: 0x0600349C RID: 13468 RVA: 0x000B578C File Offset: 0x000B398C
public IPermission CreateIdentityPermission(Evidence evidence)
{
return new SiteIdentityPermission(this.origin_site);
}
/// <summary>Compares the current <see cref="T:System.Security.Policy.Site" /> to the specified object for equivalence.</summary>
/// <returns>true if the two instances of the <see cref="T:System.Security.Policy.Site" /> class are equal; otherwise, false.</returns>
/// <param name="o">The <see cref="T:System.Security.Policy.Site" /> to test for equivalence with the current object. </param>
// Token: 0x0600349D RID: 13469 RVA: 0x000B579C File Offset: 0x000B399C
public override bool Equals(object o)
{
Site site = o as Site;
return site != null && string.Compare(site.Name, this.origin_site, true, CultureInfo.InvariantCulture) == 0;
}
/// <summary>Returns the hash code of the current Web site name.</summary>
/// <returns>The hash code of the current Web site name.</returns>
// Token: 0x0600349E RID: 13470 RVA: 0x000B57D4 File Offset: 0x000B39D4
public override int GetHashCode()
{
return this.origin_site.GetHashCode();
}
/// <summary>Returns a string representation of the current <see cref="T:System.Security.Policy.Site" />.</summary>
/// <returns>A representation the current <see cref="T:System.Security.Policy.Site" />.</returns>
// Token: 0x0600349F RID: 13471 RVA: 0x000B57E4 File Offset: 0x000B39E4
public override string ToString()
{
SecurityElement securityElement = new SecurityElement("System.Security.Policy.Site");
securityElement.AddAttribute("version", "1");
securityElement.AddChild(new SecurityElement("Name", this.origin_site));
return securityElement.ToString();
}
/// <summary>Gets the site from which the code assembly originates.</summary>
/// <returns>The name of the site from which the code assembly originates.</returns>
// Token: 0x17000A53 RID: 2643
// (get) Token: 0x060034A0 RID: 13472 RVA: 0x000B5828 File Offset: 0x000B3A28
public string Name
{
get
{
return this.origin_site;
}
}
// Token: 0x060034A1 RID: 13473 RVA: 0x000B5830 File Offset: 0x000B3A30
internal static bool IsValid(string name)
{
if (name == string.Empty)
{
return false;
}
if (name.Length == 1 && name == ".")
{
return false;
}
string[] array = name.Split(new char[] { '.' });
for (int i = 0; i < array.Length; i++)
{
string text = array[i];
if (i != 0 || !(text == "*"))
{
foreach (char c in text)
{
int num = Convert.ToInt32(c);
if (num != 33 && num != 45 && (num < 35 || num > 41) && (num < 48 || num > 57) && (num < 64 || num > 90) && (num < 94 || num > 95) && (num < 97 || num > 123) && (num < 125 || num > 126))
{
return false;
}
}
}
}
return true;
}
// Token: 0x060034A2 RID: 13474 RVA: 0x000B5974 File Offset: 0x000B3B74
internal static string UrlToSite(string url)
{
if (url == null)
{
return null;
}
Uri uri = new Uri(url);
if (uri.Scheme == Uri.UriSchemeFile)
{
return null;
}
string host = uri.Host;
return (!Site.IsValid(host)) ? null : host;
}
// Token: 0x04001573 RID: 5491
internal string origin_site;
}
}
@@ -0,0 +1,193 @@
using System;
using System.Collections;
using System.Globalization;
using System.Runtime.InteropServices;
namespace System.Security.Policy
{
/// <summary>Determines whether an assembly belongs to a code group by testing the site from which it originated. This class cannot be inherited.</summary>
// Token: 0x0200059F RID: 1439
[ComVisible(true)]
[Serializable]
public sealed class SiteMembershipCondition : IConstantMembershipCondition, IMembershipCondition, ISecurityEncodable, ISecurityPolicyEncodable
{
// Token: 0x060034A3 RID: 13475 RVA: 0x000B59C0 File Offset: 0x000B3BC0
internal SiteMembershipCondition()
{
}
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Policy.SiteMembershipCondition" /> class with name of the site that determines membership.</summary>
/// <param name="site">The site name or wildcard expression. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="site" /> parameter is null. </exception>
/// <exception cref="T:System.ArgumentException">The <paramref name="site" /> parameter is not a valid <see cref="T:System.Security.Policy.Site" />. </exception>
// Token: 0x060034A4 RID: 13476 RVA: 0x000B59D0 File Offset: 0x000B3BD0
public SiteMembershipCondition(string site)
{
this.Site = site;
}
/// <summary>Gets or sets the site for which the membership condition tests.</summary>
/// <returns>The site for which the membership condition tests.</returns>
/// <exception cref="T:System.ArgumentNullException">An attempt is made to set <see cref="P:System.Security.Policy.SiteMembershipCondition.Site" /> to null. </exception>
/// <exception cref="T:System.ArgumentException">An attempt is made to set <see cref="P:System.Security.Policy.SiteMembershipCondition.Site" /> to an invalid <see cref="T:System.Security.Policy.Site" />. </exception>
// Token: 0x17000A54 RID: 2644
// (get) Token: 0x060034A5 RID: 13477 RVA: 0x000B59E8 File Offset: 0x000B3BE8
// (set) Token: 0x060034A6 RID: 13478 RVA: 0x000B59F0 File Offset: 0x000B3BF0
public string Site
{
get
{
return this._site;
}
set
{
if (value == null)
{
throw new ArgumentNullException("site");
}
if (!global::System.Security.Policy.Site.IsValid(value))
{
throw new ArgumentException("invalid site");
}
this._site = value;
}
}
/// <summary>Determines whether the specified evidence satisfies the membership condition.</summary>
/// <returns>true if the specified evidence satisfies the membership condition; otherwise, false.</returns>
/// <param name="evidence">The <see cref="T:System.Security.Policy.Evidence" /> against which to make the test. </param>
/// <exception cref="T:System.ArgumentException">The <see cref="P:System.Security.Policy.SiteMembershipCondition.Site" /> property is null. </exception>
// Token: 0x060034A7 RID: 13479 RVA: 0x000B5A2C File Offset: 0x000B3C2C
public bool Check(Evidence evidence)
{
if (evidence == null)
{
return false;
}
IEnumerator hostEnumerator = evidence.GetHostEnumerator();
while (hostEnumerator.MoveNext())
{
if (hostEnumerator.Current is Site)
{
string[] array = this._site.Split(new char[] { '.' });
string[] array2 = (hostEnumerator.Current as Site).origin_site.Split(new char[] { '.' });
int i = array.Length - 1;
int num = array2.Length - 1;
while (i >= 0)
{
if (i == 0)
{
return string.Compare(array[0], "*", true, CultureInfo.InvariantCulture) == 0;
}
if (string.Compare(array[i], array2[num], true, CultureInfo.InvariantCulture) != 0)
{
return false;
}
i--;
num--;
}
return true;
}
}
return false;
}
/// <summary>Creates an equivalent copy of the membership condition.</summary>
/// <returns>A new, identical copy of the current membership condition.</returns>
/// <exception cref="T:System.ArgumentException">The <see cref="P:System.Security.Policy.SiteMembershipCondition.Site" /> property is null. </exception>
// Token: 0x060034A8 RID: 13480 RVA: 0x000B5AFC File Offset: 0x000B3CFC
public IMembershipCondition Copy()
{
return new SiteMembershipCondition(this._site);
}
/// <summary>Determines whether the site from the specified <see cref="T:System.Security.Policy.SiteMembershipCondition" /> object is equivalent to the site contained in the current <see cref="T:System.Security.Policy.SiteMembershipCondition" />.</summary>
/// <returns>true if the site from the specified <see cref="T:System.Security.Policy.SiteMembershipCondition" /> object is equivalent to the site contained in the current <see cref="T:System.Security.Policy.SiteMembershipCondition" />; otherwise, false.</returns>
/// <param name="o">The <see cref="T:System.Security.Policy.SiteMembershipCondition" /> object to compare to the current <see cref="T:System.Security.Policy.SiteMembershipCondition" />. </param>
/// <exception cref="T:System.ArgumentException">The <see cref="P:System.Security.Policy.SiteMembershipCondition.Site" /> property for the current object or the specified object is null. </exception>
// Token: 0x060034A9 RID: 13481 RVA: 0x000B5B0C File Offset: 0x000B3D0C
public override bool Equals(object o)
{
if (o == null)
{
return false;
}
if (o is SiteMembershipCondition)
{
Site site = new Site((o as SiteMembershipCondition)._site);
return site.Equals(new Site(this._site));
}
return false;
}
/// <summary>Reconstructs a security object with a specified state from an XML encoding.</summary>
/// <param name="e">The XML encoding to use to reconstruct the security object. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="e" /> parameter is null. </exception>
/// <exception cref="T:System.ArgumentException">The <paramref name="e" /> parameter is not a valid membership condition element. </exception>
// Token: 0x060034AA RID: 13482 RVA: 0x000B5B50 File Offset: 0x000B3D50
public void FromXml(SecurityElement e)
{
this.FromXml(e, null);
}
/// <summary>Reconstructs a security object with a specified state from an XML encoding.</summary>
/// <param name="e">The XML encoding to use to reconstruct the security object. </param>
/// <param name="level">The <see cref="T:System.Security.Policy.PolicyLevel" /> context, used to resolve <see cref="T:System.Security.NamedPermissionSet" /> references. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="e" /> parameter is null. </exception>
/// <exception cref="T:System.ArgumentException">The <paramref name="e" /> parameter is not a valid membership condition element. </exception>
// Token: 0x060034AB RID: 13483 RVA: 0x000B5B5C File Offset: 0x000B3D5C
public void FromXml(SecurityElement e, PolicyLevel level)
{
MembershipConditionHelper.CheckSecurityElement(e, "e", this.version, this.version);
this._site = e.Attribute("Site");
}
/// <summary>Gets the hash code for the current membership condition.</summary>
/// <returns>The hash code for the current membership condition.</returns>
/// <exception cref="T:System.ArgumentException">The <see cref="P:System.Security.Policy.SiteMembershipCondition.Site" /> property is null. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x060034AC RID: 13484 RVA: 0x000B5B88 File Offset: 0x000B3D88
public override int GetHashCode()
{
return this._site.GetHashCode();
}
/// <summary>Creates and returns a string representation of the membership condition.</summary>
/// <returns>A string representation of the membership condition.</returns>
/// <exception cref="T:System.ArgumentException">The <see cref="P:System.Security.Policy.SiteMembershipCondition.Site" /> property is null. </exception>
// Token: 0x060034AD RID: 13485 RVA: 0x000B5B98 File Offset: 0x000B3D98
public override string ToString()
{
return "Site - " + this._site;
}
/// <summary>Creates an XML encoding of the security object and its current state.</summary>
/// <returns>An XML encoding of the security object, including any state information.</returns>
/// <exception cref="T:System.ArgumentException">The <see cref="P:System.Security.Policy.SiteMembershipCondition.Site" /> property is null. </exception>
// Token: 0x060034AE RID: 13486 RVA: 0x000B5BAC File Offset: 0x000B3DAC
public SecurityElement ToXml()
{
return this.ToXml(null);
}
/// <summary>Creates an XML encoding of the security object and its current state with the specified <see cref="T:System.Security.Policy.PolicyLevel" />.</summary>
/// <returns>An XML encoding of the security object, including any state information.</returns>
/// <param name="level">The <see cref="T:System.Security.Policy.PolicyLevel" /> context, used to resolve <see cref="T:System.Security.NamedPermissionSet" /> references. </param>
/// <exception cref="T:System.ArgumentException">The <see cref="P:System.Security.Policy.SiteMembershipCondition.Site" /> property is null. </exception>
// Token: 0x060034AF RID: 13487 RVA: 0x000B5BB8 File Offset: 0x000B3DB8
public SecurityElement ToXml(PolicyLevel level)
{
SecurityElement securityElement = MembershipConditionHelper.Element(typeof(SiteMembershipCondition), this.version);
securityElement.AddAttribute("Site", this._site);
return securityElement;
}
// Token: 0x04001574 RID: 5492
private readonly int version = 1;
// Token: 0x04001575 RID: 5493
private string _site;
}
}
@@ -0,0 +1,156 @@
using System;
using System.Runtime.InteropServices;
using System.Security.Permissions;
namespace System.Security.Policy
{
/// <summary>Provides the strong name of a code assembly as evidence for policy evaluation. This class cannot be inherited.</summary>
// Token: 0x020005A0 RID: 1440
[ComVisible(true)]
[Serializable]
public sealed class StrongName : IBuiltInEvidence, IIdentityPermissionFactory
{
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Policy.StrongName" /> class with the strong name public key blob, name, and version.</summary>
/// <param name="blob">The <see cref="T:System.Security.Permissions.StrongNamePublicKeyBlob" /> of the software publisher. </param>
/// <param name="name">The simple name section of the strong name. </param>
/// <param name="version">The <see cref="T:System.Version" /> of the strong name. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="blob" /> parameter is null.-or- The <paramref name="name" /> parameter is null.-or- The <paramref name="version" /> parameter is null. </exception>
/// <exception cref="T:System.ArgumentException">The <paramref name="name" /> parameter is an empty string (""). </exception>
// Token: 0x060034B0 RID: 13488 RVA: 0x000B5BF0 File Offset: 0x000B3DF0
public StrongName(StrongNamePublicKeyBlob blob, string name, Version version)
{
if (blob == null)
{
throw new ArgumentNullException("blob");
}
if (name == null)
{
throw new ArgumentNullException("name");
}
if (version == null)
{
throw new ArgumentNullException("version");
}
if (name.Length == 0)
{
throw new ArgumentException(Locale.GetText("Empty"), "name");
}
this.publickey = blob;
this.name = name;
this.version = version;
}
// Token: 0x060034B1 RID: 13489 RVA: 0x000B5C74 File Offset: 0x000B3E74
int IBuiltInEvidence.GetRequiredSize(bool verbose)
{
return ((!verbose) ? 1 : 5) + this.name.Length;
}
// Token: 0x060034B2 RID: 13490 RVA: 0x000B5C90 File Offset: 0x000B3E90
[MonoTODO("IBuiltInEvidence")]
int IBuiltInEvidence.InitFromBuffer(char[] buffer, int position)
{
return 0;
}
// Token: 0x060034B3 RID: 13491 RVA: 0x000B5C94 File Offset: 0x000B3E94
[MonoTODO("IBuiltInEvidence")]
int IBuiltInEvidence.OutputToBuffer(char[] buffer, int position, bool verbose)
{
return 0;
}
/// <summary>Gets the simple name of the current <see cref="T:System.Security.Policy.StrongName" />.</summary>
/// <returns>The simple name part of the <see cref="T:System.Security.Policy.StrongName" />.</returns>
// Token: 0x17000A55 RID: 2645
// (get) Token: 0x060034B4 RID: 13492 RVA: 0x000B5C98 File Offset: 0x000B3E98
public string Name
{
get
{
return this.name;
}
}
/// <summary>Gets the <see cref="T:System.Security.Permissions.StrongNamePublicKeyBlob" /> of the current <see cref="T:System.Security.Policy.StrongName" />.</summary>
/// <returns>The <see cref="T:System.Security.Permissions.StrongNamePublicKeyBlob" /> of the current <see cref="T:System.Security.Policy.StrongName" />.</returns>
// Token: 0x17000A56 RID: 2646
// (get) Token: 0x060034B5 RID: 13493 RVA: 0x000B5CA0 File Offset: 0x000B3EA0
public StrongNamePublicKeyBlob PublicKey
{
get
{
return this.publickey;
}
}
/// <summary>Gets the <see cref="T:System.Version" /> of the current <see cref="T:System.Security.Policy.StrongName" />.</summary>
/// <returns>The <see cref="T:System.Version" /> of the current <see cref="T:System.Security.Policy.StrongName" />.</returns>
// Token: 0x17000A57 RID: 2647
// (get) Token: 0x060034B6 RID: 13494 RVA: 0x000B5CA8 File Offset: 0x000B3EA8
public Version Version
{
get
{
return this.version;
}
}
/// <summary>Creates an equivalent copy of the current <see cref="T:System.Security.Policy.StrongName" />.</summary>
/// <returns>A new, identical copy of the current <see cref="T:System.Security.Policy.StrongName" />.</returns>
// Token: 0x060034B7 RID: 13495 RVA: 0x000B5CB0 File Offset: 0x000B3EB0
public object Copy()
{
return new StrongName(this.publickey, this.name, this.version);
}
/// <summary>Creates a <see cref="T:System.Security.Permissions.StrongNameIdentityPermission" /> that corresponds to the current <see cref="T:System.Security.Policy.StrongName" />.</summary>
/// <returns>A <see cref="T:System.Security.Permissions.StrongNameIdentityPermission" /> for the specified <see cref="T:System.Security.Policy.StrongName" />.</returns>
/// <param name="evidence">The <see cref="T:System.Security.Policy.Evidence" /> from which to construct the <see cref="T:System.Security.Permissions.StrongNameIdentityPermission" />. </param>
// Token: 0x060034B8 RID: 13496 RVA: 0x000B5CCC File Offset: 0x000B3ECC
public IPermission CreateIdentityPermission(Evidence evidence)
{
return new StrongNameIdentityPermission(this.publickey, this.name, this.version);
}
/// <summary>Determines whether the specified strong name is equal to the current strong name.</summary>
/// <returns>true if the specified strong name is equal to the current strong name; otherwise, false.</returns>
/// <param name="o">The strong name to compare against the current strong name. </param>
// Token: 0x060034B9 RID: 13497 RVA: 0x000B5CE8 File Offset: 0x000B3EE8
public override bool Equals(object o)
{
StrongName strongName = o as StrongName;
return strongName != null && !(this.name != strongName.Name) && this.Version.Equals(strongName.Version) && this.PublicKey.Equals(strongName.PublicKey);
}
/// <summary>Gets the hash code of the current <see cref="T:System.Security.Policy.StrongName" />.</summary>
/// <returns>The hash code of the current <see cref="T:System.Security.Policy.StrongName" />.</returns>
// Token: 0x060034BA RID: 13498 RVA: 0x000B5D48 File Offset: 0x000B3F48
public override int GetHashCode()
{
return this.publickey.GetHashCode();
}
/// <summary>Creates a string representation of the current <see cref="T:System.Security.Policy.StrongName" />.</summary>
/// <returns>A representation of the current <see cref="T:System.Security.Policy.StrongName" />.</returns>
// Token: 0x060034BB RID: 13499 RVA: 0x000B5D58 File Offset: 0x000B3F58
public override string ToString()
{
SecurityElement securityElement = new SecurityElement(typeof(StrongName).Name);
securityElement.AddAttribute("version", "1");
securityElement.AddAttribute("Key", this.publickey.ToString());
securityElement.AddAttribute("Name", this.name);
securityElement.AddAttribute("Version", this.version.ToString());
return securityElement.ToString();
}
// Token: 0x04001576 RID: 5494
private StrongNamePublicKeyBlob publickey;
// Token: 0x04001577 RID: 5495
private string name;
// Token: 0x04001578 RID: 5496
private Version version;
}
}
@@ -0,0 +1,265 @@
using System;
using System.Collections;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using System.Text;
namespace System.Security.Policy
{
/// <summary>Determines whether an assembly belongs to a code group by testing its strong name. This class cannot be inherited.</summary>
// Token: 0x020005A1 RID: 1441
[ComVisible(true)]
[Serializable]
public sealed class StrongNameMembershipCondition : IConstantMembershipCondition, IMembershipCondition, ISecurityEncodable, ISecurityPolicyEncodable
{
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Policy.StrongNameMembershipCondition" /> class with the strong name public key blob, name, and version number that determine membership.</summary>
/// <param name="blob">The strong name public key blob of the software publisher. </param>
/// <param name="name">The simple name section of the strong name. </param>
/// <param name="version">The version number of the strong name. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="blob" /> parameter is null. </exception>
/// <exception cref="T:System.ArgumentException">The <paramref name="name" /> parameter is null.-or-The <paramref name="name" /> parameter is an empty string ("").</exception>
// Token: 0x060034BC RID: 13500 RVA: 0x000B5DD0 File Offset: 0x000B3FD0
public StrongNameMembershipCondition(StrongNamePublicKeyBlob blob, string name, Version version)
{
if (blob == null)
{
throw new ArgumentNullException("blob");
}
this.blob = blob;
this.name = name;
if (version != null)
{
this.assemblyVersion = (Version)version.Clone();
}
}
// Token: 0x060034BD RID: 13501 RVA: 0x000B5E28 File Offset: 0x000B4028
internal StrongNameMembershipCondition(SecurityElement e)
{
this.FromXml(e);
}
// Token: 0x060034BE RID: 13502 RVA: 0x000B5E40 File Offset: 0x000B4040
internal StrongNameMembershipCondition()
{
}
/// <summary>Gets or sets the simple name of the <see cref="T:System.Security.Policy.StrongName" /> for which the membership condition tests.</summary>
/// <returns>The simple name of the <see cref="T:System.Security.Policy.StrongName" /> for which the membership condition tests.</returns>
/// <exception cref="T:System.ArgumentException">The value is null.-or-The value is an empty string ("").</exception>
// Token: 0x17000A58 RID: 2648
// (get) Token: 0x060034BF RID: 13503 RVA: 0x000B5E50 File Offset: 0x000B4050
// (set) Token: 0x060034C0 RID: 13504 RVA: 0x000B5E58 File Offset: 0x000B4058
public string Name
{
get
{
return this.name;
}
set
{
this.name = value;
}
}
/// <summary>Gets or sets the <see cref="T:System.Version" /> of the <see cref="T:System.Security.Policy.StrongName" /> for which the membership condition tests.</summary>
/// <returns>The <see cref="T:System.Version" /> of the <see cref="T:System.Security.Policy.StrongName" /> for which the membership condition tests.</returns>
// Token: 0x17000A59 RID: 2649
// (get) Token: 0x060034C1 RID: 13505 RVA: 0x000B5E64 File Offset: 0x000B4064
// (set) Token: 0x060034C2 RID: 13506 RVA: 0x000B5E6C File Offset: 0x000B406C
public Version Version
{
get
{
return this.assemblyVersion;
}
set
{
this.assemblyVersion = value;
}
}
/// <summary>Gets or sets the <see cref="T:System.Security.Permissions.StrongNamePublicKeyBlob" /> of the <see cref="T:System.Security.Policy.StrongName" /> for which the membership condition tests.</summary>
/// <returns>The <see cref="T:System.Security.Permissions.StrongNamePublicKeyBlob" /> of the <see cref="T:System.Security.Policy.StrongName" /> for which the membership condition tests.</returns>
/// <exception cref="T:System.ArgumentNullException">An attempt is made to set the <see cref="P:System.Security.Policy.StrongNameMembershipCondition.PublicKey" /> to null. </exception>
// Token: 0x17000A5A RID: 2650
// (get) Token: 0x060034C3 RID: 13507 RVA: 0x000B5E78 File Offset: 0x000B4078
// (set) Token: 0x060034C4 RID: 13508 RVA: 0x000B5E80 File Offset: 0x000B4080
public StrongNamePublicKeyBlob PublicKey
{
get
{
return this.blob;
}
set
{
if (value == null)
{
throw new ArgumentNullException("PublicKey");
}
this.blob = value;
}
}
/// <summary>Determines whether the specified evidence satisfies the membership condition.</summary>
/// <returns>true if the specified evidence satisfies the membership condition; otherwise, false.</returns>
/// <param name="evidence">The <see cref="T:System.Security.Policy.Evidence" /> against which to make the test. </param>
// Token: 0x060034C5 RID: 13509 RVA: 0x000B5E9C File Offset: 0x000B409C
public bool Check(Evidence evidence)
{
if (evidence == null)
{
return false;
}
IEnumerator hostEnumerator = evidence.GetHostEnumerator();
while (hostEnumerator.MoveNext())
{
object obj = hostEnumerator.Current;
StrongName strongName = obj as StrongName;
if (strongName != null)
{
return strongName.PublicKey.Equals(this.blob) && (this.name == null || !(this.name != strongName.Name)) && (!(this.assemblyVersion != null) || this.assemblyVersion.Equals(strongName.Version));
}
}
return false;
}
/// <summary>Creates an equivalent copy of the current <see cref="T:System.Security.Policy.StrongNameMembershipCondition" />.</summary>
/// <returns>A new, identical copy of the current <see cref="T:System.Security.Policy.StrongNameMembershipCondition" /></returns>
// Token: 0x060034C6 RID: 13510 RVA: 0x000B5F44 File Offset: 0x000B4144
public IMembershipCondition Copy()
{
return new StrongNameMembershipCondition(this.blob, this.name, this.assemblyVersion);
}
/// <summary>Determines whether the <see cref="T:System.Security.Policy.StrongName" /> from the specified object is equivalent to the <see cref="T:System.Security.Policy.StrongName" /> contained in the current <see cref="T:System.Security.Policy.StrongNameMembershipCondition" />.</summary>
/// <returns>true if the <see cref="T:System.Security.Policy.StrongName" /> from the specified object is equivalent to the <see cref="T:System.Security.Policy.StrongName" /> contained in the current <see cref="T:System.Security.Policy.StrongNameMembershipCondition" />; otherwise, false.</returns>
/// <param name="o">The object to compare to the current <see cref="T:System.Security.Policy.StrongNameMembershipCondition" />. </param>
/// <exception cref="T:System.ArgumentException">The <see cref="P:System.Security.Policy.StrongNameMembershipCondition.PublicKey" /> property of the current object or the specified object is null. </exception>
// Token: 0x060034C7 RID: 13511 RVA: 0x000B5F60 File Offset: 0x000B4160
public override bool Equals(object o)
{
StrongNameMembershipCondition strongNameMembershipCondition = o as StrongNameMembershipCondition;
if (strongNameMembershipCondition == null)
{
return false;
}
if (!strongNameMembershipCondition.PublicKey.Equals(this.PublicKey))
{
return false;
}
if (this.name != strongNameMembershipCondition.Name)
{
return false;
}
if (this.assemblyVersion != null)
{
return this.assemblyVersion.Equals(strongNameMembershipCondition.Version);
}
return strongNameMembershipCondition.Version == null;
}
/// <summary>Returns the hash code for the current <see cref="T:System.Security.Policy.StrongNameMembershipCondition" />.</summary>
/// <returns>The hash code for the current <see cref="T:System.Security.Policy.StrongNameMembershipCondition" />.</returns>
/// <exception cref="T:System.ArgumentException">The <see cref="P:System.Security.Policy.StrongNameMembershipCondition.PublicKey" /> property is null. </exception>
// Token: 0x060034C8 RID: 13512 RVA: 0x000B5FDC File Offset: 0x000B41DC
public override int GetHashCode()
{
return this.blob.GetHashCode();
}
/// <summary>Reconstructs a security object with a specified state from an XML encoding.</summary>
/// <param name="e">The XML encoding to use to reconstruct the security object. </param>
// Token: 0x060034C9 RID: 13513 RVA: 0x000B5FEC File Offset: 0x000B41EC
public void FromXml(SecurityElement e)
{
this.FromXml(e, null);
}
/// <summary>Reconstructs a security object with a specified state from an XML encoding.</summary>
/// <param name="e">The XML encoding to use to reconstruct the security object. </param>
/// <param name="level">The <see cref="T:System.Security.Policy.PolicyLevel" /> context, used to resolve <see cref="T:System.Security.NamedPermissionSet" /> references. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="e" /> parameter is null. </exception>
/// <exception cref="T:System.ArgumentException">The <paramref name="e" /> parameter is not a valid membership condition element. </exception>
// Token: 0x060034CA RID: 13514 RVA: 0x000B5FF8 File Offset: 0x000B41F8
public void FromXml(SecurityElement e, PolicyLevel level)
{
MembershipConditionHelper.CheckSecurityElement(e, "e", this.version, this.version);
this.blob = StrongNamePublicKeyBlob.FromString(e.Attribute("PublicKeyBlob"));
this.name = e.Attribute("Name");
string text = e.Attribute("AssemblyVersion");
if (text == null)
{
this.assemblyVersion = null;
}
else
{
this.assemblyVersion = new Version(text);
}
}
/// <summary>Creates and returns a string representation of the current <see cref="T:System.Security.Policy.StrongNameMembershipCondition" />.</summary>
/// <returns>A representation of the current <see cref="T:System.Security.Policy.StrongNameMembershipCondition" />.</returns>
// Token: 0x060034CB RID: 13515 RVA: 0x000B6070 File Offset: 0x000B4270
public override string ToString()
{
StringBuilder stringBuilder = new StringBuilder("StrongName - ");
stringBuilder.Append(this.blob);
if (this.name != null)
{
stringBuilder.AppendFormat(" name = {0}", this.name);
}
if (this.assemblyVersion != null)
{
stringBuilder.AppendFormat(" version = {0}", this.assemblyVersion);
}
return stringBuilder.ToString();
}
/// <summary>Creates an XML encoding of the security object and its current state.</summary>
/// <returns>An XML encoding of the security object, including any state information.</returns>
// Token: 0x060034CC RID: 13516 RVA: 0x000B60DC File Offset: 0x000B42DC
public SecurityElement ToXml()
{
return this.ToXml(null);
}
/// <summary>Creates an XML encoding of the security object and its current state with the specified <see cref="T:System.Security.Policy.PolicyLevel" />.</summary>
/// <returns>An XML encoding of the security object, including any state information.</returns>
/// <param name="level">The <see cref="T:System.Security.Policy.PolicyLevel" /> context, which is used to resolve <see cref="T:System.Security.NamedPermissionSet" /> references. </param>
// Token: 0x060034CD RID: 13517 RVA: 0x000B60E8 File Offset: 0x000B42E8
public SecurityElement ToXml(PolicyLevel level)
{
SecurityElement securityElement = MembershipConditionHelper.Element(typeof(StrongNameMembershipCondition), this.version);
if (this.blob != null)
{
securityElement.AddAttribute("PublicKeyBlob", this.blob.ToString());
}
if (this.name != null)
{
securityElement.AddAttribute("Name", this.name);
}
if (this.assemblyVersion != null)
{
string text = this.assemblyVersion.ToString();
if (text != "0.0")
{
securityElement.AddAttribute("AssemblyVersion", text);
}
}
return securityElement;
}
// Token: 0x04001579 RID: 5497
private readonly int version = 1;
// Token: 0x0400157A RID: 5498
private StrongNamePublicKeyBlob blob;
// Token: 0x0400157B RID: 5499
private string name;
// Token: 0x0400157C RID: 5500
private Version assemblyVersion;
}
}
@@ -0,0 +1,150 @@
using System;
using System.Runtime.InteropServices;
namespace System.Security.Policy
{
/// <summary>Represents the context for the trust manager to consider when making the decision to run an application, and when setting up the security on a new <see cref="T:System.AppDomain" /> in which to run an application.</summary>
// Token: 0x020005A2 RID: 1442
[ComVisible(true)]
public class TrustManagerContext
{
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Policy.TrustManagerContext" /> class. </summary>
// Token: 0x060034CE RID: 13518 RVA: 0x000B6184 File Offset: 0x000B4384
public TrustManagerContext()
: this(TrustManagerUIContext.Run)
{
}
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Policy.TrustManagerContext" /> class using the specified <see cref="T:System.Security.Policy.TrustManagerUIContext" /> object. </summary>
/// <param name="uiContext">One of the enumeration values that specifies the type of trust manager user interface to use. </param>
// Token: 0x060034CF RID: 13519 RVA: 0x000B6190 File Offset: 0x000B4390
public TrustManagerContext(TrustManagerUIContext uiContext)
{
this._ignorePersistedDecision = false;
this._noPrompt = false;
this._keepAlive = false;
this._persist = false;
this._ui = uiContext;
}
/// <summary>Gets or sets a value indicating whether the application security manager should ignore any persisted decisions and call the trust manager.</summary>
/// <returns>true to call the trust manager; otherwise, false. </returns>
// Token: 0x17000A5B RID: 2651
// (get) Token: 0x060034D0 RID: 13520 RVA: 0x000B61BC File Offset: 0x000B43BC
// (set) Token: 0x060034D1 RID: 13521 RVA: 0x000B61C4 File Offset: 0x000B43C4
public virtual bool IgnorePersistedDecision
{
get
{
return this._ignorePersistedDecision;
}
set
{
this._ignorePersistedDecision = value;
}
}
/// <summary>Gets or sets a value indicating whether the trust manager should cache state for this application, to facilitate future requests to determine application trust.</summary>
/// <returns>true to cache state data; otherwise, false. The default is false.</returns>
// Token: 0x17000A5C RID: 2652
// (get) Token: 0x060034D2 RID: 13522 RVA: 0x000B61D0 File Offset: 0x000B43D0
// (set) Token: 0x060034D3 RID: 13523 RVA: 0x000B61D8 File Offset: 0x000B43D8
public virtual bool KeepAlive
{
get
{
return this._keepAlive;
}
set
{
this._keepAlive = value;
}
}
/// <summary>Gets or sets a value indicating whether the trust manager should prompt the user for trust decisions.</summary>
/// <returns>true to not prompt the user; false to prompt the user. The default is false.</returns>
// Token: 0x17000A5D RID: 2653
// (get) Token: 0x060034D4 RID: 13524 RVA: 0x000B61E4 File Offset: 0x000B43E4
// (set) Token: 0x060034D5 RID: 13525 RVA: 0x000B61EC File Offset: 0x000B43EC
public virtual bool NoPrompt
{
get
{
return this._noPrompt;
}
set
{
this._noPrompt = value;
}
}
/// <summary>Gets or sets a value indicating whether the user's response to the consent dialog should be persisted. </summary>
/// <returns>true to cache state data; otherwise, false. The default is true.</returns>
// Token: 0x17000A5E RID: 2654
// (get) Token: 0x060034D6 RID: 13526 RVA: 0x000B61F8 File Offset: 0x000B43F8
// (set) Token: 0x060034D7 RID: 13527 RVA: 0x000B6200 File Offset: 0x000B4400
public virtual bool Persist
{
get
{
return this._persist;
}
set
{
this._persist = value;
}
}
/// <summary>Gets or sets the identity of the previous application identity.</summary>
/// <returns>An <see cref="T:System.ApplicationIdentity" /> object representing the previous <see cref="T:System.ApplicationIdentity" />.</returns>
// Token: 0x17000A5F RID: 2655
// (get) Token: 0x060034D8 RID: 13528 RVA: 0x000B620C File Offset: 0x000B440C
// (set) Token: 0x060034D9 RID: 13529 RVA: 0x000B6214 File Offset: 0x000B4414
public virtual ApplicationIdentity PreviousApplicationIdentity
{
get
{
return this._previousId;
}
set
{
this._previousId = value;
}
}
/// <summary>Gets or sets the type of user interface the trust manager should display.</summary>
/// <returns>One of the enumeration values. The default is <see cref="F:System.Security.Policy.TrustManagerUIContext.Run" />. </returns>
// Token: 0x17000A60 RID: 2656
// (get) Token: 0x060034DA RID: 13530 RVA: 0x000B6220 File Offset: 0x000B4420
// (set) Token: 0x060034DB RID: 13531 RVA: 0x000B6228 File Offset: 0x000B4428
public virtual TrustManagerUIContext UIContext
{
get
{
return this._ui;
}
set
{
this._ui = value;
}
}
// Token: 0x0400157D RID: 5501
private bool _ignorePersistedDecision;
// Token: 0x0400157E RID: 5502
private bool _noPrompt;
// Token: 0x0400157F RID: 5503
private bool _keepAlive;
// Token: 0x04001580 RID: 5504
private bool _persist;
// Token: 0x04001581 RID: 5505
private ApplicationIdentity _previousId;
// Token: 0x04001582 RID: 5506
private TrustManagerUIContext _ui;
}
}
@@ -0,0 +1,21 @@
using System;
using System.Runtime.InteropServices;
namespace System.Security.Policy
{
/// <summary>Specifies the type of user interface (UI) the trust manager should use for trust decisions. </summary>
// Token: 0x020005A3 RID: 1443
[ComVisible(true)]
public enum TrustManagerUIContext
{
/// <summary>An Install UI.</summary>
// Token: 0x04001584 RID: 5508
Install,
/// <summary>An Upgrade UI.</summary>
// Token: 0x04001585 RID: 5509
Upgrade,
/// <summary>A Run UI.</summary>
// Token: 0x04001586 RID: 5510
Run
}
}
@@ -0,0 +1,139 @@
using System;
using System.Runtime.InteropServices;
namespace System.Security.Policy
{
/// <summary>Represents a code group whose policy statement is the union of the current code group's policy statement and the policy statement of all its matching child code groups. This class cannot be inherited.</summary>
// Token: 0x020005A4 RID: 1444
[ComVisible(true)]
[Serializable]
public sealed class UnionCodeGroup : CodeGroup
{
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Policy.UnionCodeGroup" /> class.</summary>
/// <param name="membershipCondition">A membership condition that tests evidence to determine whether this code group applies policy. </param>
/// <param name="policy">The policy statement for the code group in the form of a permission set and attributes to grant code that matches the membership condition. </param>
/// <exception cref="T:System.ArgumentException">The type of the <paramref name="membershipCondition" /> parameter is not valid.-or- The type of the <paramref name="policy" /> parameter is not valid. </exception>
// Token: 0x060034DC RID: 13532 RVA: 0x000B6234 File Offset: 0x000B4434
public UnionCodeGroup(IMembershipCondition membershipCondition, PolicyStatement policy)
: base(membershipCondition, policy)
{
}
// Token: 0x060034DD RID: 13533 RVA: 0x000B6240 File Offset: 0x000B4440
internal UnionCodeGroup(SecurityElement e, PolicyLevel level)
: base(e, level)
{
}
/// <summary>Makes a deep copy of the current code group.</summary>
/// <returns>An equivalent copy of the current code group, including its membership conditions and child code groups.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x060034DE RID: 13534 RVA: 0x000B624C File Offset: 0x000B444C
public override CodeGroup Copy()
{
return this.Copy(true);
}
// Token: 0x060034DF RID: 13535 RVA: 0x000B6258 File Offset: 0x000B4458
internal CodeGroup Copy(bool childs)
{
UnionCodeGroup unionCodeGroup = new UnionCodeGroup(base.MembershipCondition, base.PolicyStatement);
unionCodeGroup.Name = base.Name;
unionCodeGroup.Description = base.Description;
if (childs)
{
foreach (object obj in base.Children)
{
CodeGroup codeGroup = (CodeGroup)obj;
unionCodeGroup.AddChild(codeGroup.Copy());
}
}
return unionCodeGroup;
}
/// <summary>Resolves policy for the code group and its descendants for a set of evidence.</summary>
/// <returns>A policy statement consisting of the permissions granted by the code group with optional attributes, or null if the code group does not apply (the membership condition does not match the specified evidence).</returns>
/// <param name="evidence">The evidence for the assembly. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="evidence" /> parameter is null. </exception>
/// <exception cref="T:System.Security.Policy.PolicyException">More than one code group (including the parent code group and any child code groups) is marked <see cref="F:System.Security.Policy.PolicyStatementAttribute.Exclusive" />. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x060034E0 RID: 13536 RVA: 0x000B6300 File Offset: 0x000B4500
public override PolicyStatement Resolve(Evidence evidence)
{
if (evidence == null)
{
throw new ArgumentNullException("evidence");
}
if (!base.MembershipCondition.Check(evidence))
{
return null;
}
PermissionSet permissionSet = base.PolicyStatement.PermissionSet.Copy();
if (base.Children.Count > 0)
{
foreach (object obj in base.Children)
{
CodeGroup codeGroup = (CodeGroup)obj;
PolicyStatement policyStatement = codeGroup.Resolve(evidence);
if (policyStatement != null)
{
permissionSet = permissionSet.Union(policyStatement.PermissionSet);
}
}
}
PolicyStatement policyStatement2 = base.PolicyStatement.Copy();
policyStatement2.PermissionSet = permissionSet;
return policyStatement2;
}
/// <summary>Resolves matching code groups.</summary>
/// <returns>A <see cref="T:System.Security.Policy.CodeGroup" />.</returns>
/// <param name="evidence">The evidence for the assembly. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="evidence" /> parameter is null. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x060034E1 RID: 13537 RVA: 0x000B63E4 File Offset: 0x000B45E4
public override CodeGroup ResolveMatchingCodeGroups(Evidence evidence)
{
if (evidence == null)
{
throw new ArgumentNullException("evidence");
}
if (!base.MembershipCondition.Check(evidence))
{
return null;
}
CodeGroup codeGroup = this.Copy(false);
if (base.Children.Count > 0)
{
foreach (object obj in base.Children)
{
CodeGroup codeGroup2 = (CodeGroup)obj;
CodeGroup codeGroup3 = codeGroup2.ResolveMatchingCodeGroups(evidence);
if (codeGroup3 != null)
{
codeGroup.AddChild(codeGroup3);
}
}
}
return codeGroup;
}
/// <summary>Gets the merge logic.</summary>
/// <returns>Always the string "Union".</returns>
// Token: 0x17000A61 RID: 2657
// (get) Token: 0x060034E2 RID: 13538 RVA: 0x000B64A4 File Offset: 0x000B46A4
public override string MergeLogic
{
get
{
return "Union";
}
}
}
}
+162
View File
@@ -0,0 +1,162 @@
using System;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using Mono.Security;
namespace System.Security.Policy
{
/// <summary>Provides the URL from which a code assembly originates as evidence for policy evaluation. This class cannot be inherited.</summary>
// Token: 0x020005A5 RID: 1445
[ComVisible(true)]
[Serializable]
public sealed class Url : IBuiltInEvidence, IIdentityPermissionFactory
{
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Policy.Url" /> class with the URL from which a code assembly originates.</summary>
/// <param name="name">The URL of origin for the associated code assembly. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="name" /> parameter is null. </exception>
// Token: 0x060034E3 RID: 13539 RVA: 0x000B64AC File Offset: 0x000B46AC
public Url(string name)
: this(name, false)
{
}
// Token: 0x060034E4 RID: 13540 RVA: 0x000B64B8 File Offset: 0x000B46B8
internal Url(string name, bool validated)
{
this.origin_url = ((!validated) ? this.Prepare(name) : name);
}
// Token: 0x060034E5 RID: 13541 RVA: 0x000B64DC File Offset: 0x000B46DC
int IBuiltInEvidence.GetRequiredSize(bool verbose)
{
return ((!verbose) ? 1 : 3) + this.origin_url.Length;
}
// Token: 0x060034E6 RID: 13542 RVA: 0x000B64F8 File Offset: 0x000B46F8
[MonoTODO("IBuiltInEvidence")]
int IBuiltInEvidence.InitFromBuffer(char[] buffer, int position)
{
return 0;
}
// Token: 0x060034E7 RID: 13543 RVA: 0x000B64FC File Offset: 0x000B46FC
[MonoTODO("IBuiltInEvidence")]
int IBuiltInEvidence.OutputToBuffer(char[] buffer, int position, bool verbose)
{
return 0;
}
/// <summary>Creates a new copy of the evidence object.</summary>
/// <returns>A new, identical copy of the evidence object.</returns>
// Token: 0x060034E8 RID: 13544 RVA: 0x000B6500 File Offset: 0x000B4700
public object Copy()
{
return new Url(this.origin_url, true);
}
/// <summary>Creates an identity permission corresponding to the current instance of the <see cref="T:System.Security.Policy.Url" /> evidence class.</summary>
/// <returns>A <see cref="T:System.Security.Permissions.UrlIdentityPermission" /> for the specified <see cref="T:System.Security.Policy.Url" /> evidence.</returns>
/// <param name="evidence">The evidence set from which to construct the identity permission. </param>
// Token: 0x060034E9 RID: 13545 RVA: 0x000B6510 File Offset: 0x000B4710
public IPermission CreateIdentityPermission(Evidence evidence)
{
return new UrlIdentityPermission(this.origin_url);
}
/// <summary>Compares the current <see cref="T:System.Security.Policy.Url" /> evidence object to the specified object for equivalence.</summary>
/// <returns>true if the two <see cref="T:System.Security.Policy.Url" /> objects are equal; otherwise, false.</returns>
/// <param name="o">The <see cref="T:System.Security.Policy.Url" /> evidence object to test for equivalence with the current object. </param>
// Token: 0x060034EA RID: 13546 RVA: 0x000B6520 File Offset: 0x000B4720
public override bool Equals(object o)
{
Url url = o as Url;
if (url == null)
{
return false;
}
string text = url.Value;
string text2 = this.origin_url;
if (text.IndexOf(Uri.SchemeDelimiter) < 0)
{
text = "file://" + text;
}
if (text2.IndexOf(Uri.SchemeDelimiter) < 0)
{
text2 = "file://" + text2;
}
return string.Compare(text, text2, true, CultureInfo.InvariantCulture) == 0;
}
/// <summary>Gets the hash code of the current URL.</summary>
/// <returns>The hash code of the current URL.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x060034EB RID: 13547 RVA: 0x000B6594 File Offset: 0x000B4794
public override int GetHashCode()
{
string text = this.origin_url;
if (text.IndexOf(Uri.SchemeDelimiter) < 0)
{
text = "file://" + text;
}
return text.GetHashCode();
}
/// <summary>Returns a string representation of the current <see cref="T:System.Security.Policy.Url" />.</summary>
/// <returns>A representation of the current <see cref="T:System.Security.Policy.Url" />.</returns>
// Token: 0x060034EC RID: 13548 RVA: 0x000B65CC File Offset: 0x000B47CC
public override string ToString()
{
SecurityElement securityElement = new SecurityElement("System.Security.Policy.Url");
securityElement.AddAttribute("version", "1");
securityElement.AddChild(new SecurityElement("Url", this.origin_url));
return securityElement.ToString();
}
/// <summary>Gets the URL from which the code assembly originates.</summary>
/// <returns>The URL from which the code assembly originates.</returns>
// Token: 0x17000A62 RID: 2658
// (get) Token: 0x060034ED RID: 13549 RVA: 0x000B6610 File Offset: 0x000B4810
public string Value
{
get
{
return this.origin_url;
}
}
// Token: 0x060034EE RID: 13550 RVA: 0x000B6618 File Offset: 0x000B4818
private string Prepare(string url)
{
if (url == null)
{
throw new ArgumentNullException("Url");
}
if (url == string.Empty)
{
throw new FormatException(Locale.GetText("Invalid (empty) Url"));
}
int num = url.IndexOf(Uri.SchemeDelimiter);
if (num > 0)
{
if (url.StartsWith("file://"))
{
url = "file://" + url.Substring(7);
}
Uri uri = new Uri(url, false, false);
url = uri.ToString();
}
int num2 = url.Length - 1;
if (url[num2] == '/')
{
url = url.Substring(0, num2);
}
return url;
}
// Token: 0x04001587 RID: 5511
private string origin_url;
}
}
@@ -0,0 +1,216 @@
using System;
using System.Collections;
using System.Globalization;
using System.Runtime.InteropServices;
using Mono.Security;
namespace System.Security.Policy
{
/// <summary>Determines whether an assembly belongs to a code group by testing its URL. This class cannot be inherited.</summary>
// Token: 0x020005A6 RID: 1446
[ComVisible(true)]
[Serializable]
public sealed class UrlMembershipCondition : IConstantMembershipCondition, IMembershipCondition, ISecurityEncodable, ISecurityPolicyEncodable
{
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Policy.UrlMembershipCondition" /> class with the URL that determines membership.</summary>
/// <param name="url">The URL for which to test. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="url" /> parameter is null. </exception>
// Token: 0x060034EF RID: 13551 RVA: 0x000B66C0 File Offset: 0x000B48C0
public UrlMembershipCondition(string url)
{
if (url == null)
{
throw new ArgumentNullException("url");
}
this.CheckUrl(url);
this.userUrl = url;
this.url = new Url(url);
}
// Token: 0x060034F0 RID: 13552 RVA: 0x000B6708 File Offset: 0x000B4908
internal UrlMembershipCondition(Url url, string userUrl)
{
this.url = (Url)url.Copy();
this.userUrl = userUrl;
}
/// <summary>Gets or sets the URL for which the membership condition tests.</summary>
/// <returns>The URL for which the membership condition tests.</returns>
/// <exception cref="T:System.ArgumentNullException">An attempt is made to set <see cref="P:System.Security.Policy.UrlMembershipCondition.Url" /> to null. </exception>
// Token: 0x17000A63 RID: 2659
// (get) Token: 0x060034F1 RID: 13553 RVA: 0x000B6730 File Offset: 0x000B4930
// (set) Token: 0x060034F2 RID: 13554 RVA: 0x000B6760 File Offset: 0x000B4960
public string Url
{
get
{
if (this.userUrl == null)
{
this.userUrl = this.url.Value;
}
return this.userUrl;
}
set
{
this.url = new Url(value);
}
}
/// <summary>Determines whether the specified evidence satisfies the membership condition.</summary>
/// <returns>true if the specified evidence satisfies the membership condition; otherwise, false.</returns>
/// <param name="evidence">The evidence set against which to make the test. </param>
/// <exception cref="T:System.ArgumentNullException">The <see cref="P:System.Security.Policy.UrlMembershipCondition.Url" /> property is null. </exception>
// Token: 0x060034F3 RID: 13555 RVA: 0x000B6770 File Offset: 0x000B4970
public bool Check(Evidence evidence)
{
if (evidence == null)
{
return false;
}
string value = this.url.Value;
int num = value.LastIndexOf("*");
if (num == -1)
{
num = value.Length;
}
IEnumerator hostEnumerator = evidence.GetHostEnumerator();
while (hostEnumerator.MoveNext())
{
if (hostEnumerator.Current is Url && string.Compare(value, 0, (hostEnumerator.Current as Url).Value, 0, num, true, CultureInfo.InvariantCulture) == 0)
{
return true;
}
}
return false;
}
/// <summary>Creates an equivalent copy of the membership condition.</summary>
/// <returns>A new, identical copy of the current membership condition.</returns>
/// <exception cref="T:System.ArgumentNullException">The <see cref="P:System.Security.Policy.UrlMembershipCondition.Url" /> property is null. </exception>
// Token: 0x060034F4 RID: 13556 RVA: 0x000B67FC File Offset: 0x000B49FC
public IMembershipCondition Copy()
{
return new UrlMembershipCondition(this.url, this.userUrl);
}
/// <summary>Determines whether the URL from the specified object is equivalent to the URL contained in the current <see cref="T:System.Security.Policy.UrlMembershipCondition" />.</summary>
/// <returns>true if the URL from the specified object is equivalent to the URL contained in the current <see cref="T:System.Security.Policy.UrlMembershipCondition" />; otherwise, false.</returns>
/// <param name="o">The object to compare to the current <see cref="T:System.Security.Policy.UrlMembershipCondition" />. </param>
/// <exception cref="T:System.ArgumentNullException">The <see cref="P:System.Security.Policy.UrlMembershipCondition.Url" /> property of the current object or the specified object is null. </exception>
// Token: 0x060034F5 RID: 13557 RVA: 0x000B6810 File Offset: 0x000B4A10
public override bool Equals(object o)
{
UrlMembershipCondition urlMembershipCondition = o as UrlMembershipCondition;
if (o == null)
{
return false;
}
string value = this.url.Value;
int num = value.Length;
if (value[num - 1] == '*')
{
num--;
if (value[num - 1] == '/')
{
num--;
}
}
return string.Compare(value, 0, urlMembershipCondition.Url, 0, num, true, CultureInfo.InvariantCulture) == 0;
}
/// <summary>Reconstructs a security object with a specified state from an XML encoding.</summary>
/// <param name="e">The XML encoding to use to reconstruct the security object. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="e" /> parameter is null. </exception>
/// <exception cref="T:System.ArgumentException">The <paramref name="e" /> parameter is not a valid membership condition element. </exception>
// Token: 0x060034F6 RID: 13558 RVA: 0x000B6880 File Offset: 0x000B4A80
public void FromXml(SecurityElement e)
{
this.FromXml(e, null);
}
/// <summary>Reconstructs a security object with a specified state from an XML encoding.</summary>
/// <param name="e">The XML encoding to use to reconstruct the security object. </param>
/// <param name="level">The policy level context, used to resolve named permission set references. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="e" /> parameter is null. </exception>
/// <exception cref="T:System.ArgumentException">The <paramref name="e" /> parameter is not a valid membership condition element. </exception>
// Token: 0x060034F7 RID: 13559 RVA: 0x000B688C File Offset: 0x000B4A8C
public void FromXml(SecurityElement e, PolicyLevel level)
{
MembershipConditionHelper.CheckSecurityElement(e, "e", this.version, this.version);
string text = e.Attribute("Url");
if (text != null)
{
this.CheckUrl(text);
this.url = new Url(text);
}
else
{
this.url = null;
}
this.userUrl = text;
}
/// <summary>Gets the hash code for the current membership condition.</summary>
/// <returns>The hash code for the current membership condition.</returns>
/// <exception cref="T:System.ArgumentNullException">The <see cref="P:System.Security.Policy.UrlMembershipCondition.Url" /> property is null. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x060034F8 RID: 13560 RVA: 0x000B68EC File Offset: 0x000B4AEC
public override int GetHashCode()
{
return this.url.GetHashCode();
}
/// <summary>Creates and returns a string representation of the membership condition.</summary>
/// <returns>A string representation of the state of the membership condition.</returns>
/// <exception cref="T:System.ArgumentNullException">The <see cref="P:System.Security.Policy.UrlMembershipCondition.Url" /> property is null. </exception>
// Token: 0x060034F9 RID: 13561 RVA: 0x000B68FC File Offset: 0x000B4AFC
public override string ToString()
{
return "Url - " + this.Url;
}
/// <summary>Creates an XML encoding of the security object and its current state.</summary>
/// <returns>An XML encoding of the security object, including any state information.</returns>
// Token: 0x060034FA RID: 13562 RVA: 0x000B6910 File Offset: 0x000B4B10
public SecurityElement ToXml()
{
return this.ToXml(null);
}
/// <summary>Creates an XML encoding of the security object and its current state with the specified <see cref="T:System.Security.Policy.PolicyLevel" />.</summary>
/// <returns>An XML encoding of the security object, including any state information.</returns>
/// <param name="level">The policy level context for resolving named permission set references. </param>
/// <exception cref="T:System.ArgumentNullException">The <see cref="P:System.Security.Policy.UrlMembershipCondition.Url" /> property is null. </exception>
// Token: 0x060034FB RID: 13563 RVA: 0x000B691C File Offset: 0x000B4B1C
public SecurityElement ToXml(PolicyLevel level)
{
SecurityElement securityElement = MembershipConditionHelper.Element(typeof(UrlMembershipCondition), this.version);
securityElement.AddAttribute("Url", this.userUrl);
return securityElement;
}
// Token: 0x060034FC RID: 13564 RVA: 0x000B6954 File Offset: 0x000B4B54
internal void CheckUrl(string url)
{
int num = url.IndexOf(Uri.SchemeDelimiter);
string text = ((num >= 0) ? url : ("file://" + url));
Uri uri = new Uri(text, false, false);
if (uri.Host.IndexOf('*') >= 1)
{
string text2 = Locale.GetText("Invalid * character in url");
throw new ArgumentException(text2, "name");
}
}
// Token: 0x04001588 RID: 5512
private readonly int version = 1;
// Token: 0x04001589 RID: 5513
private Url url;
// Token: 0x0400158A RID: 5514
private string userUrl;
}
}
+162
View File
@@ -0,0 +1,162 @@
using System;
using System.Globalization;
using System.IO;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using Mono.Security;
namespace System.Security.Policy
{
/// <summary>Provides the security zone of a code assembly as evidence for policy evaluation. This class cannot be inherited.</summary>
// Token: 0x020005A7 RID: 1447
[ComVisible(true)]
[Serializable]
public sealed class Zone : IBuiltInEvidence, IIdentityPermissionFactory
{
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Policy.Zone" /> class with the zone from which a code assembly originates.</summary>
/// <param name="zone">The zone of origin for the associated code assembly. </param>
/// <exception cref="T:System.ArgumentException">The <paramref name="zone" /> parameter is not a valid <see cref="T:System.Security.SecurityZone" />. </exception>
// Token: 0x060034FD RID: 13565 RVA: 0x000B69BC File Offset: 0x000B4BBC
public Zone(SecurityZone zone)
{
if (!Enum.IsDefined(typeof(SecurityZone), zone))
{
string text = string.Format(Locale.GetText("Invalid zone {0}."), zone);
throw new ArgumentException(text, "zone");
}
this.zone = zone;
}
// Token: 0x060034FE RID: 13566 RVA: 0x000B6A14 File Offset: 0x000B4C14
int IBuiltInEvidence.GetRequiredSize(bool verbose)
{
return 3;
}
// Token: 0x060034FF RID: 13567 RVA: 0x000B6A18 File Offset: 0x000B4C18
int IBuiltInEvidence.InitFromBuffer(char[] buffer, int position)
{
int num = (int)buffer[position++];
num += (int)buffer[position++];
return position;
}
// Token: 0x06003500 RID: 13568 RVA: 0x000B6A3C File Offset: 0x000B4C3C
int IBuiltInEvidence.OutputToBuffer(char[] buffer, int position, bool verbose)
{
buffer[position++] = '\u0003';
buffer[position++] = (char)(this.zone >> 16);
buffer[position++] = (char)(this.zone & (SecurityZone)65535);
return position;
}
/// <summary>Gets the zone from which the code assembly originates.</summary>
/// <returns>The zone from which the code assembly originates.</returns>
// Token: 0x17000A64 RID: 2660
// (get) Token: 0x06003501 RID: 13569 RVA: 0x000B6A70 File Offset: 0x000B4C70
public SecurityZone SecurityZone
{
get
{
return this.zone;
}
}
/// <summary>Creates an equivalent copy of the evidence object.</summary>
/// <returns>A new, identical copy of the evidence object.</returns>
// Token: 0x06003502 RID: 13570 RVA: 0x000B6A78 File Offset: 0x000B4C78
public object Copy()
{
return new Zone(this.zone);
}
/// <summary>Creates an identity permission that corresponds to the current instance of the <see cref="T:System.Security.Policy.Zone" /> evidence class.</summary>
/// <returns>A <see cref="T:System.Security.Permissions.ZoneIdentityPermission" /> for the specified <see cref="T:System.Security.Policy.Zone" /> evidence.</returns>
/// <param name="evidence">The evidence set from which to construct the identity permission. </param>
// Token: 0x06003503 RID: 13571 RVA: 0x000B6A88 File Offset: 0x000B4C88
public IPermission CreateIdentityPermission(Evidence evidence)
{
return new ZoneIdentityPermission(this.zone);
}
/// <summary>Creates a new zone with the specified URL.</summary>
/// <returns>A new zone with the specified URL.</returns>
/// <param name="url">The URL from which to create the zone. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="url" /> parameter is null. </exception>
// Token: 0x06003504 RID: 13572 RVA: 0x000B6A98 File Offset: 0x000B4C98
[MonoTODO("Not user configurable yet")]
public static Zone CreateFromUrl(string url)
{
if (url == null)
{
throw new ArgumentNullException("url");
}
SecurityZone securityZone = SecurityZone.NoZone;
if (url.Length == 0)
{
return new Zone(securityZone);
}
Uri uri = new Uri(url);
if (securityZone == SecurityZone.NoZone)
{
if (uri.IsFile)
{
if (File.Exists(uri.LocalPath))
{
securityZone = SecurityZone.MyComputer;
}
else if (string.Compare("FILE://", 0, url, 0, 7, true, CultureInfo.InvariantCulture) == 0)
{
securityZone = SecurityZone.Intranet;
}
else
{
securityZone = SecurityZone.Internet;
}
}
else if (uri.IsLoopback)
{
securityZone = SecurityZone.Intranet;
}
else
{
securityZone = SecurityZone.Internet;
}
}
return new Zone(securityZone);
}
/// <summary>Compares the current <see cref="T:System.Security.Policy.Zone" /> evidence object to the specified object for equivalence.</summary>
/// <returns>true if the two <see cref="T:System.Security.Policy.Zone" /> objects are equal; otherwise, false.</returns>
/// <param name="o">The <see cref="T:System.Security.Policy.Zone" /> evidence object to test for equivalence with the current object. </param>
/// <exception cref="T:System.ArgumentException">The <paramref name="o" /> parameter is not a <see cref="T:System.Security.Policy.Zone" /> object. </exception>
// Token: 0x06003505 RID: 13573 RVA: 0x000B6B3C File Offset: 0x000B4D3C
public override bool Equals(object o)
{
Zone zone = o as Zone;
return zone != null && zone.zone == this.zone;
}
/// <summary>Gets the hash code of the current zone.</summary>
/// <returns>The hash code of the current zone.</returns>
// Token: 0x06003506 RID: 13574 RVA: 0x000B6B68 File Offset: 0x000B4D68
public override int GetHashCode()
{
return (int)this.zone;
}
/// <summary>Returns a string representation of the current <see cref="T:System.Security.Policy.Zone" />.</summary>
/// <returns>A representation of the current <see cref="T:System.Security.Policy.Zone" />.</returns>
// Token: 0x06003507 RID: 13575 RVA: 0x000B6B70 File Offset: 0x000B4D70
public override string ToString()
{
SecurityElement securityElement = new SecurityElement("System.Security.Policy.Zone");
securityElement.AddAttribute("version", "1");
securityElement.AddChild(new SecurityElement("Zone", this.zone.ToString()));
return securityElement.ToString();
}
// Token: 0x0400158B RID: 5515
private SecurityZone zone;
}
}
@@ -0,0 +1,176 @@
using System;
using System.Collections;
using System.Runtime.InteropServices;
namespace System.Security.Policy
{
/// <summary>Determines whether an assembly belongs to a code group by testing its zone of origin. This class cannot be inherited.</summary>
// Token: 0x020005A8 RID: 1448
[ComVisible(true)]
[Serializable]
public sealed class ZoneMembershipCondition : IConstantMembershipCondition, IMembershipCondition, ISecurityEncodable, ISecurityPolicyEncodable
{
// Token: 0x06003508 RID: 13576 RVA: 0x000B6BC0 File Offset: 0x000B4DC0
internal ZoneMembershipCondition()
{
}
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Policy.ZoneMembershipCondition" /> class with the zone that determines membership.</summary>
/// <param name="zone">The <see cref="T:System.Security.SecurityZone" /> for which to test. </param>
/// <exception cref="T:System.ArgumentException">The <paramref name="zone" /> parameter is not a valid <see cref="T:System.Security.SecurityZone" />. </exception>
// Token: 0x06003509 RID: 13577 RVA: 0x000B6BD0 File Offset: 0x000B4DD0
public ZoneMembershipCondition(SecurityZone zone)
{
this.SecurityZone = zone;
}
/// <summary>Gets or sets the zone for which the membership condition tests.</summary>
/// <returns>The zone for which the membership condition tests.</returns>
/// <exception cref="T:System.ArgumentNullException">The value is null. </exception>
/// <exception cref="T:System.ArgumentException">An attempt is made to set <see cref="P:System.Security.Policy.ZoneMembershipCondition.SecurityZone" /> to an invalid <see cref="T:System.Security.SecurityZone" />. </exception>
// Token: 0x17000A65 RID: 2661
// (get) Token: 0x0600350A RID: 13578 RVA: 0x000B6BE8 File Offset: 0x000B4DE8
// (set) Token: 0x0600350B RID: 13579 RVA: 0x000B6BF0 File Offset: 0x000B4DF0
public SecurityZone SecurityZone
{
get
{
return this.zone;
}
set
{
if (!Enum.IsDefined(typeof(SecurityZone), value))
{
throw new ArgumentException(Locale.GetText("invalid zone"));
}
if (value == SecurityZone.NoZone)
{
throw new ArgumentException(Locale.GetText("NoZone isn't valid for membership condition"));
}
this.zone = value;
}
}
/// <summary>Determines whether the specified evidence satisfies the membership condition.</summary>
/// <returns>true if the specified evidence satisfies the membership condition; otherwise, false.</returns>
/// <param name="evidence">The evidence set against which to make the test. </param>
/// <exception cref="T:System.ArgumentNullException">The <see cref="P:System.Security.Policy.ZoneMembershipCondition.SecurityZone" /> property is null. </exception>
/// <exception cref="T:System.ArgumentException">The <see cref="P:System.Security.Policy.ZoneMembershipCondition.SecurityZone" /> property is not a valid <see cref="T:System.Security.SecurityZone" />. </exception>
// Token: 0x0600350C RID: 13580 RVA: 0x000B6C48 File Offset: 0x000B4E48
public bool Check(Evidence evidence)
{
if (evidence == null)
{
return false;
}
IEnumerator hostEnumerator = evidence.GetHostEnumerator();
while (hostEnumerator.MoveNext())
{
object obj = hostEnumerator.Current;
Zone zone = obj as Zone;
if (zone != null && zone.SecurityZone == this.zone)
{
return true;
}
}
return false;
}
/// <summary>Creates an equivalent copy of the membership condition.</summary>
/// <returns>A new, identical copy of the current membership condition.</returns>
/// <exception cref="T:System.ArgumentNullException">The <see cref="P:System.Security.Policy.ZoneMembershipCondition.SecurityZone" /> property is null. </exception>
/// <exception cref="T:System.ArgumentException">The <see cref="P:System.Security.Policy.ZoneMembershipCondition.SecurityZone" /> property is not a valid <see cref="T:System.Security.SecurityZone" />. </exception>
// Token: 0x0600350D RID: 13581 RVA: 0x000B6C9C File Offset: 0x000B4E9C
public IMembershipCondition Copy()
{
return new ZoneMembershipCondition(this.zone);
}
/// <summary>Determines whether the zone from the specified object is equivalent to the zone contained in the current <see cref="T:System.Security.Policy.ZoneMembershipCondition" />.</summary>
/// <returns>true if the zone from the specified object is equivalent to the zone contained in the current <see cref="T:System.Security.Policy.ZoneMembershipCondition" />; otherwise, false.</returns>
/// <param name="o">The object to compare to the current <see cref="T:System.Security.Policy.ZoneMembershipCondition" />. </param>
/// <exception cref="T:System.ArgumentNullException">The <see cref="P:System.Security.Policy.ZoneMembershipCondition.SecurityZone" /> property for the current object or the specified object is null. </exception>
/// <exception cref="T:System.ArgumentException">The <see cref="P:System.Security.Policy.ZoneMembershipCondition.SecurityZone" /> property for the current object or the specified object is not a valid <see cref="T:System.Security.SecurityZone" />. </exception>
// Token: 0x0600350E RID: 13582 RVA: 0x000B6CAC File Offset: 0x000B4EAC
public override bool Equals(object o)
{
ZoneMembershipCondition zoneMembershipCondition = o as ZoneMembershipCondition;
return zoneMembershipCondition != null && zoneMembershipCondition.SecurityZone == this.zone;
}
/// <summary>Reconstructs a security object with a specified state from an XML encoding.</summary>
/// <param name="e">The XML encoding to use to reconstruct the security object. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="e" /> parameter is null. </exception>
/// <exception cref="T:System.ArgumentException">The <paramref name="e" /> parameter is not a valid membership condition element.</exception>
// Token: 0x0600350F RID: 13583 RVA: 0x000B6CD8 File Offset: 0x000B4ED8
public void FromXml(SecurityElement e)
{
this.FromXml(e, null);
}
/// <summary>Reconstructs a security object with a specified state from an XML encoding.</summary>
/// <param name="e">The XML encoding to use to reconstruct the security object. </param>
/// <param name="level">The policy level context used to resolve named permission set references. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="e" /> parameter is null. </exception>
/// <exception cref="T:System.ArgumentException">The <paramref name="e" /> parameter is not a valid membership condition element. </exception>
// Token: 0x06003510 RID: 13584 RVA: 0x000B6CE4 File Offset: 0x000B4EE4
public void FromXml(SecurityElement e, PolicyLevel level)
{
MembershipConditionHelper.CheckSecurityElement(e, "e", this.version, this.version);
string text = e.Attribute("Zone");
if (text != null)
{
this.zone = (SecurityZone)((int)Enum.Parse(typeof(SecurityZone), text));
}
}
/// <summary>Gets the hash code for the current membership condition.</summary>
/// <returns>The hash code for the current membership condition.</returns>
/// <exception cref="T:System.ArgumentNullException">The <see cref="P:System.Security.Policy.ZoneMembershipCondition.SecurityZone" /> property is null. </exception>
/// <exception cref="T:System.ArgumentException">The <see cref="P:System.Security.Policy.ZoneMembershipCondition.SecurityZone" /> property is not a valid <see cref="T:System.Security.SecurityZone" />. </exception>
// Token: 0x06003511 RID: 13585 RVA: 0x000B6D38 File Offset: 0x000B4F38
public override int GetHashCode()
{
return this.zone.GetHashCode();
}
/// <summary>Creates and returns a string representation of the membership condition.</summary>
/// <returns>A string representation of the state of the membership condition.</returns>
/// <exception cref="T:System.ArgumentNullException">The <see cref="P:System.Security.Policy.ZoneMembershipCondition.SecurityZone" /> property is null. </exception>
/// <exception cref="T:System.ArgumentException">The <see cref="P:System.Security.Policy.ZoneMembershipCondition.SecurityZone" /> property is not a valid <see cref="T:System.Security.SecurityZone" />. </exception>
// Token: 0x06003512 RID: 13586 RVA: 0x000B6D4C File Offset: 0x000B4F4C
public override string ToString()
{
return "Zone - " + this.zone;
}
/// <summary>Creates an XML encoding of the security object and its current state.</summary>
/// <returns>An XML encoding of the security object, including any state information.</returns>
/// <exception cref="T:System.ArgumentNullException">The <see cref="P:System.Security.Policy.ZoneMembershipCondition.SecurityZone" /> property is null. </exception>
/// <exception cref="T:System.ArgumentException">The <see cref="P:System.Security.Policy.ZoneMembershipCondition.SecurityZone" /> property is not a valid <see cref="T:System.Security.SecurityZone" />. </exception>
// Token: 0x06003513 RID: 13587 RVA: 0x000B6D64 File Offset: 0x000B4F64
public SecurityElement ToXml()
{
return this.ToXml(null);
}
/// <summary>Creates an XML encoding of the security object and its current state with the specified <see cref="T:System.Security.Policy.PolicyLevel" />.</summary>
/// <returns>An XML encoding of the security object, including any state information.</returns>
/// <param name="level">The policy level context for resolving named permission set references. </param>
/// <exception cref="T:System.ArgumentNullException">The <see cref="P:System.Security.Policy.ZoneMembershipCondition.SecurityZone" /> property is null. </exception>
/// <exception cref="T:System.ArgumentException">The <see cref="P:System.Security.Policy.ZoneMembershipCondition.SecurityZone" /> property is not a valid <see cref="T:System.Security.SecurityZone" />. </exception>
// Token: 0x06003514 RID: 13588 RVA: 0x000B6D70 File Offset: 0x000B4F70
public SecurityElement ToXml(PolicyLevel level)
{
SecurityElement securityElement = MembershipConditionHelper.Element(typeof(ZoneMembershipCondition), this.version);
securityElement.AddAttribute("Zone", this.zone.ToString());
return securityElement;
}
// Token: 0x0400158C RID: 5516
private readonly int version = 1;
// Token: 0x0400158D RID: 5517
private SecurityZone zone;
}
}