RevokedInfo.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509;
  5. using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
  6. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Ocsp
  7. {
  8. public class RevokedInfo
  9. : Asn1Encodable
  10. {
  11. private readonly DerGeneralizedTime revocationTime;
  12. private readonly CrlReason revocationReason;
  13. public static RevokedInfo GetInstance(
  14. Asn1TaggedObject obj,
  15. bool explicitly)
  16. {
  17. return GetInstance(Asn1Sequence.GetInstance(obj, explicitly));
  18. }
  19. public static RevokedInfo GetInstance(
  20. object obj)
  21. {
  22. if (obj == null || obj is RevokedInfo)
  23. {
  24. return (RevokedInfo) obj;
  25. }
  26. if (obj is Asn1Sequence)
  27. {
  28. return new RevokedInfo((Asn1Sequence) obj);
  29. }
  30. throw new ArgumentException("unknown object in factory: " + BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.GetTypeName(obj), "obj");
  31. }
  32. public RevokedInfo(
  33. DerGeneralizedTime revocationTime)
  34. : this(revocationTime, null)
  35. {
  36. }
  37. public RevokedInfo(
  38. DerGeneralizedTime revocationTime,
  39. CrlReason revocationReason)
  40. {
  41. if (revocationTime == null)
  42. throw new ArgumentNullException("revocationTime");
  43. this.revocationTime = revocationTime;
  44. this.revocationReason = revocationReason;
  45. }
  46. private RevokedInfo(
  47. Asn1Sequence seq)
  48. {
  49. this.revocationTime = (DerGeneralizedTime) seq[0];
  50. if (seq.Count > 1)
  51. {
  52. this.revocationReason = new CrlReason(
  53. DerEnumerated.GetInstance((Asn1TaggedObject) seq[1], true));
  54. }
  55. }
  56. public DerGeneralizedTime RevocationTime
  57. {
  58. get { return revocationTime; }
  59. }
  60. public CrlReason RevocationReason
  61. {
  62. get { return revocationReason; }
  63. }
  64. /**
  65. * Produce an object suitable for an Asn1OutputStream.
  66. * <pre>
  67. * RevokedInfo ::= Sequence {
  68. * revocationTime GeneralizedTime,
  69. * revocationReason [0] EXPLICIT CRLReason OPTIONAL }
  70. * </pre>
  71. */
  72. public override Asn1Object ToAsn1Object()
  73. {
  74. Asn1EncodableVector v = new Asn1EncodableVector(revocationTime);
  75. if (revocationReason != null)
  76. {
  77. v.Add(new DerTaggedObject(true, 0, revocationReason));
  78. }
  79. return new DerSequence(v);
  80. }
  81. }
  82. }
  83. #pragma warning restore
  84. #endif