IAIK CMS/SMIME Toolkit Demo API Documentation
Version 6.1

demo.smime.ess
Class SignedReceiptDemo

java.lang.Object
  extended by demo.smime.ess.SignedReceiptDemo

public class SignedReceiptDemo
extends java.lang.Object

An RFC2634 ESS ReceiptRequest -- SignedReceipt demo.

This demo creates a message with a ReceiptRequest attribute and "sends" it to some intended recipient. The recipient then "sends" a signed receipt message back to the original sender who finally validates the signed receipt. A further test run adds a MLA layer with a MLExpansionHistory attribute, that supersedes the original receipt request.

To run this demo the following packages are required:

See Also:
ReceiptRequest, Receipt, MLExpansionHistory, MLData, MLReceiptPolicy, SignedReceipt

Constructor Summary
SignedReceiptDemo()
          Empty default constructor.
 
Method Summary
 javax.mail.Message createMessage(javax.mail.Session session, java.lang.String from, java.lang.String to, java.lang.String subject)
          Creates a MimeMessage.
 javax.mail.Message createMessageWithSignedReceipt(javax.mail.Session session, javax.mail.Message receivedMsg)
          Creates a signed-receipt message from the received message.
static iaik.smime.ess.MLExpansionHistory createMLExpansionHistory(iaik.x509.X509Certificate mlaCertificate, java.util.Date expansionTime, java.lang.String mlaEmailAddress)
          Creates a MLExpansionHistory containing only one MLData for the given MLA with given expansion time and a MLReceiptPolicy of type IN_ADDITION_TO for the given mlaEmailAddress.
 iaik.smime.ess.ReceiptRequest createReceiptRequest(java.security.PublicKey publicKey, java.util.Date sentDate, java.lang.String email)
          Creates a ReceiptRequest attribute to request all recipients to send a signed receipt to the entity to the given email address.
 javax.mail.Message createSignedMessageWithReceiptRequest(javax.mail.Session session, boolean implicit, java.io.OutputStream os)
          Creates a signed message that contains a ReceiptRequest attribute.
static void main(java.lang.String[] argv)
          Main method.
 void start()
          Starts the SignedReceipt demo.
 void storeDigestValues(iaik.smime.SignedContent signedContent)
          Keeps the signature message digest value of the sender and the receipt content digest values for later SignedReceipt validation.
 void test(boolean implicit, boolean mla)
          Runs the ReceiptRequest - SignedReceipt test.
 void verifyReceiptContent(javax.mail.Message receiptMsg)
          Validates a signed receipt message received in return to a receipt request message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SignedReceiptDemo

public SignedReceiptDemo()
Empty default constructor. Reads all required keys and certificates from the demo keystore (created by running @link demo.keystore.SetupCMSKeySrore) stored at "cms.keystore" in your current working directoy.

Method Detail

start

public void start()
Starts the SignedReceipt demo.


test

public void test(boolean implicit,
                 boolean mla)
Runs the ReceiptRequest - SignedReceipt test.

Parameters:
implicit - whether to create implicit (application/pkcs7-mime) or explicit (multipart/signed) ReceiptRequest messages
mla - whether to add a MLA layer

createMessage

public javax.mail.Message createMessage(javax.mail.Session session,
                                        java.lang.String from,
                                        java.lang.String to,
                                        java.lang.String subject)
                                 throws javax.mail.MessagingException
Creates a MimeMessage.

Parameters:
session - the current mail session
from - the sender of the message
to - the recipient of the message
subject - the subject of the message
Returns:
the newly created MimeMessage
Throws:
javax.mail.MessagingException - if an error occurs when creating the message

createSignedMessageWithReceiptRequest

public javax.mail.Message createSignedMessageWithReceiptRequest(javax.mail.Session session,
                                                                boolean implicit,
                                                                java.io.OutputStream os)
                                                         throws java.lang.Exception
Creates a signed message that contains a ReceiptRequest attribute.

Parameters:
session - the current mail session
implicit - whether to sign the content implicitly or explicitly
os - the output stream to which to write the message
Returns:
the message containing a ReceiptRequest attribute
Throws:
java.lang.Exception

createReceiptRequest

public iaik.smime.ess.ReceiptRequest createReceiptRequest(java.security.PublicKey publicKey,
                                                          java.util.Date sentDate,
                                                          java.lang.String email)
Creates a ReceiptRequest attribute to request all recipients to send a signed receipt to the entity to the given email address.

Parameters:
publicKey - the public key of the sender (used for ContentIdentifier calculation)
sentDate - the sent date of the message (used for ContentIdentifier calculation)
email - the email address of the sender (to whom to return a signed receipt)
Returns:
the ReceiptRequest

createMLExpansionHistory

public static iaik.smime.ess.MLExpansionHistory createMLExpansionHistory(iaik.x509.X509Certificate mlaCertificate,
                                                                         java.util.Date expansionTime,
                                                                         java.lang.String mlaEmailAddress)
Creates a MLExpansionHistory containing only one MLData for the given MLA with given expansion time and a MLReceiptPolicy of type IN_ADDITION_TO for the given mlaEmailAddress.

Parameters:
mlaCertificate - the certificate of the MLA from which to create the MLData EntityIdentiifier of type IssuerAndSerialNumber
expansionTime - the expansion time
mlaEmailAddress - to be set as IN_ADDITION_TO recipient list for the MLData MLRecipientPolicy
Returns:
the newly created MLExpansionHistory

storeDigestValues

public void storeDigestValues(iaik.smime.SignedContent signedContent)
                       throws iaik.smime.ess.ESSException
Keeps the signature message digest value of the sender and the receipt content digest values for later SignedReceipt validation.

Parameters:
signedContent - the signed message for which to keep the digest values
Throws:
iaik.smime.ess.ESSException - if an error occurs while gathering the required digest values

createMessageWithSignedReceipt

public javax.mail.Message createMessageWithSignedReceipt(javax.mail.Session session,
                                                         javax.mail.Message receivedMsg)
                                                  throws java.lang.Exception
Creates a signed-receipt message from the received message.

Parameters:
session - the current mail session
receivedMsg - the message containing a ReceiptRequest attribute
Returns:
a message containing s signed receipt to be sent in return to the receipt request
Throws:
java.lang.Exception - if some error occurs during receipt request processing or signed receipt creation

verifyReceiptContent

public void verifyReceiptContent(javax.mail.Message receiptMsg)
                          throws java.lang.Exception
Validates a signed receipt message received in return to a receipt request message.

Parameters:
receiptMsg - the message containing the signed receipt
Throws:
java.lang.Exception - if the receipt validation fails for some reason

main

public static void main(java.lang.String[] argv)
                 throws java.io.IOException
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