public class SignedReceiptDemo extends java.lang.Object
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:
iaik_cms.jar
iaik_jce(_full).jar
(IAIK-JCE Core Crypto Library).
ReceiptRequest
,
Receipt
,
MLExpansionHistory
,
MLData
,
MLReceiptPolicy
,
SignedReceipt
Constructor and Description |
---|
SignedReceiptDemo()
Empty default constructor.
|
Modifier and Type | Method and Description |
---|---|
jakarta.mail.Message |
createMessage(jakarta.mail.Session session,
java.lang.String from,
java.lang.String to,
java.lang.String subject)
Creates a MimeMessage.
|
jakarta.mail.Message |
createMessageWithSignedReceipt(jakarta.mail.Session session,
jakarta.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.
|
jakarta.mail.Message |
createSignedMessageWithReceiptRequest(jakarta.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(jakarta.mail.Message receiptMsg)
Validates a signed receipt message received in return to a receipt request
message.
|
public SignedReceiptDemo()
public void start()
public void test(boolean implicit, boolean mla)
implicit
- whether to create implicit (application/pkcs7-mime) or
explicit (multipart/signed) ReceiptRequest messagesmla
- whether to add a MLA layerpublic jakarta.mail.Message createMessage(jakarta.mail.Session session, java.lang.String from, java.lang.String to, java.lang.String subject) throws jakarta.mail.MessagingException
session
- the current mail sessionfrom
- the sender of the messageto
- the recipient of the messagesubject
- the subject of the messagejakarta.mail.MessagingException
- if an error occurs when creating the messagepublic jakarta.mail.Message createSignedMessageWithReceiptRequest(jakarta.mail.Session session, boolean implicit, java.io.OutputStream os) throws java.lang.Exception
ReceiptRequest
attribute.session
- the current mail sessionimplicit
- whether to sign the content implicitly or explicitlyos
- the output stream to which to write the messagejava.lang.Exception
public iaik.smime.ess.ReceiptRequest createReceiptRequest(java.security.PublicKey publicKey, java.util.Date sentDate, java.lang.String email)
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)public static iaik.smime.ess.MLExpansionHistory createMLExpansionHistory(iaik.x509.X509Certificate mlaCertificate, java.util.Date expansionTime, java.lang.String mlaEmailAddress)
mlaCertificate
- the certificate of the MLA from which to create the
MLData EntityIdentiifier of type IssuerAndSerialNumberexpansionTime
- the expansion timemlaEmailAddress
- to be set as IN_ADDITION_TO recipient list for
the MLData MLRecipientPolicypublic void storeDigestValues(iaik.smime.SignedContent signedContent) throws iaik.smime.ess.ESSException
signedContent
- the signed message for which to keep the digest valuesiaik.smime.ess.ESSException
- if an error occurs while gathering the required digest valuespublic jakarta.mail.Message createMessageWithSignedReceipt(jakarta.mail.Session session, jakarta.mail.Message receivedMsg) throws java.lang.Exception
session
- the current mail sessionreceivedMsg
- the message containing a ReceiptRequest attributejava.lang.Exception
- if some error occurs during receipt request processing
or signed receipt creationpublic void verifyReceiptContent(jakarta.mail.Message receiptMsg) throws java.lang.Exception
receiptMsg
- the message containing the signed receiptjava.lang.Exception
- if the receipt validation fails for some reasonpublic static void main(java.lang.String[] argv) throws java.io.IOException
java.io.IOException