CrlListID.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using System.Collections.Generic;
  5. using Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities;
  6. namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Esf
  7. {
  8. /// <remarks>
  9. /// RFC 3126: 4.2.2 Complete Revocation Refs Attribute Definition
  10. /// <code>
  11. /// CRLListID ::= SEQUENCE
  12. /// {
  13. /// crls SEQUENCE OF CrlValidatedID
  14. /// }
  15. /// </code>
  16. /// </remarks>
  17. public class CrlListID
  18. : Asn1Encodable
  19. {
  20. private readonly Asn1Sequence crls;
  21. public static CrlListID GetInstance(
  22. object obj)
  23. {
  24. if (obj == null || obj is CrlListID)
  25. return (CrlListID) obj;
  26. if (obj is Asn1Sequence)
  27. return new CrlListID((Asn1Sequence) obj);
  28. throw new ArgumentException(
  29. "Unknown object in 'CrlListID' factory: "
  30. + Org.BouncyCastle.Utilities.Platform.GetTypeName(obj),
  31. "obj");
  32. }
  33. private CrlListID(
  34. Asn1Sequence seq)
  35. {
  36. if (seq == null)
  37. throw new ArgumentNullException("seq");
  38. if (seq.Count != 1)
  39. throw new ArgumentException("Bad sequence size: " + seq.Count, "seq");
  40. this.crls = (Asn1Sequence) seq[0].ToAsn1Object();
  41. foreach (Asn1Encodable ae in this.crls)
  42. {
  43. CrlValidatedID.GetInstance(ae.ToAsn1Object());
  44. }
  45. }
  46. public CrlListID(
  47. params CrlValidatedID[] crls)
  48. {
  49. if (crls == null)
  50. throw new ArgumentNullException("crls");
  51. this.crls = new DerSequence(crls);
  52. }
  53. public CrlListID(
  54. IEnumerable<CrlValidatedID> crls)
  55. {
  56. if (crls == null)
  57. throw new ArgumentNullException("crls");
  58. this.crls = new DerSequence(
  59. Asn1EncodableVector.FromEnumerable(crls));
  60. }
  61. public CrlValidatedID[] GetCrls()
  62. {
  63. CrlValidatedID[] result = new CrlValidatedID[crls.Count];
  64. for (int i = 0; i < crls.Count; ++i)
  65. {
  66. result[i] = CrlValidatedID.GetInstance(crls[i].ToAsn1Object());
  67. }
  68. return result;
  69. }
  70. public override Asn1Object ToAsn1Object()
  71. {
  72. return new DerSequence(crls);
  73. }
  74. }
  75. }
  76. #pragma warning restore
  77. #endif