Restriction.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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(
  20. object obj)
  21. {
  22. if (obj is Restriction)
  23. return (Restriction) obj;
  24. if (obj is IAsn1String)
  25. return new Restriction(DirectoryString.GetInstance(obj));
  26. throw new ArgumentException("Unknown object in GetInstance: " + BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.GetTypeName(obj), "obj");
  27. }
  28. /**
  29. * Constructor from DirectoryString.
  30. * <p/>
  31. * The DirectoryString is of type RestrictionSyntax:
  32. * <p/>
  33. * <pre>
  34. * RestrictionSyntax ::= DirectoryString (SIZE(1..1024))
  35. * </pre>
  36. *
  37. * @param restriction A IAsn1String.
  38. */
  39. private Restriction(
  40. DirectoryString restriction)
  41. {
  42. this.restriction = restriction;
  43. }
  44. /**
  45. * Constructor from a given details.
  46. *
  47. * @param restriction The description of the restriction.
  48. */
  49. public Restriction(
  50. string restriction)
  51. {
  52. this.restriction = new DirectoryString(restriction);
  53. }
  54. public virtual DirectoryString RestrictionString
  55. {
  56. get { return restriction; }
  57. }
  58. /**
  59. * Produce an object suitable for an Asn1OutputStream.
  60. * <p/>
  61. * Returns:
  62. * <p/>
  63. * <pre>
  64. * RestrictionSyntax ::= DirectoryString (SIZE(1..1024))
  65. * <p/>
  66. * </pre>
  67. *
  68. * @return an Asn1Object
  69. */
  70. public override Asn1Object ToAsn1Object()
  71. {
  72. return restriction.ToAsn1Object();
  73. }
  74. }
  75. }
  76. #pragma warning restore
  77. #endif