RevokedInfo.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. v.AddOptionalTagged(true, 0, revocationReason);
  76. return new DerSequence(v);
  77. }
  78. }
  79. }
  80. #pragma warning restore
  81. #endif