OtherName.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509
  5. {
  6. /**
  7. * The OtherName object.
  8. * <pre>
  9. * OtherName ::= SEQUENCE {
  10. * type-id OBJECT IDENTIFIER,
  11. * value [0] EXPLICIT ANY DEFINED BY type-id }
  12. * </pre>
  13. */
  14. public class OtherName
  15. : Asn1Encodable
  16. {
  17. private readonly DerObjectIdentifier typeID;
  18. private readonly Asn1Encodable value;
  19. /**
  20. * OtherName factory method.
  21. * @param obj the object used to construct an instance of <code>
  22. * OtherName</code>. It must be an instance of <code>OtherName
  23. * </code> or <code>ASN1Sequence</code>.
  24. * @return the instance of <code>OtherName</code> built from the
  25. * supplied object.
  26. * @throws java.lang.IllegalArgumentException if the object passed
  27. * to the factory is not an instance of <code>OtherName</code> or something that
  28. * can be converted into an appropriate <code>ASN1Sequence</code>.
  29. */
  30. public static OtherName GetInstance(object obj)
  31. {
  32. if (obj is OtherName)
  33. return (OtherName)obj;
  34. if (obj == null)
  35. return null;
  36. return new OtherName(Asn1Sequence.GetInstance(obj));
  37. }
  38. /**
  39. * Base constructor.
  40. * @param typeID the type of the other name.
  41. * @param value the ANY object that represents the value.
  42. */
  43. public OtherName(DerObjectIdentifier typeID, Asn1Encodable value)
  44. {
  45. this.typeID = typeID;
  46. this.value = value;
  47. }
  48. private OtherName(Asn1Sequence seq)
  49. {
  50. this.typeID = DerObjectIdentifier.GetInstance(seq[0]);
  51. this.value = DerTaggedObject.GetInstance(seq[1]).GetObject(); // explicitly tagged
  52. }
  53. public virtual DerObjectIdentifier TypeID
  54. {
  55. get { return typeID; }
  56. }
  57. public Asn1Encodable Value
  58. {
  59. get { return value; }
  60. }
  61. public override Asn1Object ToAsn1Object()
  62. {
  63. return new DerSequence(typeID, new DerTaggedObject(true, 0, value));
  64. }
  65. }
  66. }
  67. #pragma warning restore
  68. #endif