using System; using System.Globalization; using System.Runtime.InteropServices; using System.Security.Permissions; using Mono.Security; namespace System.Security.Policy { /// Provides the Web site from which a code assembly originates as evidence for policy evaluation. This class cannot be inherited. // Token: 0x0200059E RID: 1438 [ComVisible(true)] [Serializable] public sealed class Site : IBuiltInEvidence, IIdentityPermissionFactory { /// Initializes a new instance of the class with the Web site from which a code assembly originates. /// The Web site of origin for the associated code assembly. /// The parameter is null. // 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; } /// Creates a new from the specified URL. /// The new . /// The URL from which to create the new . /// The parameter is not a valid URL. -or-The parameter is a file name. // 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); } /// Creates an equivalent copy of the . /// A new, identical copy of the . // Token: 0x0600349B RID: 13467 RVA: 0x000B577C File Offset: 0x000B397C public object Copy() { return new Site(this.origin_site); } /// Creates an identity permission that corresponds to the current . /// A for the specified . /// The from which to construct the identity permission. // Token: 0x0600349C RID: 13468 RVA: 0x000B578C File Offset: 0x000B398C public IPermission CreateIdentityPermission(Evidence evidence) { return new SiteIdentityPermission(this.origin_site); } /// Compares the current to the specified object for equivalence. /// true if the two instances of the class are equal; otherwise, false. /// The to test for equivalence with the current object. // 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; } /// Returns the hash code of the current Web site name. /// The hash code of the current Web site name. // Token: 0x0600349E RID: 13470 RVA: 0x000B57D4 File Offset: 0x000B39D4 public override int GetHashCode() { return this.origin_site.GetHashCode(); } /// Returns a string representation of the current . /// A representation the current . // 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(); } /// Gets the site from which the code assembly originates. /// The name of the site from which the code assembly originates. // 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; } }