|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.webdocwf.util.smime.smime.EnvelopedSMIME
EnvelopedSMIME class is used for creating and sending encrypted S/MIME
message.
Email message is in general composed of the content of the message and of one or
more attachments. The content is visible part of the message, and attacments are
mostly files or other binary data, which are not visible parts of message and
which are used by email as a transport medium. In this implementation content
can be represented in two different forms:
Constructor Summary | |
EnvelopedSMIME(java.lang.String smtpHost,
java.lang.String fromAddress,
java.lang.String subject)
Initializes the JavaMail session for SMTP and the MimeMessage for encryption. |
|
EnvelopedSMIME(java.lang.String smtpHost,
java.lang.String fromAddress,
java.lang.String subject,
java.lang.String content)
Initializes the JavaMail session for SMTP and the MimeMessage for encryption. |
Method Summary | |
void |
addAttachment(java.io.File file)
Adds file as attachment to email message |
void |
addAttachment(java.io.InputStream data,
java.lang.String fileName)
Adds data from InputStream as attachment to email message |
void |
addAttachment(java.lang.String fileName)
Adds file as attachment to email message |
void |
addRecipient(java.lang.String recipientAddress,
java.lang.String type,
java.lang.String cerFileName)
Adds recipient address, type and .cer file of email recipient to encrypted message. |
void |
enveloping()
Envelopes message with default algorithm RC2_CBC, 40 bits |
void |
enveloping(java.lang.String algorithmName,
int keyLength)
Envelopes message with given algorithm name and key length |
javax.mail.internet.MimeMessage |
getEnvelopedMessage()
Returns SMIME Message |
void |
send()
Sends S/MIME message to SMTP host |
void |
setContent(java.io.File inFile,
java.lang.String type)
Sets message content from file represented by File object. |
void |
setContent(java.io.InputStream content,
java.lang.String type)
Sets message content from InputStream. |
void |
setContent(java.io.InputStream content,
java.lang.String type,
java.lang.String path,
java.io.InputStream[] resources)
Sets message content from InputStream. |
void |
setContent(java.lang.String content,
java.lang.String type)
Sets message content from String. |
void |
setContent(java.lang.String content,
java.lang.String type,
java.lang.String path,
java.io.InputStream[] resources)
Sets message content. |
void |
setReply(java.lang.String replyAddress)
Sets REPLY TO field in message header |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public EnvelopedSMIME(java.lang.String smtpHost, java.lang.String fromAddress, java.lang.String subject, java.lang.String content) throws SMIMEException
smtpHost
- name of SMTP host used for sending emailfromAddress
- email address of sender (FROM field in email header)subject
- subject of email (SUBJECT field in email header)content
- text/plain content of email messageSMIMEException
- if smtpHost or fromAddress parameters are null.
Also, it can be caused by non SMIMEException which is MessagingException.public EnvelopedSMIME(java.lang.String smtpHost, java.lang.String fromAddress, java.lang.String subject) throws SMIMEException
smtpHost
- name of SMTP host used for sending emailfromAddress
- email address of sender (FROM field in email header)subject
- subject of email (SUBJECT field in email header)SMIMEException
- if smtpHost or fromAddress parameters are null.
Also, it can be caused by non SMIMEException which is MessagingException.Method Detail |
public void setContent(java.lang.String content, java.lang.String type, java.lang.String path, java.io.InputStream[] resources) throws SMIMEException
*****nnn<virtual_file_name>Five '*' characters (must be five) define that it is resource expected from the stream. Other three characters must be digits (000-999) and represent index of corresponding stream in stream array. virtual_file_name is name and extension assigned to data passed from stream. Name is used in construction of "name" parameter in Content-Type, while extension of file name is used in detection of appropriate mime-type. Lenght of virtual_file_name is not important. If there is no data referenced from byte array stream ,4th parameter of this method named "resources" can be null. Also, if all resources are passed through the array of streams, 3th parameter ("path") can be null. Location of resource is transformed to corresponding Content ID if no error has occured during the process of allocation.
content
- String representation of message content (text or html code).type
- type of given content. It can take values: "text/plain" or
"text/html".path
- common directory path for relative file locations in html code.
It can be null if all resources set absolute path or are defined by
byte array streams, or if sending resources with relative address it is not desired.
Also, it is set to null in case of text/plain message.resources
- way for representing resources used in the given html code
which will be added to message as array of InputStream. Detail use
of this argument is described above. It can be null if no resources as byte
array stream are used, or if sending resources given in that way is not desired.
Also, it is set to null in case of text/plain message.SMIMEException
- if content is tried to be added twice, or in case of
wrong "type" parameter. Also, it can be caused by non SMIMEException which can
be one of the following: MessagingException UnsoportedEncodingException.public void setContent(java.io.InputStream content, java.lang.String type, java.lang.String path, java.io.InputStream[] resources) throws SMIMEException
content
- message content data given from any InputStream.
Data can be text or html code and will be interpreted according to second
parameter: "type".type
- type of given content. It can take values: "text/plain" or
"text/html".path
- common directory path for relative file locations in html code.
It can be null if all resources in html code have set absolute path or are
defined by byte array streams, or if sending resources with relative address
is not desired. Also, it is set to null in case of text/plain message.resources
- way for representing resources used in the given html code
which will be added to message as array of InputStreams. Detail use
of this argument is described in other setContent methods mentioned before.
It can be null if no resources as byte array stream are used, or if sending
resources given in that way is not desired. Also, it is set to null in case
of text/plain message.SMIMEException
- if content is tried to be added twice , in case of
wrong "type" parameter or in case when parameter content is null. Also, it can
be caused by non SMIMEException which is MessagingException.public void setContent(java.io.InputStream content, java.lang.String type) throws SMIMEException
content
- message content data given from any InputStream.
Data could be text or html code and will be interpreted according to second
parameter: "type".type
- type of given content. It can take values: "text/plain" or
"text/html".SMIMEException
- if content is tried to be added twice , in case of
wrong "type" parameter or in case when parameter content is null. Also, it can
be caused by non SMIMEException which is MessagingException.public void setContent(java.lang.String content, java.lang.String type) throws SMIMEException
content
- message content data given as String which can
be text or html code and will be interpreted according to second parameter:
"type".type
- type of given content. It can take values: "text/plain" or
"text/html".SMIMEException
- if content is tried to be added twice, or in case of
wrong "type" parameter. Also, it can be caused by non SMIMEException which can
be one of the following: MessagingException UnsoportedEncodingException.public void setContent(java.io.File inFile, java.lang.String type) throws SMIMEException
inFile
- location of file which is used for content of the messagetype
- type of given content. It can take values: "text/plain" or
"text/html".SMIMEException
- if content is tried to be added twice, in case of
wrong "type" parameter, or if passed file (as File object) does not exist in
file sistem. Also, it can be caused by non SMIMEException which can be one of
the following: MessagingException or IOException.public void setReply(java.lang.String replyAddress) throws SMIMEException
replyAddress
- email address used to replySMIMEException
- caused by non SMIMEException which is
MessagingException. Also, javax.mail.internet.AddressException is thrown
from instances of InternetAddress class (but AddressException extends
MessagingException).public void addRecipient(java.lang.String recipientAddress, java.lang.String type, java.lang.String cerFileName) throws SMIMEException
recipientAddress
- email address of recipent (fields TO or CC or BCC
in email message header)type
- should be TO, CC or BCCcerFileName
- path and file name with certificate corresponding
to recipient (file with .cer extension)SMIMEException
- if type of addressing of messages is not TO, CC
or BCC.SMIMEException
- caused by non SMIMEException which is
MessagingException.public void addAttachment(java.lang.String fileName) throws SMIMEException
fileName
- path and file name used for attachmentSMIMEException
- if passed file (as File object) does not exist in
file sistem. Also, it can be caused by non SMIMEException which is
MessagingExceptionpublic void addAttachment(java.io.File file) throws SMIMEException
file
- used for attachment represented as File objectSMIMEException
- if passed file (as File object) does not exist in
file sistem. Also, it can be caused by non SMIMEException which is
MessagingExceptionpublic void addAttachment(java.io.InputStream data, java.lang.String fileName) throws SMIMEException
data
- byte array from InputStreamfileName
- virtual or real file name (wihouth path). Correct information
about name; extension of file name is especially important. Name
is used in construction of "name" parameter in Content-Type header line of
body parts of mime message. Extension of file is used in detection of
appropriate mime-type.SMIMEException
- caused by non SMIMEException which is
MessagingExceptionpublic void enveloping() throws SMIMEException
SMIMEException
- if one of recipients is not declared as TO
recipient, or if there is no message for enveloping. Also, it can be caused
by non SMIMEException which can be one of the following: CertificateException,
IOException, MessagingException or FileNotFoundException.public void enveloping(java.lang.String algorithmName, int keyLength) throws SMIMEException
algorithmName
- name of chosen algorithm used for encryptionkeyLength
- key size in bitsSMIMEException
- if one of recipients is not declared as TO
recipient, or if there is no message for enveloping. Also, it can be caused
by non SMIMEException which can be one of the following: CertificateException,
IOException, MessagingException or FileNotFoundException.public javax.mail.internet.MimeMessage getEnvelopedMessage()
public void send() throws javax.mail.MessagingException
javax.mail.MessagingException
- caused by use of methods from objects of class
Transport.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |