org.bouncycastle.mail.smime

Class SMIMEEnvelopedGenerator


public class SMIMEEnvelopedGenerator
extends SMIMEGenerator

General class for generating a pkcs7-mime message. A simple example of usage.
      SMIMEEnvelopedGenerator  fact = new SMIMEEnvelopedGenerator();

      fact.addKeyTransRecipient(cert);

      MimeBodyPart           smime = fact.generate(content, algorithm, "BC");
 
Note: Most clients expect the MimeBodyPart to be in a MimeMultipart when it's sent.

Field Summary

static String
AES128_CBC
static String
AES192_CBC
static String
AES256_CBC
static String
CAST5_CBC
static String
DES_EDE3_CBC
static String
IDEA_CBC
static String
RC2_CBC

Fields inherited from class org.bouncycastle.mail.smime.SMIMEGenerator

encoding, useBase64

Constructor Summary

SMIMEEnvelopedGenerator()
base constructor

Method Summary

void
addKeyTransRecipient(PublicKey key, byte[] subKeyId)
add a recipient - note: this will only work on V3 and later clients.
void
addKeyTransRecipient(X509Certificate cert)
add a recipient.
MimeBodyPart
generate(MimeBodyPart content, String encryptionOID, String provider)
generate an enveloped object that contains an SMIME Enveloped object using the given provider.
MimeBodyPart
generate(MimeBodyPart content, String encryptionOID, int keySize, String provider)
generate an enveloped object that contains an SMIME Enveloped object using the given provider.
MimeBodyPart
generate(MimeMessage message, String encryptionOID, String provider)
generate an enveloped object that contains an SMIME Enveloped object using the given provider from the contents of the passed in message
MimeBodyPart
generate(MimeMessage message, String encryptionOID, int keySize, String provider)
generate an enveloped object that contains an SMIME Enveloped object using the given provider from the contents of the passed in message.
void
setBerEncodeRecipients(boolean berEncodeRecipientSet)
Use a BER Set to store the recipient information

Methods inherited from class org.bouncycastle.mail.smime.SMIMEGenerator

makeContentBodyPart, makeContentBodyPart, setContentTransferEncoding

Field Details

AES128_CBC

public static final String AES128_CBC

AES192_CBC

public static final String AES192_CBC

AES256_CBC

public static final String AES256_CBC

CAST5_CBC

public static final String CAST5_CBC

DES_EDE3_CBC

public static final String DES_EDE3_CBC

IDEA_CBC

public static final String IDEA_CBC

RC2_CBC

public static final String RC2_CBC

Constructor Details

SMIMEEnvelopedGenerator

public SMIMEEnvelopedGenerator()
base constructor

Method Details

addKeyTransRecipient

public void addKeyTransRecipient(PublicKey key,
                                 byte[] subKeyId)
            throws IllegalArgumentException
add a recipient - note: this will only work on V3 and later clients.
Parameters:
key - the recipient's public key
subKeyId - the subject key id for the recipient's public key

addKeyTransRecipient

public void addKeyTransRecipient(X509Certificate cert)
            throws IllegalArgumentException
add a recipient.

generate

public MimeBodyPart generate(MimeBodyPart content,
                             String encryptionOID,
                             String provider)
            throws NoSuchAlgorithmException,
                   NoSuchProviderException,
                   SMIMEException
generate an enveloped object that contains an SMIME Enveloped object using the given provider.

generate

public MimeBodyPart generate(MimeBodyPart content,
                             String encryptionOID,
                             int keySize,
                             String provider)
            throws NoSuchAlgorithmException,
                   NoSuchProviderException,
                   SMIMEException
generate an enveloped object that contains an SMIME Enveloped object using the given provider. The size of the encryption key is determined by keysize.

generate

public MimeBodyPart generate(MimeMessage message,
                             String encryptionOID,
                             String provider)
            throws NoSuchAlgorithmException,
                   NoSuchProviderException,
                   SMIMEException
generate an enveloped object that contains an SMIME Enveloped object using the given provider from the contents of the passed in message

generate

public MimeBodyPart generate(MimeMessage message,
                             String encryptionOID,
                             int keySize,
                             String provider)
            throws NoSuchAlgorithmException,
                   NoSuchProviderException,
                   SMIMEException
generate an enveloped object that contains an SMIME Enveloped object using the given provider from the contents of the passed in message. The size of the encryption key used to protect the message is determined by keysize.

setBerEncodeRecipients

public void setBerEncodeRecipients(boolean berEncodeRecipientSet)
Use a BER Set to store the recipient information