|
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
org.enhydra.oyster.smime.BaseSignedSMIMEObject
org.enhydra.oyster.smime.SignedAndEnvelopedSMIME
SignedAndEnvelopedSMIME class is used for creating and sending signed and
encrypted, or encrypted and signed S/MIME messages. Which process will be
first (encrypting or signing) is defined in the method signingAndEnveloping
by using appropriate parameter: SIGN_FIRST or ENCRYPT_FIRST.
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:
Field Summary |
Fields inherited from class org.enhydra.oyster.smime.BaseSignedSMIMEObject |
aditionalCerts, capabilities, capabilities2, capabilitiesTemp, certChainArray, digestArray, digestArray2, including, including2, ksArray, privKeyArray |
Fields inherited from class org.enhydra.oyster.smime.BaseSMIMEObject |
bodyPartArray, certArray, charsetEnc, contentPresence, externalMessagePresence, indicatorTo, message |
Fields inherited from interface org.enhydra.oyster.crypto.consts.EnvelopedConstants |
DES, DES_EDE3_CBC, RC2_CBC |
Fields inherited from interface org.enhydra.oyster.crypto.consts.KeyStoreConstants |
BKS, JKS, PKCS12, UBER |
Fields inherited from interface org.enhydra.oyster.crypto.consts.SignedConstants |
MD2_WITH_RSA, MD5_WITH_RSA, SHA1_WITH_DSA, SHA1_WITH_RSA |
Constructor Summary | |
protected |
SignedAndEnvelopedSMIME()
Simple constructor. |
|
SignedAndEnvelopedSMIME(javax.mail.internet.MimeMessage mimeMessage)
Construction of message with external prepared MimeMessage object. |
|
SignedAndEnvelopedSMIME(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. |
|
SignedAndEnvelopedSMIME(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 |
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. |
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 signed and encrypted message. |
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 |
getSignedAndEnvelopedSMimeMessage()
Deprecated. |
void |
signingAndEnveloping(java.lang.String type)
Signes and envelopes message with default algorithm RC2, 40 bits. |
void |
signingAndEnveloping(java.lang.String algorithmName,
int keyLength,
java.lang.String type)
Signes and envelopes message with given algorithm name and key length. |
Methods inherited from class org.enhydra.oyster.smime.BaseSignedSMIMEObject |
addCertificate, addSigner, addSigner, addSigner, addSigner, reset, setCapabilities |
Methods inherited from class org.enhydra.oyster.smime.BaseSMIMEObject |
addAttachment, addAttachment, addAttachment, addAttachment, addAttachment, addAttachment, getMimeMessage, initMimeMessage, send, setCharsetEncoding, setContent, setContent, setContent, setContent, setContent, setContent, setContent, setContent, setContent, setContent, setReply |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
protected SignedAndEnvelopedSMIME()
public SignedAndEnvelopedSMIME(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.public SignedAndEnvelopedSMIME(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.public SignedAndEnvelopedSMIME(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 addRecipient(java.lang.String recipientAddress, java.lang.String type, java.lang.String cerFileName) throws SMIMEException
addRecipient
in class BaseSMIMEObject
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 the messages is not TO, CC,
or BCC. Also it can be caused by non SMIMEException which is MessagingException.public void addRecipient(java.lang.String recipientAddress, java.lang.String type, java.security.KeyStore kStore, java.lang.String alias) throws SMIMEException
addRecipient
in class BaseSMIMEObject
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.public 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
addRecipient
in class BaseSMIMEObject
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 signingAndEnveloping(java.lang.String type) throws SMIMEException
type
- defines which action will be performed first (signing or
enveloping). Allowed parameters are: SIGN_FIRST (signing first and then
enveloping), and ENCRYPT_FIRST (enveloping first and then signing).
SMIMEException
- if one of recipients is not declared as TO
recipient, if there is no message for enveloping, or if parameter "type"
for message protection order in not SIGN_FIRST or ENCRYPT_FIRST. Also, it
can be caused by non SMIMEException which can be one of the following:
CertificateException, IOException, MessagingException, or FileNotFoundException.public void signingAndEnveloping(java.lang.String algorithmName, int keyLength, java.lang.String type) throws SMIMEException
algorithmName
- name of chosen algorithm used for encryptionkeyLength
- key size in bitstype
- defines which action will be performed first (signing or
enveloping). Allowed parameters are: SIGN_FIRST (signing first and then
enveloping), and ENCRYPT_FIRST (enveloping first and then signing).
SMIMEException
- if one of recipients is not declared as TO
recipient, if there is no message for enveloping or if parameter "type"
for message protection order in not SIGN_FIRST or ENCRYPT_FIRST. 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 getSignedAndEnvelopedSMimeMessage()
|
Enhydra-Oyster 2.1-7 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |