CompleteCertificateRefs.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using System.Collections.Generic;
  5. using Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities;
  6. namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Esf
  7. {
  8. /// <remarks>
  9. /// RFC 3126: 4.2.1 Complete Certificate Refs Attribute Definition
  10. /// <code>
  11. /// CompleteCertificateRefs ::= SEQUENCE OF OtherCertID
  12. /// </code>
  13. /// </remarks>
  14. public class CompleteCertificateRefs
  15. : Asn1Encodable
  16. {
  17. private readonly Asn1Sequence otherCertIDs;
  18. public static CompleteCertificateRefs GetInstance(
  19. object obj)
  20. {
  21. if (obj == null || obj is CompleteCertificateRefs)
  22. return (CompleteCertificateRefs) obj;
  23. if (obj is Asn1Sequence)
  24. return new CompleteCertificateRefs((Asn1Sequence) obj);
  25. throw new ArgumentException(
  26. "Unknown object in 'CompleteCertificateRefs' factory: "
  27. + Org.BouncyCastle.Utilities.Platform.GetTypeName(obj),
  28. "obj");
  29. }
  30. private CompleteCertificateRefs(
  31. Asn1Sequence seq)
  32. {
  33. if (seq == null)
  34. throw new ArgumentNullException("seq");
  35. foreach (Asn1Encodable ae in seq)
  36. {
  37. OtherCertID.GetInstance(ae.ToAsn1Object());
  38. }
  39. this.otherCertIDs = seq;
  40. }
  41. public CompleteCertificateRefs(
  42. params OtherCertID[] otherCertIDs)
  43. {
  44. if (otherCertIDs == null)
  45. throw new ArgumentNullException("otherCertIDs");
  46. this.otherCertIDs = new DerSequence(otherCertIDs);
  47. }
  48. public CompleteCertificateRefs(
  49. IEnumerable<OtherCertID> otherCertIDs)
  50. {
  51. if (otherCertIDs == null)
  52. throw new ArgumentNullException("otherCertIDs");
  53. this.otherCertIDs = new DerSequence(
  54. Asn1EncodableVector.FromEnumerable(otherCertIDs));
  55. }
  56. public OtherCertID[] GetOtherCertIDs()
  57. {
  58. OtherCertID[] result = new OtherCertID[otherCertIDs.Count];
  59. for (int i = 0; i < otherCertIDs.Count; ++i)
  60. {
  61. result[i] = OtherCertID.GetInstance(otherCertIDs[i].ToAsn1Object());
  62. }
  63. return result;
  64. }
  65. public override Asn1Object ToAsn1Object()
  66. {
  67. return otherCertIDs;
  68. }
  69. }
  70. }
  71. #pragma warning restore
  72. #endif