222 lines
9.3 KiB
C#
222 lines
9.3 KiB
C#
using System;
|
|
using System.Collections;
|
|
using Mono.Security;
|
|
using Mono.Security.X509;
|
|
|
|
namespace System.Security.Cryptography.X509Certificates
|
|
{
|
|
/// <summary>Represents a collection of <see cref="T:System.Security.Cryptography.X509Certificates.X509Extension" /> objects. This class cannot be inherited.</summary>
|
|
// Token: 0x02000296 RID: 662
|
|
public sealed class X509ExtensionCollection : ICollection, IEnumerable
|
|
{
|
|
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Cryptography.X509Certificates.X509ExtensionCollection" /> class. </summary>
|
|
// Token: 0x06001867 RID: 6247 RVA: 0x00053010 File Offset: 0x00051210
|
|
public X509ExtensionCollection()
|
|
{
|
|
this._list = new ArrayList();
|
|
}
|
|
|
|
// Token: 0x06001868 RID: 6248 RVA: 0x00053024 File Offset: 0x00051224
|
|
internal X509ExtensionCollection(X509Certificate cert)
|
|
{
|
|
this._list = new ArrayList(cert.Extensions.Count);
|
|
if (cert.Extensions.Count == 0)
|
|
{
|
|
return;
|
|
}
|
|
object[] array = new object[2];
|
|
foreach (object obj in cert.Extensions)
|
|
{
|
|
X509Extension x509Extension = (X509Extension)obj;
|
|
bool critical = x509Extension.Critical;
|
|
string oid = x509Extension.Oid;
|
|
byte[] array2 = null;
|
|
ASN1 value = x509Extension.Value;
|
|
if (value.Tag == 4 && value.Count > 0)
|
|
{
|
|
array2 = value[0].GetBytes();
|
|
}
|
|
array[0] = new AsnEncodedData(oid, array2);
|
|
array[1] = critical;
|
|
X509Extension x509Extension2 = (X509Extension)CryptoConfig.CreateFromName(oid, array);
|
|
if (x509Extension2 == null)
|
|
{
|
|
x509Extension2 = new X509Extension(oid, array2, critical);
|
|
}
|
|
this._list.Add(x509Extension2);
|
|
}
|
|
}
|
|
|
|
/// <summary>Copies the collection into an array starting at the specified index.</summary>
|
|
/// <param name="array">An array of <see cref="T:System.Security.Cryptography.X509Certificates.X509Extension" /> objects. </param>
|
|
/// <param name="index">The location in the array at which copying starts. </param>
|
|
/// <exception cref="T:System.ArgumentException">
|
|
/// <paramref name="index" /> is a zero-length string or contains an invalid value. </exception>
|
|
/// <exception cref="T:System.ArgumentNullException">
|
|
/// <paramref name="index" /> is null. </exception>
|
|
/// <exception cref="T:System.ArgumentOutOfRangeException">
|
|
/// <paramref name="index" /> specifies a value that is not in the range of the array. </exception>
|
|
// Token: 0x06001869 RID: 6249 RVA: 0x0005314C File Offset: 0x0005134C
|
|
void ICollection.CopyTo(Array array, int index)
|
|
{
|
|
if (array == null)
|
|
{
|
|
throw new ArgumentNullException("array");
|
|
}
|
|
if (index < 0)
|
|
{
|
|
throw new ArgumentOutOfRangeException("negative index");
|
|
}
|
|
if (index >= array.Length)
|
|
{
|
|
throw new ArgumentOutOfRangeException("index >= array.Length");
|
|
}
|
|
this._list.CopyTo(array, index);
|
|
}
|
|
|
|
/// <summary>Returns an enumerator that can iterate through an <see cref="T:System.Security.Cryptography.X509Certificates.X509ExtensionCollection" /> object.</summary>
|
|
/// <returns>An <see cref="T:System.Collections.IEnumerator" /> object to use to iterate through the <see cref="T:System.Security.Cryptography.X509Certificates.X509ExtensionCollection" /> object.</returns>
|
|
// Token: 0x0600186A RID: 6250 RVA: 0x000531A0 File Offset: 0x000513A0
|
|
IEnumerator IEnumerable.GetEnumerator()
|
|
{
|
|
return new X509ExtensionEnumerator(this._list);
|
|
}
|
|
|
|
/// <summary>Gets the number of <see cref="T:System.Security.Cryptography.X509Certificates.X509Extension" /> objects in a <see cref="T:System.Security.Cryptography.X509Certificates.X509ExtensionCollection" /> object.</summary>
|
|
/// <returns>An integer representing the number of <see cref="T:System.Security.Cryptography.X509Certificates.X509Extension" /> objects in the <see cref="T:System.Security.Cryptography.X509Certificates.X509ExtensionCollection" /> object.</returns>
|
|
// Token: 0x170007AA RID: 1962
|
|
// (get) Token: 0x0600186B RID: 6251 RVA: 0x000531B0 File Offset: 0x000513B0
|
|
public int Count
|
|
{
|
|
get
|
|
{
|
|
return this._list.Count;
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets a value indicating whether the collection is guaranteed to be thread safe.</summary>
|
|
/// <returns>true if the collection is thread safe; otherwise, false.</returns>
|
|
// Token: 0x170007AB RID: 1963
|
|
// (get) Token: 0x0600186C RID: 6252 RVA: 0x000531C0 File Offset: 0x000513C0
|
|
public bool IsSynchronized
|
|
{
|
|
get
|
|
{
|
|
return this._list.IsSynchronized;
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets an object that you can use to synchronize access to the <see cref="T:System.Security.Cryptography.X509Certificates.X509ExtensionCollection" /> object.</summary>
|
|
/// <returns>An object that you can use to synchronize access to the <see cref="T:System.Security.Cryptography.X509Certificates.X509ExtensionCollection" /> object.</returns>
|
|
// Token: 0x170007AC RID: 1964
|
|
// (get) Token: 0x0600186D RID: 6253 RVA: 0x000531D0 File Offset: 0x000513D0
|
|
public object SyncRoot
|
|
{
|
|
get
|
|
{
|
|
return this;
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets the <see cref="T:System.Security.Cryptography.X509Certificates.X509Extension" /> object at the specified index.</summary>
|
|
/// <returns>An <see cref="T:System.Security.Cryptography.X509Certificates.X509Extension" /> object.</returns>
|
|
/// <param name="index">The location of the <see cref="T:System.Security.Cryptography.X509Certificates.X509Extension" /> object to retrieve. </param>
|
|
/// <exception cref="T:System.InvalidOperationException">
|
|
/// <paramref name="index" /> is less than zero. </exception>
|
|
/// <exception cref="T:System.ArgumentOutOfRangeException">
|
|
/// <paramref name="index" /> is equal to or greater than the length of the array. </exception>
|
|
// Token: 0x170007AD RID: 1965
|
|
public X509Extension this[int index]
|
|
{
|
|
get
|
|
{
|
|
if (index < 0)
|
|
{
|
|
throw new InvalidOperationException("index");
|
|
}
|
|
return (X509Extension)this._list[index];
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets the first <see cref="T:System.Security.Cryptography.X509Certificates.X509Extension" /> object whose value or friendly name is specified by an object identifier (OID).</summary>
|
|
/// <returns>An <see cref="T:System.Security.Cryptography.X509Certificates.X509Extension" /> object.</returns>
|
|
/// <param name="oid">The object identifier (OID) of the extension to retrieve. </param>
|
|
// Token: 0x170007AE RID: 1966
|
|
public X509Extension this[string oid]
|
|
{
|
|
get
|
|
{
|
|
if (oid == null)
|
|
{
|
|
throw new ArgumentNullException("oid");
|
|
}
|
|
if (this._list.Count == 0 || oid.Length == 0)
|
|
{
|
|
return null;
|
|
}
|
|
foreach (object obj in this._list)
|
|
{
|
|
X509Extension x509Extension = (X509Extension)obj;
|
|
if (x509Extension.Oid.Value.Equals(oid))
|
|
{
|
|
return x509Extension;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/// <summary>Adds an <see cref="T:System.Security.Cryptography.X509Certificates.X509Extension" /> object to an <see cref="T:System.Security.Cryptography.X509Certificates.X509ExtensionCollection" /> object.</summary>
|
|
/// <returns>The index at which the <paramref name="extension" /> parameter was added.</returns>
|
|
/// <param name="extension">An <see cref="T:System.Security.Cryptography.X509Certificates.X509Extension" /> object to add to the <see cref="T:System.Security.Cryptography.X509Certificates.X509ExtensionCollection" /> object. </param>
|
|
/// <exception cref="T:System.ArgumentNullException">The value of the <paramref name="extension" /> parameter is null.</exception>
|
|
// Token: 0x06001870 RID: 6256 RVA: 0x000532B4 File Offset: 0x000514B4
|
|
public int Add(X509Extension extension)
|
|
{
|
|
if (extension == null)
|
|
{
|
|
throw new ArgumentNullException("extension");
|
|
}
|
|
return this._list.Add(extension);
|
|
}
|
|
|
|
/// <summary>Copies a collection into an array starting at the specified index.</summary>
|
|
/// <param name="array">An array of <see cref="T:System.Security.Cryptography.X509Certificates.X509Extension" /> objects. </param>
|
|
/// <param name="index">The location in the array at which copying starts. </param>
|
|
/// <exception cref="T:System.ArgumentException">
|
|
/// <paramref name="index" /> is a zero-length string or contains an invalid value. </exception>
|
|
/// <exception cref="T:System.ArgumentNullException">
|
|
/// <paramref name="index" /> is null. </exception>
|
|
/// <exception cref="T:System.ArgumentOutOfRangeException">
|
|
/// <paramref name="index" /> specifies a value that is not in the range of the array. </exception>
|
|
// Token: 0x06001871 RID: 6257 RVA: 0x000532D4 File Offset: 0x000514D4
|
|
public void CopyTo(X509Extension[] array, int index)
|
|
{
|
|
if (array == null)
|
|
{
|
|
throw new ArgumentNullException("array");
|
|
}
|
|
if (index < 0)
|
|
{
|
|
throw new ArgumentOutOfRangeException("negative index");
|
|
}
|
|
if (index >= array.Length)
|
|
{
|
|
throw new ArgumentOutOfRangeException("index >= array.Length");
|
|
}
|
|
this._list.CopyTo(array, index);
|
|
}
|
|
|
|
/// <summary>Returns an enumerator that can iterate through an <see cref="T:System.Security.Cryptography.X509Certificates.X509ExtensionCollection" /> object.</summary>
|
|
/// <returns>An <see cref="T:System.Security.Cryptography.X509Certificates.X509ExtensionEnumerator" /> object to use to iterate through the <see cref="T:System.Security.Cryptography.X509Certificates.X509ExtensionCollection" /> object.</returns>
|
|
// Token: 0x06001872 RID: 6258 RVA: 0x00053328 File Offset: 0x00051528
|
|
public X509ExtensionEnumerator GetEnumerator()
|
|
{
|
|
return new X509ExtensionEnumerator(this._list);
|
|
}
|
|
|
|
// Token: 0x04001344 RID: 4932
|
|
private ArrayList _list;
|
|
}
|
|
}
|