CompleteRevocationRefs.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. /// CompleteRevocationRefs ::= SEQUENCE OF CrlOcspRef
  12. /// </code>
  13. /// </remarks>
  14. public class CompleteRevocationRefs
  15. : Asn1Encodable
  16. {
  17. private readonly Asn1Sequence crlOcspRefs;
  18. public static CompleteRevocationRefs GetInstance(
  19. object obj)
  20. {
  21. if (obj == null || obj is CompleteRevocationRefs)
  22. return (CompleteRevocationRefs) obj;
  23. if (obj is Asn1Sequence)
  24. return new CompleteRevocationRefs((Asn1Sequence) obj);
  25. throw new ArgumentException(
  26. "Unknown object in 'CompleteRevocationRefs' factory: "
  27. + Org.BouncyCastle.Utilities.Platform.GetTypeName(obj),
  28. "obj");
  29. }
  30. private CompleteRevocationRefs(
  31. Asn1Sequence seq)
  32. {
  33. if (seq == null)
  34. throw new ArgumentNullException("seq");
  35. foreach (Asn1Encodable ae in seq)
  36. {
  37. CrlOcspRef.GetInstance(ae.ToAsn1Object());
  38. }
  39. this.crlOcspRefs = seq;
  40. }
  41. public CompleteRevocationRefs(
  42. params CrlOcspRef[] crlOcspRefs)
  43. {
  44. if (crlOcspRefs == null)
  45. throw new ArgumentNullException("crlOcspRefs");
  46. this.crlOcspRefs = new DerSequence(crlOcspRefs);
  47. }
  48. public CompleteRevocationRefs(
  49. IEnumerable<CrlOcspRef> crlOcspRefs)
  50. {
  51. if (crlOcspRefs == null)
  52. throw new ArgumentNullException("crlOcspRefs");
  53. this.crlOcspRefs = new DerSequence(
  54. Asn1EncodableVector.FromEnumerable(crlOcspRefs));
  55. }
  56. public CrlOcspRef[] GetCrlOcspRefs()
  57. {
  58. CrlOcspRef[] result = new CrlOcspRef[crlOcspRefs.Count];
  59. for (int i = 0; i < crlOcspRefs.Count; ++i)
  60. {
  61. result[i] = CrlOcspRef.GetInstance(crlOcspRefs[i].ToAsn1Object());
  62. }
  63. return result;
  64. }
  65. public override Asn1Object ToAsn1Object()
  66. {
  67. return crlOcspRefs;
  68. }
  69. }
  70. }
  71. #pragma warning restore
  72. #endif