Restriction.cs 1.9 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.Asn1.X500;
  5. using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
  6. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.IsisMtt.X509
  7. {
  8. /**
  9. * Some other restriction regarding the usage of this certificate.
  10. * <p/>
  11. * <pre>
  12. * RestrictionSyntax ::= DirectoryString (SIZE(1..1024))
  13. * </pre>
  14. */
  15. public class Restriction
  16. : Asn1Encodable
  17. {
  18. private readonly DirectoryString restriction;
  19. public static Restriction GetInstance(object obj)
  20. {
  21. if (obj is Restriction)
  22. return (Restriction) obj;
  23. if (obj is IAsn1String)
  24. return new Restriction(DirectoryString.GetInstance(obj));
  25. throw new ArgumentException("Unknown object in GetInstance: " + Org.BouncyCastle.Utilities.Platform.GetTypeName(obj), "obj");
  26. }
  27. /**
  28. * Constructor from DirectoryString.
  29. * <p/>
  30. * The DirectoryString is of type RestrictionSyntax:
  31. * <p/>
  32. * <pre>
  33. * RestrictionSyntax ::= DirectoryString (SIZE(1..1024))
  34. * </pre>
  35. *
  36. * @param restriction A IAsn1String.
  37. */
  38. private Restriction(DirectoryString restriction)
  39. {
  40. this.restriction = restriction;
  41. }
  42. /**
  43. * Constructor from a given details.
  44. *
  45. * @param restriction The description of the restriction.
  46. */
  47. public Restriction(string restriction)
  48. {
  49. this.restriction = new DirectoryString(restriction);
  50. }
  51. public virtual DirectoryString RestrictionString
  52. {
  53. get { return restriction; }
  54. }
  55. /**
  56. * Produce an object suitable for an Asn1OutputStream.
  57. * <p/>
  58. * Returns:
  59. * <p/>
  60. * <pre>
  61. * RestrictionSyntax ::= DirectoryString (SIZE(1..1024))
  62. * <p/>
  63. * </pre>
  64. *
  65. * @return an Asn1Object
  66. */
  67. public override Asn1Object ToAsn1Object()
  68. {
  69. return restriction.ToAsn1Object();
  70. }
  71. }
  72. }
  73. #pragma warning restore
  74. #endif