IAIK CMS/SMIME Toolkit Demo API Documentation
Version 6.1

demo.smime.ess
Class SigningCertificateDemo

java.lang.Object
  extended by demo.smime.ess.SigningCertificateDemo
Direct Known Subclasses:
SigningCertificateV2Demo

public class SigningCertificateDemo
extends java.lang.Object

Demonstrates how to add and parse a SigningCertificate attribute to the SignerInfo of a SignedDataStream or SignedData object. The SigningCertificate attributes maybe used to include certificate identification information into the signed attributes of a CMS SignerInfo object.

See Also:
SigningCertificate, SignerInfo, SignedDataStream, SignedData

Constructor Summary
SigningCertificateDemo()
          Setups the demo certificate chains.
 
Method Summary
 iaik.x509.attr.AttributeCertificate createAttributeCertificate()
          Creates an attribute certificate just for testing.
 byte[] createSignedData(byte[] message, int mode)
          Creates a CMS SignedData object.
 byte[] createSignedDataStream(byte[] message, int mode)
          Creates a CMS SignedData object.
protected  iaik.smime.ess.SigningCertificate createSigningCertificate(java.security.cert.Certificate[] certs)
          Creates a SigningCertificate attribute for the given certificates.
 byte[] getSignedData(byte[] encoding, byte[] message)
          Parses a CMS SignedData object and verifies the signatures for all participated signers.
 byte[] getSignedDataStream(byte[] signedData, byte[] message)
          Parses a CMS SignedData object and verifies the signatures for all participated signers.
protected  iaik.smime.ess.SigningCertificate getSigningCertificate(iaik.cms.SignerInfo signerInfo)
          Gets the SigningCertificate attribute from the given SignerInfo.
static void main(java.lang.String[] argv)
          The main method.
protected  void printHeader()
          Prints some header lines to System.out.
 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

SigningCertificateDemo

public SigningCertificateDemo()
                       throws java.io.IOException
Setups the demo certificate chains. Keys and certificate are retrieved from the demo KeyStore.

Throws:
java.io.IOException - if an file read error occurs
Method Detail

createSignedDataStream

public byte[] createSignedDataStream(byte[] message,
                                     int mode)
                              throws iaik.cms.CMSException,
                                     java.io.IOException
Creates a CMS SignedData object.

Parameters:
message - the message to be signed, as byte representation
mode - the transmission mode, either IMPLICIT or EXPLICIT
Returns:
the BER encoding of the SignedData object just created
Throws:
iaik.cms.CMSException - if the SignedData object cannot be created
java.io.IOException - if some stream I/O error occurs

getSignedDataStream

public byte[] getSignedDataStream(byte[] signedData,
                                  byte[] message)
                           throws iaik.cms.CMSException,
                                  java.io.IOException
Parses a CMS SignedData object and verifies the signatures for all participated signers.

Parameters:
signedData - SignedData object as BER encoded byte array
message - the the message which was transmitted out-of-band (explicit signed)
Returns:
the inherent message as byte array
Throws:
iaik.cms.CMSException - if any signature does not verify
java.io.IOException - if some stream I/O error occurs

createSignedData

public byte[] createSignedData(byte[] message,
                               int mode)
                        throws iaik.cms.CMSException
Creates a CMS SignedData object.

Parameters:
message - the message to be signed, as byte representation
mode - the mode, either SignedData.IMPLICIT or SignedData.EXPLICIT
Returns:
the DER encoded SignedData object
Throws:
iaik.cms.CMSException - if the SignedData object cannot be created

getSignedData

public byte[] getSignedData(byte[] encoding,
                            byte[] message)
                     throws iaik.cms.CMSException,
                            java.io.IOException
Parses a CMS SignedData object and verifies the signatures for all participated signers.

Parameters:
encoding - the DER encoded SignedData object
message - the the message which was transmitted out-of-band (explicit signed)
Returns:
the inherent message as byte array
Throws:
iaik.cms.CMSException - if any signature does not verify
java.io.IOException - if some stream I/O error occurs

createAttributeCertificate

public iaik.x509.attr.AttributeCertificate createAttributeCertificate()
                                                               throws iaik.cms.CMSException
Creates an attribute certificate just for testing.

Returns:
the attribute certificate created
Throws:
iaik.cms.CMSException - if an error occurs when creating the attribute certificate

start

public void start()
Starts the demo.


createSigningCertificate

protected iaik.smime.ess.SigningCertificate createSigningCertificate(java.security.cert.Certificate[] certs)
                                                              throws iaik.cms.CMSException
Creates a SigningCertificate attribute for the given certificates.

Parameters:
certs - the certificates for which to create the SigningCertificate attribute
Returns:
the SigningCertificate attribute just created
Throws:
iaik.cms.CMSException - if an error occurs when creating the SigningCertificate attribute

getSigningCertificate

protected iaik.smime.ess.SigningCertificate getSigningCertificate(iaik.cms.SignerInfo signerInfo)
                                                           throws iaik.cms.CMSException
Gets the SigningCertificate attribute from the given SignerInfo.

Parameters:
signerInfo - the SignerInfo from which to get the SigningCertificate attribute
Returns:
the SigningCertificate attribute, or null if no SigningCertificate attribute is included
Throws:
iaik.cms.CMSException - if an error occurs when getting the SigningCertificate attribute

printHeader

protected void printHeader()
Prints some header lines to System.out.


main

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

Throws:
java.io.IOException - if an I/O error occurs when reading required keys and certificates from files
java.lang.Exception

IAIK CMS/SMIME Toolkit Demo API Documentation
Version 6.1

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