128 lines
5.5 KiB
C#
128 lines
5.5 KiB
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
using System.Security.Cryptography.X509Certificates;
|
|
using System.Security.Permissions;
|
|
|
|
namespace System.Security.Policy
|
|
{
|
|
/// <summary>Provides the Authenticode X.509v3 digital signature of a code assembly as evidence for policy evaluation. This class cannot be inherited.</summary>
|
|
// Token: 0x0200059C RID: 1436
|
|
[ComVisible(true)]
|
|
[Serializable]
|
|
public sealed class Publisher : IBuiltInEvidence, IIdentityPermissionFactory
|
|
{
|
|
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Policy.Publisher" /> class with the Authenticode X.509v3 certificate containing the publisher's public key.</summary>
|
|
/// <param name="cert">An <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> that contains the software publisher's public key. </param>
|
|
/// <exception cref="T:System.ArgumentNullException">The <paramref name="cert" /> parameter is null. </exception>
|
|
// Token: 0x0600347F RID: 13439 RVA: 0x000B5378 File Offset: 0x000B3578
|
|
public Publisher(X509Certificate cert)
|
|
{
|
|
if (cert == null)
|
|
{
|
|
throw new ArgumentNullException("cert");
|
|
}
|
|
if (cert.GetHashCode() == 0)
|
|
{
|
|
throw new ArgumentException("cert");
|
|
}
|
|
this.m_cert = cert;
|
|
}
|
|
|
|
// Token: 0x06003480 RID: 13440 RVA: 0x000B53BC File Offset: 0x000B35BC
|
|
int IBuiltInEvidence.GetRequiredSize(bool verbose)
|
|
{
|
|
return ((!verbose) ? 1 : 3) + this.m_cert.GetRawCertData().Length;
|
|
}
|
|
|
|
// Token: 0x06003481 RID: 13441 RVA: 0x000B53DC File Offset: 0x000B35DC
|
|
[MonoTODO("IBuiltInEvidence")]
|
|
int IBuiltInEvidence.InitFromBuffer(char[] buffer, int position)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
// Token: 0x06003482 RID: 13442 RVA: 0x000B53E0 File Offset: 0x000B35E0
|
|
[MonoTODO("IBuiltInEvidence")]
|
|
int IBuiltInEvidence.OutputToBuffer(char[] buffer, int position, bool verbose)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
/// <summary>Gets the publisher's Authenticode X.509v3 certificate.</summary>
|
|
/// <returns>The publisher's <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" />.</returns>
|
|
// Token: 0x17000A51 RID: 2641
|
|
// (get) Token: 0x06003483 RID: 13443 RVA: 0x000B53E4 File Offset: 0x000B35E4
|
|
public X509Certificate Certificate
|
|
{
|
|
get
|
|
{
|
|
if (this.m_cert.GetHashCode() == 0)
|
|
{
|
|
throw new ArgumentException("m_cert");
|
|
}
|
|
return this.m_cert;
|
|
}
|
|
}
|
|
|
|
/// <summary>Creates an equivalent copy of the <see cref="T:System.Security.Policy.Publisher" />.</summary>
|
|
/// <returns>A new, identical copy of the <see cref="T:System.Security.Policy.Publisher" />.</returns>
|
|
// Token: 0x06003484 RID: 13444 RVA: 0x000B5408 File Offset: 0x000B3608
|
|
public object Copy()
|
|
{
|
|
return new Publisher(this.m_cert);
|
|
}
|
|
|
|
/// <summary>Creates an identity permission that corresponds to the current instance of the <see cref="T:System.Security.Policy.Publisher" /> class.</summary>
|
|
/// <returns>A <see cref="T:System.Security.Permissions.PublisherIdentityPermission" /> for the specified <see cref="T:System.Security.Policy.Publisher" />.</returns>
|
|
/// <param name="evidence">The <see cref="T:System.Security.Policy.Evidence" /> from which to construct the identity permission. </param>
|
|
// Token: 0x06003485 RID: 13445 RVA: 0x000B5418 File Offset: 0x000B3618
|
|
public IPermission CreateIdentityPermission(Evidence evidence)
|
|
{
|
|
return new PublisherIdentityPermission(this.m_cert);
|
|
}
|
|
|
|
/// <summary>Compares the current <see cref="T:System.Security.Policy.Publisher" /> to the specified object for equivalence.</summary>
|
|
/// <returns>true if the two instances of the <see cref="T:System.Security.Policy.Publisher" /> class are equal; otherwise, false.</returns>
|
|
/// <param name="o">The <see cref="T:System.Security.Policy.Publisher" /> to test for equivalence with the current object. </param>
|
|
/// <exception cref="T:System.ArgumentException">The <paramref name="o" /> parameter is not a <see cref="T:System.Security.Policy.Publisher" /> object. </exception>
|
|
// Token: 0x06003486 RID: 13446 RVA: 0x000B5428 File Offset: 0x000B3628
|
|
public override bool Equals(object o)
|
|
{
|
|
Publisher publisher = o as Publisher;
|
|
if (publisher == null)
|
|
{
|
|
throw new ArgumentException("o", Locale.GetText("not a Publisher instance."));
|
|
}
|
|
return this.m_cert.Equals(publisher.Certificate);
|
|
}
|
|
|
|
/// <summary>Gets the hash code of the current <see cref="P:System.Security.Policy.Publisher.Certificate" />.</summary>
|
|
/// <returns>The hash code of the current <see cref="P:System.Security.Policy.Publisher.Certificate" />.</returns>
|
|
// Token: 0x06003487 RID: 13447 RVA: 0x000B5468 File Offset: 0x000B3668
|
|
public override int GetHashCode()
|
|
{
|
|
return this.m_cert.GetHashCode();
|
|
}
|
|
|
|
/// <summary>Returns a string representation of the current <see cref="T:System.Security.Policy.Publisher" />.</summary>
|
|
/// <returns>A representation of the current <see cref="T:System.Security.Policy.Publisher" />.</returns>
|
|
// Token: 0x06003488 RID: 13448 RVA: 0x000B5478 File Offset: 0x000B3678
|
|
public override string ToString()
|
|
{
|
|
SecurityElement securityElement = new SecurityElement("System.Security.Policy.Publisher");
|
|
securityElement.AddAttribute("version", "1");
|
|
SecurityElement securityElement2 = new SecurityElement("X509v3Certificate");
|
|
string rawCertDataString = this.m_cert.GetRawCertDataString();
|
|
if (rawCertDataString != null)
|
|
{
|
|
securityElement2.Text = rawCertDataString;
|
|
}
|
|
securityElement.AddChild(securityElement2);
|
|
return securityElement.ToString();
|
|
}
|
|
|
|
// Token: 0x04001570 RID: 5488
|
|
private X509Certificate m_cert;
|
|
}
|
|
}
|