public final class SmimeUtil extends Object
| Modifier and Type | Field and Description |
|---|---|
static org.bouncycastle.asn1.ASN1ObjectIdentifier |
DEFAULT_CIPHER |
static KeyEncapsulationAlgorithm |
DEFAULT_KEY_ENCAPSULATION_ALGORITHM |
static String |
DEFAULT_SIGNATURE_ALGORITHM_NAME
Unfortunately, these constants are not available in the Bouncy Castle, and they have to be passed as strings.
|
| Modifier and Type | Method and Description |
|---|---|
static boolean |
checkSignature(jakarta.mail.internet.MimeMultipart mimeMultipart)
Checks the signature on an S/MIME signed MIME multipart.
|
static boolean |
checkSignature(jakarta.mail.internet.MimePart mimePart)
Checks the signature on an S/MIME signed MIME part (i.e.
|
static jakarta.mail.internet.MimeBodyPart |
decrypt(jakarta.mail.internet.MimeBodyPart mimeBodyPart,
SmimeKey smimeKey)
Decrypts an S/MIME encrypted MIME body part and yields a new MIME body
part.
|
static jakarta.mail.internet.MimeBodyPart |
decrypt(jakarta.mail.internet.MimeMultipart mimeMultipart,
SmimeKey smimeKey)
Decrypts an S/MIME encrypted MIME multipart and yields a new MIME body
part.
|
static jakarta.mail.internet.MimeMessage |
decrypt(jakarta.mail.Session session,
jakarta.mail.internet.MimeMessage mimeMessage,
SmimeKey smimeKey)
Decrypts an S/MIME encrypted MIME message and yields a new MIME message.
|
static jakarta.mail.internet.MimeBodyPart |
encrypt(jakarta.mail.internet.MimeBodyPart mimeBodyPart,
X509Certificate certificate)
Encrypts a MIME body part and yields a new S/MIME encrypted MIME body
part.
|
static jakarta.mail.internet.MimeBodyPart |
encrypt(jakarta.mail.internet.MimeBodyPart mimeBodyPart,
X509Certificate certificate,
KeyEncapsulationAlgorithm keyEncapsulationAlgorithm,
org.bouncycastle.asn1.ASN1ObjectIdentifier cmsAlgorithm)
Encrypts a MIME body part and yields a new S/MIME encrypted MIME body
part.
|
static jakarta.mail.internet.MimeMessage |
encrypt(jakarta.mail.Session session,
jakarta.mail.internet.MimeMessage mimeMessage,
@Nullable String messageId,
X509Certificate certificate,
KeyEncapsulationAlgorithm keyEncapsulationAlgorithm,
org.bouncycastle.asn1.ASN1ObjectIdentifier cmsAlgorithm)
Encrypts a MIME message and yields a new S/MIME encrypted MIME message.
|
static jakarta.mail.internet.MimeMessage |
encrypt(jakarta.mail.Session session,
@Nullable String messageId,
jakarta.mail.internet.MimeMessage mimeMessage,
X509Certificate certificate)
Encrypts a MIME message and yields a new S/MIME encrypted MIME message.
|
static String |
getSignedByAddress(jakarta.mail.internet.MimeMultipart mimeMultipart) |
static String |
getSignedByAddress(jakarta.mail.internet.MimePart mimePart) |
static jakarta.mail.internet.MimeBodyPart |
getSignedContent(jakarta.mail.internet.MimeMultipart mimeMultipart)
Returns the signed MIME body part of an S/MIME signed MIME multipart.
|
static jakarta.mail.internet.MimeBodyPart |
getSignedContent(jakarta.mail.internet.MimePart mimePart)
Returns the signed MIME body part of an S/MIME signed MIME part (i.e.
|
static SmimeState |
getStatus(jakarta.mail.internet.MimeMultipart mimeMultipart)
Returns the S/MIME state of a MIME multipart.
|
static SmimeState |
getStatus(jakarta.mail.internet.MimePart mimePart)
Returns the S/MIME state of a MIME part (i.e.
|
static jakarta.mail.internet.MimeBodyPart |
sign(jakarta.mail.internet.MimeBodyPart mimeBodyPart,
SmimeKey smimeKey)
Signs a MIME body part and yields a new S/MIME signed MIME body part.
|
static jakarta.mail.internet.MimeBodyPart |
sign(jakarta.mail.internet.MimeBodyPart mimeBodyPart,
SmimeKey smimeKey,
String algorithmName)
Signs a MIME body part and yields a new S/MIME signed MIME body part.
|
static <T extends jakarta.mail.internet.MimeMessage> |
sign(jakarta.mail.Session session,
@Nullable String messageId,
T mimeMessage,
SmimeKey smimeKey)
Signs a MIME message and yields a new S/MIME signed MIME message.
|
static <T extends jakarta.mail.internet.MimeMessage> |
sign(jakarta.mail.Session session,
@Nullable String messageId,
T mimeMessage,
SmimeKey smimeKey,
String algorithmName)
Signs a MIME message and yields a new S/MIME signed MIME message.
|
public static final String DEFAULT_SIGNATURE_ALGORITHM_NAME
for a list of supported algorithms.,
Constant Field Valuespublic static final KeyEncapsulationAlgorithm DEFAULT_KEY_ENCAPSULATION_ALGORITHM
public static final org.bouncycastle.asn1.ASN1ObjectIdentifier DEFAULT_CIPHER
public static jakarta.mail.internet.MimeMessage encrypt(jakarta.mail.Session session,
@Nullable
@Nullable String messageId,
jakarta.mail.internet.MimeMessage mimeMessage,
X509Certificate certificate)
session - The Session that is used in conjunction with the original MimeMessage.messageId - Optional MessageID that should be preserved on the encrypted MimeMessage result.mimeMessage - The original MimeMessage to be encrypted.certificate - The X509Certificate used to obtain the PublicKey to encrypt the original message with.MimeMessage.public static jakarta.mail.internet.MimeMessage encrypt(jakarta.mail.Session session,
jakarta.mail.internet.MimeMessage mimeMessage,
@Nullable
@Nullable String messageId,
X509Certificate certificate,
KeyEncapsulationAlgorithm keyEncapsulationAlgorithm,
org.bouncycastle.asn1.ASN1ObjectIdentifier cmsAlgorithm)
session - The Session that is used in conjunction with the
original MimeMessage.mimeMessage - The original MimeMessage to be encrypted.messageId - Optional MessageID that should be preserved on the encrypted MimeMessage result.certificate - The X509Certificate used to obtain the
PublicKey to encrypt the original message with.keyEncapsulationAlgorithm - Algorithm used to encapsulate the symmetric encryption key.
Currently, RSA RSA-OAEP with various SHA digest lengths are supported.cmsAlgorithm - Encryption algorithm for symmetric content encryption.MimeMessage.public static jakarta.mail.internet.MimeBodyPart encrypt(jakarta.mail.internet.MimeBodyPart mimeBodyPart,
X509Certificate certificate)
mimeBodyPart - The original MimeBodyPart to be encrypted.certificate - The X509Certificate used to obtain the
PublicKey to encrypt the original body part with.MimeBodyPart.public static jakarta.mail.internet.MimeBodyPart encrypt(jakarta.mail.internet.MimeBodyPart mimeBodyPart,
X509Certificate certificate,
KeyEncapsulationAlgorithm keyEncapsulationAlgorithm,
org.bouncycastle.asn1.ASN1ObjectIdentifier cmsAlgorithm)
mimeBodyPart - The original MimeBodyPart to be encrypted.certificate - The X509Certificate used to obtain the
PublicKey to encrypt the original body part with.keyEncapsulationAlgorithm - Algorithm used to encapsulate the symmetric encryption key.
Currently, RSA RSA-OAEP with various SHA digest lengths are supported.cmsAlgorithm - Encryption algorithm for symmetric content encryption.MimeBodyPart.public static jakarta.mail.internet.MimeMessage decrypt(jakarta.mail.Session session,
jakarta.mail.internet.MimeMessage mimeMessage,
SmimeKey smimeKey)
session - The Session that is used in conjunction with the
encrypted MimeMessage.mimeMessage - The encrypted MimeMessage to be decrypted.smimeKey - The SmimeKey used to obtain the PrivateKey to
decrypt the encrypted message with.MimeMessage.public static jakarta.mail.internet.MimeBodyPart decrypt(jakarta.mail.internet.MimeBodyPart mimeBodyPart,
SmimeKey smimeKey)
mimeBodyPart - The encrypted MimeBodyPart to be decrypted.smimeKey - The SmimeKey used to obtain the PrivateKey to
decrypt the encrypted body part with.MimeBodyPart.public static jakarta.mail.internet.MimeBodyPart decrypt(jakarta.mail.internet.MimeMultipart mimeMultipart,
SmimeKey smimeKey)
mimeMultipart - The encrypted MimeMultipart to be decrypted.smimeKey - The SmimeKey used to obtain the PrivateKey to
decrypt the encrypted multipart with.MimeBodyPart.public static jakarta.mail.internet.MimeBodyPart sign(jakarta.mail.internet.MimeBodyPart mimeBodyPart,
SmimeKey smimeKey)
mimeBodyPart - The original MimeBodyPart to be signed.smimeKey - The SmimeKey used to obtain the PrivateKey to
sign the original body part with.MimeBodyPart.public static jakarta.mail.internet.MimeBodyPart sign(jakarta.mail.internet.MimeBodyPart mimeBodyPart,
SmimeKey smimeKey,
String algorithmName)
mimeBodyPart - The original MimeBodyPart to be signed.smimeKey - The SmimeKey used to obtain the PrivateKey to
sign the original body part with.algorithmName - The name of the signature algorithm to use. Must be an algorithm
supported by the Bouncy Castle security provider.MimeBodyPart.public static <T extends jakarta.mail.internet.MimeMessage> T sign(jakarta.mail.Session session,
@Nullable
@Nullable String messageId,
T mimeMessage,
SmimeKey smimeKey)
session - The Session that is used in conjunction with the original MimeMessage.messageId - Optional MessageID that should be preserved on the signed MimeMessage.mimeMessage - The original MimeMessage or SMTPMessage to be signed.smimeKey - The SmimeKey used to obtain the PrivateKey to sign the original message with.MimeMessage or SMTPMessage.public static <T extends jakarta.mail.internet.MimeMessage> T sign(jakarta.mail.Session session,
@Nullable
@Nullable String messageId,
T mimeMessage,
SmimeKey smimeKey,
String algorithmName)
session - The Session that is used in conjunction with the original MimeMessage.messageId - Optional MessageID that should be preserved on the signed MimeMessage.mimeMessage - The original MimeMessage or SMTPMessage to be signed.smimeKey - The SmimeKey used to obtain the PrivateKey to sign the original message with.algorithmName - The name of the signature algorithm to use. Must be an algorithm supported by the Bouncy Castle security provider.MimeMessage or SMTPMessage.public static boolean checkSignature(jakarta.mail.internet.MimeMultipart mimeMultipart)
mimeMultipart - The MimeMultipart to be checked.true if the multipart is correctly signed, false
otherwise.public static boolean checkSignature(jakarta.mail.internet.MimePart mimePart)
mimePart - The MimePart to be checked.true if the part is correctly signed, false
otherwise.public static String getSignedByAddress(jakarta.mail.internet.MimeMultipart mimeMultipart)
mimeMultipart - The MimeMultipart to be checked."Signed by: <subject / address>"public static String getSignedByAddress(jakarta.mail.internet.MimePart mimePart)
mimePart - The MimePart to be checked."Signed by: <subject / address>"public static jakarta.mail.internet.MimeBodyPart getSignedContent(jakarta.mail.internet.MimeMultipart mimeMultipart)
mimeMultipart - The MimeMultipart to be stripped off.MimeBodyPart contained in the
MimeMultipart.public static jakarta.mail.internet.MimeBodyPart getSignedContent(jakarta.mail.internet.MimePart mimePart)
mimePart - The MimePart to be stripped off.MimeBodyPart contained in the MimePart
.public static SmimeState getStatus(jakarta.mail.internet.MimeMultipart mimeMultipart)
mimeMultipart - The MimeMultipart to be checked.SmimeState of the MimeMultipart.public static SmimeState getStatus(jakarta.mail.internet.MimePart mimePart)
mimePart - The MimePart to be checked.SmimeState of the MimePart.Copyright © 2021–2024. All rights reserved.