X509CertificateExCollection.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. //
  2. // X509CertificateExCollection.cs - System.Security.Cryptography.X509Certificates.X509CertificateExCollection
  3. //
  4. // Author:
  5. // Sebastien Pouliot ([email protected])
  6. //
  7. // (C) 2003 Motus Technologies Inc. (http://www.motus.com)
  8. //
  9. #if NET_1_2
  10. using System;
  11. using System.Collections;
  12. namespace System.Security.Cryptography.X509Certificates {
  13. // Note: Match the definition of framework version 1.2.3400.0 on http://longhorn.msdn.microsoft.com
  14. public sealed class X509CertificateExCollection : X509CertificateCollection {
  15. // constructors
  16. public X509CertificateExCollection () {}
  17. public X509CertificateExCollection (X509CertificateExCollection certificates)
  18. {
  19. AddRange (certificates);
  20. }
  21. public X509CertificateExCollection (X509CertificateEx[] certificates)
  22. {
  23. AddRange (certificates);
  24. }
  25. // properties
  26. public new X509CertificateEx this [int index] {
  27. get {
  28. if (index < 0)
  29. throw new ArgumentOutOfRangeException ("negative index");
  30. if (index >= InnerList.Count)
  31. throw new ArgumentOutOfRangeException ("index >= Count");
  32. return (X509CertificateEx) InnerList [index];
  33. }
  34. }
  35. // methods
  36. public int Add (X509CertificateEx certificate)
  37. {
  38. if (certificate == null)
  39. throw new ArgumentNullException ("certificate");
  40. return InnerList.Add (certificate);
  41. }
  42. // note: transactional
  43. public void AddRange (X509CertificateEx[] certificates)
  44. {
  45. if (certificates == null)
  46. throw new ArgumentNullException ("certificates");
  47. for (int i=0; i < certificates.Length; i++)
  48. InnerList.Add (certificates [i]);
  49. }
  50. // note: transactional
  51. public void AddRange (X509CertificateExCollection certificates)
  52. {
  53. if (certificates == null)
  54. throw new ArgumentNullException ("certificates");
  55. InnerList.AddRange (certificates);
  56. }
  57. public bool Contains (X509CertificateEx certificate)
  58. {
  59. if (certificate == null)
  60. throw new ArgumentNullException ("certificate");
  61. foreach (X509CertificateEx c in InnerList) {
  62. if (certificate.Equals (c))
  63. return true;
  64. }
  65. return false;
  66. }
  67. public byte[] Export (X509ContentType contentType)
  68. {
  69. return null;
  70. }
  71. public byte[] Export (X509ContentType contentType, string password)
  72. {
  73. return null;
  74. }
  75. public X509CertificateExCollection Find (X509FindType findType, object findValue, bool validOnly)
  76. {
  77. return null;
  78. }
  79. public new X509CertificateExEnumerator GetEnumerator ()
  80. {
  81. return null;
  82. }
  83. public void Import (byte[] rawData)
  84. {
  85. }
  86. public void Import (byte[] rawData, string password, X509KeyStorageFlags keyStorageFlags)
  87. {
  88. }
  89. public void Import (string fileName)
  90. {
  91. }
  92. public void Import (string fileName, string password, X509KeyStorageFlags keyStorageFlags)
  93. {
  94. }
  95. public void Insert (int index, X509CertificateEx certificate)
  96. {
  97. if (certificate == null)
  98. throw new ArgumentNullException ("certificate");
  99. if (index < 0)
  100. throw new ArgumentOutOfRangeException ("negative index");
  101. if (index >= InnerList.Count)
  102. throw new ArgumentOutOfRangeException ("index >= Count");
  103. InnerList.Insert (index, certificate);
  104. }
  105. public void Remove (X509CertificateEx certificate)
  106. {
  107. if (certificate == null)
  108. throw new ArgumentNullException ("certificate");
  109. for (int i=0; i < InnerList.Count; i++) {
  110. X509CertificateEx c = (X509CertificateEx) InnerList [i];
  111. if (certificate.Equals (c)) {
  112. InnerList.RemoveAt (i);
  113. // only first instance is removed
  114. return;
  115. }
  116. }
  117. }
  118. // note: transactional
  119. public void RemoveRange (X509CertificateEx[] certificates)
  120. {
  121. if (certificates == null)
  122. throw new ArgumentNullException ("certificate");
  123. }
  124. // note: transactional
  125. public void RemoveRange (X509CertificateExCollection certificates)
  126. {
  127. if (certificates == null)
  128. throw new ArgumentNullException ("certificate");
  129. }
  130. // note: UI
  131. public X509CertificateExCollection Select (string title, string message, X509SelectionFlag selectionFlag)
  132. {
  133. return null;
  134. }
  135. // note: UI
  136. public X509CertificateExCollection Select (string title, string message, X509SelectionFlag selectionFlag, IntPtr hwndParent)
  137. {
  138. return null;
  139. }
  140. }
  141. }
  142. #endif