using System; using System.Collections; using System.Globalization; using System.Runtime.InteropServices; using Mono.Security; namespace System.Security.Policy { /// Determines whether an assembly belongs to a code group by testing its URL. This class cannot be inherited. // Token: 0x020005A6 RID: 1446 [ComVisible(true)] [Serializable] public sealed class UrlMembershipCondition : IConstantMembershipCondition, IMembershipCondition, ISecurityEncodable, ISecurityPolicyEncodable { /// Initializes a new instance of the class with the URL that determines membership. /// The URL for which to test. /// The parameter is null. // 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; } /// Gets or sets the URL for which the membership condition tests. /// The URL for which the membership condition tests. /// An attempt is made to set to null. // 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); } } /// Determines whether the specified evidence satisfies the membership condition. /// true if the specified evidence satisfies the membership condition; otherwise, false. /// The evidence set against which to make the test. /// The property is null. // 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; } /// Creates an equivalent copy of the membership condition. /// A new, identical copy of the current membership condition. /// The property is null. // Token: 0x060034F4 RID: 13556 RVA: 0x000B67FC File Offset: 0x000B49FC public IMembershipCondition Copy() { return new UrlMembershipCondition(this.url, this.userUrl); } /// Determines whether the URL from the specified object is equivalent to the URL contained in the current . /// true if the URL from the specified object is equivalent to the URL contained in the current ; otherwise, false. /// The object to compare to the current . /// The property of the current object or the specified object is null. // 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; } /// Reconstructs a security object with a specified state from an XML encoding. /// The XML encoding to use to reconstruct the security object. /// The parameter is null. /// The parameter is not a valid membership condition element. // Token: 0x060034F6 RID: 13558 RVA: 0x000B6880 File Offset: 0x000B4A80 public void FromXml(SecurityElement e) { this.FromXml(e, null); } /// Reconstructs a security object with a specified state from an XML encoding. /// The XML encoding to use to reconstruct the security object. /// The policy level context, used to resolve named permission set references. /// The parameter is null. /// The parameter is not a valid membership condition element. // 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; } /// Gets the hash code for the current membership condition. /// The hash code for the current membership condition. /// The property is null. /// /// /// // Token: 0x060034F8 RID: 13560 RVA: 0x000B68EC File Offset: 0x000B4AEC public override int GetHashCode() { return this.url.GetHashCode(); } /// Creates and returns a string representation of the membership condition. /// A string representation of the state of the membership condition. /// The property is null. // Token: 0x060034F9 RID: 13561 RVA: 0x000B68FC File Offset: 0x000B4AFC public override string ToString() { return "Url - " + this.Url; } /// Creates an XML encoding of the security object and its current state. /// An XML encoding of the security object, including any state information. // Token: 0x060034FA RID: 13562 RVA: 0x000B6910 File Offset: 0x000B4B10 public SecurityElement ToXml() { return this.ToXml(null); } /// Creates an XML encoding of the security object and its current state with the specified . /// An XML encoding of the security object, including any state information. /// The policy level context for resolving named permission set references. /// The property is null. // 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; } }