Pkcs7RecipientCollection.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. //
  2. // Pkcs7RecipientCollection.cs - System.Security.Cryptography.Pkcs.Pkcs7RecipientCollection
  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. using System.Security.Cryptography.X509Certificates;
  13. namespace System.Security.Cryptography.Pkcs {
  14. public class Pkcs7RecipientCollection : ICollection, IEnumerable {
  15. private ArrayList _list;
  16. // constructors
  17. public Pkcs7RecipientCollection ()
  18. {
  19. _list = new ArrayList ();
  20. }
  21. public Pkcs7RecipientCollection (Pkcs7Recipient recipient) : base ()
  22. {
  23. _list.Add (recipient);
  24. }
  25. public Pkcs7RecipientCollection (SubjectIdentifierType recipientIdentifierType, X509CertificateExCollection certificates) : base ()
  26. {
  27. foreach (X509CertificateEx x509 in certificates) {
  28. Pkcs7Recipient p7r = new Pkcs7Recipient (recipientIdentifierType, x509);
  29. _list.Add (p7r);
  30. }
  31. }
  32. // properties
  33. public int Count {
  34. get { return _list.Count; }
  35. }
  36. public bool IsSynchronized {
  37. get { return _list.IsSynchronized; }
  38. }
  39. public Pkcs7Recipient this [int index] {
  40. get { return (Pkcs7Recipient) _list [index]; }
  41. }
  42. public object SyncRoot {
  43. get { return _list.SyncRoot; }
  44. }
  45. // methods
  46. public int Add (Pkcs7Recipient recipient)
  47. {
  48. return _list.Add (recipient);
  49. }
  50. public void CopyTo (Array array, int index)
  51. {
  52. _list.CopyTo (array, index);
  53. }
  54. public void CopyTo (Pkcs7Recipient[] array, int index)
  55. {
  56. _list.CopyTo (array, index);
  57. }
  58. public Pkcs7RecipientEnumerator GetEnumerator ()
  59. {
  60. return new Pkcs7RecipientEnumerator (_list);
  61. }
  62. IEnumerator IEnumerable.GetEnumerator ()
  63. {
  64. return new Pkcs7RecipientEnumerator (_list);
  65. }
  66. public void Remove (Pkcs7Recipient recipient)
  67. {
  68. _list.Remove (recipient);
  69. }
  70. }
  71. }
  72. #endif