CRLDistPoint.cs 2.4 KB

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