SMimeMessage¶
-
public class
SMimeMessage
¶ SMimeMessage represents a Secure MIME Message. It encapsulates a MIME body part and provides methods for digital signing, signature verification, encryption, decryption, compression, and decompression.
Author: Hugo Y. K. Lam
Constructors¶
SMimeMessage¶
-
public
SMimeMessage
(MimeBodyPart bodyPart)¶ Creates a new instance of SMimeMessage.
Parameters: - bodyPart – the original MIME body part.
SMimeMessage¶
-
public
SMimeMessage
(MimeBodyPart bodyPart, X509Certificate cert)¶ Creates a new instance of SMimeMessage.
Parameters: - bodyPart – the original MIME body part.
- cert – the certificate for signature verification or encryption.
SMimeMessage¶
-
public
SMimeMessage
(MimeBodyPart bodyPart, X509Certificate cert, Session session)¶ Creates a new instance of SMimeMessage.
Parameters: - bodyPart – the original MIME body part.
- cert – the certificate for signature verification or encryption.
- session – the mail session.
SMimeMessage¶
-
public
SMimeMessage
(MimeBodyPart bodyPart, X509Certificate cert, PrivateKey privateKey)¶ Creates a new instance of SMimeMessage.
Parameters: - bodyPart – the original MIME body part.
- cert – the certificate for signature verification or encryption.
- privateKey – the private key for digital signing or decryption.
SMimeMessage¶
-
public
SMimeMessage
(MimeBodyPart bodyPart, X509Certificate cert, PrivateKey privateKey, Session session)¶ Creates a new instance of SMimeMessage.
Parameters: - bodyPart – the original MIME body part.
- cert – the certificate for signature verification or encryption.
- privateKey – the private key for digital signing or decryption.
- session – the mail session.
SMimeMessage¶
-
protected
SMimeMessage
(MimeBodyPart bodyPart, SMimeMessage smime)¶ Creates a new instance of SMimeMessage.
Parameters: - bodyPart – the original MIME body part.
- smime – the S/MIME message from which the configuration is copied.
Methods¶
compress¶
-
public SMimeMessage
compress
()¶ Compresses the encapsulated MIME body part.
Throws: - SMimeException – if unable to compress the body part.
Returns: an S/MIME message encapsulating the compressed MIME body part.
decompress¶
-
public SMimeMessage
decompress
()¶ Decompresses the encapsulated MIME body part.
Throws: - SMimeException – if unable to decompress the body part.
Returns: an S/MIME message encapsulating the decompressed MIME body part.
decrypt¶
-
public SMimeMessage
decrypt
()¶ Decrypts the encapsulated MIME body part.
Throws: - SMimeException – if unable to decrpyt the body part.
Returns: an S/MIME message encapsulating the decrypted MIME body part.
decrypt¶
-
public SMimeMessage
decrypt
(PrivateKey privateKey)¶ Decrypts the encapsulated MIME body part.
Parameters: - privateKey – the private key for decryption.
Throws: - SMimeException – if unable to decrpyt the body part.
Returns: an S/MIME message encapsulating the decrypted MIME body part.
digest¶
-
public String
digest
()¶ Digests the encapsulated MIME body part.
Throws: - SMimeException – if unable to compute the digest value.
Returns: the digested value in Base 64 format.
digest¶
-
public String
digest
(String digestAlg, boolean isHeadersIncluded)¶ Digests the encapsulated MIME body part.
Parameters: - digestAlg – digest algorithm.
- isHeadersIncluded – true if the digest should be computed on both the headers and the content of the encapsulated body part.
Throws: - SMimeException – if unable to compute the digest value.
Returns: the digested value in Base 64 format.
encrypt¶
-
public SMimeMessage
encrypt
()¶ Encrypts the encapsulated MIME body part.
Throws: - SMimeException – if unable to encrpyt the body part.
Returns: an S/MIME message encapsulating the encrypted MIME body part.
encrypt¶
-
public SMimeMessage
encrypt
(X509Certificate cert)¶ Encrypts the encapsulated MIME body part.
Parameters: - cert – the certificate for encryption.
Throws: - SMimeException – if unable to encrpyt the body part.
Returns: an S/MIME message encapsulating the encrypted MIME body part.
getBodyPart¶
-
public MimeBodyPart
getBodyPart
()¶ Gets the encapsulated MIME body part.
Returns: the encapsulated MIME body part.
getContentTransferEncoding¶
getDigestAlgorithm¶
getEncryptAlgorithm¶
isCompressed¶
-
public boolean
isCompressed
()¶ Checks if the encapsulated MIME body part is compressed.
Throws: - SMimeException – if error occurred in checking.
Returns: true if the encapsulated MIME body part is compressed.
isEncrypted¶
-
public boolean
isEncrypted
()¶ Checks if the encapsulated MIME body part is encrypted.
Throws: - SMimeException – if error occurred in checking.
Returns: true if the encapsulated MIME body part is encrypted.
isSigned¶
-
public boolean
isSigned
()¶ Checks if the encapsulated MIME body part is signed.
Throws: - SMimeException – if error occurred in checking.
Returns: true if the encapsulated MIME body part is signed.
setContentTransferEncoding¶
setDigestAlgorithm¶
setEncryptAlgorithm¶
sign¶
-
public SMimeMessage
sign
()¶ Signs the encapsulated MIME body part.
Throws: - SMimeException – if unable to sign the body part.
Returns: an S/MIME message encapsulating the signed MIME body part.
unsign¶
-
public SMimeMessage
unsign
()¶ Unsigns the encapsulated MIME body part.
Throws: - SMimeException – if unable to unsign the body part.
Returns: the an S/MIME message encapsulating the signed content.
verify¶
-
public SMimeMessage
verify
()¶ Verifies the encapsulated MIME body part.
Throws: - SMimeException – if unable to verify the body part.
Returns: an S/MIME message encapsulating the signed content.
verify¶
-
public SMimeMessage
verify
(X509Certificate cert)¶ Verifies the encapsulated MIME body part.
Parameters: - cert – the certificate for verification.
Throws: - SMimeException – if unable to verify the body part.
Returns: an S/MIME message encapsulating the signed content.