AttCertIssuer.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
  5. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509
  6. {
  7. public class AttCertIssuer
  8. : Asn1Encodable, IAsn1Choice
  9. {
  10. internal readonly Asn1Encodable obj;
  11. internal readonly Asn1Object choiceObj;
  12. public static AttCertIssuer GetInstance(
  13. object obj)
  14. {
  15. if (obj is AttCertIssuer)
  16. {
  17. return (AttCertIssuer)obj;
  18. }
  19. else if (obj is V2Form)
  20. {
  21. return new AttCertIssuer(V2Form.GetInstance(obj));
  22. }
  23. else if (obj is GeneralNames)
  24. {
  25. return new AttCertIssuer((GeneralNames)obj);
  26. }
  27. else if (obj is Asn1TaggedObject)
  28. {
  29. return new AttCertIssuer(V2Form.GetInstance((Asn1TaggedObject)obj, false));
  30. }
  31. else if (obj is Asn1Sequence)
  32. {
  33. return new AttCertIssuer(GeneralNames.GetInstance(obj));
  34. }
  35. throw new ArgumentException("unknown object in factory: " + BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.GetTypeName(obj), "obj");
  36. }
  37. public static AttCertIssuer GetInstance(
  38. Asn1TaggedObject obj,
  39. bool isExplicit)
  40. {
  41. return GetInstance(obj.GetObject()); // must be explictly tagged
  42. }
  43. /// <summary>
  44. /// Don't use this one if you are trying to be RFC 3281 compliant.
  45. /// Use it for v1 attribute certificates only.
  46. /// </summary>
  47. /// <param name="names">Our GeneralNames structure</param>
  48. public AttCertIssuer(
  49. GeneralNames names)
  50. {
  51. obj = names;
  52. choiceObj = obj.ToAsn1Object();
  53. }
  54. public AttCertIssuer(
  55. V2Form v2Form)
  56. {
  57. obj = v2Form;
  58. choiceObj = new DerTaggedObject(false, 0, obj);
  59. }
  60. public Asn1Encodable Issuer
  61. {
  62. get { return obj; }
  63. }
  64. /**
  65. * Produce an object suitable for an Asn1OutputStream.
  66. * <pre>
  67. * AttCertIssuer ::= CHOICE {
  68. * v1Form GeneralNames, -- MUST NOT be used in this
  69. * -- profile
  70. * v2Form [0] V2Form -- v2 only
  71. * }
  72. * </pre>
  73. */
  74. public override Asn1Object ToAsn1Object()
  75. {
  76. return choiceObj;
  77. }
  78. }
  79. }
  80. #pragma warning restore
  81. #endif