Ejemplo n.º 1
0
        public byte[] GetContent()
        {
            CompressedData comData = CompressedData.GetInstance(contentInfo.Content);
            ContentInfo content = comData.EncapContentInfo;

            Asn1OctetString bytes = (Asn1OctetString) content.Content;

            ZInflaterInputStream zIn = new ZInflaterInputStream(new MemoryStream(bytes.GetOctets(), false));
            MemoryStream bOut = new MemoryStream();

            byte[] buf = new byte[1024];
            int len;

            try
            {
                while ((len = zIn.Read(buf, 0, buf.Length)) > 0)
                {
                    bOut.Write(buf, 0, len);
                }
            }
            catch (IOException e)
            {
                throw new CmsException("exception reading compressed stream.", e);
            }

            return bOut.ToArray();
        }
Ejemplo n.º 2
0
	    /**
	     * Return the uncompressed content, throwing an exception if the data size
	     * is greater than the passed in limit. If the content is exceeded getCause()
	     * on the CMSException will contain a StreamOverflowException
	     *
	     * @param limit maximum number of bytes to read
	     * @return the content read
	     * @throws CMSException if there is an exception uncompressing the data.
	     */
		public byte[] GetContent(int limit)
		{
			CompressedData  comData = CompressedData.GetInstance(contentInfo.Content);
			ContentInfo     content = comData.EncapContentInfo;

			Asn1OctetString bytes = (Asn1OctetString)content.Content;

			ZInflaterInputStream zIn = new ZInflaterInputStream(new MemoryStream(bytes.GetOctets(), false));

			try
			{
				return CmsUtilities.StreamToByteArray(zIn, limit);
			}
			catch (IOException e)
			{
				throw new CmsException("exception reading compressed stream.", e);
			}
		}
Ejemplo n.º 3
0
		/**
		 * Return the uncompressed content.
		 *
		 * @return the uncompressed content
		 * @throws CmsException if there is an exception uncompressing the data.
		 */
		public byte[] GetContent()
        {
            CompressedData comData = CompressedData.GetInstance(contentInfo.Content);
            ContentInfo content = comData.EncapContentInfo;

			Asn1OctetString bytes = (Asn1OctetString) content.Content;
			ZInflaterInputStream zIn = new ZInflaterInputStream(bytes.GetOctetStream());

			try
			{
				return CmsUtilities.StreamToByteArray(zIn);
			}
			catch (IOException e)
			{
				throw new CmsException("exception reading compressed stream.", e);
			}
			finally
			{
				zIn.Close();
			}
        }