OtherRevVals.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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.Esf
  6. {
  7. /// <remarks>
  8. /// RFC 3126: 4.3.2 Revocation Values Attribute Definition
  9. /// <code>
  10. /// OtherRevVals ::= SEQUENCE
  11. /// {
  12. /// otherRevValType OtherRevValType,
  13. /// otherRevVals ANY DEFINED BY otherRevValType
  14. /// }
  15. ///
  16. /// OtherRevValType ::= OBJECT IDENTIFIER
  17. /// </code>
  18. /// </remarks>
  19. public class OtherRevVals
  20. : Asn1Encodable
  21. {
  22. private readonly DerObjectIdentifier otherRevValType;
  23. private readonly Asn1Object otherRevVals;
  24. public static OtherRevVals GetInstance(
  25. object obj)
  26. {
  27. if (obj == null || obj is OtherRevVals)
  28. return (OtherRevVals) obj;
  29. if (obj is Asn1Sequence)
  30. return new OtherRevVals((Asn1Sequence) obj);
  31. throw new ArgumentException(
  32. "Unknown object in 'OtherRevVals' factory: "
  33. + BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.GetTypeName(obj),
  34. "obj");
  35. }
  36. private OtherRevVals(
  37. Asn1Sequence seq)
  38. {
  39. if (seq == null)
  40. throw new ArgumentNullException("seq");
  41. if (seq.Count != 2)
  42. throw new ArgumentException("Bad sequence size: " + seq.Count, "seq");
  43. this.otherRevValType = (DerObjectIdentifier) seq[0].ToAsn1Object();
  44. this.otherRevVals = seq[1].ToAsn1Object();
  45. }
  46. public OtherRevVals(
  47. DerObjectIdentifier otherRevValType,
  48. Asn1Encodable otherRevVals)
  49. {
  50. if (otherRevValType == null)
  51. throw new ArgumentNullException("otherRevValType");
  52. if (otherRevVals == null)
  53. throw new ArgumentNullException("otherRevVals");
  54. this.otherRevValType = otherRevValType;
  55. this.otherRevVals = otherRevVals.ToAsn1Object();
  56. }
  57. public DerObjectIdentifier OtherRevValType
  58. {
  59. get { return otherRevValType; }
  60. }
  61. public Asn1Object OtherRevValsObject
  62. {
  63. get { return otherRevVals; }
  64. }
  65. public override Asn1Object ToAsn1Object()
  66. {
  67. return new DerSequence(otherRevValType, otherRevVals);
  68. }
  69. }
  70. }
  71. #pragma warning restore
  72. #endif