org.bouncycastle.mail.smime
Class SMIMESignedGenerator
public class SMIMESignedGenerator
general class for generating a pkcs7-signature message.
A simple example of usage.
CertStore certs...
SMIMESignedGenerator fact = new SMIMESignedGenerator();
fact.addSigner(privKey, cert, SMIMESignedGenerator.DIGEST_SHA1);
fact.addCertificatesAndCRLs(certs);
MimeMultipart smime = fact.generate(content, "BC");
Note: if you are using this class with AS2 or some other protocol
that does not use "7bit" as the default content transfer encoding you
will need to use the constructor that allows you to specify the default
content transfer encoding, such as "binary".
SMIMESignedGenerator() - base constructor - default content transfer encoding 7bit
|
SMIMESignedGenerator(String defaultContentTransferEncoding) - base constructor - default content transfer encoding explicitly set
|
void | addCertificatesAndCRLs(CertStore certStore) - add the certificates and CRLs contained in the given CertStore
to the pool that will be included in the encoded signature block.
|
void | addSigner(PrivateKey key, X509Certificate cert, String digestOID) - add a signer - no attributes other than the default ones will be
provided here.
|
void | addSigner(PrivateKey key, X509Certificate cert, String digestOID, AttributeTable signedAttr, AttributeTable unsignedAttr) - add a signer with extra signed/unsigned attributes.
|
MimeMultipart | generate(MimeBodyPart content, String sigProvider) - generate a signed object that contains an SMIME Signed Multipart
object using the given provider.
|
MimeMultipart | generate(MimeMessage message, String sigProvider) - generate a signed object that contains an SMIME Signed Multipart
object using the given provider from the given MimeMessage
|
MimeBodyPart | generateCertificateManagement(String provider) - Creates a certificate management message which is like a signed message with no content
or signers but that still carries certificates and CRLs.
|
MimeBodyPart | generateEncapsulated(MimeBodyPart content, String sigProvider) - generate a signed message with encapsulated content
Note: doing this is strongly not recommended as it means a
recipient of the message will have to be able to read the signature to read the
message.
|
MimeBodyPart | generateEncapsulated(MimeMessage message, String sigProvider) - generate a signed object that contains an SMIME Signed Multipart
object using the given provider from the given MimeMessage.
|
DIGEST_MD5
public static final String DIGEST_MD5
DIGEST_SHA1
public static final String DIGEST_SHA1
DIGEST_SHA224
public static final String DIGEST_SHA224
DIGEST_SHA256
public static final String DIGEST_SHA256
DIGEST_SHA384
public static final String DIGEST_SHA384
DIGEST_SHA512
public static final String DIGEST_SHA512
ENCRYPTION_DSA
public static final String ENCRYPTION_DSA
ENCRYPTION_RSA
public static final String ENCRYPTION_RSA
SMIMESignedGenerator
public SMIMESignedGenerator()
base constructor - default content transfer encoding 7bit
SMIMESignedGenerator
public SMIMESignedGenerator(String defaultContentTransferEncoding)
base constructor - default content transfer encoding explicitly set
defaultContentTransferEncoding
- new default to use.
addCertificatesAndCRLs
public void addCertificatesAndCRLs(CertStore certStore)
throws CertStoreException,
SMIMEException
add the certificates and CRLs contained in the given CertStore
to the pool that will be included in the encoded signature block.
Note: this assumes the CertStore will support null in the get
methods.
addSigner
public void addSigner(PrivateKey key,
X509Certificate cert,
String digestOID)
throws IllegalArgumentException
add a signer - no attributes other than the default ones will be
provided here.
addSigner
public void addSigner(PrivateKey key,
X509Certificate cert,
String digestOID,
AttributeTable signedAttr,
AttributeTable unsignedAttr)
throws IllegalArgumentException
add a signer with extra signed/unsigned attributes.
generate
public MimeMultipart generate(MimeBodyPart content,
String sigProvider)
throws NoSuchAlgorithmException,
NoSuchProviderException,
SMIMEException
generate a signed object that contains an SMIME Signed Multipart
object using the given provider.
generate
public MimeMultipart generate(MimeMessage message,
String sigProvider)
throws NoSuchAlgorithmException,
NoSuchProviderException,
SMIMEException
generate a signed object that contains an SMIME Signed Multipart
object using the given provider from the given MimeMessage
generateCertificateManagement
public MimeBodyPart generateCertificateManagement(String provider)
throws SMIMEException,
NoSuchProviderException
Creates a certificate management message which is like a signed message with no content
or signers but that still carries certificates and CRLs.
- a MimeBodyPart containing the certs and CRLs.
generateEncapsulated
public MimeBodyPart generateEncapsulated(MimeBodyPart content,
String sigProvider)
throws NoSuchAlgorithmException,
NoSuchProviderException,
SMIMEException
generate a signed message with encapsulated content
Note: doing this is strongly
not recommended as it means a
recipient of the message will have to be able to read the signature to read the
message.
generateEncapsulated
public MimeBodyPart generateEncapsulated(MimeMessage message,
String sigProvider)
throws NoSuchAlgorithmException,
NoSuchProviderException,
SMIMEException
generate a signed object that contains an SMIME Signed Multipart
object using the given provider from the given MimeMessage.
Note: doing this is strongly
not recommended as it means a
recipient of the message will have to be able to read the signature to read the
message.