public class TimeStampToken
extends java.lang.Object
SignedData (CMS) structure, with
content type id-ct-TSTInfo, signed by the TSA. Provides access to the embedded
TimeStampTokenInfo and the means to verify the token against the signing certificate
(see validate(SignerInformationVerifier)).
Construction checks the token's structure: the content type is id-ct-TSTInfo, there is exactly one
signer, a signing-certificate signed attribute is present, and a signing-time signed attribute, if
present, agrees with the TSTInfo genTime to within the token's accuracy (plus a one minute allowance).
The last check can be disabled with Properties.TSP_ALLOW_INCONSISTENT_SIGNING_TIME.
| Constructor and Description |
|---|
TimeStampToken(CMSSignedData signedData) |
TimeStampToken(org.bouncycastle.asn1.cms.ContentInfo contentInfo) |
| Modifier and Type | Method and Description |
|---|---|
org.bouncycastle.util.Store<X509AttributeCertificateHolder> |
getAttributeCertificates() |
org.bouncycastle.util.Store<X509CertificateHolder> |
getCertificates() |
org.bouncycastle.util.Store<X509CRLHolder> |
getCRLs() |
byte[] |
getEncoded()
Return a ASN.1 encoded byte stream representing the encoded object.
|
byte[] |
getEncoded(java.lang.String encoding)
return the ASN.1 encoded representation of this object using the specified encoding.
|
SignerId |
getSID() |
org.bouncycastle.asn1.cms.AttributeTable |
getSignedAttributes() |
TimeStampTokenInfo |
getTimeStampInfo() |
org.bouncycastle.asn1.cms.AttributeTable |
getUnsignedAttributes() |
boolean |
isSignatureValid(SignerInformationVerifier sigVerifier)
Return true if the signature on time stamp token is valid.
|
CMSSignedData |
toCMSSignedData()
Return the underlying CMSSignedData object.
|
void |
validate(SignerInformationVerifier sigVerifier)
Validate the time stamp token.
|
void |
validate(SignerInformationVerifier sigVerifier,
java.util.Set allowedImprintAlgorithms)
Validate the time stamp token, as for
validate(SignerInformationVerifier), but accepting a
message imprint calculated with any of the passed in hash algorithms. |
public TimeStampToken(org.bouncycastle.asn1.cms.ContentInfo contentInfo)
throws TSPException,
java.io.IOException
TSPExceptionjava.io.IOExceptionpublic TimeStampToken(CMSSignedData signedData) throws TSPException, java.io.IOException
TSPExceptionjava.io.IOExceptionpublic TimeStampTokenInfo getTimeStampInfo()
public SignerId getSID()
public org.bouncycastle.asn1.cms.AttributeTable getSignedAttributes()
public org.bouncycastle.asn1.cms.AttributeTable getUnsignedAttributes()
public org.bouncycastle.util.Store<X509CertificateHolder> getCertificates()
public org.bouncycastle.util.Store<X509CRLHolder> getCRLs()
public org.bouncycastle.util.Store<X509AttributeCertificateHolder> getAttributeCertificates()
public void validate(SignerInformationVerifier sigVerifier) throws TSPException, TSPValidationException
To be valid the token must be signed by the passed in certificate and the certificate must be the one referred to by the SigningCertificate attribute included in the hashed attributes of the token. The certificate must also have the ExtendedKeyUsageExtension with only KeyPurposeId.id_kp_timeStamping and have been valid at the time the timestamp was created.
The message imprint must also use a hash algorithm in TSPAlgorithms.ALLOWED, or in the list
given by Properties.TSP_ALLOWED_IMPRINT_ALGORITHMS if it is set.
A successful call to validate means all the above are true.
sigVerifier - the content verifier create the objects required to verify the CMS object in the timestamp.TSPException - if an exception occurs in processing the token, or the imprint algorithm property
names an unknown digest.TSPValidationException - if the certificate or signature fail to be valid.java.lang.IllegalArgumentException - if the sigVerifierProvider has no associated certificate.public void validate(SignerInformationVerifier sigVerifier, java.util.Set allowedImprintAlgorithms) throws TSPException, TSPValidationException
validate(SignerInformationVerifier), but accepting a
message imprint calculated with any of the passed in hash algorithms.sigVerifier - the content verifier create the objects required to verify the CMS object in the timestamp.allowedImprintAlgorithms - the OIDs of the hash algorithms acceptable for the message imprint.TSPException - if an exception occurs in processing the token.TSPValidationException - if the imprint algorithm is not allowed (failure code badAlg), or the
certificate or signature fail to be valid.java.lang.IllegalArgumentException - if the sigVerifierProvider has no associated certificate.public boolean isSignatureValid(SignerInformationVerifier sigVerifier) throws TSPException
Note: this is a much weaker proof of correctness than calling validate().
sigVerifier - the content verifier create the objects required to verify the CMS object in the timestamp.TSPException - if the signature cannot be processed or the provider cannot match the algorithm.public CMSSignedData toCMSSignedData()
public byte[] getEncoded()
throws java.io.IOException
java.io.IOException - if encoding fails.public byte[] getEncoded(java.lang.String encoding)
throws java.io.IOException
encoding - the ASN.1 encoding format to use ("BER", "DL", or "DER").java.io.IOException