IAIK CMS/SMIME Toolkit Demo API Documentation
Version 6.1

demo.smime.pkcs11
Class SignedMailDemo

java.lang.Object
  extended by demo.cms.pkcs11.PKCS11Demo
      extended by demo.smime.pkcs11.SignedMailDemo
Direct Known Subclasses:
ExplicitSignedMailDemo, ImplicitSignedMailDemo

public abstract class SignedMailDemo
extends PKCS11Demo

Base class of signed mail demos using PKCS#11 for accessing the signer key on a smart card.


Field Summary
protected  java.lang.String recipient_
          The email address of the recipient.
protected  java.lang.String sender_
          The email address of the sender.
protected  iaik.x509.X509Certificate[] signerCertificates_
          The certificate chain of the signer.
protected  java.security.PrivateKey signerKey_
          The private key of the signer.
 
Fields inherited from class demo.cms.pkcs11.PKCS11Demo
iaikPkcs11Provider_, iaikSoftwareProvider_, moduleName_, tokenKeyStore_, userPin_
 
Constructor Summary
protected SignedMailDemo(java.lang.String moduleName, char[] userPin)
          Creates a SignedMailDemo object for the given module name.
 
Method Summary
protected  javax.mail.internet.MimeMessage createSignedMessage(javax.mail.Session session, javax.activation.DataHandler dataHandler, boolean implicit)
          Creates a signed message.
protected  void getSignatureKey()
          This method gets the key stores of all inserted (compatible) smart cards and simply takes the first key-entry.
protected  void start(boolean implicit)
          Starts the demo.
 
Methods inherited from class demo.cms.pkcs11.PKCS11Demo
getKeyStore, init
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

signerKey_

protected java.security.PrivateKey signerKey_
The private key of the signer. In this case only a proxy object, but the application cannot see this.


signerCertificates_

protected iaik.x509.X509Certificate[] signerCertificates_
The certificate chain of the signer. In contrast to the private signer key, the certificate holds the actual public keying material.


sender_

protected java.lang.String sender_
The email address of the sender.


recipient_

protected java.lang.String recipient_
The email address of the recipient.

Constructor Detail

SignedMailDemo

protected SignedMailDemo(java.lang.String moduleName,
                         char[] userPin)
Creates a SignedMailDemo object for the given module name.

Parameters:
moduleName - the name of the module
userPin - the user-pin (password) for the TokenKeyStore (may be null to pou-up a dialog asking for the pin)
Method Detail

getSignatureKey

protected void getSignatureKey()
                        throws java.security.GeneralSecurityException,
                               java.io.IOException
This method gets the key stores of all inserted (compatible) smart cards and simply takes the first key-entry. From this key entry it takes the private key and the certificate to retrieve the public key from. The keys are stored in the member variables signerKey_ and signerCertificate_.

Throws:
java.security.GeneralSecurityException - If anything with the provider fails.
java.io.IOException - If loading the key store fails.

createSignedMessage

protected javax.mail.internet.MimeMessage 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

start

protected void start(boolean implicit)
              throws java.lang.Exception
Starts the demo.

Parameters:
implicit - whether to create an implicit (content included; application/pkcs7-mime) or an explicit (content not included; multipart/signed) signed message
Throws:
java.lang.Exception - if an error occurs

IAIK CMS/SMIME Toolkit Demo API Documentation
Version 6.1

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