|
Bouncy Castle Cryptography Library 1.44 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.bouncycastle.mail.smime.SMIMEGenerator
org.bouncycastle.mail.smime.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".
Field Summary | |
---|---|
static java.lang.String |
DIGEST_GOST3411
|
static java.lang.String |
DIGEST_MD5
|
static java.lang.String |
DIGEST_RIPEMD128
|
static java.lang.String |
DIGEST_RIPEMD160
|
static java.lang.String |
DIGEST_RIPEMD256
|
static java.lang.String |
DIGEST_SHA1
|
static java.lang.String |
DIGEST_SHA224
|
static java.lang.String |
DIGEST_SHA256
|
static java.lang.String |
DIGEST_SHA384
|
static java.lang.String |
DIGEST_SHA512
|
static java.lang.String |
ENCRYPTION_DSA
|
static java.lang.String |
ENCRYPTION_ECDSA
|
static java.lang.String |
ENCRYPTION_ECGOST3410
|
static java.lang.String |
ENCRYPTION_GOST3410
|
static java.lang.String |
ENCRYPTION_RSA
|
static java.lang.String |
ENCRYPTION_RSA_PSS
|
Fields inherited from class org.bouncycastle.mail.smime.SMIMEGenerator |
---|
encoding, useBase64 |
Constructor Summary | |
---|---|
SMIMESignedGenerator()
base constructor - default content transfer encoding 7bit |
|
SMIMESignedGenerator(java.lang.String defaultContentTransferEncoding)
base constructor - default content transfer encoding explicitly set |
Method Summary | |
---|---|
void |
addAttributeCertificates(org.bouncycastle.x509.X509Store store)
Add the attribute certificates contained in the passed in store to the generator. |
void |
addCertificatesAndCRLs(java.security.cert.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(java.security.PrivateKey key,
java.security.cert.X509Certificate cert,
java.lang.String digestOID)
add a signer - no attributes other than the default ones will be provided here. |
void |
addSigner(java.security.PrivateKey key,
java.security.cert.X509Certificate cert,
java.lang.String digestOID,
org.bouncycastle.asn1.cms.AttributeTable signedAttr,
org.bouncycastle.asn1.cms.AttributeTable unsignedAttr)
Add a signer with extra signed/unsigned attributes or overrides for the standard attributes. |
void |
addSigner(java.security.PrivateKey key,
java.security.cert.X509Certificate cert,
java.lang.String encryptionOID,
java.lang.String digestOID)
add a signer - no attributes other than the default ones will be provided here. |
void |
addSigner(java.security.PrivateKey key,
java.security.cert.X509Certificate cert,
java.lang.String encryptionOID,
java.lang.String digestOID,
org.bouncycastle.asn1.cms.AttributeTable signedAttr,
org.bouncycastle.asn1.cms.AttributeTable unsignedAttr)
Add a signer with extra signed/unsigned attributes or overrides for the standard attributes and a digest encryption algorithm. |
void |
addSigners(SignerInformationStore signerStore)
Add a store of precalculated signers to the generator. |
javax.mail.internet.MimeMultipart |
generate(javax.mail.internet.MimeBodyPart content,
java.security.Provider sigProvider)
generate a signed object that contains an SMIME Signed Multipart object using the given provider. |
javax.mail.internet.MimeMultipart |
generate(javax.mail.internet.MimeBodyPart content,
java.lang.String sigProvider)
generate a signed object that contains an SMIME Signed Multipart object using the given provider. |
javax.mail.internet.MimeMultipart |
generate(javax.mail.internet.MimeMessage message,
java.security.Provider sigProvider)
generate a signed object that contains an SMIME Signed Multipart object using the given provider from the given MimeMessage |
javax.mail.internet.MimeMultipart |
generate(javax.mail.internet.MimeMessage message,
java.lang.String sigProvider)
generate a signed object that contains an SMIME Signed Multipart object using the given provider from the given MimeMessage |
javax.mail.internet.MimeBodyPart |
generateCertificateManagement(java.security.Provider provider)
Creates a certificate management message which is like a signed message with no content or signers but that still carries certificates and CRLs. |
javax.mail.internet.MimeBodyPart |
generateCertificateManagement(java.lang.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. |
javax.mail.internet.MimeBodyPart |
generateEncapsulated(javax.mail.internet.MimeBodyPart content,
java.security.Provider 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. |
javax.mail.internet.MimeBodyPart |
generateEncapsulated(javax.mail.internet.MimeBodyPart content,
java.lang.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. |
javax.mail.internet.MimeBodyPart |
generateEncapsulated(javax.mail.internet.MimeMessage message,
java.security.Provider sigProvider)
generate a signed object that contains an SMIME Signed Multipart object using the given provider from the given MimeMessage. |
javax.mail.internet.MimeBodyPart |
generateEncapsulated(javax.mail.internet.MimeMessage message,
java.lang.String sigProvider)
generate a signed object that contains an SMIME Signed Multipart object using the given provider from the given MimeMessage. |
java.util.Map |
getGeneratedDigests()
Return a map of oids and byte arrays representing the digests calculated on the content during the last generate. |
Methods inherited from class org.bouncycastle.mail.smime.SMIMEGenerator |
---|
createSymmetricKeyGenerator, makeContentBodyPart, makeContentBodyPart, setContentTransferEncoding |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String DIGEST_SHA1
public static final java.lang.String DIGEST_MD5
public static final java.lang.String DIGEST_SHA224
public static final java.lang.String DIGEST_SHA256
public static final java.lang.String DIGEST_SHA384
public static final java.lang.String DIGEST_SHA512
public static final java.lang.String DIGEST_GOST3411
public static final java.lang.String DIGEST_RIPEMD128
public static final java.lang.String DIGEST_RIPEMD160
public static final java.lang.String DIGEST_RIPEMD256
public static final java.lang.String ENCRYPTION_RSA
public static final java.lang.String ENCRYPTION_DSA
public static final java.lang.String ENCRYPTION_ECDSA
public static final java.lang.String ENCRYPTION_RSA_PSS
public static final java.lang.String ENCRYPTION_GOST3410
public static final java.lang.String ENCRYPTION_ECGOST3410
Constructor Detail |
---|
public SMIMESignedGenerator()
public SMIMESignedGenerator(java.lang.String defaultContentTransferEncoding)
defaultContentTransferEncoding
- new default to use.Method Detail |
---|
public void addSigner(java.security.PrivateKey key, java.security.cert.X509Certificate cert, java.lang.String digestOID) throws java.lang.IllegalArgumentException
key
- key to use to generate the signaturecert
- the public key certificate associated with the signer's key.digestOID
- object ID of the digest algorithm to use.
java.lang.IllegalArgumentException
- any of the arguments are inappropriatepublic void addSigner(java.security.PrivateKey key, java.security.cert.X509Certificate cert, java.lang.String encryptionOID, java.lang.String digestOID) throws java.lang.IllegalArgumentException
key
- key to use to generate the signaturecert
- the public key certificate associated with the signer's key.encryptionOID
- object ID of the digest ecnryption algorithm to use.digestOID
- object ID of the digest algorithm to use.
java.lang.IllegalArgumentException
- any of the arguments are inappropriatepublic void addSigner(java.security.PrivateKey key, java.security.cert.X509Certificate cert, java.lang.String digestOID, org.bouncycastle.asn1.cms.AttributeTable signedAttr, org.bouncycastle.asn1.cms.AttributeTable unsignedAttr) throws java.lang.IllegalArgumentException
key
- key to use to generate the signaturecert
- 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.
java.lang.IllegalArgumentException
- any of the arguments are inappropriatepublic void addSigner(java.security.PrivateKey key, java.security.cert.X509Certificate cert, java.lang.String encryptionOID, java.lang.String digestOID, org.bouncycastle.asn1.cms.AttributeTable signedAttr, org.bouncycastle.asn1.cms.AttributeTable unsignedAttr) throws java.lang.IllegalArgumentException
key
- key to use to generate the signaturecert
- the public key certificate associated with the signer's key.encryptionOID
- the digest encryption algorithm OID.digestOID
- object ID of the digest algorithm to use.signedAttr
- signed attributes to be included in the signature.unsignedAttr
- unsigned attribitues to be included.
java.lang.IllegalArgumentException
- any of the arguments are inappropriatepublic void addSigners(SignerInformationStore signerStore)
signerStore
- store of signerspublic void addCertificatesAndCRLs(java.security.cert.CertStore certStore) throws java.security.cert.CertStoreException, SMIMEException
Note: this assumes the CertStore will support null in the get methods.
certStore
- CertStore containing the certificates and CRLs to be added.
java.security.cert.CertStoreException
SMIMEException
public void addAttributeCertificates(org.bouncycastle.x509.X509Store store) throws CMSException
store
- a store of Version 2 attribute certificates
CMSException
- if an error occurse processing the store.public java.util.Map getGeneratedDigests()
public javax.mail.internet.MimeMultipart generate(javax.mail.internet.MimeBodyPart content, java.lang.String sigProvider) throws java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException, SMIMEException
content
- the MimeBodyPart to be signed.sigProvider
- the provider to be used for the signature.
java.security.NoSuchAlgorithmException
- if the required algorithms for the signature cannot be found.
java.security.NoSuchProviderException
- if no provider can be found.
SMIMEException
- if an exception occurs in processing the signature.public javax.mail.internet.MimeMultipart generate(javax.mail.internet.MimeBodyPart content, java.security.Provider sigProvider) throws java.security.NoSuchAlgorithmException, SMIMEException
content
- the MimeBodyPart to be signed.sigProvider
- the provider to be used for the signature.
java.security.NoSuchAlgorithmException
- if the required algorithms for the signature cannot be found.
SMIMEException
- if an exception occurs in processing the signature.public javax.mail.internet.MimeMultipart generate(javax.mail.internet.MimeMessage message, java.lang.String sigProvider) throws java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException, SMIMEException
java.security.NoSuchAlgorithmException
- if the required algorithms for the signature cannot be found.
java.security.NoSuchProviderException
- if no provider can be found.
SMIMEException
- if an exception occurs in processing the signature.public javax.mail.internet.MimeMultipart generate(javax.mail.internet.MimeMessage message, java.security.Provider sigProvider) throws java.security.NoSuchAlgorithmException, SMIMEException
java.security.NoSuchAlgorithmException
- if the required algorithms for the signature cannot be found.
java.security.NoSuchProviderException
- if no provider can be found.
SMIMEException
- if an exception occurs in processing the signature.public javax.mail.internet.MimeBodyPart generateEncapsulated(javax.mail.internet.MimeBodyPart content, java.lang.String sigProvider) throws java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException, SMIMEException
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.
java.security.NoSuchAlgorithmException
java.security.NoSuchProviderException
SMIMEException
public javax.mail.internet.MimeBodyPart generateEncapsulated(javax.mail.internet.MimeBodyPart content, java.security.Provider sigProvider) throws java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException, SMIMEException
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.
java.security.NoSuchAlgorithmException
java.security.NoSuchProviderException
SMIMEException
public javax.mail.internet.MimeBodyPart generateEncapsulated(javax.mail.internet.MimeMessage message, java.lang.String sigProvider) throws java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException, SMIMEException
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.
java.security.NoSuchAlgorithmException
java.security.NoSuchProviderException
SMIMEException
public javax.mail.internet.MimeBodyPart generateEncapsulated(javax.mail.internet.MimeMessage message, java.security.Provider sigProvider) throws java.security.NoSuchAlgorithmException, SMIMEException
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.
java.security.NoSuchAlgorithmException
SMIMEException
public javax.mail.internet.MimeBodyPart generateCertificateManagement(java.lang.String provider) throws SMIMEException, java.security.NoSuchProviderException
SMIMEException
java.security.NoSuchProviderException
public javax.mail.internet.MimeBodyPart generateCertificateManagement(java.security.Provider provider) throws SMIMEException
SMIMEException
|
Bouncy Castle Cryptography Library 1.44 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |