using System; using System.Collections; using System.Runtime.InteropServices; using System.Security.Cryptography.X509Certificates; using Mono.Security.Cryptography; namespace System.Security.Policy { /// Determines whether an assembly belongs to a code group by testing its software publisher's Authenticode X.509v3 certificate. This class cannot be inherited. // Token: 0x0200059D RID: 1437 [ComVisible(true)] [Serializable] public sealed class PublisherMembershipCondition : IConstantMembershipCondition, IMembershipCondition, ISecurityEncodable, ISecurityPolicyEncodable { // Token: 0x06003489 RID: 13449 RVA: 0x000B54D4 File Offset: 0x000B36D4 internal PublisherMembershipCondition() { } /// Initializes a new instance of the class with the Authenticode X.509v3 certificate that determines membership. /// An that contains the software publisher's public key. /// The parameter is null. // Token: 0x0600348A RID: 13450 RVA: 0x000B54E4 File Offset: 0x000B36E4 public PublisherMembershipCondition(X509Certificate certificate) { if (certificate == null) { throw new ArgumentNullException("certificate"); } if (certificate.GetHashCode() == 0) { throw new ArgumentException("certificate"); } this.x509 = certificate; } /// Gets or sets the Authenticode X.509v3 certificate for which the membership condition tests. /// The for which the membership condition tests. /// The property value is null. /// /// /// // Token: 0x17000A52 RID: 2642 // (get) Token: 0x0600348B RID: 13451 RVA: 0x000B5524 File Offset: 0x000B3724 // (set) Token: 0x0600348C RID: 13452 RVA: 0x000B552C File Offset: 0x000B372C public X509Certificate Certificate { get { return this.x509; } set { if (value == null) { throw new ArgumentNullException("value"); } this.x509 = 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. /// The property is null. /// /// /// // Token: 0x0600348D RID: 13453 RVA: 0x000B5548 File Offset: 0x000B3748 public bool Check(Evidence evidence) { if (evidence == null) { return false; } IEnumerator hostEnumerator = evidence.GetHostEnumerator(); while (hostEnumerator.MoveNext()) { if (hostEnumerator.Current is Publisher && this.x509.Equals((hostEnumerator.Current as Publisher).Certificate)) { 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: 0x0600348E RID: 13454 RVA: 0x000B55A8 File Offset: 0x000B37A8 public IMembershipCondition Copy() { return new PublisherMembershipCondition(this.x509); } /// Determines whether the publisher certificate from the specified object is equivalent to the publisher certificate contained in the current . /// true if the publisher certificate from the specified object is equivalent to the publisher certificate contained in the current ; otherwise, false. /// The object to compare to the current . /// The property is null. /// /// /// // Token: 0x0600348F RID: 13455 RVA: 0x000B55B8 File Offset: 0x000B37B8 public override bool Equals(object o) { PublisherMembershipCondition publisherMembershipCondition = o as PublisherMembershipCondition; return publisherMembershipCondition != null && this.x509.Equals(publisherMembershipCondition.Certificate); } /// 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: 0x06003490 RID: 13456 RVA: 0x000B55E8 File Offset: 0x000B37E8 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: 0x06003491 RID: 13457 RVA: 0x000B55F4 File Offset: 0x000B37F4 public void FromXml(SecurityElement e, PolicyLevel level) { MembershipConditionHelper.CheckSecurityElement(e, "e", this.version, this.version); string text = e.Attribute("X509Certificate"); if (text != null) { byte[] array = CryptoConvert.FromHex(text); this.x509 = new X509Certificate(array); } } /// Gets the hash code for the current membership condition. /// The hash code for the current membership condition. /// The property is null. /// /// /// // Token: 0x06003492 RID: 13458 RVA: 0x000B5640 File Offset: 0x000B3840 public override int GetHashCode() { return this.x509.GetHashCode(); } /// Creates and returns a string representation of the . /// A representation of the . /// The property is null. /// /// /// // Token: 0x06003493 RID: 13459 RVA: 0x000B5650 File Offset: 0x000B3850 public override string ToString() { return "Publisher - " + this.x509.GetPublicKeyString(); } /// Creates an XML encoding of the security object and its current state. /// An XML encoding of the security object, including any state information. /// The property is null. /// /// /// // Token: 0x06003494 RID: 13460 RVA: 0x000B5668 File Offset: 0x000B3868 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. /// The property is null. /// /// /// // Token: 0x06003495 RID: 13461 RVA: 0x000B5674 File Offset: 0x000B3874 public SecurityElement ToXml(PolicyLevel level) { SecurityElement securityElement = MembershipConditionHelper.Element(typeof(PublisherMembershipCondition), this.version); securityElement.AddAttribute("X509Certificate", this.x509.GetRawCertDataString()); return securityElement; } // Token: 0x04001571 RID: 5489 private readonly int version = 1; // Token: 0x04001572 RID: 5490 private X509Certificate x509; } }