|
Enhydra-Oyster 2.1-7 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.enhydra.oyster.smime.BaseSMIMEObject
This class is used as super class for all four email types with SMIME cryptography capabilities (Enveloped, Signed Signed and Enveloped and Enveloped and Signed). It contains the common methods for all this types. Also, this class is used as a super class for class PureMIME which can be used in creation and sending of pure MIME messages withouth cryptography posibilities.
Field Summary | |
protected java.util.Vector |
bodyPartArray
Storage for MIME bodyparts |
protected java.util.Vector |
certArray
Storage for .cer files coresponding to appropriate enveloping session |
protected java.lang.String |
charsetEnc
Character set definition. |
protected boolean |
contentPresence
Indicator of the email message content part presence (it can be plain text or html content). |
protected boolean |
externalMessagePresence
Indicator of the external MimeMessage object presence. |
protected boolean |
indicatorTo
Indication that at least one recipient must be TO (others may be CC or BCC) |
protected javax.mail.internet.MimeMessage |
message
Container for MIME message |
Fields inherited from interface org.enhydra.oyster.crypto.consts.KeyStoreConstants |
BKS, JKS, PKCS12, UBER |
Constructor Summary | |
protected |
BaseSMIMEObject()
Simple constructor. |
protected |
BaseSMIMEObject(javax.mail.internet.MimeMessage mimeMessage)
Construction of message with external prepared MimeMessage object. |
protected |
BaseSMIMEObject(java.lang.String smtpHost,
java.lang.String fromAddress,
java.lang.String subject,
java.lang.String charset)
Initializes the JavaMail session for SMTP and the MimeMessage object for message which will be sent. |
protected |
BaseSMIMEObject(java.lang.String smtpHost,
java.lang.String fromAddress,
java.lang.String subject,
java.lang.String content,
java.lang.String charset)
Initializes the JavaMail session for SMTP and the MimeMessage object for message which will be sent. |
Method Summary | |
void |
addAttachment(java.io.File file)
Adds file as attachment to email message. |
void |
addAttachment(java.io.File file,
java.lang.String encoding)
Adds file as attachment to email message with given value for prefered Content-Transfer-Encoding argument. |
void |
addAttachment(java.io.InputStream data,
java.lang.String fileName)
Adds data from InputStream as attachment to email message. |
void |
addAttachment(java.io.InputStream data,
java.lang.String fileName,
java.lang.String encoding)
Adds data from InputStream as attachment to email message with given value for prefered Content-Transfer-Encoding argument. |
void |
addAttachment(java.lang.String fileName)
Adds file as attachment to email message. |
void |
addAttachment(java.lang.String fileName,
java.lang.String encoding)
Adds file as attachment to email message with given value for prefered Content-Transfer-Encoding argument. |
protected void |
addRecipient(java.lang.String recipientAddress,
java.lang.String type,
java.security.KeyStore kStore,
java.lang.String alias)
Adds recipient address, type and recipient's certificate via KeyStore object and apropriate alias. |
protected 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. |
protected void |
addRecipient(java.lang.String recipientAddress,
java.lang.String type,
java.lang.String ksPath,
java.lang.String ksType,
java.lang.String password,
java.lang.String alias)
Adds recipient address, type and recipient's certificate via path to the KeyStore file, KeyStore type, password and apropriate alias. |
javax.mail.internet.MimeMessage |
getMimeMessage()
Returns MimeMessage. |
void |
initMimeMessage(java.lang.String smtpHost,
java.lang.String fromAddress,
java.lang.String subject,
java.lang.String content,
java.lang.String charset)
Initializes the JavaMail session for SMTP and the MimeMessage object for message which will be sent. |
void |
reset()
Resets all attributes in BaseSMIMEObject to their initial values. |
void |
send()
Sends S/MIME message to SMTP host. |
void |
setCharsetEncoding(java.lang.String charset)
Sets the character set encoding. |
void |
setContent(java.io.File inFile,
java.lang.String type)
Sets message content from file represented by File object. |
void |
setContent(java.io.File inFile,
java.lang.String type,
java.lang.String externalPlainText)
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 externalPlainText)
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.io.InputStream content,
java.lang.String type,
java.lang.String path,
java.io.InputStream[] resources,
java.lang.String externalPlainText)
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 externalPlainText)
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 from String. |
void |
setContent(java.lang.String content,
java.lang.String type,
java.lang.String path,
java.io.InputStream[] resources,
java.lang.String externalPlainText)
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 |
Field Detail |
protected javax.mail.internet.MimeMessage message
protected boolean contentPresence
protected boolean externalMessagePresence
protected java.util.Vector bodyPartArray
protected java.util.Vector certArray
protected boolean indicatorTo
protected java.lang.String charsetEnc
Constructor Detail |
protected BaseSMIMEObject()
protected BaseSMIMEObject(java.lang.String smtpHost, java.lang.String fromAddress, java.lang.String subject, java.lang.String content, java.lang.String charset) 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). This
argument can be null, but email message will be sent withouth SUBJECT.content
- text/plain content of email message. This argument can be
null, but later one of setContent() methods or one of addAttachment()
methods should be calledcharset
- character set for passed subject and content. The given
Unicode string will be charset-encoded using the specified charset. The
charset is also used to set the "charset" parameter. For example German
letters should be encoded by usage of 'ISO-8859-1' charset. If charset
parameter is null and subject or content contains non US-ASCII characters,
it will be encoded using the platform's default charset.
SMIMEException
- if smtpHost or fromAddress parameters are null.
Also, it can be caused by non SMIMEException which is MessagingException.protected BaseSMIMEObject(java.lang.String smtpHost, java.lang.String fromAddress, java.lang.String subject, java.lang.String charset) 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). This
argument can be null, but email message will be sent withouth SUBJECT.charset
- character set for passed subject and content. The given
Unicode string will be charset-encoded using the specified charset. The
charset is also used to set the "charset" parameter. For example German
letters should be encoded by usage of 'ISO-8859-1' charset. If charset
parameter is null and subject or content contains non US-ASCII characters,
it will be encoded using the platform's default charset.
SMIMEException
- if smtpHost or fromAddress parameters are null.
Also, it can be caused by non SMIMEException which is MessagingException.protected BaseSMIMEObject(javax.mail.internet.MimeMessage mimeMessage) throws SMIMEException
mimeMessage
- external created MimeMessage object
SMIMEException
- if smtpHost or fromAddress parameter is null.
Also, it can be caused by non SMIMEException which is MessagingException.Method Detail |
public void initMimeMessage(java.lang.String smtpHost, java.lang.String fromAddress, java.lang.String subject, java.lang.String content, java.lang.String charset) 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). This
argument can be null, but email message will be sent withouth SUBJECT.content
- text/plain content of email messagecharset
- character set for passed subject and content. The given
Unicode string will be charset-encoded using the specified charset. The
charset is also used to set the "charset" parameter. For example German
letters should be encoded by usage of 'ISO-8859-1' charset. If 'charset'
argument is null and subject or content contains non US-ASCII characters,
it will be encoded using the platform's default charset.
SMIMEException
- if smtpHost or fromAddress parameters are null.
Also, it can be caused by non SMIMEException which is MessagingException.public void setCharsetEncoding(java.lang.String charset)
charset
- characterset encoding definition which will be used in
process of string to byte array (and vice versa) transformation. The
'charset' argument is also used to set the 'charset' parameter in message
or body header. For example German letters should be encoded by usage of
'ISO-8859-1' charset. If 'charset' argument is null and String contains non
US-ASCII characters it will be encoded using the platform's default charset.public void setContent(java.lang.String content, java.lang.String type, java.lang.String path, java.io.InputStream[] resources, java.lang.String externalPlainText) 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).
This argument is mandatory.type
- type of given content. It can take values: "text/plain" or
"text/html". This argument is mandatory.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.externalPlainText
- external text/plain message represented as String.
This argument is used as alternative message to given html message in the process
of generation multipart/alternative MimeMultipart message. If this argument
has value null then autogeneration of text/plain message is performed
according to passed html code (content argument). 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.lang.String content, java.lang.String type, java.lang.String path, java.io.InputStream[] resources) throws SMIMEException
content
- String representation of message content (text or html code).
This argument is mandatory.type
- type of given content. It can take values: "text/plain" or
"text/html". This argument is mandatory.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, java.lang.String externalPlainText) 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". This argument is mandatory.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.externalPlainText
- external text/plain message represented as String.
This argument is used as alternative message to given html message in the process
of generation multipart/alternative MimeMultipart message. If this argument
has value null then autogeneration of text/plain message is performed
according to passed html code (content argument). 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, 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". This argument is mandatory.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, java.lang.String externalPlainText) 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". This argument is mandatory.type
- type of given content. It can take values: "text/plain" or
"text/html". This argument is mandatory.externalPlainText
- external text/plain message represented as String.
This argument is used as alternative message to given html message in the process
of generation multipart/alternative MimeMultipart message. If this argument
has value null then autogeneration of text/plain message is performed
according to passed html code (content argument). 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". This argument is mandatory.type
- type of given content. It can take values: "text/plain" or
"text/html". This argument is mandatory.
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, java.lang.String externalPlainText) 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". This argument is mandatory.type
- type of given content. It can take values: "text/plain" or
"text/html". This argument is mandatory.externalPlainText
- external text/plain message represented as String.
This argument is used as alternative message to given html message in the process
of generation multipart/alternative MimeMultipart message. If this argument
has value null then autogeneration of text/plain message is performed
according to passed html code (content argument). 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.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". This argument is mandatory.type
- type of given content. It can take values: "text/plain" or
"text/html". This argument is mandatory.
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.File inFile, java.lang.String type, java.lang.String externalPlainText) throws SMIMEException
inFile
- location of file which is used for content of the message.
This argument is mandatory.type
- type of given content. It can take values: "text/plain" or
"text/html". This argument is mandatory.externalPlainText
- external text/plain message represented as String.
This argument is used as alternative message to given html message in the process
of generation multipart/alternative MimeMultipart message. If this argument
has value null then autogeneration of text/plain message is performed
according to passed html code (content argument). 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 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 setContent(java.io.File inFile, java.lang.String type) throws SMIMEException
inFile
- location of file which is used for content of the message.
This argument is mandatory.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 addAttachment(java.lang.String fileName) throws SMIMEException
fileName
- path and file name used for attachment
SMIMEException
- if passed file (as File object) does not exist in
the file sistem. Also, it can be caused by non SMIMEException which is
MessagingExceptionpublic void addAttachment(java.lang.String fileName, java.lang.String encoding) throws SMIMEException
fileName
- path and file name used for attachmentencoding
- Content-Transfer-Encoding value. It can take values: 7bit,
quoted-printable, and base64
SMIMEException
- if passed file (as File object) does not exist in
the 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 object
SMIMEException
- if passed file (as File object) does not exist in
the file sistem. Also, it can be caused by non SMIMEException which is
MessagingException or IOExceptionpublic void addAttachment(java.io.File file, java.lang.String encoding) throws SMIMEException
file
- path and file name used for attachmentencoding
- Content-Transfer-Encoding value. It can take values: 7bit,
quoted-printable, and base64
SMIMEException
- if passed file (as File object) does not exist in
the 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 the
appropriate mime-type.
SMIMEException
- caused by non SMIMEException which is
MessagingExceptionpublic void addAttachment(java.io.InputStream data, java.lang.String fileName, java.lang.String encoding) throws SMIMEException
fileName
- path and file name used for attachmentencoding
- Content-Transfer-Encoding value. It can take values: 7bit,
quoted-printable, and base64
SMIMEException
- if passed file (as File object) does not exist in
the file sistem. Also, it can be caused by non SMIMEException which is
MessagingExceptionprotected 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. Also, it can be caused by non SMIMEException which can be one of
the following: IOException, MessagingException, FileNotFoundException,
NoSuchProviderException, CertificateException.protected void addRecipient(java.lang.String recipientAddress, java.lang.String type, java.security.KeyStore kStore, java.lang.String alias) throws SMIMEException
recipientAddress
- email address of recipent (fields TO or CC or BCC
in email message header)type
- should be TO, CC or BCCkStore
- instance of KeyStore class which represents an in-memory
collection of keys and certificates.alias
- alias name which corresponds to desired certificate. If alias
is given as null, then reading results are unpredictable.
SMIMEException
- if type of addressing of messages is not TO, CC
or BCC. Also, it can be caused by non SMIMEException which can be one of
the following: IOException, MessagingException, FileNotFoundException,
NoSuchProviderException, CertificateException.protected void addRecipient(java.lang.String recipientAddress, java.lang.String type, java.lang.String ksPath, java.lang.String ksType, java.lang.String password, java.lang.String alias) throws SMIMEException
recipientAddress
- email address of recipent (fields TO or CC or BCC
in email message header)type
- should be TO, CC or BCCksPath
- is path to the file representation of KeyStore which holds
collection of keys and certificates. This file can be PKCS12 type (file
with .p12 or .pfx extension) or can be key store of other types readable
by 'BouncyCastle' or 'Sun' KeyStore implementation.ksType
- is type of KeyStore. It can be one of the following types:
JKS for 'Sun' KeyStore, 'BKS', 'PKCS12' or 'UBER') for 'BouncyCastle'
KeyStore. If ksType is given as null it will be assumed that .cer file is
in use, and alias parameter will be ignored, so this method becomes
equivalent to addRecipient() method which deal only with .cer files.password
- password used to access the corresponding private key,
stored in given KeyStore file.alias
- alias name which corresponds to desired private key. If alias
is given as null, then reading results are unpredictable.
to recipient (file with .cer extension)
SMIMEException
- if type of addressing of messages is not TO, CC
or BCC. Also, it can be caused by non SMIMEException which can be one of
the following: IOException, MessagingException, FileNotFoundException,
NoSuchProviderException, CertificateException.public void setReply(java.lang.String replyAddress) throws SMIMEException
replyAddress
- email address used in reply
SMIMEException
- caused by non SMIMEException which is
MessagingException. Also, javax.mail.internet.AddressException is thrown
from instances of InternetAddress class (but AddressException extends
MessagingException).public javax.mail.internet.MimeMessage getMimeMessage()
public void reset()
public void send() throws javax.mail.MessagingException
javax.mail.MessagingException
- caused by use of methods from objects of class
Transport.
|
Enhydra-Oyster 2.1-7 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |