|
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.Objectiaik.cms.SDSEncodeListener
demo.cms.tsp.TimeStampListener
public class TimeStampListener
A simple SignedDataStream encode listener implementation allowing an application to add a SignatureTimeStampToken attribute to the SignerInfo of a SignedDataStream (during the encoding is performed).
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
.
This SDSEncodeListener implements method afterComputeSignature
to add a SignatureTimeStampToken attribute to the SignerInfo of a
SignedDataStream object (Attention: This demo assumes that the SignedData contains
only one single SignerInfo). When creating
a TimeStampListener
the HTTP URL of the Time Stamp Authority from which to get the TimeStamp has to be
supplied (Attention: This demo only works for TSAs that can be accessed via http).
This SDSEncodeListener implements method afterComputeSignature
to connect to the specified TSA service to get a timestamp for the signature value
of the single SignerInfo object. The TimeStampToken received from the TSA then is
included as unsigned SignatureTimeStampToken
attribute into the SignerInfo object. If there occurs an error during the TSP processing
an exception is thrown, except the application has decided to finsih
the SignedData creating/encoding procedure without including the SignatureTimeStampToken
attribute (which then may be added later).
This SDSEncodeListener implementation is part of the CMS TimeStamp demo.
Please look at TimeStampDemo
for an usage example:
// cretae a SignedDataStream object SignedDataStream signedData = ...; ... // add certificates and SignerInfo... ... // create and add a TimeStampListener to include a TimeStampToken to be obtained from the specified TSA String tsaUrl = "http://..."; TimeStampListener tsl = new TimeStampListener(tsaUrl); // debug info goes to System.out tsl.setDebugStream(System.out); signedData.setSDSEncodeListener(tsl); ... // encode the SignedData to some output stream OutputStream os = ...; signedData.writeTo(...);
TimeStampDemo
,
SDSEncodeListener
,
SignedDataStream
,
SignerInfo
,
SignatureTimeStampToken
Field Summary |
---|
Fields inherited from class iaik.cms.SDSEncodeListener |
---|
digestAlgorithms_, outputStream_, report_ |
Constructor Summary | |
---|---|
TimeStampListener(java.lang.String tsaUrl)
Creates a TimeStampListener for the given TSA url. |
Method Summary | |
---|---|
protected void |
afterComputeSignature(iaik.cms.SignedDataStream signedData)
|
protected void |
beforeComputeSignature(iaik.cms.SignedDataStream signedData)
Does nothing. |
iaik.tsp.TimeStampReq |
getTimeStampRequest()
Gets the TimeStampRequest. |
iaik.tsp.TimeStampResp |
getTimeStampResponse()
Gets the TimeStampResponse. |
iaik.tsp.TspException |
getTspFailure()
Returns a TspException, if has been thrown during TSP processing. |
void |
setDebugStream(java.io.OutputStream out)
Sets the stream to which debug information shall be printed. |
void |
setStopOnTSPProcessingError(boolean stop)
Decides whether SignedData creation shall be stopped and an exception shall be thrown if the TSA response is invalid, or if the SignedData should be finished without including a SignatureTimeStampToken attribute (which then may be added later). |
void |
setTimeStampResponse(iaik.tsp.TimeStampResp response)
Sets the (already validated) TimeStamp response. |
void |
setTSAPolicyID(iaik.asn1.ObjectID tsaPolicyID)
Sets the policyID of the TSA (if only some specific TSA (policy) shall be trusted). |
Methods inherited from class iaik.cms.SDSEncodeListener |
---|
getDigestAlgorithms, getOutputStream, getReport, setDigestAlgorithms, setOutputStream |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TimeStampListener(java.lang.String tsaUrl)
tsaUrl
- the URL of the TimeStamp responder to which to connect toMethod Detail |
---|
public void setStopOnTSPProcessingError(boolean stop)
stop
- whether to stop processing if the TSA response is invalid or
to continue without including a TimeStampToken attributepublic void setTSAPolicyID(iaik.asn1.ObjectID tsaPolicyID)
tsaPolicyID
- the TSA policy id to be trustedpublic void setTimeStampResponse(iaik.tsp.TimeStampResp response)
response
- the (already validated) TimeStampResponse containing the
TimeStampToken to be included as attribute into the SignedData messagepublic iaik.tsp.TimeStampResp getTimeStampResponse()
public iaik.tsp.TimeStampReq getTimeStampRequest()
public iaik.tsp.TspException getTspFailure()
finish
the SignedData
encoding (and not include a TimeStamp attribute) if an TSP processing error has
been occured, you may use this method to query if the TSP processing has been completed
successfully or not.
null
if the TSP processing has completed successfullyprotected void beforeComputeSignature(iaik.cms.SignedDataStream signedData) throws iaik.cms.CMSException
beforeComputeSignature
in class iaik.cms.SDSEncodeListener
iaik.cms.CMSException
protected void afterComputeSignature(iaik.cms.SignedDataStream signedData) throws iaik.cms.CMSException
afterComputeSignature
in class iaik.cms.SDSEncodeListener
signedData
- the SignedDataStream to which to add a SignatureTimeStampToken
iaik.cms.CMSException
- if the SignatureTimeStampToken cannot be added (e.g. because
the SignerInfo to which to add the SignatureTimeStampToken cannot be
verified, or an error occurs when connecting to the TSA, or parsing/verifying
the response)public void setDebugStream(java.io.OutputStream out)
out
- the stream to which debug information shall be written;
maybe null
for disabling debug output
|
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 |
![]() |