Package org.bouncycastle.tsp.cms
Class CMSTimeStampedData
- java.lang.Object
-
- org.bouncycastle.tsp.cms.CMSTimeStampedData
-
public class CMSTimeStampedData extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description CMSTimeStampedData(byte[] baseData)
CMSTimeStampedData(java.io.InputStream in)
CMSTimeStampedData(org.bouncycastle.asn1.cms.ContentInfo contentInfo)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CMSTimeStampedData
addTimeStamp(TimeStampToken token)
Return a new timeStampedData object with the additional token attached.byte[]
calculateNextHash(DigestCalculator calculator)
byte[]
getContent()
java.net.URI
getDataUri()
byte[]
getEncoded()
java.lang.String
getFileName()
java.lang.String
getMediaType()
DigestCalculator
getMessageImprintDigestCalculator(DigestCalculatorProvider calculatorProvider)
Returns an appropriately initialised digest calculator based on the message imprint algorithm described in the first time stamp in the TemporalData for this message.org.bouncycastle.asn1.cms.AttributeTable
getOtherMetaData()
TimeStampToken[]
getTimeStampTokens()
void
initialiseMessageImprintDigestCalculator(DigestCalculator calculator)
Initialise the passed in calculator with the MetaData for this message, if it is required as part of the initial message imprint calculation.void
validate(DigestCalculatorProvider calculatorProvider, byte[] dataDigest)
Validate the digests present in the TimeStampTokens contained in the CMSTimeStampedData.void
validate(DigestCalculatorProvider calculatorProvider, byte[] dataDigest, TimeStampToken timeStampToken)
Validate the passed in timestamp token against the tokens and data present in the message.
-
-
-
Constructor Detail
-
CMSTimeStampedData
public CMSTimeStampedData(org.bouncycastle.asn1.cms.ContentInfo contentInfo)
-
CMSTimeStampedData
public CMSTimeStampedData(java.io.InputStream in) throws java.io.IOException
- Throws:
java.io.IOException
-
CMSTimeStampedData
public CMSTimeStampedData(byte[] baseData) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
calculateNextHash
public byte[] calculateNextHash(DigestCalculator calculator) throws CMSException
- Throws:
CMSException
-
addTimeStamp
public CMSTimeStampedData addTimeStamp(TimeStampToken token) throws CMSException
Return a new timeStampedData object with the additional token attached.- Throws:
CMSException
-
getContent
public byte[] getContent()
-
getDataUri
public java.net.URI getDataUri() throws java.net.URISyntaxException
- Throws:
java.net.URISyntaxException
-
getFileName
public java.lang.String getFileName()
-
getMediaType
public java.lang.String getMediaType()
-
getOtherMetaData
public org.bouncycastle.asn1.cms.AttributeTable getOtherMetaData()
-
getTimeStampTokens
public TimeStampToken[] getTimeStampTokens() throws CMSException
- Throws:
CMSException
-
initialiseMessageImprintDigestCalculator
public void initialiseMessageImprintDigestCalculator(DigestCalculator calculator) throws CMSException
Initialise the passed in calculator with the MetaData for this message, if it is required as part of the initial message imprint calculation.- Parameters:
calculator
- the digest calculator to be initialised.- Throws:
CMSException
- if the MetaData is required and cannot be processed
-
getMessageImprintDigestCalculator
public DigestCalculator getMessageImprintDigestCalculator(DigestCalculatorProvider calculatorProvider) throws OperatorCreationException
Returns an appropriately initialised digest calculator based on the message imprint algorithm described in the first time stamp in the TemporalData for this message. If the metadata is required to be included in the digest calculation, the returned calculator will be pre-initialised.- Parameters:
calculatorProvider
- a provider of DigestCalculator objects.- Returns:
- an initialised digest calculator.
- Throws:
OperatorCreationException
- if the provider is unable to create the calculator.
-
validate
public void validate(DigestCalculatorProvider calculatorProvider, byte[] dataDigest) throws ImprintDigestInvalidException, CMSException
Validate the digests present in the TimeStampTokens contained in the CMSTimeStampedData.- Parameters:
calculatorProvider
- provider for digest calculatorsdataDigest
- the calculated data digest for the message- Throws:
ImprintDigestInvalidException
- if an imprint digest fails to compareCMSException
- if an exception occurs processing the message.
-
validate
public void validate(DigestCalculatorProvider calculatorProvider, byte[] dataDigest, TimeStampToken timeStampToken) throws ImprintDigestInvalidException, CMSException
Validate the passed in timestamp token against the tokens and data present in the message.- Parameters:
calculatorProvider
- provider for digest calculatorsdataDigest
- the calculated data digest for the message.timeStampToken
- the timestamp token of interest.- Throws:
ImprintDigestInvalidException
- if the token is not present in the message, or an imprint digest fails to compare.CMSException
- if an exception occurs processing the message.
-
getEncoded
public byte[] getEncoded() throws java.io.IOException
- Throws:
java.io.IOException
-
-