|
IAIK CMS/SMIME Toolkit Demo API Documentation
Version 6.1 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdemo.cms.tsp.TimeStampDemo
public class TimeStampDemo
This demo shows how to add a time stamp to a SignedData message.
For the stream-based part of this demo we use a SDSEncodeListener to add a SignatureTimeStampToken attribute the SignerInfo of a SignedDataStream object.
A SignatureTimeStampToken
attribute may
be included as an unsigned attribute into a SignerInfo
for time stamping
the signature value of a SignerInfo included in a SignedData. Using an SignedDataStream encode
listener for adding a SignatureTimeStampToken may be useful when having to time stamp the signature
calculated from a large data volume. Since reading all the data into memory may cause an OutOfMemory
problem, class SignedDataStream
should to be used for
creating/encoding the SignedData object and the SignatureTimeStampToken may be added by means
of a SDSEncodeListener
.
The SDSEncodeListener used by this demo is implemented by class TimeStampListener
assuming that only one SignerInfo is included in the SignedData.
This TSA from which to get the time stamp has to be provided by its HTTP URL, i.e. this demo
only works with time stamp authorities providing a HTTP service (like "http://tsp.iaik.at/tsp/TspRequest").
To run this demo, you must have the IAIK-TSP (2.x) library in your classpath. You can get it from https://sic.tech/products/public-key-infrastructure/tsp/.
TimeStampListener
,
SDSEncodeListener
,
SignedDataStream
,
SignedData
,
SignerInfo
,
SignatureTimeStampToken
Constructor Summary | |
---|---|
TimeStampDemo()
Constructor. |
Method Summary | |
---|---|
byte[] |
createSignedData(byte[] message,
int mode)
Creates a CMS SignedData object and adds a TimeStampToken as unsigned attribute. |
byte[] |
createSignedDataStream(byte[] message,
int mode)
Creates a CMS SignedData object (stream version) and adds
a TimeStampToken as unsigned attribute. |
byte[] |
getSignedData(byte[] encoding,
byte[] message)
Parses a CMS SignedData object and verifies the signature. |
byte[] |
getSignedDataStream(byte[] encoding,
byte[] message)
Parses a CMS SignedData object and verifies the signature. |
static void |
main(java.lang.String[] argv)
Main method. |
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 |
---|
public TimeStampDemo()
Method Detail |
---|
public byte[] createSignedDataStream(byte[] message, int mode) throws java.lang.Exception
SignedData
object (stream version) and adds
a TimeStampToken as unsigned attribute.
message
- the message to be signed, as byte representationmode
- the mode indicating whether to include the content
(SignedDataStream.IMPLICIT) or not (SignedDataStream.EXPLICIT)
SignedData
object just created
java.lang.Exception
- if the SignedData
object cannot
be created for some reasonpublic byte[] getSignedDataStream(byte[] encoding, byte[] message) throws java.lang.Exception
SignedData
object and verifies the signature.
encoding
- the SignedData, as BER encoded byte arraymessage
- the message which was transmitted out-of-band (explicit signed), or null
in implicit mode
java.lang.Exception
- if some error occurspublic byte[] createSignedData(byte[] message, int mode) throws java.lang.Exception
SignedData
object and adds a TimeStampToken as unsigned attribute.
message
- the message to be signed, as byte representationmode
- the mode indicating whether to include the content
(SignedData.IMPLICIT) or not (SignedData.EXPLICIT)
SignedData
object just created
java.lang.Exception
- if the SignedData
object cannot
be created for some reasonpublic byte[] getSignedData(byte[] encoding, byte[] message) throws java.lang.Exception
SignedData
object and verifies the signature.
encoding
- the SignedData, as BER encoded byte arraymessage
- the message which was transmitted out-of-band (explicit signed), or null
in implicit mode
java.lang.Exception
- if some error occurspublic void start()
public static void main(java.lang.String[] argv) throws java.io.IOException
java.io.IOException
- if an I/O error occurs when reading required keys
and certificates from files
|
IAIK CMS/SMIME Toolkit Demo API Documentation
Version 6.1 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
![]() |
v6.1 (c) 2002 IAIK, (c) 2003 - 2025 SIC |
![]() |