OtherRecipientInfo.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Cms
  5. {
  6. public class OtherRecipientInfo
  7. : Asn1Encodable
  8. {
  9. private readonly DerObjectIdentifier oriType;
  10. private readonly Asn1Encodable oriValue;
  11. public OtherRecipientInfo(
  12. DerObjectIdentifier oriType,
  13. Asn1Encodable oriValue)
  14. {
  15. this.oriType = oriType;
  16. this.oriValue = oriValue;
  17. }
  18. private OtherRecipientInfo(Asn1Sequence seq)
  19. {
  20. oriType = DerObjectIdentifier.GetInstance(seq[0]);
  21. oriValue = seq[1];
  22. }
  23. /**
  24. * return a OtherRecipientInfo object from a tagged object.
  25. *
  26. * @param obj the tagged object holding the object we want.
  27. * @param explicitly true if the object is meant to be explicitly
  28. * tagged false otherwise.
  29. * @exception ArgumentException if the object held by the
  30. * tagged object cannot be converted.
  31. */
  32. public static OtherRecipientInfo GetInstance(
  33. Asn1TaggedObject obj,
  34. bool explicitly)
  35. {
  36. return GetInstance(Asn1Sequence.GetInstance(obj, explicitly));
  37. }
  38. /**
  39. * return a OtherRecipientInfo object from the given object.
  40. *
  41. * @param obj the object we want converted.
  42. * @exception ArgumentException if the object cannot be converted.
  43. */
  44. public static OtherRecipientInfo GetInstance(
  45. object obj)
  46. {
  47. if (obj == null)
  48. return null;
  49. OtherRecipientInfo existing = obj as OtherRecipientInfo;
  50. if (existing != null)
  51. return existing;
  52. return new OtherRecipientInfo(Asn1Sequence.GetInstance(obj));
  53. }
  54. public virtual DerObjectIdentifier OriType
  55. {
  56. get { return oriType; }
  57. }
  58. public virtual Asn1Encodable OriValue
  59. {
  60. get { return oriValue; }
  61. }
  62. /**
  63. * Produce an object suitable for an Asn1OutputStream.
  64. * <pre>
  65. * OtherRecipientInfo ::= Sequence {
  66. * oriType OBJECT IDENTIFIER,
  67. * oriValue ANY DEFINED BY oriType }
  68. * </pre>
  69. */
  70. public override Asn1Object ToAsn1Object()
  71. {
  72. return new DerSequence(oriType, oriValue);
  73. }
  74. }
  75. }
  76. #pragma warning restore
  77. #endif