AccessDescription.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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.X509
  6. {
  7. /**
  8. * The AccessDescription object.
  9. * <pre>
  10. * AccessDescription ::= SEQUENCE {
  11. * accessMethod OBJECT IDENTIFIER,
  12. * accessLocation GeneralName }
  13. * </pre>
  14. */
  15. public class AccessDescription
  16. : Asn1Encodable
  17. {
  18. public readonly static DerObjectIdentifier IdADCAIssuers = new DerObjectIdentifier("1.3.6.1.5.5.7.48.2");
  19. public readonly static DerObjectIdentifier IdADOcsp = new DerObjectIdentifier("1.3.6.1.5.5.7.48.1");
  20. private readonly DerObjectIdentifier accessMethod;
  21. private readonly GeneralName accessLocation;
  22. public static AccessDescription GetInstance(
  23. object obj)
  24. {
  25. if (obj is AccessDescription)
  26. return (AccessDescription) obj;
  27. if (obj is Asn1Sequence)
  28. return new AccessDescription((Asn1Sequence) obj);
  29. throw new ArgumentException("unknown object in factory: " + BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.GetTypeName(obj), "obj");
  30. }
  31. private AccessDescription(
  32. Asn1Sequence seq)
  33. {
  34. if (seq.Count != 2)
  35. throw new ArgumentException("wrong number of elements in sequence");
  36. accessMethod = DerObjectIdentifier.GetInstance(seq[0]);
  37. accessLocation = GeneralName.GetInstance(seq[1]);
  38. }
  39. /**
  40. * create an AccessDescription with the oid and location provided.
  41. */
  42. public AccessDescription(
  43. DerObjectIdentifier oid,
  44. GeneralName location)
  45. {
  46. accessMethod = oid;
  47. accessLocation = location;
  48. }
  49. /**
  50. *
  51. * @return the access method.
  52. */
  53. public DerObjectIdentifier AccessMethod
  54. {
  55. get { return accessMethod; }
  56. }
  57. /**
  58. *
  59. * @return the access location
  60. */
  61. public GeneralName AccessLocation
  62. {
  63. get { return accessLocation; }
  64. }
  65. public override Asn1Object ToAsn1Object()
  66. {
  67. return new DerSequence(accessMethod, accessLocation);
  68. }
  69. public override string ToString()
  70. {
  71. return "AccessDescription: Oid(" + this.accessMethod.Id + ")";
  72. }
  73. }
  74. }
  75. #pragma warning restore
  76. #endif