CrlSource.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509;
  5. namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Cmp
  6. {
  7. /**
  8. * GenMsg: {id-it TBD1}, SEQUENCE SIZE (1..MAX) OF CRLStatus
  9. * GenRep: {id-it TBD2}, SEQUENCE SIZE (1..MAX) OF
  10. * CertificateList | < absent >
  11. * <p>
  12. * CRLSource ::= CHOICE {
  13. * dpn [0] DistributionPointName,
  14. * issuer [1] GeneralNames }
  15. * </p>
  16. */
  17. public class CrlSource
  18. : Asn1Encodable, IAsn1Choice
  19. {
  20. public static CrlSource GetInstance(object obj)
  21. {
  22. if (obj is CrlSource crlSource)
  23. return crlSource;
  24. if (obj != null)
  25. return new CrlSource(Asn1TaggedObject.GetInstance(obj));
  26. return null;
  27. }
  28. private readonly DistributionPointName m_dpn;
  29. private readonly GeneralNames m_issuer;
  30. private CrlSource(Asn1TaggedObject taggedObject)
  31. {
  32. switch (taggedObject.TagNo)
  33. {
  34. case 0:
  35. m_dpn = DistributionPointName.GetInstance(taggedObject, true);
  36. m_issuer = null;
  37. break;
  38. case 1:
  39. m_dpn = null;
  40. m_issuer = GeneralNames.GetInstance(taggedObject, true);
  41. break;
  42. default:
  43. throw new ArgumentException("unknown tag: " + Asn1Utilities.GetTagText(taggedObject));
  44. }
  45. }
  46. public CrlSource(DistributionPointName dpn, GeneralNames issuer)
  47. {
  48. if ((dpn == null) == (issuer == null))
  49. throw new ArgumentException("either dpn or issuer must be set");
  50. m_dpn = dpn;
  51. m_issuer = issuer;
  52. }
  53. public virtual DistributionPointName Dpn => m_dpn;
  54. public virtual GeneralNames Issuer => m_issuer;
  55. public override Asn1Object ToAsn1Object()
  56. {
  57. if (m_dpn != null)
  58. return new DerTaggedObject(true, 0, m_dpn);
  59. return new DerTaggedObject(true, 1, m_issuer);
  60. }
  61. }
  62. }
  63. #pragma warning restore
  64. #endif