org.webdocwf.util.smime.util
Class MimeAssist

java.lang.Object
  |
  +--org.webdocwf.util.smime.util.MimeAssist

public class MimeAssist
extends java.lang.Object

MimeAssist contains static methods which help in manipulation and work with mime messages.


Constructor Summary
MimeAssist()
           
 
Method Summary
static java.lang.String generateID()
          Generates value for Content-ID MIME header line which is used in construction of multipart/related type of MimeMessage.
static byte[] getBASE64WithBreak(byte[] b0, int breakPosition0)
          Returns BASE64 encoded byte array with the break at the defined character.
static byte[] getBASE64WithBreak(java.lang.String s0, int breakPosition0)
          Returns BASE64 encoded byte array with the break at the defined character.
static byte[] getBASE64WithBreakOn76(byte[] b0)
          Returns BASE64 encoded byte array with the break at the 76th character.
static byte[] getBASE64WithBreakOn76(java.lang.String s0)
          Returns BASE64 encoded byte array with the break at the 76th character.
static javax.activation.MimetypesFileTypeMap getFileTypeMap(java.lang.String path0)
          Returns object of class MimetypesFileTypeMap generated by using data stored in the given file.
static java.lang.String getMimeTypeFromFileName(java.io.File file0, java.lang.String mimeFile0)
          Returns mime-type for given file name and extension.
static java.lang.String getMimeTypeFromFileName(java.lang.String file0, java.lang.String mimeFile0)
          Returns mime-type for given file name and extension.
static java.lang.String getStringBASE64WithBreak(byte[] b0, int breakPosition0)
          Returns BASE64 encoded String with the break at the defined character.
static java.lang.String getStringBASE64WithBreak(java.lang.String s0, int breakPosition0)
          Returns BASE64 encoded String with the break at the defined character.
static java.lang.String getStringBASE64WithBreakOn76(byte[] b0)
          Returns BASE64 encoded String with the break at the 76th character.
static java.lang.String getStringBASE64WithBreakOn76(java.lang.String s0)
          Returns BASE64 encoded String with the break at the 76th character.
static byte[] messageConvertor(javax.mail.internet.MimeMessage message0)
          Converts email messages, previously composed in Java MimeMessage object, to byte array suitable for later processing within CMS object.
static java.lang.String messageStringConvertor(javax.mail.internet.MimeMessage message0)
          Converts email messages, previously composed in Java MimeMessage object, to String suitable for later criptographic processing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MimeAssist

public MimeAssist()
Method Detail

messageConvertor

public static byte[] messageConvertor(javax.mail.internet.MimeMessage message0)
                               throws SMIMEException
Converts email messages, previously composed in Java MimeMessage object, to byte array suitable for later processing within CMS object. Input (MimeMessage) has all the necessary data for sending MIME message (attachments, text content, Content-Type, Content-Transfer-Encoding etc). All RFC822 header lines except Content-Type, Content-Transfer-Encoding, Content-Disposition and Content-Description are removed in proces of converting.
Parameters:
message0 - MIME email prepared for sending as MimeMessage
Returns:
Byte array representation of MIME email prepared for later use in criptographic processing.
Throws:
SMIMEException - if there is no MimeBodyPart in MimeMultipart message, or in the cases of unrecognisable content of bodypart in MIME multipart/mixed message or unrecognisable Content-Transfer-Encoding of message. Also, it can be caused by non SMIMEException which can be one of the following: MessagingException, IOException or UnsupportedEncodingException.

messageStringConvertor

public static java.lang.String messageStringConvertor(javax.mail.internet.MimeMessage message0)
                                               throws SMIMEException
Converts email messages, previously composed in Java MimeMessage object, to String suitable for later criptographic processing. Input (MimeMessage) has all the necessery data for sending MIME message (attachments, text content, Content-Type, Content-Transfer-Encoding etc). All RFC822 header lines except Content-Type, Content-Transfer-Encoding, Content-Disposition and Content-Description are removed in the process of converting.
Parameters:
message0 - MIME email prepared for sending as MimeMessage
Returns:
String representation of MIME email prepared for later use in criptographic processing.
Throws:
SMIMEException - if there is no MimeBodyPart in MimeMultipart message, or in the cases of unrecognisable content of bodypart in MIME multipart/mixed message or unrecognisable Content-Transfer-Encoding of message. Also, it can be caused by non SMIMEException which can be one of the following: MessagingException or IOException.

generateID

public static java.lang.String generateID()
                                   throws SMIMEException
Generates value for Content-ID MIME header line which is used in construction of multipart/related type of MimeMessage. Generated value is composed from four parts in order to be unique: random number, unique session number, current date and time defined in milliseconds and the host name.

<random-number>-<unique_session_number>-<date_&_time_in_ms>@<host-name>
Returns:
Content-ID value represented as String.
Throws:
SMIMEException - caused by non SMIMEException which is UnknownHostException

getFileTypeMap

public static javax.activation.MimetypesFileTypeMap getFileTypeMap(java.lang.String path0)
                                                            throws SMIMEException
Returns object of class MimetypesFileTypeMap generated by using data stored in the given file. For more information see Java documentation related to class MimetypesFileTypeMap.
Parameters:
path0 - path and file name of the file which contains desired mime-type definitions in appropriate format (usually file name is mime.types).
Returns:
MimetypesFileTypeMap object which can be used for getting appropriate mime-types from desired file names.

getMimeTypeFromFileName

public static java.lang.String getMimeTypeFromFileName(java.io.File file0,
                                                       java.lang.String mimeFile0)
                                                throws SMIMEException
Returns mime-type for given file name and extension.
Parameters:
file0 - is File type object that represents file which mime-type is looking for.
mimeFile0 - path and file name of the file which contains desired mime-type definitions in appropriate format (usually file name is mime.types).
Returns:
mime-type for given file.

getMimeTypeFromFileName

public static java.lang.String getMimeTypeFromFileName(java.lang.String file0,
                                                       java.lang.String mimeFile0)
                                                throws SMIMEException
Returns mime-type for given file name and extension.
Parameters:
file0 - path and file name of the file which mime-type is looking for.
mimeFile0 - path and file name to file which contains desired mime-type definitions in appropriate format (usually file name is mime.types).
Returns:
mime-type for given file.

getStringBASE64WithBreakOn76

public static java.lang.String getStringBASE64WithBreakOn76(byte[] b0)
                                                     throws SMIMEException
Returns BASE64 encoded String with the break at the 76th character. Base64 is necessary for encoding, for transport binary data by email in MIME format. After encoding, data must be split at the 76th charachter (maximum) by inserting CRLF characters.
Parameters:
b0 - input byte array
Returns:
BASE64 encoded String with the break at the 76th character
Throws:
SMIMEException - in case of wrong parameter breakPosition0. Also, it can be caused by non SMIMEException which can be one of the following: NoSuchPaddingException, NoSuchProviderException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException or UnsupportedEncodingException.

getBASE64WithBreakOn76

public static byte[] getBASE64WithBreakOn76(byte[] b0)
                                     throws SMIMEException
Returns BASE64 encoded byte array with the break at the 76th character. Base64 is necessary for encoding, for transport binary data by email in MIME format. After encoding, data must be split at the 76th charachter (maximum) by inserting CRLF characters.
Parameters:
b0 - input byte array
Returns:
BASE64 encoded byte array with the break at the 76th character
Throws:
SMIMEException - in case of wrong parameter breakPosition0. Also, it can be caused by non SMIMEException which can be one of the following: NoSuchPaddingException, NoSuchProviderException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException or UnsupportedEncodingException.

getStringBASE64WithBreakOn76

public static java.lang.String getStringBASE64WithBreakOn76(java.lang.String s0)
                                                     throws SMIMEException
Returns BASE64 encoded String with the break at the 76th character. Base64 is necessary for encoding, for transport binary data by email in MIME format. After encoding, data must be split at the 76th charachter (maximum) by inserting CRLF characters.
Parameters:
s0 - input String
Returns:
BASE64 encoded String with the break at the 76th character
Throws:
SMIMEException - in case of wrong parameter breakPosition0. Also, it can be caused by non SMIMEException which can be one of the following: NoSuchPaddingException, NoSuchProviderException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException or UnsupportedEncodingException.

getBASE64WithBreakOn76

public static byte[] getBASE64WithBreakOn76(java.lang.String s0)
                                     throws SMIMEException
Returns BASE64 encoded byte array with the break at the 76th character. Base64 is necessary for encoding, for transport binary data by email in MIME format. After encoding, data must be split at the 76th charachter (maximum) by inserting CRLF characters.
Parameters:
s0 - input String
Returns:
BASE64 encoded byte array with the break at the 76th character
Throws:
SMIMEException - in case of wrong parameter breakPosition0. Also, it can be caused by non SMIMEException which can be one of the following: NoSuchPaddingException, NoSuchProviderException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException or UnsupportedEncodingException.

getStringBASE64WithBreak

public static java.lang.String getStringBASE64WithBreak(byte[] b0,
                                                        int breakPosition0)
                                                 throws SMIMEException
Returns BASE64 encoded String with the break at the defined character. Base64 is necessary for encoding, for transport binary data by email in MIME format. After encoding, data must be split at the 76th charachter (maximum) by inserting CRLF characters.
Parameters:
b0 - input byte array
breakPosition0 - position for breaking lines in resulted Base64 encoding message content. It should be grather than 0 and less or equal than 76.
Returns:
BASE64 encoded String with the break at the 76th character
Throws:
SMIMEException - in case of wrong parameter breakPosition0. Also, it can be caused by non SMIMEException which can be one of the following: NoSuchPaddingException, NoSuchProviderException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException or UnsupportedEncodingException.

getBASE64WithBreak

public static byte[] getBASE64WithBreak(byte[] b0,
                                        int breakPosition0)
                                 throws SMIMEException
Returns BASE64 encoded byte array with the break at the defined character. Base64 is necessary for encoding, for transport binary data by email in MIME format. After encoding, data must be split at the 76th charachter (maximum) by inserting CRLF characters.
Parameters:
b0 - input byte array
breakPosition0 - position for breaking lines in resulted Base64 encoding message content. It should be grather than 0 and less or equal than 76.
Returns:
BASE64 encoded byte array with the break at the 76th character
Throws:
SMIMEException - in case of wrong parameter breakPosition0. Also, it can be caused by non SMIMEException which can be one of the following: NoSuchPaddingException, NoSuchProviderException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException or UnsupportedEncodingException.

getStringBASE64WithBreak

public static java.lang.String getStringBASE64WithBreak(java.lang.String s0,
                                                        int breakPosition0)
                                                 throws SMIMEException
Returns BASE64 encoded String with the break at the defined character. Base64 is necessary for encoding, for transport binary data by email in MIME format. After encoding, data must be split at the 76th charachter (maximum) by inserting CRLF characters.
Parameters:
s0 - input String
breakPosition0 - position for breaking lines in resulted Base64 encoding message content. It should be grather than 0 and less or equal than 76.
Returns:
BASE64 encoded String with the break at the 76th character
Throws:
SMIMEException - in case of wrong parameter breakPosition0. Also, it can be caused by non SMIMEException which can be one of the following: NoSuchPaddingException, NoSuchProviderException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException or UnsupportedEncodingException.

getBASE64WithBreak

public static byte[] getBASE64WithBreak(java.lang.String s0,
                                        int breakPosition0)
                                 throws SMIMEException
Returns BASE64 encoded byte array with the break at the defined character. Base64 is necessary for encoding, for transport binary data by email in MIME format. After encoding, data must be split at the 76th charachter (maximum) by inserting CRLF characters.
Parameters:
s0 - input String
breakPosition0 - position for breaking lines in resulted Base64 encoding message content. It should be grather than 0 and less or equal than 76.
Returns:
BASE64 encoded byte array with the break at the 76th character
Throws:
SMIMEException - in case of wrong parameter breakPosition0. Also, it can be caused by non SMIMEException which can be one of the following: NoSuchPaddingException, NoSuchProviderException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException or UnsupportedEncodingException.


Copyright © 2002-2002 Together Teamlösungen. All Rights Reserved.