PollRepContent.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Cmp
  4. {
  5. /**
  6. * PollRepContent ::= SEQUENCE OF SEQUENCE {
  7. * certReqId INTEGER,
  8. * checkAfter INTEGER, -- time in seconds
  9. * reason PKIFreeText OPTIONAL }
  10. */
  11. public class PollRepContent
  12. : Asn1Encodable
  13. {
  14. public static PollRepContent GetInstance(object obj)
  15. {
  16. if (obj is PollRepContent pollRepContent)
  17. return pollRepContent;
  18. if (obj != null)
  19. return new PollRepContent(Asn1Sequence.GetInstance(obj));
  20. return null;
  21. }
  22. private readonly DerInteger[] m_certReqID;
  23. private readonly DerInteger[] m_checkAfter;
  24. private readonly PkiFreeText[] m_reason;
  25. private PollRepContent(Asn1Sequence seq)
  26. {
  27. int count = seq.Count;
  28. m_certReqID = new DerInteger[count];
  29. m_checkAfter = new DerInteger[count];
  30. m_reason = new PkiFreeText[count];
  31. for (int i = 0; i != count; i++)
  32. {
  33. Asn1Sequence s = Asn1Sequence.GetInstance(seq[i]);
  34. m_certReqID[i] = DerInteger.GetInstance(s[0]);
  35. m_checkAfter[i] = DerInteger.GetInstance(s[1]);
  36. if (s.Count > 2)
  37. {
  38. m_reason[i] = PkiFreeText.GetInstance(s[2]);
  39. }
  40. }
  41. }
  42. public PollRepContent(DerInteger certReqID, DerInteger checkAfter)
  43. : this(certReqID, checkAfter, null)
  44. {
  45. }
  46. public PollRepContent(DerInteger certReqID, DerInteger checkAfter, PkiFreeText reason)
  47. {
  48. m_certReqID = new DerInteger[1]{ certReqID };
  49. m_checkAfter = new DerInteger[1]{ checkAfter };
  50. m_reason = new PkiFreeText[1]{ reason };
  51. }
  52. public virtual int Count => m_certReqID.Length;
  53. public virtual DerInteger GetCertReqID(int index) => m_certReqID[index];
  54. public virtual DerInteger GetCheckAfter(int index) => m_checkAfter[index];
  55. public virtual PkiFreeText GetReason(int index) => m_reason[index];
  56. /**
  57. * <pre>
  58. * PollRepContent ::= SEQUENCE OF SEQUENCE {
  59. * certReqId INTEGER,
  60. * checkAfter INTEGER, -- time in seconds
  61. * reason PKIFreeText OPTIONAL
  62. * }
  63. * </pre>
  64. * @return a basic ASN.1 object representation.
  65. */
  66. public override Asn1Object ToAsn1Object()
  67. {
  68. Asn1EncodableVector outer = new Asn1EncodableVector(m_certReqID.Length);
  69. for (int i = 0; i != m_certReqID.Length; i++)
  70. {
  71. Asn1EncodableVector v = new Asn1EncodableVector(3);
  72. v.Add(m_certReqID[i]);
  73. v.Add(m_checkAfter[i]);
  74. v.AddOptional(m_reason[i]);
  75. outer.Add(new DerSequence(v));
  76. }
  77. return new DerSequence(outer);
  78. }
  79. }
  80. }
  81. #pragma warning restore
  82. #endif