RevRepContent.cs 2.8 KB

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