org.bouncycastle.mail.smime
public class SMIMESignedGenerator extends SMIMEGenerator
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".
Field Summary | |
---|---|
static String | DIGEST_GOST3411 |
static String | DIGEST_MD5 |
static String | DIGEST_RIPEMD128 |
static String | DIGEST_RIPEMD160 |
static String | DIGEST_RIPEMD256 |
static String | DIGEST_SHA1 |
static String | DIGEST_SHA224 |
static String | DIGEST_SHA256 |
static String | DIGEST_SHA384 |
static String | DIGEST_SHA512 |
static String | ENCRYPTION_DSA |
static String | ENCRYPTION_ECDSA |
static String | ENCRYPTION_ECGOST3410 |
static String | ENCRYPTION_GOST3410 |
static String | ENCRYPTION_RSA |
static String | ENCRYPTION_RSA_PSS |
Constructor Summary | |
---|---|
SMIMESignedGenerator()
base constructor - default content transfer encoding 7bit | |
SMIMESignedGenerator(String defaultContentTransferEncoding)
base constructor - default content transfer encoding explicitly set
|
Method Summary | |
---|---|
void | addAttributeCertificates(X509Store store)
Add the attribute certificates contained in the passed in store to the
generator.
|
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 or overrides
for the standard 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.
|
Map | getGeneratedDigests()
Return a map of oids and byte arrays representing the digests calculated on the content during
the last generate.
|
Parameters: defaultContentTransferEncoding new default to use.
Parameters: store a store of Version 2 attribute certificates
Throws: CMSException if an error occurse processing the store.
Note: this assumes the CertStore will support null in the get methods.
Parameters: certStore CertStore containing the certificates and CRLs to be added.
Parameters: key key to use to generate the signature cert the public key certificate associated with the signer's key. digestOID object ID of the digest algorithm to use.
Throws: IllegalArgumentException any of the arguments are inappropriate
Parameters: key key to use to generate the signature cert the public key certificate associated with the signer's key. digestOID object ID of the digest algorithm to use. signedAttr signed attributes to be included in the signature. unsignedAttr unsigned attribitues to be included.
Throws: IllegalArgumentException any of the arguments are inappropriate
Parameters: content the MimeBodyPart to be signed. sigProvider the provider to be used for the signature.
Returns: a Multipart containing the content and signature.
Throws: NoSuchAlgorithmException if the required algorithms for the signature cannot be found. NoSuchProviderException if no provider can be found. SMIMEException if an exception occurs in processing the signature.
Throws: NoSuchAlgorithmException if the required algorithms for the signature cannot be found. NoSuchProviderException if no provider can be found. SMIMEException if an exception occurs in processing the signature.
Returns: a MimeBodyPart containing the certs and CRLs.
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.
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.
Returns: a map of oids (as String objects) and byte[] representing digests.