PKIPublicationInfo.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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.Crmf
  6. {
  7. public class PkiPublicationInfo
  8. : Asn1Encodable
  9. {
  10. private readonly DerInteger action;
  11. private readonly Asn1Sequence pubInfos;
  12. private PkiPublicationInfo(Asn1Sequence seq)
  13. {
  14. action = DerInteger.GetInstance(seq[0]);
  15. pubInfos = Asn1Sequence.GetInstance(seq[1]);
  16. }
  17. public static PkiPublicationInfo GetInstance(object obj)
  18. {
  19. if (obj is PkiPublicationInfo)
  20. return (PkiPublicationInfo)obj;
  21. if (obj is Asn1Sequence)
  22. return new PkiPublicationInfo((Asn1Sequence)obj);
  23. throw new ArgumentException("Invalid object: " + BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.GetTypeName(obj), "obj");
  24. }
  25. public virtual DerInteger Action
  26. {
  27. get { return action; }
  28. }
  29. public virtual SinglePubInfo[] GetPubInfos()
  30. {
  31. if (pubInfos == null)
  32. return null;
  33. SinglePubInfo[] results = new SinglePubInfo[pubInfos.Count];
  34. for (int i = 0; i != results.Length; ++i)
  35. {
  36. results[i] = SinglePubInfo.GetInstance(pubInfos[i]);
  37. }
  38. return results;
  39. }
  40. /**
  41. * <pre>
  42. * PkiPublicationInfo ::= SEQUENCE {
  43. * action INTEGER {
  44. * dontPublish (0),
  45. * pleasePublish (1) },
  46. * pubInfos SEQUENCE SIZE (1..MAX) OF SinglePubInfo OPTIONAL }
  47. * -- pubInfos MUST NOT be present if action is "dontPublish"
  48. * -- (if action is "pleasePublish" and pubInfos is omitted,
  49. * -- "dontCare" is assumed)
  50. * </pre>
  51. * @return a basic ASN.1 object representation.
  52. */
  53. public override Asn1Object ToAsn1Object()
  54. {
  55. return new DerSequence(action, pubInfos);
  56. }
  57. }
  58. }
  59. #pragma warning restore
  60. #endif