Top Description Inners Fields Constructors Methods
org.bouncycastle.mail.smime

public Class SMIMEEnvelopedGenerator

extends SMIMEGenerator
Class Inheritance
Imports
java.io.IOException, .OutputStream, java.security.AccessController, .PrivilegedAction, jakarta.activation.CommandMap, .MailcapCommandMap, jakarta.mail.MessagingException, jakarta.mail.internet.MimeBodyPart, .MimeMessage, org.bouncycastle.asn1.ASN1EncodableVector, .ASN1ObjectIdentifier, org.bouncycastle.cms.CMSEnvelopedDataGenerator, .CMSEnvelopedDataStreamGenerator, .CMSException, .RecipientInfoGenerator, org.bouncycastle.operator.OutputEncryptor

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

     fact.addRecipientInfoGenerator(new JceKeyTransRecipientInfoGenerator(recipientCert).setProvider("BC"));

     MimeBodyPart mp = fact.generate(content, new JceCMSContentEncryptorBuilder(CMSAlgorithm.RC2_CBC, 40).setProvider("BC").build());

Note

Most clients expect the MimeBodyPart to be in a MimeMultipart when it's sent.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
private class
private static class

Field Summary

Modifier and TypeField and Description
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
private static final String
private SMIMEEnvelopedGenerator.EnvelopedGenerator
public static final String
public static final String
public static final String
public static final String
Inherited from org.bouncycastle.mail.smime.SMIMEGenerator:
encodinguseBase64

Constructor Summary

AccessConstructor and Description
public
SMIMEEnvelopedGenerator()

base constructor

Method Summary

Modifier and TypeMethod and Description
public void
addRecipientInfoGenerator(RecipientInfoGenerator recipientInfoGen)

add a recipientInfoGenerator.

public MimeBodyPart
generate(MimeBodyPart content, OutputEncryptor encryptor)

generate an enveloped object that contains an SMIME Enveloped object using the given content encryptor

public MimeBodyPart
generate(MimeMessage message, OutputEncryptor encryptor)

generate an enveloped object that contains an SMIME Enveloped object using the given provider from the contents of the passed in message

private MimeBodyPart
make(MimeBodyPart content, OutputEncryptor encryptor)

if we get here we expect the Mime body part to be well defined.

public void
setBerEncodeRecipients(boolean berEncodeRecipientSet)

Use a BER Set to store the recipient information

Inherited from org.bouncycastle.mail.smime.SMIMEGenerator:
createSymmetricKeyGeneratormakeContentBodyPartmakeContentBodyPartsetContentTransferEncoding

Field Detail

AES128_CBCback to summary
public static final String AES128_CBC
AES128_WRAPback to summary
public static final String AES128_WRAP
AES192_CBCback to summary
public static final String AES192_CBC
AES256_CBCback to summary
public static final String AES256_CBC
AES256_WRAPback to summary
public static final String AES256_WRAP
CAMELLIA128_CBCback to summary
public static final String CAMELLIA128_CBC
CAMELLIA128_WRAPback to summary
public static final String CAMELLIA128_WRAP
CAMELLIA192_CBCback to summary
public static final String CAMELLIA192_CBC
CAMELLIA192_WRAPback to summary
public static final String CAMELLIA192_WRAP
CAMELLIA256_CBCback to summary
public static final String CAMELLIA256_CBC
CAMELLIA256_WRAPback to summary
public static final String CAMELLIA256_WRAP
CAST5_CBCback to summary
public static final String CAST5_CBC
DES_EDE3_CBCback to summary
public static final String DES_EDE3_CBC
DES_EDE3_WRAPback to summary
public static final String DES_EDE3_WRAP
ECDH_SHA1KDFback to summary
public static final String ECDH_SHA1KDF
ENCRYPTED_CONTENT_TYPEback to summary
private static final String ENCRYPTED_CONTENT_TYPE
factback to summary
private SMIMEEnvelopedGenerator.EnvelopedGenerator fact
IDEA_CBCback to summary
public static final String IDEA_CBC
RC2_CBCback to summary
public static final String RC2_CBC
SEED_CBCback to summary
public static final String SEED_CBC
SEED_WRAPback to summary
public static final String SEED_WRAP

Constructor Detail

SMIMEEnvelopedGeneratorback to summary
public SMIMEEnvelopedGenerator()

base constructor

Method Detail

addRecipientInfoGeneratorback to summary
public void addRecipientInfoGenerator(RecipientInfoGenerator recipientInfoGen) throws IllegalArgumentException

add a recipientInfoGenerator.

generateback to summary
public MimeBodyPart generate(MimeBodyPart content, OutputEncryptor encryptor) throws SMIMEException

generate an enveloped object that contains an SMIME Enveloped object using the given content encryptor

generateback to summary
public MimeBodyPart generate(MimeMessage message, OutputEncryptor encryptor) throws SMIMEException

generate an enveloped object that contains an SMIME Enveloped object using the given provider from the contents of the passed in message

makeback to summary
private MimeBodyPart make(MimeBodyPart content, OutputEncryptor encryptor) throws SMIMEException

if we get here we expect the Mime body part to be well defined.

setBerEncodeRecipientsback to summary
public void setBerEncodeRecipients(boolean berEncodeRecipientSet)

Use a BER Set to store the recipient information

org.bouncycastle.mail.smime back to summary

private Class SMIMEEnvelopedGenerator.ContentEncryptor

extends Object
implements SMIMEStreamingProcessor
Class Inheritance
  • java.lang.Object
  • org.bouncycastle.mail.smime.SMIMEEnvelopedGenerator.ContentEncryptor
All Implemented Interfaces
org.bouncycastle.mail.smime.SMIMEStreamingProcessor

Field Summary

Modifier and TypeField and Description
private final MimeBodyPart
private OutputEncryptor
private boolean

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_contentback to summary
private final MimeBodyPart _content
_encryptorback to summary
private OutputEncryptor _encryptor
_firstTimeback to summary
private boolean _firstTime

Constructor Detail

ContentEncryptorback to summary
pack-priv ContentEncryptor(MimeBodyPart content, OutputEncryptor encryptor)

Method Detail

writeback to summary
public void write(OutputStream out) throws IOException

Implements org.bouncycastle.mail.smime.SMIMEStreamingProcessor.write.

org.bouncycastle.mail.smime back to summary

private Class SMIMEEnvelopedGenerator.EnvelopedGenerator

extends CMSEnvelopedDataStreamGenerator
Class Inheritance

Field Summary

Modifier and TypeField and Description
private ASN1ObjectIdentifier
private ASN1EncodableVector

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
protected OutputStream
pack-priv OutputStream
Inherited from org.bouncycastle.cms.CMSEnvelopedDataStreamGenerator:
openopenopensetBEREncodeRecipientssetBufferSize

Field Detail

dataTypeback to summary
private ASN1ObjectIdentifier dataType
recipientInfosback to summary
private ASN1EncodableVector recipientInfos

Constructor Detail

EnvelopedGeneratorback to summary
private EnvelopedGenerator()

Method Detail

openback to summary
protected OutputStream open(ASN1ObjectIdentifier dataType, OutputStream out, ASN1EncodableVector recipientInfos, OutputEncryptor encryptor) throws IOException

Overrides org.bouncycastle.cms.CMSEnvelopedDataStreamGenerator.open.

regenerateback to summary
pack-priv OutputStream regenerate(OutputStream out, OutputEncryptor encryptor) throws IOException
org.bouncycastle.mail.smime back to summary

private Class SMIMEEnvelopedGenerator.WrappingIOException

extends IOException
Class Inheritance

Field Summary

Modifier and TypeField and Description
private Throwable

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public Throwable
getCause()

Overrides java.lang.Throwable.getCause.

Returns the cause of this throwable or null if the cause is nonexistent or unknown.

Field Detail

causeback to summary
private Throwable cause

Hides java.lang.Throwable.cause.

Constructor Detail

WrappingIOExceptionback to summary
pack-priv WrappingIOException(String msg, Throwable cause)

Method Detail

getCauseback to summary
public Throwable getCause()

Overrides java.lang.Throwable.getCause.

Doc from java.lang.Throwable.getCause.

Returns the cause of this throwable or null if the cause is nonexistent or unknown. (The cause is the throwable that caused this throwable to get thrown.)

This implementation returns the cause that was supplied via one of the constructors requiring a Throwable, or that was set after creation with the initCause(Throwable) method. While it is typically unnecessary to override this method, a subclass can override it to return a cause set by some other means. This is appropriate for a "legacy chained throwable" that predates the addition of chained exceptions to Throwable. Note that it is not necessary to override any of the PrintStackTrace methods, all of which invoke the getCause method to determine the cause of a throwable.

Returns:Throwable

the cause of this throwable or null if the cause is nonexistent or unknown.