CMSContentInfoParser.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using System.IO;
  5. using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1;
  6. using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Cms;
  7. using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
  8. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Cms
  9. {
  10. public class CmsContentInfoParser
  11. {
  12. protected ContentInfoParser contentInfo;
  13. protected Stream data;
  14. protected CmsContentInfoParser(
  15. Stream data)
  16. {
  17. if (data == null)
  18. throw new ArgumentNullException("data");
  19. this.data = data;
  20. try
  21. {
  22. Asn1StreamParser inStream = new Asn1StreamParser(data);
  23. this.contentInfo = new ContentInfoParser((Asn1SequenceParser)inStream.ReadObject());
  24. }
  25. catch (IOException e)
  26. {
  27. throw new CmsException("IOException reading content.", e);
  28. }
  29. catch (InvalidCastException e)
  30. {
  31. throw new CmsException("Unexpected object reading content.", e);
  32. }
  33. }
  34. /**
  35. * Close the underlying data stream.
  36. * @throws IOException if the close fails.
  37. */
  38. public void Close()
  39. {
  40. BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.Dispose(this.data);
  41. }
  42. }
  43. }
  44. #pragma warning restore
  45. #endif