Enhydra-Oyster 2.1-7 API

org.enhydra.oyster.mail
Class PureMIME

java.lang.Object
  extended byorg.enhydra.oyster.smime.BaseSMIMEObject
      extended byorg.enhydra.oyster.mail.PureMIME
All Implemented Interfaces:
KeyStoreConstants

public class PureMIME
extends BaseSMIMEObject

PureMIME class is used for creating and sending pure (clear) MIME message (withouth any cryptographic posibilities). Initialization, creating and sending of pure (clear) MIME message has the same functionalities as S/MIME type of message.


Field Summary
 
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.KeyStoreConstants
BKS, JKS, PKCS12, UBER
 
Constructor Summary
PureMIME(javax.mail.internet.MimeMessage mimeMessage)
          Construction of message with external prepared MimeMessage object.
PureMIME(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.
PureMIME(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)
          Adds recipient email address and type.
 void composeMessage()
          Creates and composes the message.
 
Methods inherited from class org.enhydra.oyster.smime.BaseSMIMEObject
addAttachment, addAttachment, addAttachment, addAttachment, addAttachment, addAttachment, addRecipient, addRecipient, addRecipient, getMimeMessage, initMimeMessage, reset, 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

PureMIME

public PureMIME(java.lang.String smtpHost,
                java.lang.String fromAddress,
                java.lang.String subject,
                java.lang.String content,
                java.lang.String charset)
         throws SMIMEException
Initializes the JavaMail session for SMTP and the MimeMessage object for message which will be sent. Dynamically loads the BC and SUN provider necessary for cryptography processing. This constructor is used for creating message with text/plain content. For creating html formated content (text/html), other constructor should be used in combination with one of setContent methods. Note that after using this constructor setContent method can be used only if "content" argument of constructor was given as null, otherwise setContent method can't be used because content is already set as text/plain.

Parameters:
smtpHost - name of SMTP host used for sending email
fromAddress - 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 called
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.
Throws:
SMIMEException - if smtpHost or fromAddress parameters are null. Also, it can be caused by non SMIMEException which is MessagingException.

PureMIME

public PureMIME(java.lang.String smtpHost,
                java.lang.String fromAddress,
                java.lang.String subject,
                java.lang.String charset)
         throws SMIMEException
Initializes the JavaMail session for SMTP and the MimeMessage object for message which will be sent. Dynamically loads the BC and SUN provider necessary for cryptography processing. This constructor does not create content of message and it can be set later with one of setContent methods. Also, message can be left withouth content, but then at least one attachement must be added.

Parameters:
smtpHost - name of SMTP host used for sending email
fromAddress - 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.
Throws:
SMIMEException - if smtpHost or fromAddress parameters are null. Also, it can be caused by non SMIMEException which is MessagingException.

PureMIME

public PureMIME(javax.mail.internet.MimeMessage mimeMessage)
         throws SMIMEException
Construction of message with external prepared MimeMessage object. Usage of this constructor disables usage of setContent() and addAttachment() methods. Also, all recipients (TO, CC or BCC type) must be declared again via setRecipient() method, even if they were previously set. Be very carefull with usage of this constructor because all MimeBodyPart objects and MimeMultipart objects used in construction of given MimeMessage object, must have correct defined Content header arguments, and contents. Contents must be formed in format which can be recognised and appropriate interpreted in the process of sending mail. If there is any special content object added to MimeBodyPart object or MimeMultipart object, the appropriate DataContent handler must be created for that object and set to corresponding BodyPart.

Parameters:
mimeMessage - external created MimeMessage object
Throws:
SMIMEException - if smtpHost or fromAddress parameter is null. Also, it can be caused by non SMIMEException which is MessagingException.
Method Detail

addRecipient

public void addRecipient(java.lang.String recipientAddress,
                         java.lang.String type)
                  throws SMIMEException
Adds recipient email address and type. At least one recipient must be declared as TO type.

Parameters:
recipientAddress - email address of recipent (fields TO or CC or BCC in email message header)
type - should be TO, CC or BCC.
Throws:
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.

composeMessage

public void composeMessage()
                    throws SMIMEException
Creates and composes the message.

Throws:
SMIMEException - if one of recipients is not declared as TO recipient. Also, it can be caused by non SMIMEException which can be one of the following: MessagingException, or IOException.

Enhydra-Oyster 2.1-7 API