SinglePubInfo.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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.Crmf
  7. {
  8. public class SinglePubInfo
  9. : Asn1Encodable
  10. {
  11. private readonly DerInteger pubMethod;
  12. private readonly GeneralName pubLocation;
  13. private SinglePubInfo(Asn1Sequence seq)
  14. {
  15. pubMethod = DerInteger.GetInstance(seq[0]);
  16. if (seq.Count == 2)
  17. {
  18. pubLocation = GeneralName.GetInstance(seq[1]);
  19. }
  20. }
  21. public static SinglePubInfo GetInstance(object obj)
  22. {
  23. if (obj is SinglePubInfo)
  24. return (SinglePubInfo)obj;
  25. if (obj is Asn1Sequence)
  26. return new SinglePubInfo((Asn1Sequence)obj);
  27. throw new ArgumentException("Invalid object: " + BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.GetTypeName(obj), "obj");
  28. }
  29. public virtual GeneralName PubLocation
  30. {
  31. get { return pubLocation; }
  32. }
  33. /**
  34. * <pre>
  35. * SinglePubInfo ::= SEQUENCE {
  36. * pubMethod INTEGER {
  37. * dontCare (0),
  38. * x500 (1),
  39. * web (2),
  40. * ldap (3) },
  41. * pubLocation GeneralName OPTIONAL }
  42. * </pre>
  43. * @return a basic ASN.1 object representation.
  44. */
  45. public override Asn1Object ToAsn1Object()
  46. {
  47. Asn1EncodableVector v = new Asn1EncodableVector(pubMethod);
  48. v.AddOptional(pubLocation);
  49. return new DerSequence(v);
  50. }
  51. }
  52. }
  53. #pragma warning restore
  54. #endif