using System;
using System.Collections;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using System.Text;
namespace System.Security.Policy
{
/// Determines whether an assembly belongs to a code group by testing its strong name. This class cannot be inherited.
// Token: 0x020005A1 RID: 1441
[ComVisible(true)]
[Serializable]
public sealed class StrongNameMembershipCondition : IConstantMembershipCondition, IMembershipCondition, ISecurityEncodable, ISecurityPolicyEncodable
{
/// Initializes a new instance of the class with the strong name public key blob, name, and version number that determine membership.
/// The strong name public key blob of the software publisher.
/// The simple name section of the strong name.
/// The version number of the strong name.
/// The parameter is null.
/// The parameter is null.-or-The parameter is an empty string ("").
// 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()
{
}
/// Gets or sets the simple name of the for which the membership condition tests.
/// The simple name of the for which the membership condition tests.
/// The value is null.-or-The value is an empty string ("").
// 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;
}
}
/// Gets or sets the of the for which the membership condition tests.
/// The of the for which the membership condition tests.
// 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;
}
}
/// Gets or sets the of the for which the membership condition tests.
/// The of the for which the membership condition tests.
/// An attempt is made to set the to null.
// 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;
}
}
/// Determines whether the specified evidence satisfies the membership condition.
/// true if the specified evidence satisfies the membership condition; otherwise, false.
/// The against which to make the test.
// 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;
}
/// Creates an equivalent copy of the current .
/// A new, identical copy of the current
// Token: 0x060034C6 RID: 13510 RVA: 0x000B5F44 File Offset: 0x000B4144
public IMembershipCondition Copy()
{
return new StrongNameMembershipCondition(this.blob, this.name, this.assemblyVersion);
}
/// Determines whether the from the specified object is equivalent to the contained in the current .
/// true if the from the specified object is equivalent to the 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: 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;
}
/// Returns the hash code for the current .
/// The hash code for the current .
/// The property is null.
// Token: 0x060034C8 RID: 13512 RVA: 0x000B5FDC File Offset: 0x000B41DC
public override int GetHashCode()
{
return this.blob.GetHashCode();
}
/// Reconstructs a security object with a specified state from an XML encoding.
/// The XML encoding to use to reconstruct the security object.
// Token: 0x060034C9 RID: 13513 RVA: 0x000B5FEC File Offset: 0x000B41EC
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 context, used to resolve references.
/// The parameter is null.
/// The parameter is not a valid membership condition element.
// 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);
}
}
/// Creates and returns a string representation of the current .
/// A representation of the current .
// 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();
}
/// Creates an XML encoding of the security object and its current state.
/// An XML encoding of the security object, including any state information.
// Token: 0x060034CC RID: 13516 RVA: 0x000B60DC File Offset: 0x000B42DC
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 context, which is used to resolve references.
// 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;
}
}