Controls.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using System.Text;
  5. using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
  6. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Crmf
  7. {
  8. public class Controls
  9. : Asn1Encodable
  10. {
  11. private readonly Asn1Sequence content;
  12. private Controls(Asn1Sequence seq)
  13. {
  14. content = seq;
  15. }
  16. public static Controls GetInstance(object obj)
  17. {
  18. if (obj is Controls)
  19. return (Controls)obj;
  20. if (obj is Asn1Sequence)
  21. return new Controls((Asn1Sequence)obj);
  22. throw new ArgumentException("Invalid object: " + BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.GetTypeName(obj), "obj");
  23. }
  24. public Controls(params AttributeTypeAndValue[] atvs)
  25. {
  26. content = new DerSequence(atvs);
  27. }
  28. public virtual AttributeTypeAndValue[] ToAttributeTypeAndValueArray()
  29. {
  30. AttributeTypeAndValue[] result = new AttributeTypeAndValue[content.Count];
  31. for (int i = 0; i != result.Length; ++i)
  32. {
  33. result[i] = AttributeTypeAndValue.GetInstance(content[i]);
  34. }
  35. return result;
  36. }
  37. /**
  38. * <pre>
  39. * Controls ::= SEQUENCE SIZE(1..MAX) OF AttributeTypeAndValue
  40. * </pre>
  41. * @return a basic ASN.1 object representation.
  42. */
  43. public override Asn1Object ToAsn1Object()
  44. {
  45. return content;
  46. }
  47. }
  48. }
  49. #pragma warning restore
  50. #endif