IAIK CMS/SMIME Toolkit Demo API Documentation
Version 6.1

demo.smime.big
Class BigSMimeMailDemo

java.lang.Object
  extended by demo.smime.big.BigSMimeMailDemo

public class BigSMimeMailDemo
extends java.lang.Object

This class demonstrates the usage of the IAIK S/MIME implementation for handling S/MIME message with big content data.

The only difference to the common usage of this S/MIME library is that this demo uses a temporary file directory to which the content of the big messages is written during processing. The temporary directory is created by calling method SMimeParameters#setTempDirectory:

 int bufSize = 16348;
 String tmpDir = ...;
 SMimeParameters.setTempDirectory(tmpDir, bufSize);
 
See Javadoc of SMimeParameters#setTempDirectory for usage information.

To run this demo the following packages are required:

The data for this demo is randomly created and stored into a file which is deleted again at the end of this demo. Note that running this demo may take some certain time because it processes some MB of data.


Constructor Summary
BigSMimeMailDemo()
          Default constructor.
 
Method Summary
 javax.mail.Message createCompressedMessage(javax.mail.Session session, javax.activation.DataHandler dataHandler, iaik.asn1.structures.AlgorithmID algorithm)
          Creates a compressed message.
 javax.mail.Message createEncryptedMessage(javax.mail.Session session, javax.activation.DataHandler dataHandler, iaik.asn1.structures.AlgorithmID algorithm, int keyLength, boolean authEncrypt)
          Creates an encrypted message.
 javax.mail.Message createMessage(javax.mail.Session session, java.lang.String subject)
          Creates a MIME message container with the given subject for the given session.
 javax.mail.Message createSignedAndEncryptedMessage(javax.mail.Session session, javax.activation.DataHandler dataHandler, iaik.asn1.structures.AlgorithmID algorithm, int keyLength, boolean implicit, boolean authEncrypt)
          Creates a signed and encrypted message.
 javax.mail.Message createSignedMessage(javax.mail.Session session, javax.activation.DataHandler dataHandler, boolean implicit)
          Creates a signed message.
static void main(java.lang.String[] argv)
          The main method.
 void parse(java.lang.Object o)
          Parses the given object (message, part, ... ).
 void start()
          Starts the demo.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BigSMimeMailDemo

public BigSMimeMailDemo()
Default constructor. Reads certificates and keys from the demo keystore.

Method Detail

start

public void start()
           throws java.io.IOException
Starts the demo.

Throws:
java.io.IOException - if an I/O related error occurs

createMessage

public javax.mail.Message createMessage(javax.mail.Session session,
                                        java.lang.String subject)
                                 throws javax.mail.MessagingException
Creates a MIME message container with the given subject for the given session.

Parameters:
session - the mail sesion
subject - the subject of the message
Returns:
the MIME message with FROM, TO, DATE and SUBJECT headers (without content)
Throws:
javax.mail.MessagingException - if the message cannot be created

createSignedAndEncryptedMessage

public javax.mail.Message createSignedAndEncryptedMessage(javax.mail.Session session,
                                                          javax.activation.DataHandler dataHandler,
                                                          iaik.asn1.structures.AlgorithmID algorithm,
                                                          int keyLength,
                                                          boolean implicit,
                                                          boolean authEncrypt)
                                                   throws javax.mail.MessagingException
Creates a signed and encrypted message.

Parameters:
session - the mail session
dataHandler - the content of the message to be signed and encrypted
algorithm - the content encryption algorithm to be used
keyLength - the length of the secret content encryption key to be created and used
implicit - whether to use implicit (application/pkcs7-mime) or explicit (multipart/signed) signing
authEncrypt - whether to create an authenticated encrypted or an encrypted message
Returns:
the signed and encrypted message
Throws:
javax.mail.MessagingException - if an error occurs when creating the message

createSignedMessage

public javax.mail.Message createSignedMessage(javax.mail.Session session,
                                              javax.activation.DataHandler dataHandler,
                                              boolean implicit)
                                       throws javax.mail.MessagingException
Creates a signed message.

Parameters:
session - the mail session
dataHandler - the content of the message to be signed
implicit - whether to use implicit (application/pkcs7-mime) or explicit (multipart/signed) signing
Returns:
the signed message
Throws:
javax.mail.MessagingException - if an error occurs when creating the message

createEncryptedMessage

public javax.mail.Message createEncryptedMessage(javax.mail.Session session,
                                                 javax.activation.DataHandler dataHandler,
                                                 iaik.asn1.structures.AlgorithmID algorithm,
                                                 int keyLength,
                                                 boolean authEncrypt)
                                          throws javax.mail.MessagingException
Creates an encrypted message.

Parameters:
session - the mail session
dataHandler - the dataHandler providing the content to be encrypted
algorithm - the content encryption algorithm to be used
keyLength - the length of the secret content encryption key to be created and used
authEncrypt - whether to create an authenticated encrypted or an encrypted message
Returns:
the encrypted message
Throws:
javax.mail.MessagingException - if an error occurs when creating the message

createCompressedMessage

public javax.mail.Message createCompressedMessage(javax.mail.Session session,
                                                  javax.activation.DataHandler dataHandler,
                                                  iaik.asn1.structures.AlgorithmID algorithm)
                                           throws javax.mail.MessagingException
Creates a compressed message.

Parameters:
session - the mail session
dataHandler - the datahandler supplying the content to be compressed
algorithm - the compression algorithm to be used
Returns:
the compressed message
Throws:
javax.mail.MessagingException - if an error occurs when creating the message

parse

public void parse(java.lang.Object o)
           throws java.lang.Exception
Parses the given object (message, part, ... ).

Parameters:
o - the object (message, part, ... ) to be parsed
Throws:
java.lang.Exception - if an exception occurs while parsing

main

public static void main(java.lang.String[] argv)
                 throws java.io.IOException
The main method.

Throws:
java.io.IOException

IAIK CMS/SMIME Toolkit Demo API Documentation
Version 6.1

v6.1
(c) 2002 IAIK, (c) 2003 - 2025 SIC