Java Doc for BaseSMIMEObject.java in  » Web-Mail » oyster » org » enhydra » oyster » smime » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Mail » oyster » org.enhydra.oyster.smime 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.enhydra.oyster.smime.BaseSMIMEObject

All known Subclasses:   org.enhydra.oyster.smime.BaseSignedSMIMEObject,  org.enhydra.oyster.mail.PureMIME,  org.enhydra.oyster.smime.EnvelopedSMIME,
BaseSMIMEObject
public class BaseSMIMEObject implements KeyStoreConstants(Code)
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  VectorbodyPartArray
    
protected  VectorcertArray
    
protected  StringcharsetEnc
     Character set definition.
protected  booleancontentPresence
     Indicator of the email message content part presence (it can be plain text or html content).
protected  booleanexternalMessagePresence
     Indicator of the external MimeMessage object presence.
protected  booleanindicatorTo
    
protected  MimeMessagemessage
    

Constructor Summary
protected  BaseSMIMEObject()
     Simple constructor.
protected  BaseSMIMEObject(String smtpHost, String fromAddress, String subject, String content, String charset)
     Initializes the JavaMail session for SMTP and the MimeMessage object for message which will be sent.
protected  BaseSMIMEObject(String smtpHost, String fromAddress, String subject, String charset)
     Initializes the JavaMail session for SMTP and the MimeMessage object for message which will be sent.
protected  BaseSMIMEObject(MimeMessage mimeMessage)
     Construction of message with external prepared MimeMessage object.

Method Summary
public  voidaddAttachment(String fileName)
     Adds file as attachment to email message.
public  voidaddAttachment(String fileName, String encoding)
     Adds file as attachment to email message with given value for prefered Content-Transfer-Encoding argument.
public  voidaddAttachment(File file)
     Adds file as attachment to email message.
public  voidaddAttachment(File file, String encoding)
     Adds file as attachment to email message with given value for prefered Content-Transfer-Encoding argument.
public  voidaddAttachment(InputStream data, String fileName)
     Adds data from InputStream as attachment to email message.
public  voidaddAttachment(InputStream data, String fileName, String encoding)
     Adds data from InputStream as attachment to email message with given value for prefered Content-Transfer-Encoding argument.
protected  voidaddRecipient(String recipientAddress, String type, String cerFileName)
     Adds recipient address, type and .cer file of email recipient to encrypted message.
protected  voidaddRecipient(String recipientAddress, String type, KeyStore kStore, String alias)
     Adds recipient address, type and recipient's certificate via KeyStore object and apropriate alias.
protected  voidaddRecipient(String recipientAddress, String type, String ksPath, String ksType, String password, String alias)
     Adds recipient address, type and recipient's certificate via path to the KeyStore file, KeyStore type, password and apropriate alias.
public  MimeMessagegetMimeMessage()
     Returns MimeMessage.
public  voidinitMimeMessage(String smtpHost, String fromAddress, String subject, String content, String charset)
     Initializes the JavaMail session for SMTP and the MimeMessage object for message which will be sent.
public  voidreset()
     Resets all attributes in BaseSMIMEObject to their initial values.
public  voidsend()
     Sends S/MIME message to SMTP host.
public  voidsetCharsetEncoding(String charset)
     Sets the character set encoding.
public  voidsetContent(String content, String type, String path, InputStream[] resources, String externalPlainText)
     Sets message content.
public  voidsetContent(String content, String type, String path, InputStream[] resources)
     Sets message content from String.
public  voidsetContent(InputStream content, String type, String path, InputStream[] resources, String externalPlainText)
     Sets message content from InputStream.
public  voidsetContent(InputStream content, String type, String path, InputStream[] resources)
     Sets message content from InputStream.
public  voidsetContent(InputStream content, String type, String externalPlainText)
     Sets message content from InputStream.
public  voidsetContent(InputStream content, String type)
     Sets message content from InputStream.
public  voidsetContent(String content, String type, String externalPlainText)
     Sets message content from String.
public  voidsetContent(String content, String type)
     Sets message content from String.
public  voidsetContent(File inFile, String type, String externalPlainText)
     Sets message content from file represented by File object.
public  voidsetContent(File inFile, String type)
     Sets message content from file represented by File object.
public  voidsetReply(String replyAddress)
     Sets REPLY TO field in message header.
Parameters:
  replyAddress - email address used in reply
exception:
  SMIMEException - caused by non SMIMEException which isMessagingException.

Field Detail
bodyPartArray
protected Vector bodyPartArray(Code)
Storage for MIME bodyparts



certArray
protected Vector certArray(Code)
Storage for .cer files coresponding to appropriate enveloping session



charsetEnc
protected String charsetEnc(Code)
Character set definition. The given Unicode strings will be charset-encoded by using theis attribute. 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. For more information about character sets refer to 'Character Encodings' chapter of package java.lang Java documentation page, or to RFC2278.



contentPresence
protected boolean contentPresence(Code)
Indicator of the email message content part presence (it can be plain text or html content). Other part of message contains attachements.



externalMessagePresence
protected boolean externalMessagePresence(Code)
Indicator of the external MimeMessage object presence. This parameter is true when constructor with MimeMessage object is used.



indicatorTo
protected boolean indicatorTo(Code)
Indication that at least one recipient must be TO (others may be CC or BCC)



message
protected MimeMessage message(Code)
Container for MIME message




Constructor Detail
BaseSMIMEObject
protected BaseSMIMEObject()(Code)
Simple constructor. Dynamically loads the BC and SUN provider necessary for cryptography processing. This constructor does not create MIME message object, so it is obligatory to invoke initMimeMessage() method after this constructor.



BaseSMIMEObject
protected BaseSMIMEObject(String smtpHost, String fromAddress, String subject, String content, String charset) throws SMIMEException(Code)
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
Parameters:
  fromAddress - email address of sender (FROM field in email header)
Parameters:
  subject - subject of email (SUBJECT field in email header). Thisargument can be null, but email message will be sent withouth SUBJECT.
Parameters:
  content - text/plain content of email message. This argument can benull, but later one of setContent() methods or one of addAttachment()methods should be called
Parameters:
  charset - character set for passed subject and content. The givenUnicode string will be charset-encoded using the specified charset. Thecharset is also used to set the "charset" parameter. For example Germanletters should be encoded by usage of 'ISO-8859-1' charset. If charsetparameter is null and subject or content contains non US-ASCII characters,it will be encoded using the platform's default charset.
exception:
  SMIMEException - if smtpHost or fromAddress parameters are null.Also, it can be caused by non SMIMEException which is MessagingException.



BaseSMIMEObject
protected BaseSMIMEObject(String smtpHost, String fromAddress, String subject, String charset) throws SMIMEException(Code)
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
Parameters:
  fromAddress - email address of sender (FROM field in email header)
Parameters:
  subject - subject of email (SUBJECT field in email header). Thisargument can be null, but email message will be sent withouth SUBJECT.
Parameters:
  charset - character set for passed subject and content. The givenUnicode string will be charset-encoded using the specified charset. Thecharset is also used to set the "charset" parameter. For example Germanletters should be encoded by usage of 'ISO-8859-1' charset. If charsetparameter is null and subject or content contains non US-ASCII characters,it will be encoded using the platform's default charset.
exception:
  SMIMEException - if smtpHost or fromAddress parameters are null.Also, it can be caused by non SMIMEException which is MessagingException.



BaseSMIMEObject
protected BaseSMIMEObject(MimeMessage mimeMessage) throws SMIMEException(Code)
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
exception:
  SMIMEException - if smtpHost or fromAddress parameter is null.Also, it can be caused by non SMIMEException which is MessagingException.




Method Detail
addAttachment
public void addAttachment(String fileName) throws SMIMEException(Code)
Adds file as attachment to email message. Content-Type will be automatically detected. Note that for linux files, if they are recognised as files with text/... MIME Content-Type, line breaks (LF) will be transformed to Windows line breaks (CRLF). Same transformation will be performed to single Carriage Return (CR) character. If linux textual file should be transported via email untouched, the best solution is to force usage of BASE64 encoding with other addAttachment() method.
Parameters:
  fileName - path and file name used for attachment
exception:
  SMIMEException - if passed file (as File object) does not exist inthe file sistem. Also, it can be caused by non SMIMEException which isMessagingException



addAttachment
public void addAttachment(String fileName, String encoding) throws SMIMEException(Code)
Adds file as attachment to email message with given value for prefered Content-Transfer-Encoding argument. Attachment will be encoded acording to this parameter. Be carful with usage of this method, because you must know nature and content of file well, to avoid errors in encoding. Since this method does not employ automatic detection of Content-Transfer-Encoding, it is sligtly faster. Note that for linux textual files, if they are encoded as quoted-printable, line breaks (LF) will be transformed to Windows line breaks (CRLF). Same transformation will be performed to single Carriage Return (CR) character. If linux textual file should be transported via email untouched, the best solution is to force usage of BASE64 encoding.
Parameters:
  fileName - path and file name used for attachment
Parameters:
  encoding - Content-Transfer-Encoding value. It can take values: 7bit,quoted-printable, and base64
exception:
  SMIMEException - if passed file (as File object) does not exist inthe file sistem. Also, it can be caused by non SMIMEException which isMessagingException



addAttachment
public void addAttachment(File file) throws SMIMEException(Code)
Adds file as attachment to email message. Content-Type will be automatically detected. Note that for linux files, if they are recognised as files with text/... MIME Content-Type, line breaks (LF) will be transformed to Windows line breaks (CRLF). Same transformation will be performed to single Carriage Return (CR) character. If linux textual file should be transported via email untouched, the best solution is to force usage of BASE64 encoding with other addAttachment() method.
Parameters:
  file - used for attachment represented as File object
exception:
  SMIMEException - if passed file (as File object) does not exist inthe file sistem. Also, it can be caused by non SMIMEException which isMessagingException or IOException



addAttachment
public void addAttachment(File file, String encoding) throws SMIMEException(Code)
Adds file as attachment to email message with given value for prefered Content-Transfer-Encoding argument. Attachment will be encoded acording to this parameter. Be carful with usage of this method, because you must know nature and content of file well, to avoid errors in encoding. Since this method does not employ automatic detection of Content-Transfer-Encoding, it is sligtly faster. Note that for linux textual files, if they are encoded as quoted-printable, line breaks (LF) will be transformed to Windows line breaks (CRLF). Same transformation will be performed to single Carriage Return (CR) character. If linux textual file should be transported via email untouched, the best solution is to force usage of BASE64 encoding.
Parameters:
  file - path and file name used for attachment
Parameters:
  encoding - Content-Transfer-Encoding value. It can take values: 7bit,quoted-printable, and base64
exception:
  SMIMEException - if passed file (as File object) does not exist inthe file sistem. Also, it can be caused by non SMIMEException which isMessagingException



addAttachment
public void addAttachment(InputStream data, String fileName) throws SMIMEException(Code)
Adds data from InputStream as attachment to email message. Content-Type will be automaticaly detected. Note that for linux files (virtual or real), if they are recognised as files with text/... MIME Content-Type, line breaks (LF) will be transformed to Windows line breaks (CRLF). Same transformation will be performed to single Carriage Return (CR) character. If linux textual file should be transported via email untouched, the best solution is to force usage of BASE64 encoding with other addAttachment() method.
Parameters:
  data - byte array from InputStream
Parameters:
  fileName - virtual or real file name (wihouth path). Correct informationabout name; extension of file name is especially important. Nameis used in construction of "name" parameter in Content-Type header line ofbody parts of mime message. Extension of file is used in detection of theappropriate mime-type.
exception:
  SMIMEException - caused by non SMIMEException which isMessagingException



addAttachment
public void addAttachment(InputStream data, String fileName, String encoding) throws SMIMEException(Code)
Adds data from InputStream as attachment to email message with given value for prefered Content-Transfer-Encoding argument. Attachment will be encoded acording to this parameter. Be carful with usage of this method, because you must know nature and content of file well, to avoid errors in encoding. Since this method does not employ automatic detection of Content-Transfer-Encoding, it is sligtly faster. Note that for linux textual files, if they are encoded as quoted-printable, line breaks (LF) will be transformed to Windows line breaks (CRLF). Same transformation will be performed to single Carriage Return (CR) character. If linux textual file should be transported via email untouched, the best solution is to force usage of BASE64 encoding.
Parameters:
  fileName - path and file name used for attachment
Parameters:
  encoding - Content-Transfer-Encoding value. It can take values: 7bit,quoted-printable, and base64
exception:
  SMIMEException - if passed file (as File object) does not exist inthe file sistem. Also, it can be caused by non SMIMEException which isMessagingException



addRecipient
protected void addRecipient(String recipientAddress, String type, String cerFileName) throws SMIMEException(Code)
Adds recipient address, type and .cer file of email recipient to encrypted message. Certificate file should be passed only in the case of Enveloped message or Signed and Enveloped message. Otherwise this argument represents redundance value and it should be given as null.
Parameters:
  recipientAddress - email address of recipent (fields TO or CC or BCCin email message header)
Parameters:
  type - should be TO, CC or BCC
Parameters:
  cerFileName - path and file name with certificate correspondingto recipient (file with .cer extension)
exception:
  SMIMEException - if type of addressing of messages is not TO, CCor BCC. Also, it can be caused by non SMIMEException which can be one ofthe following: IOException, MessagingException, FileNotFoundException,NoSuchProviderException, CertificateException.



addRecipient
protected void addRecipient(String recipientAddress, String type, KeyStore kStore, String alias) throws SMIMEException(Code)
Adds recipient address, type and recipient's certificate via KeyStore object and apropriate alias. Certificate information should be passed only in the case of Enveloped message or Signed and Enveloped message. Otherwise those arguments represent redundance values and they should be given as null.
Parameters:
  recipientAddress - email address of recipent (fields TO or CC or BCCin email message header)
Parameters:
  type - should be TO, CC or BCC
Parameters:
  kStore - instance of KeyStore class which represents an in-memorycollection of keys and certificates.
Parameters:
  alias - alias name which corresponds to desired certificate. If aliasis given as null, then reading results are unpredictable.
exception:
  SMIMEException - if type of addressing of messages is not TO, CCor BCC. Also, it can be caused by non SMIMEException which can be one ofthe following: IOException, MessagingException, FileNotFoundException,NoSuchProviderException, CertificateException.



addRecipient
protected void addRecipient(String recipientAddress, String type, String ksPath, String ksType, String password, String alias) throws SMIMEException(Code)
Adds recipient address, type and recipient's certificate via path to the KeyStore file, KeyStore type, password and apropriate alias. Certificate information should be passed only in the case of Enveloped message or Signed and Enveloped message. Otherwise those arguments represent redundance values and they should be given as null.
Parameters:
  recipientAddress - email address of recipent (fields TO or CC or BCCin email message header)
Parameters:
  type - should be TO, CC or BCC
Parameters:
  ksPath - is path to the file representation of KeyStore which holdscollection of keys and certificates. This file can be PKCS12 type (filewith .p12 or .pfx extension) or can be key store of other types readableby 'BouncyCastle' or 'Sun' KeyStore implementation.
Parameters:
  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 isin use, and alias parameter will be ignored, so this method becomesequivalent to addRecipient() method which deal only with .cer files.
Parameters:
  password - password used to access the corresponding private key,stored in given KeyStore file.
Parameters:
  alias - alias name which corresponds to desired private key. If aliasis given as null, then reading results are unpredictable.to recipient (file with .cer extension)
exception:
  SMIMEException - if type of addressing of messages is not TO, CCor BCC. Also, it can be caused by non SMIMEException which can be one ofthe following: IOException, MessagingException, FileNotFoundException,NoSuchProviderException, CertificateException.



getMimeMessage
public MimeMessage getMimeMessage()(Code)
Returns MimeMessage. Signed S/MIME message



initMimeMessage
public void initMimeMessage(String smtpHost, String fromAddress, String subject, String content, String charset) throws SMIMEException(Code)
Initializes the JavaMail session for SMTP and the MimeMessage object for message which will be sent. If the argument 'content' is not given as null this method is used for creating new message with text/plain content. For creating html formated content (text/html), argument 'content' should be given as null, and content of message should be set with one of setContent methods. Note that after using initMimeMessage method, 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
Parameters:
  fromAddress - email address of sender (FROM field in email header)
Parameters:
  subject - subject of email (SUBJECT field in email header). Thisargument can be null, but email message will be sent withouth SUBJECT.
Parameters:
  content - text/plain content of email message
Parameters:
  charset - character set for passed subject and content. The givenUnicode string will be charset-encoded using the specified charset. Thecharset is also used to set the "charset" parameter. For example Germanletters 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.
exception:
  SMIMEException - if smtpHost or fromAddress parameters are null.Also, it can be caused by non SMIMEException which is MessagingException.



reset
public void reset()(Code)
Resets all attributes in BaseSMIMEObject to their initial values. The attributes have the same values as when simple construcor is invoked. It means that after this method call, MIME message object should be rebuild again by calling initMimeMessage() method and optionaly other setContent() and addAttachment() method calls.



send
public void send() throws MessagingException(Code)
Sends S/MIME message to SMTP host.
exception:
  MessagingException - caused by use of methods from objects of classTransport.



setCharsetEncoding
public void setCharsetEncoding(String charset)(Code)
Sets the character set encoding. This attribute also can be set during the construction of object, or by invoking initMimeMessage() method. By invoking this method, previously set parameter will be overriden.
Parameters:
  charset - characterset encoding definition which will be used inprocess of string to byte array (and vice versa) transformation. The'charset' argument is also used to set the 'charset' parameter in messageor body header. For example German letters should be encoded by usage of'ISO-8859-1' charset. If 'charset' argument is null and String contains nonUS-ASCII characters it will be encoded using the platform's default charset.



setContent
public void setContent(String content, String type, String path, InputStream[] resources, String externalPlainText) throws SMIMEException(Code)
Sets message content. Message content can be given in two differrent forms: text and html code. If content is type of text, parameter "type" should be "text/plain" and other two parameters are not in use (should be set to null). If content is type of html code, parameter "type" should be set as "text/html", otherwise (if it is set as "text/plain") html code is processed as plain text. This method can be performed only once.

In case of html content, it is essential to (on appropriate way) associate some attributes of particular elements in html code ("background" or "src" atributes) with corresponding ressources (URL-s, relative file addresses or byte array streams). This resources should all be sent with message to enable recipient to see complete html message. Location of resources can be given in few different forms and depending on that, allocation resolving can be successful or not. Following text represents different possibilities for defining locations of resources (pictures, animations, sound...) inside of html code passed to this method, and necessery passed additional parameters used for resolving this resource locations.

  • URL defined as: http://... is left unchanged. This resource is not sent with the message and it couldn't be seen by recipient if it is not online on the internet.
  • URL defined as: file://... is transformed to corresponding Content ID if the resource can be found on specified location and it is sent with message.
  • Absolute path, for example defined as: "c:\tmp\test\picture.bmp", is transformed to corresponding Content ID if the resource can be found on specified location, and is sent with message. If all resources in html code are specified with its absolute path, the 3rd parameter in this method can be null.
  • Relative path of all resources specified in html code, for example defined as: ".\test\picture.bmp" and ".\example\flush.swf", must be defined to be relative to same directory path (in this case it is c:\tmp). This parameter (common directory path) is given as 3rd parameter in this method, and is named "path". If html code is obtained from .html file, necessery common directory path is usually path to this .html file. Location of resource is transformed to corresponding Content ID if the resource can be found on specified location. This location is sent with the message.
  • Byte array stream as resource for html attribute must be referenced from html code as:

     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.

All mentioned resource allocation types can be combined together in the same html code, and all will be processed with appropriate use of this method.

Note that number of resource references that are defined in html code by using virtual_file_names must be greater than or equal to number of elements in array of InputStream (4th parameter). If one resource (one element in array of IputStream) is used in html code more than once, it is advisable to use same virtual_file_name in html code because message is then sent with only one attached resource (image, movie...). It is essetntial that desired resource in input stream array corresponds to specified "nnn" part of virtual_file_name.

If resources specified on any described name can not be found or resolved, or if any exception has occured during its processing, they won't be added and html message will be sent withouth them.
Parameters:
  content - String representation of message content (text or html code).This argument is mandatory.
Parameters:
  type - type of given content. It can take values: "text/plain" or"text/html". This argument is mandatory.
Parameters:
  path - common directory path for relative file locations in html code.It can be null if all resources set absolute path or are defined bybyte 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.
Parameters:
  resources - way for representing resources used in the given html codewhich will be added to message as array of InputStream. Detail useof this argument is described above. It can be null if no resources as bytearray 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.
Parameters:
  externalPlainText - external text/plain message represented as String.This argument is used as alternative message to given html message in the processof generation multipart/alternative MimeMultipart message. If this argumenthas value null then autogeneration of text/plain message is performedaccording to passed html code (content argument). Also, it is set to nullin case of text/plain message.
exception:
  SMIMEException - if content is tried to be added twice, or in case ofwrong "type" parameter. Also, it can be caused by non SMIMEException which canbe one of the following: MessagingException UnsoportedEncodingException.



setContent
public void setContent(String content, String type, String path, InputStream[] resources) throws SMIMEException(Code)
Sets message content from String. This method can be performed only once. Method is the same as corresponding method setContent with five parameters, where fifth parameter is set to null. This setContent method (in case that second argument - type has value text/html) is used with autogeneration of text/plain message according to given html code in the process of generation multipart/alternative MimeMultipart message. For further information refer to setContent method with five arguments.
Parameters:
  content - String representation of message content (text or html code).This argument is mandatory.
Parameters:
  type - type of given content. It can take values: "text/plain" or"text/html". This argument is mandatory.
Parameters:
  path - common directory path for relative file locations in html code.It can be null if all resources set absolute path or are defined bybyte 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.
Parameters:
  resources - way for representing resources used in the given html codewhich will be added to message as array of InputStream. Detail useof this argument is described above. It can be null if no resources as bytearray 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.
exception:
  SMIMEException - if content is tried to be added twice, or in case ofwrong "type" parameter. Also, it can be caused by non SMIMEException which canbe one of the following: MessagingException UnsoportedEncodingException.



setContent
public void setContent(InputStream content, String type, String path, InputStream[] resources, String externalPlainText) throws SMIMEException(Code)
Sets message content from InputStream. This method can be performed only once. Message content can be given in two differrent forms: text and html code. If content is type of text, parameter "type" should be "text/plain", while if content is type of html code, parameter "type" should be set as "html/code". For further information refer to setContent method with five arguments (String, String, String, InputStream[], String) which is called by this method.
Parameters:
  content - message content data given from any InputStream.Data can be text or html code and will be interpreted according to secondparameter: "type".
Parameters:
  type - type of given content. It can take values: "text/plain" or"text/html". This argument is mandatory.
Parameters:
  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 aredefined by byte array streams, or if sending resources with relative addressis not desired. Also, it is set to null in case of text/plain message.
Parameters:
  resources - way for representing resources used in the given html codewhich will be added to message as array of InputStreams. Detail useof 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 sendingresources given in that way is not desired. Also, it is set to null in caseof text/plain message.
Parameters:
  externalPlainText - external text/plain message represented as String.This argument is used as alternative message to given html message in the processof generation multipart/alternative MimeMultipart message. If this argumenthas value null then autogeneration of text/plain message is performedaccording to passed html code (content argument). Also, it is set to nullin case of text/plain message.
exception:
  SMIMEException - if content is tried to be added twice , in case ofwrong "type" parameter or in case when parameter content is null. Also, it canbe caused by non SMIMEException which is MessagingException.



setContent
public void setContent(InputStream content, String type, String path, InputStream[] resources) throws SMIMEException(Code)
Sets message content from InputStream. This method can be performed only once. Method is same as corresponding method setContent with five parameters, where fifth parameter is set to null. This setContent method (in case that second argument - type has value text/html) is used with autogeneration of text/plain message according to given html code in process of generation multipart/alternative MimeMultipart message. For further information refer to setContent method with five arguments (InputStream, String, String, InputStream[], String) which is called by this method.
Parameters:
  content - message content data given from any InputStream.Data can be text or html code and will be interpreted according to secondparameter: "type".
Parameters:
  type - type of given content. It can take values: "text/plain" or"text/html". This argument is mandatory.
Parameters:
  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 aredefined by byte array streams, or if sending resources with relative addressis not desired. Also, it is set to null in case of text/plain message.
Parameters:
  resources - way for representing resources used in the given html codewhich will be added to message as array of InputStreams. Detail useof 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 sendingresources given in that way is not desired. Also, it is set to null in caseof text/plain message.
exception:
  SMIMEException - if content is tried to be added twice , in case ofwrong "type" parameter or in case when parameter content is null. Also, it canbe caused by non SMIMEException which is MessagingException.



setContent
public void setContent(InputStream content, String type, String externalPlainText) throws SMIMEException(Code)
Sets message content from InputStream. This method can be performed only once. Message content can be given in two differrent forms: text and html code. If content is type of text, parameter "type" should be "text/plain", while if content is type of html code, parameter "type" should be set as "html/code". If html code content is set by this method, message will be generated withouth inclusion of the resources defined in paricular html element's attribute ("src" and "background"). Only plain html code will be sent and any reference to local file system resources will be useless for recipient of the message. HTTP referenced resources can still be available if recipient is online on Internet. Message generated on this way is smaller so encrypting process should be faster.
Parameters:
  content - message content data given from any InputStream.Data could be text or html code and will be interpreted according to secondparameter: "type". This argument is mandatory.
Parameters:
  type - type of given content. It can take values: "text/plain" or"text/html". This argument is mandatory.
Parameters:
  externalPlainText - external text/plain message represented as String.This argument is used as alternative message to given html message in the processof generation multipart/alternative MimeMultipart message. If this argumenthas value null then autogeneration of text/plain message is performedaccording to passed html code (content argument). Also, it is set to nullin case of text/plain message.
exception:
  SMIMEException - if content is tried to be added twice , in case ofwrong "type" parameter or in case when parameter content is null. Also, it canbe caused by non SMIMEException which is MessagingException.



setContent
public void setContent(InputStream content, String type) throws SMIMEException(Code)
Sets message content from InputStream. This method can be performed only once. Method is the same as corresponding method setContent with three parameters, where third parameter is set to null. This setContent method (in case that second argument - type has value text/html) is used with autogeneration of text/plain message according to given html code in the process of generation multipart/alternative MimeMultipart message. For further information refer to setContent method with thre arguments.
Parameters:
  content - message content data given from any InputStream.Data could be text or html code and will be interpreted according to secondparameter: "type". This argument is mandatory.
Parameters:
  type - type of given content. It can take values: "text/plain" or"text/html". This argument is mandatory.
exception:
  SMIMEException - if content is tried to be added twice , in case ofwrong "type" parameter or in case when parameter content is null. Also, it canbe caused by non SMIMEException which is MessagingException.



setContent
public void setContent(String content, String type, String externalPlainText) throws SMIMEException(Code)
Sets message content from String. This method can be performed only once. Message content can be given in two differrent forms: text and html code. If content is type of text, parameter "type" should be "text/plain", while if content is type of html code, parameter "type" should be set as "html/code". If html code content is set by this method, message will be generated withouth inclusion of the resources defined in paricular html element's attribute ("src" or "background"). Only plain html code will be sent and any reference to local file system resources will be useless for recipient of the message. HTTP referenced resources can still be available if recipient is online on Internet. Message generated on this way is smaller, so encrypting process should be faster.
Parameters:
  content - message content data given as String which canbe text or html code and will be interpreted according to second parameter:"type". This argument is mandatory.
Parameters:
  type - type of given content. It can take values: "text/plain" or"text/html". This argument is mandatory.
Parameters:
  externalPlainText - external text/plain message represented as String.This argument is used as alternative message to given html message in the processof generation multipart/alternative MimeMultipart message. If this argumenthas value null then autogeneration of text/plain message is performedaccording to passed html code (content argument). Also, it is set to nullin case of text/plain message.
exception:
  SMIMEException - if content is tried to be added twice, or in case ofwrong "type" parameter. Also, it can be caused by non SMIMEException which canbe one of the following: MessagingException UnsoportedEncodingException.



setContent
public void setContent(String content, String type) throws SMIMEException(Code)
Sets message content from String. This method can be performed only once. Method is same as corresponding method setContent with three parameters, where third parameter is set to null. This setContent method (in case that second argument - type has value text/html) is used with autogeneration of text/plain message according to given html code in the process of generation multipart/alternative MimeMultipart message. For further information refer to setContent method with three arguments.
Parameters:
  content - message content data given as String which canbe text or html code and will be interpreted according to second parameter:"type". This argument is mandatory.
Parameters:
  type - type of given content. It can take values: "text/plain" or"text/html". This argument is mandatory.
exception:
  SMIMEException - if content is tried to be added twice , in case ofwrong "type" parameter or in case when parameter content is null. Also, it canbe caused by non SMIMEException which is MessagingException.



setContent
public void setContent(File inFile, String type, String externalPlainText) throws SMIMEException(Code)
Sets message content from file represented by File object. This method can be performed only once. Message content can be given in two differrent forms: text and html code. If content is type of text, parameter "type" should be "text/plain", while if content is type of html code, parameter "type" should be set as "html/code". Note that for this method, location of resources needed by html file (pictures, sounds... ) shouldn't be defined in html code as they should be passed as InputStream arrays. For further information refer to setContent method with five arguments (String, String, String, InputStream[], String) which is called by this method.
Parameters:
  inFile - location of file which is used for content of the message.This argument is mandatory.
Parameters:
  type - type of given content. It can take values: "text/plain" or"text/html". This argument is mandatory.
Parameters:
  externalPlainText - external text/plain message represented as String.This argument is used as alternative message to given html message in the processof generation multipart/alternative MimeMultipart message. If this argumenthas value null then autogeneration of text/plain message is performedaccording to passed html code (content argument). Also, it is set to nullin case of text/plain message.
exception:
  SMIMEException - if content is tried to be added twice, in case ofwrong "type" parameter, or if passed file (as File object) does not exist infile sistem. Also, it can be caused by non SMIMEException which can be one ofthe following: MessagingException or IOException.



setContent
public void setContent(File inFile, String type) throws SMIMEException(Code)
Sets message content from file represented by File object. This method can be performed only once. Method is the same as corresponding method setContent with three parameters, where third parameter is set to null. This setContent method (in case that second argument - type has value text/html) is used with autogeneration of text/plain message according to given html code in the process of generation multipart/alternative MimeMultipart message. For further information refer to corresponding setContent method with thre arguments.
Parameters:
  inFile - location of file which is used for content of the message.This argument is mandatory.
Parameters:
  type - type of given content. It can take values: "text/plain" or"text/html".
exception:
  SMIMEException - if content is tried to be added twice , in case ofwrong "type" parameter or in case when parameter content is null. Also, it canbe caused by non SMIMEException which is MessagingException.



setReply
public void setReply(String replyAddress) throws SMIMEException(Code)
Sets REPLY TO field in message header.
Parameters:
  replyAddress - email address used in reply
exception:
  SMIMEException - caused by non SMIMEException which isMessagingException. Also, javax.mail.internet.AddressException is thrownfrom instances of InternetAddress class (but AddressException extendsMessagingException).



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.