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,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;
}
}