RevRepContent.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Crmf;
  4. using Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509;
  5. namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Cmp
  6. {
  7. /**
  8. * <pre>
  9. * RevRepContent ::= SEQUENCE {
  10. * status SEQUENCE SIZE (1..MAX) OF PKIStatusInfo,
  11. * -- in same order as was sent in RevReqContent
  12. * revCerts [0] SEQUENCE SIZE (1..MAX) OF CertId
  13. * OPTIONAL,
  14. * -- IDs for which revocation was requested
  15. * -- (same order as status)
  16. * crls [1] SEQUENCE SIZE (1..MAX) OF CertificateList OPTIONAL
  17. * -- the resulting CRLs (there may be more than one)
  18. * }
  19. *</pre>
  20. */
  21. public class RevRepContent
  22. : Asn1Encodable
  23. {
  24. public static RevRepContent GetInstance(object obj)
  25. {
  26. if (obj is RevRepContent revRepContent)
  27. return revRepContent;
  28. if (obj != null)
  29. return new RevRepContent(Asn1Sequence.GetInstance(obj));
  30. return null;
  31. }
  32. private readonly Asn1Sequence m_status;
  33. private readonly Asn1Sequence m_revCerts;
  34. private readonly Asn1Sequence m_crls;
  35. private RevRepContent(Asn1Sequence seq)
  36. {
  37. m_status = Asn1Sequence.GetInstance(seq[0]);
  38. for (int pos = 1; pos < seq.Count; ++pos)
  39. {
  40. Asn1TaggedObject tObj = Asn1TaggedObject.GetInstance(seq[pos]);
  41. if (tObj.TagNo == 0)
  42. {
  43. m_revCerts = Asn1Sequence.GetInstance(tObj, true);
  44. }
  45. else
  46. {
  47. m_crls = Asn1Sequence.GetInstance(tObj, true);
  48. }
  49. }
  50. }
  51. public virtual PkiStatusInfo[] GetStatus()
  52. {
  53. return m_status.MapElements(PkiStatusInfo.GetInstance);
  54. }
  55. public virtual CertId[] GetRevCerts()
  56. {
  57. if (m_revCerts == null)
  58. return null;
  59. return m_revCerts.MapElements(CertId.GetInstance);
  60. }
  61. public virtual CertificateList[] GetCrls()
  62. {
  63. if (m_crls == null)
  64. return null;
  65. return m_crls.MapElements(CertificateList.GetInstance);
  66. }
  67. /**
  68. * <pre>
  69. * RevRepContent ::= SEQUENCE {
  70. * status SEQUENCE SIZE (1..MAX) OF PKIStatusInfo,
  71. * -- in same order as was sent in RevReqContent
  72. * revCerts [0] SEQUENCE SIZE (1..MAX) OF CertId OPTIONAL,
  73. * -- IDs for which revocation was requested
  74. * -- (same order as status)
  75. * crls [1] SEQUENCE SIZE (1..MAX) OF CertificateList OPTIONAL
  76. * -- the resulting CRLs (there may be more than one)
  77. * }
  78. * </pre>
  79. * @return a basic ASN.1 object representation.
  80. */
  81. public override Asn1Object ToAsn1Object()
  82. {
  83. Asn1EncodableVector v = new Asn1EncodableVector(m_status);
  84. v.AddOptionalTagged(true, 0, m_revCerts);
  85. v.AddOptionalTagged(true, 1, m_crls);
  86. return new DerSequence(v);
  87. }
  88. }
  89. }
  90. #pragma warning restore
  91. #endif