/// <summary> /// Initializes a new instance of the <see cref="MimeKit.Cryptography.ApplicationPkcs7Mime"/> class. /// </summary> /// <remarks> /// <para>Creates a new MIME part with a Content-Type of application/pkcs7-mime /// and the <paramref name="stream"/> as its content.</para> /// <para>Unless you are writing your own pkcs7 implementation, you'll probably /// want to use the <see cref="Compress(MimeEntity)"/>, /// <see cref="Encrypt(CmsRecipientCollection, MimeEntity)"/>, and/or /// <see cref="Sign(CmsSigner, MimeEntity)"/> method to create new instances /// of this class.</para> /// </remarks> /// <param name="type">The S/MIME type.</param> /// <param name="stream">The content stream.</param> /// <exception cref="System.ArgumentNullException"> /// <paramref name="stream"/> is <c>null</c>. /// </exception> /// <exception cref="System.ArgumentOutOfRangeException"> /// <paramref name="type"/> is not a valid value. /// </exception> /// <exception cref="System.ArgumentException"> /// <para><paramref name="stream"/> does not support reading.</para> /// <para>-or-</para> /// <para><paramref name="stream"/> does not support seeking.</para> /// </exception> public ApplicationPkcs7Mime (SecureMimeType type, Stream stream) : base ("application", "pkcs7-mime") { ContentDisposition = new ContentDisposition ("attachment"); ContentTransferEncoding = ContentEncoding.Base64; ContentObject = new ContentObject (stream); switch (type) { case SecureMimeType.CompressedData: ContentType.Parameters["smime-type"] = "compressed-data"; ContentDisposition.FileName = "smime.p7z"; ContentType.Name = "smime.p7z"; break; case SecureMimeType.EnvelopedData: ContentType.Parameters["smime-type"] = "enveloped-data"; ContentDisposition.FileName = "smime.p7m"; ContentType.Name = "smime.p7m"; break; case SecureMimeType.SignedData: ContentType.Parameters["smime-type"] = "signed-data"; ContentDisposition.FileName = "smime.p7m"; ContentType.Name = "smime.p7m"; break; case SecureMimeType.CertsOnly: ContentType.Parameters["smime-type"] = "certs-only"; ContentDisposition.FileName = "smime.p7c"; ContentType.Name = "smime.p7c"; break; default: throw new ArgumentOutOfRangeException ("type"); } }
/// <summary> /// Initializes a new instance of the <see cref="MimeKit.Cryptography.ApplicationPkcs7Mime"/> class. /// </summary> /// <remarks> /// <para>Creates a new MIME part with a Content-Type of application/pkcs7-mime /// and the <paramref name="stream"/> as its content.</para> /// <para>Unless you are writing your own pkcs7 implementation, you'll probably /// want to use the <see cref="Compress(MimeEntity)"/>, /// <see cref="Encrypt(CmsRecipientCollection, MimeEntity)"/>, and/or /// <see cref="Sign(CmsSigner, MimeEntity)"/> method to create new instances /// of this class.</para> /// </remarks> /// <param name="type">The S/MIME type.</param> /// <param name="stream">The content stream.</param> /// <exception cref="System.ArgumentNullException"> /// <paramref name="stream"/> is <c>null</c>. /// </exception> /// <exception cref="System.ArgumentOutOfRangeException"> /// <paramref name="type"/> is not a valid value. /// </exception> /// <exception cref="System.ArgumentException"> /// <para><paramref name="stream"/> does not support reading.</para> /// <para>-or-</para> /// <para><paramref name="stream"/> does not support seeking.</para> /// </exception> public ApplicationPkcs7Mime(SecureMimeType type, Stream stream) : base("application", "pkcs7-mime") { ContentDisposition = new ContentDisposition("attachment"); ContentTransferEncoding = ContentEncoding.Base64; ContentObject = new ContentObject(stream); switch (type) { case SecureMimeType.CompressedData: ContentType.Parameters["smime-type"] = "compressed-data"; ContentDisposition.FileName = "smime.p7z"; ContentType.Name = "smime.p7z"; break; case SecureMimeType.EnvelopedData: ContentType.Parameters["smime-type"] = "enveloped-data"; ContentDisposition.FileName = "smime.p7m"; ContentType.Name = "smime.p7m"; break; case SecureMimeType.SignedData: ContentType.Parameters["smime-type"] = "signed-data"; ContentDisposition.FileName = "smime.p7m"; ContentType.Name = "smime.p7m"; break; case SecureMimeType.CertsOnly: ContentType.Parameters["smime-type"] = "certs-only"; ContentDisposition.FileName = "smime.p7c"; ContentType.Name = "smime.p7c"; break; default: throw new ArgumentOutOfRangeException("type"); } }