|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.security.smime.SMIMESender
Sends a S/MIME message to a recipient or writes the S/MIME message to a file. Construct this object with a PKCS #7 ContentInfo, PKCS #10 CertificationRequest, or a preconstructed SMIMEMessage object.
This definition reflects the S/MIME Version 2 Message Specification RFC 2311 specifications dated March 1998.
SMIME
Constructor Summary | |
SMIMESender()
Create an uninitialized SMIMESender object. |
|
SMIMESender(byte[] der)
Create a SMIMESender object with a DER byte array of a ContentInfo object. |
|
SMIMESender(byte[] der,
String provider)
Create a SMIMESender object with a DER byte array of a ContentInfo object. |
|
SMIMESender(CertificationRequest certRequest)
Create a SMIMESender object with the specified CertificationRequest object. |
|
SMIMESender(CertificationRequest certRequest,
String provider)
Create a SMIMESender object with the specified CertificationRequest object. |
|
SMIMESender(ContentInfo contentInfo)
Create a SMIMESender object with the specified ContentInfo object. |
|
SMIMESender(ContentInfo contentInfo,
String provider)
Create a SMIMESender object with the specified ContentInfo object. |
|
SMIMESender(SMIMEMessage message)
Create a SMIMESender object with the specified SMIMEMessage object. |
|
SMIMESender(SMIMEMessage message,
String provider)
Create a SMIMESender object with the specified SMIMEMessage object. |
|
SMIMESender(String provider)
Create an uninitialized SMIMESender object. |
Method Summary | |
void |
addRecipientCertificate(Certificate[] certs)
Add an array of recipient certificates to the S/MIME message. |
Object |
clone()
Creates a clone of this SMIMESender object. |
byte[] |
encrypt(int encryptionStrength)
Encrypts the current ContentInfo with a generated secret key and encrypts the secret key with the recipient certificate(s) that were already specified for this SMIMESender object. |
byte[] |
encrypt(String encryptionAlgorithm,
int keySize)
Encrypts the current ContentInfo with a generated secret key and encrypts the secret key with the recipient certificate(s) that were already specified for this SMIMESender object. |
byte[] |
getBase64Content()
Returns the BASE64 DER-encoded content of the ContentInfo or CertificationRequest that this SMIMESender object contains. |
CertificationRequest |
getCertificationRequest()
Returns the CertificationRequest object for this SMIMESender object. |
ContentInfo |
getContentInfo()
Returns a copy of the ContentInfo object for this SMIMESender object. |
String |
getFileName()
Returns the value for the filename Content-Disposition MIME attribute. |
String |
getMailhost()
Get the mailhost value for this SMIMESender object. |
String |
getSMIMEType()
Returns the value for the smime-type Content-Type MIME attribute. |
boolean |
hasRecipientCertificate()
Check if this SMIMESender object contains one or more recipient certificates. |
void |
mail(byte[] message,
String senderAddress,
String recipientAddress,
String subject)
Mails the specified byte array message to the specified recipient address via SMTP. |
void |
mail(String senderAddress,
String recipientAddress,
String subject)
Mails the SMIMEMessage to the specified recipient address via SMTP. |
void |
setCertificateOnly(Certificate[] certs)
Set the ContentInfo object to a certificate-only SignedData object with the specified certificate array. |
void |
setCertificationRequest(CertificationRequest certRequest)
Set the CertificationRequest object for this SMIMESender object. |
void |
setContentInfo(ContentInfo contentInfo)
Set the ContentInfo object for this SMIMESender object. |
void |
setMailhost(String mailhost)
Set the mailhost value for this SMIMESender object. |
void |
setMessageWithHeader(String message)
Creates a ContentInfo Data object with the specified message and predefined MIME header for this SMIMESender object. |
void |
setRecipientCertificate(Certificate[] certs)
Set the recipient certificates for the S/MIME message. |
byte[] |
sign(Certificate signerCert,
String digestSignatureAlgorithm,
PrivateKey privateKey)
Signs the current ContentInfo with the specified certificate and private key. |
byte[] |
signSignatureOnly(Certificate signerCert,
String digestSignatureAlgorithm,
PrivateKey privateKey)
Signs the current ContentInfo with the specified certificate and private key. |
String |
toString()
Returns a string representation of this SMIMESender object. |
void |
writeMailToFile(byte[] message,
String filename,
String senderAddress,
String recipientAddress,
String subject)
Writes the specified byte array to the specified file. |
void |
writeMailToFile(String filename,
String senderAddress,
String recipientAddress,
String subject)
Writes the SMIMEMessage to the specified file. |
Methods inherited from class java.lang.Object |
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
public SMIMESender()
public SMIMESender(String provider)
public SMIMESender(byte[] der) throws IOException
der
- a DER byte array of a ContentInfo object.public SMIMESender(byte[] der, String provider) throws IOException
der
- a DER byte array of a ContentInfo object.provider
- the provider to be used with pkcs.public SMIMESender(ContentInfo contentInfo)
contentInfo
- ContentInfo objectpublic SMIMESender(ContentInfo contentInfo, String provider)
contentInfo
- ContentInfo objectprovider
- the provider to be used with pkcspublic SMIMESender(CertificationRequest certRequest)
contentInfo
- ContentInfo objectpublic SMIMESender(CertificationRequest certRequest, String provider)
contentInfo
- ContentInfo objectprovider
- the provider to be used with pkcspublic SMIMESender(SMIMEMessage message) throws IOException
SMIMEMessage
- SMIMEMessage objectpublic SMIMESender(SMIMEMessage message, String provider) throws IOException
SMIMEMessage
- SMIMEMessage objectprovider
- the provider to be usedMethod Detail |
public Object clone()
public boolean hasRecipientCertificate()
public void addRecipientCertificate(Certificate[] certs)
certs
- Certificate arraypublic void setRecipientCertificate(Certificate[] certs)
certs
- Certificate arraypublic void setCertificateOnly(Certificate[] certs) throws IOException, PKCSException
certs
- Certificate arraypublic void setContentInfo(ContentInfo contentInfo) throws PKCSException
contentInfo
- ContentInfo objectpublic ContentInfo getContentInfo()
public void setCertificationRequest(CertificationRequest certRequest) throws PKCSException
certRequest
- CertificationRequest objectpublic CertificationRequest getCertificationRequest()
public void setMailhost(String mailhost)
mailhost
- SMTP mail host addresspublic String getMailhost()
public void setMessageWithHeader(String message) throws PKCSException
To specify a different header, create the Data object independently and store it as a ContentInfo object on an uninitialized SMIMESender object.
message
- String to set as the message contents.public byte[] encrypt(int encryptionStrength) throws PKCSException, IOException, NoSuchAlgorithmException
This method requires that the recipient certificate(s) must have been previously set on this SMIMESender object.
encryptionStrength
- specified by SMIME.WEAK_ENCRYPTION,
SMIME.MEDIUM_ENCRYPTION, or SMIME.STRONG_ENCRYPTIONpublic byte[] encrypt(String encryptionAlgorithm, int keySize) throws PKCSException, IOException, NoSuchAlgorithmException
This method requires that the recipient certificate(s) must have been previously set on this SMIMESender object.
encryptionAlgorithm
- encryption algorithm StringkeySize
- length of the encryption keypublic byte[] sign(Certificate signerCert, String digestSignatureAlgorithm, PrivateKey privateKey) throws PKCSException, IOException, NoSuchAlgorithmException
signerCert
- certificate of the signerprivateKey
- private key of the certificatedigestSignatureAlgorithm
- signature algorithmpublic byte[] signSignatureOnly(Certificate signerCert, String digestSignatureAlgorithm, PrivateKey privateKey) throws PKCSException, IOException, NoSuchAlgorithmException
For the S/MIME message byte array returned by the signSignatureOnly method, use the mail method that accepts a byte array, otherwise the generated multipart message will not be mailed.
signerCert
- certificate of the signerprivateKey
- private key of the certificatedigestSignatureAlgorithm
- signature algorithmpublic byte[] getBase64Content() throws IOException
public String getSMIMEType()
public String getFileName()
public void mail(String senderAddress, String recipientAddress, String subject) throws PKCSException, IOException
For the S/MIME message byte array returned by the signSignatureOnly method, use the mail method that accepts a byte array, otherwise the generated multipart message will not be mailed.
The recipientAddress and recipient certificates for this object govern to whom this message is sent:
senderAddress
- e-mail address of the senderrecipientAddress
- e-mail address of the recipient.subject
- Subject of the messagepublic void mail(byte[] message, String senderAddress, String recipientAddress, String subject) throws PKCSException, IOException
The recipientAddress and recipient certificates for this object govern to whom this message is sent:
message
- Byte array of the messagesenderAddress
- e-mail address of the senderrecipientAddress
- e-mail address of the recipient.subject
- Subject of the messagepublic void writeMailToFile(String filename, String senderAddress, String recipientAddress, String subject) throws PKCSException, IOException
The recipientAddress and recipient certificates for this object govern to whom this message is sent:
If there are more than one recipientAddress e-mails, the method will append a "." + filenumber string to the end of the specified filename.
filename
- File name to which to writesenderAddress
- e-mail address of the senderrecipientAddress
- e-mail address of the recipient.subject
- Subject of the messagepublic void writeMailToFile(byte[] message, String filename, String senderAddress, String recipientAddress, String subject) throws PKCSException, IOException
The recipientAddress and recipient certificates for this object govern to whom this message is sent:
If there are more than one recipientAddress e-mails, the method will append a "." + filenumber string to the end of the specified filename.
message
- Byte array of the messagefilename
- File name to which to writesenderAddress
- e-mail address of the senderrecipientAddress
- e-mail address of the recipient.subject
- Subject of the messagepublic String toString()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |