CRLDistPoint.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. using System;
  3. using System.Text;
  4. using Org.BouncyCastle.Utilities;
  5. namespace Org.BouncyCastle.Asn1.X509
  6. {
  7. public class CrlDistPoint
  8. : Asn1Encodable
  9. {
  10. internal readonly Asn1Sequence seq;
  11. public static CrlDistPoint GetInstance(
  12. Asn1TaggedObject obj,
  13. bool explicitly)
  14. {
  15. return GetInstance(Asn1Sequence.GetInstance(obj, explicitly));
  16. }
  17. public static CrlDistPoint GetInstance(
  18. object obj)
  19. {
  20. if (obj is CrlDistPoint || obj == null)
  21. {
  22. return (CrlDistPoint) obj;
  23. }
  24. if (obj is Asn1Sequence)
  25. {
  26. return new CrlDistPoint((Asn1Sequence) obj);
  27. }
  28. throw new ArgumentException("unknown object in factory: " + Org.BouncyCastle.Utilities.Platform.GetTypeName(obj), "obj");
  29. }
  30. private CrlDistPoint(
  31. Asn1Sequence seq)
  32. {
  33. this.seq = seq;
  34. }
  35. public CrlDistPoint(
  36. DistributionPoint[] points)
  37. {
  38. seq = new DerSequence(points);
  39. }
  40. /**
  41. * Return the distribution points making up the sequence.
  42. *
  43. * @return DistributionPoint[]
  44. */
  45. public DistributionPoint[] GetDistributionPoints()
  46. {
  47. DistributionPoint[] dp = new DistributionPoint[seq.Count];
  48. for (int i = 0; i != seq.Count; ++i)
  49. {
  50. dp[i] = DistributionPoint.GetInstance(seq[i]);
  51. }
  52. return dp;
  53. }
  54. /**
  55. * Produce an object suitable for an Asn1OutputStream.
  56. * <pre>
  57. * CrlDistPoint ::= Sequence SIZE {1..MAX} OF DistributionPoint
  58. * </pre>
  59. */
  60. public override Asn1Object ToAsn1Object()
  61. {
  62. return seq;
  63. }
  64. public override string ToString()
  65. {
  66. StringBuilder buf = new StringBuilder();
  67. string sep = Org.BouncyCastle.Utilities.Platform.NewLine;
  68. buf.Append("CRLDistPoint:");
  69. buf.Append(sep);
  70. DistributionPoint[] dp = GetDistributionPoints();
  71. for (int i = 0; i != dp.Length; i++)
  72. {
  73. buf.Append(" ");
  74. buf.Append(dp[i]);
  75. buf.Append(sep);
  76. }
  77. return buf.ToString();
  78. }
  79. }
  80. }
  81. #endif