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 { /// Encapsulates security decisions about an application. This class cannot be inherited. // Token: 0x0200057E RID: 1406 [ComVisible(true)] [Serializable] public sealed class ApplicationTrust : ISecurityEncodable { /// Initializes a new instance of the class. // Token: 0x0600335C RID: 13148 RVA: 0x000B07D0 File Offset: 0x000AE9D0 public ApplicationTrust() { this.fullTrustAssemblies = new List(0); } /// Initializes a new instance of the class with an . /// An that uniquely identifies an application. // 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 fullTrustAssemblies) { if (defaultGrantSet == null) { throw new ArgumentNullException("defaultGrantSet"); } this._defaultPolicy = new PolicyStatement(defaultGrantSet); if (fullTrustAssemblies == null) { throw new ArgumentNullException("fullTrustAssemblies"); } this.fullTrustAssemblies = new List(); 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()); } } /// Gets or sets the application identity for the application trust object. /// An for the application trust object. /// /// cannot be set because it has a value of null. // 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; } } /// Gets or sets the policy statement defining the default grant set. /// A describing the default grants. // 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; } } /// Gets or sets extra security information about the application. /// An object containing additional security information about the application. /// /// /// // 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; } } /// Gets or sets a value indicating whether the application has the required permission grants and is trusted to run. /// true if the application is trusted to run; otherwise, false. The default is false. // 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; } } /// Gets or sets a value indicating whether application trust information is persisted. /// true if application trust information is persisted; otherwise, false. The default is false. // 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; } } /// Reconstructs an object with a given state from an XML encoding. /// The XML encoding to use to reconstruct the object. /// /// is null. /// The XML encoding used for is invalid. /// /// /// // 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); } } } } /// Creates an XML encoding of the object and its current state. /// An XML encoding of the security object, including any state information. /// /// /// /// /// // 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 fullTrustAssemblies; } }