Top Description Fields Constructors Methods
org.bouncycastle.tsp

public Class TimeStampTokenGenerator

extends Object
Class Inheritance
Imports
java.io.IOException, .OutputStream, java.math.BigInteger, java.text.SimpleDateFormat, java.util.ArrayList, .Collection, .Date, .Enumeration, .HashMap, .Iterator, .List, .Locale, .Map, .SimpleTimeZone, org.bouncycastle.asn1.ASN1Boolean, .ASN1Encoding, .ASN1GeneralizedTime, .ASN1Integer, .ASN1ObjectIdentifier, .LocaleUtil, org.bouncycastle.asn1.cms.AttributeTable, org.bouncycastle.asn1.ess.ESSCertID, .ESSCertIDv2, .SigningCertificate, .SigningCertificateV2, org.bouncycastle.asn1.oiw.OIWObjectIdentifiers, org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers, org.bouncycastle.asn1.tsp.Accuracy, .MessageImprint, .TSTInfo, org.bouncycastle.asn1.x509.AlgorithmIdentifier, .Extensions, .ExtensionsGenerator, .GeneralName, .GeneralNames, .IssuerSerial, org.bouncycastle.cert.X509CertificateHolder, org.bouncycastle.cms.CMSAttributeTableGenerationException, .CMSAttributeTableGenerator, .CMSException, .CMSProcessableByteArray, .CMSSignedData, .CMSSignedDataGenerator, .SignerInfoGenerator, org.bouncycastle.operator.DigestCalculator, org.bouncycastle.util.CollectionStore, .Store

Currently the class supports ESSCertID by if a digest calculator based on SHA1 is passed in, otherwise it uses ESSCertIDv2. In the event you need to pass both types, you will need to override the SignedAttributeGenerator for the SignerInfoGeneratorBuilder you are using. For the default for ESSCertIDv2 the code will look something like the following:
final ESSCertID essCertid = new ESSCertID(certHashSha1, issuerSerial);
final ESSCertIDv2 essCertidV2 = new ESSCertIDv2(certHashSha256, issuerSerial);

signerInfoGenBuilder.setSignedAttributeGenerator(new CMSAttributeTableGenerator()
{
    public AttributeTable getAttributes(Map parameters)
        throws CMSAttributeTableGenerationException
    {
        CMSAttributeTableGenerator attrGen = new DefaultSignedAttributeTableGenerator();

        AttributeTable table = attrGen.getAttributes(parameters);

        table = table.add(PKCSObjectIdentifiers.id_aa_signingCertificate, new SigningCertificate(essCertid));
        table = table.add(PKCSObjectIdentifiers.id_aa_signingCertificateV2, new SigningCertificateV2(essCertidV2));

        return table;
    }
});

Field Summary

Modifier and TypeField and Description
private int
private int
private int
private List<E>
private List<E>
private List<E>
private Locale
pack-priv boolean
private Map<K, V>
public static final int
R_HUNDREDTHS_OF_SECONDS

Create time-stamps with a resolution of 1 hundredth of a second.

public static final int
R_MICROSECONDS

Deprecated use R_HUNDREDTHS_OF_SECONDS - this field will be deleted!!
public static final int
R_MILLISECONDS

Create time-stamps with a resolution of 1 millisecond.

public static final int
R_SECONDS

Create time-stamps with a resolution of 1 second (the default).

public static final int
R_TENTHS_OF_SECONDS

Create time-stamps with a resolution of 1 tenth of a second.

private int
private SignerInfoGenerator
pack-priv GeneralName
private ASN1ObjectIdentifier

Constructor Summary

AccessConstructor and Description
public
TimeStampTokenGenerator(final SignerInfoGenerator
the generator for the signer we are using.
signerInfoGen
,
DigestCalculator
calculator for to use for digest of certificate.
digestCalculator
,
ASN1ObjectIdentifier
tasPolicy to send.
tsaPolicy
)

Basic Constructor - set up a calculator based on signerInfoGen with a ESSCertID calculated from the signer's associated certificate using the sha1DigestCalculator.

public
TimeStampTokenGenerator(final SignerInfoGenerator
the generator for the signer we are using.
signerInfoGen
,
DigestCalculator
calculator for to use for digest of certificate.
digestCalculator
,
ASN1ObjectIdentifier
tasPolicy to send.
tsaPolicy
,
boolean
should issuerSerial be included in the ESSCertIDs, true if yes, by default false.
isIssuerSerialIncluded
)

Basic Constructor - set up a calculator based on signerInfoGen with a ESSCertID calculated from the signer's associated certificate using the sha1DigestCalculator.

Method Summary

Modifier and TypeMethod and Description
public void
addAttributeCertificates(Store<T>
a Store containing X509AttributeCertificate objects.
attrStore
)

public void
addCertificates(Store<T>
a Store containing X509CertificateHolder objects
certStore
)

Add the store of X509 Certificates to the generator.

public void
addCRLs(Store<T>
a Store containing X509CRLHolder objects.
crlStore
)

public void
addOtherRevocationInfo(ASN1ObjectIdentifier
the OID specifying the format of the otherRevocationInfo data.
otherRevocationInfoFormat
,
Store<T>
a Store of otherRevocationInfo data to add.
otherRevocationInfos
)

Add a Store of otherRevocationData to the CRL set to be included with the generated TimeStampToken.

private ASN1GeneralizedTime
public TimeStampToken

Returns:

a TimeStampToken
generate
(TimeStampRequest
the originating request.
request
,
BigInteger
serial number for the TimeStampToken
serialNumber
,
Date
token generation time.
genTime
)

Generate a TimeStampToken for the passed in request and serialNumber marking it with the passed in genTime.

public TimeStampToken

Returns:

a TimeStampToken
generate
(TimeStampRequest
the originating request.
request
,
BigInteger
serial number for the TimeStampToken
serialNumber
,
Date
token generation time.
genTime
,
Extensions
extra extensions to be added to the response token.
additionalExtensions
)

Generate a TimeStampToken for the passed in request and serialNumber marking it with the passed in genTime.

public void
setAccuracyMicros(int accuracyMicros)

public void
setAccuracyMillis(int accuracyMillis)

public void
setAccuracySeconds(int accuracySeconds)

public void
setLocale(Locale
a locale to use for converting system time into a GeneralizedTime.
locale
)

Set a Locale for time creation - you may need to use this if the default locale doesn't use a Gregorian calender so that the GeneralizedTime produced is compatible with other ASN.1 implementations.

public void
setOrdering(boolean ordering)

public void
setResolution(int
resolution of timestamps to be produced.
resolution
)

Set the resolution of the time stamp - R_SECONDS (the default), R_TENTH_OF_SECONDS, R_MICROSECONDS, R_MILLISECONDS

public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

accuracyMicrosback to summary
private int accuracyMicros
accuracyMillisback to summary
private int accuracyMillis
accuracySecondsback to summary
private int accuracySeconds
attrCertsback to summary
private List<E> attrCerts
certsback to summary
private List<E> certs
crlsback to summary
private List<E> crls
localeback to summary
private Locale locale
orderingback to summary
pack-priv boolean ordering
otherRevocback to summary
private Map<K, V> otherRevoc
R_HUNDREDTHS_OF_SECONDSback to summary
public static final int R_HUNDREDTHS_OF_SECONDS

Create time-stamps with a resolution of 1 hundredth of a second.

R_MICROSECONDSback to summary
public static final int R_MICROSECONDS

Deprecated

use R_HUNDREDTHS_OF_SECONDS - this field will be deleted!!

R_MILLISECONDSback to summary
public static final int R_MILLISECONDS

Create time-stamps with a resolution of 1 millisecond.

R_SECONDSback to summary
public static final int R_SECONDS

Create time-stamps with a resolution of 1 second (the default).

R_TENTHS_OF_SECONDSback to summary
public static final int R_TENTHS_OF_SECONDS

Create time-stamps with a resolution of 1 tenth of a second.

resolutionback to summary
private int resolution
signerInfoGenback to summary
private SignerInfoGenerator signerInfoGen
tsaback to summary
pack-priv GeneralName tsa
tsaPolicyOIDback to summary
private ASN1ObjectIdentifier tsaPolicyOID

Constructor Detail

TimeStampTokenGeneratorback to summary
public TimeStampTokenGenerator(final SignerInfoGenerator signerInfoGen, DigestCalculator digestCalculator, ASN1ObjectIdentifier tsaPolicy) throws IllegalArgumentException, TSPException

Basic Constructor - set up a calculator based on signerInfoGen with a ESSCertID calculated from the signer's associated certificate using the sha1DigestCalculator. If alternate values are required for id-aa-signingCertificate they should be added to the signerInfoGen object before it is passed in, otherwise a standard digest based value will be added.

Parameters
signerInfoGen:SignerInfoGenerator

the generator for the signer we are using.

digestCalculator:DigestCalculator

calculator for to use for digest of certificate.

tsaPolicy:ASN1ObjectIdentifier

tasPolicy to send.

Exceptions
IllegalArgumentException:
if calculator is not SHA-1 or there is no associated certificate for the signer,
TSPException:
if the signer certificate cannot be processed.
TimeStampTokenGeneratorback to summary
public TimeStampTokenGenerator(final SignerInfoGenerator signerInfoGen, DigestCalculator digestCalculator, ASN1ObjectIdentifier tsaPolicy, boolean isIssuerSerialIncluded) throws IllegalArgumentException, TSPException

Basic Constructor - set up a calculator based on signerInfoGen with a ESSCertID calculated from the signer's associated certificate using the sha1DigestCalculator. If alternate values are required for id-aa-signingCertificate they should be added to the signerInfoGen object before it is passed in, otherwise a standard digest based value will be added.

Parameters
signerInfoGen:SignerInfoGenerator

the generator for the signer we are using.

digestCalculator:DigestCalculator

calculator for to use for digest of certificate.

tsaPolicy:ASN1ObjectIdentifier

tasPolicy to send.

isIssuerSerialIncluded:boolean

should issuerSerial be included in the ESSCertIDs, true if yes, by default false.

Exceptions
IllegalArgumentException:
if calculator is not SHA-1 or there is no associated certificate for the signer,
TSPException:
if the signer certificate cannot be processed.

Method Detail

addAttributeCertificatesback to summary
public void addAttributeCertificates(Store<T> attrStore)
Parameters
attrStore:Store<T>

a Store containing X509AttributeCertificate objects.

addCertificatesback to summary
public void addCertificates(Store<T> certStore)

Add the store of X509 Certificates to the generator.

Parameters
certStore:Store<T>

a Store containing X509CertificateHolder objects

addCRLsback to summary
public void addCRLs(Store<T> crlStore)
Parameters
crlStore:Store<T>

a Store containing X509CRLHolder objects.

addOtherRevocationInfoback to summary
public void addOtherRevocationInfo(ASN1ObjectIdentifier otherRevocationInfoFormat, Store<T> otherRevocationInfos)

Add a Store of otherRevocationData to the CRL set to be included with the generated TimeStampToken.

Parameters
otherRevocationInfoFormat:ASN1ObjectIdentifier

the OID specifying the format of the otherRevocationInfo data.

otherRevocationInfos:Store<T>

a Store of otherRevocationInfo data to add.

createGeneralizedTimeback to summary
private ASN1GeneralizedTime createGeneralizedTime(Date time) throws TSPException
generateback to summary
public TimeStampToken generate(TimeStampRequest request, BigInteger serialNumber, Date genTime) throws TSPException

Generate a TimeStampToken for the passed in request and serialNumber marking it with the passed in genTime.

Parameters
request:TimeStampRequest

the originating request.

serialNumber:BigInteger

serial number for the TimeStampToken

genTime:Date

token generation time.

Returns:TimeStampToken

a TimeStampToken

generateback to summary
public TimeStampToken generate(TimeStampRequest request, BigInteger serialNumber, Date genTime, Extensions additionalExtensions) throws TSPException

Generate a TimeStampToken for the passed in request and serialNumber marking it with the passed in genTime.

Parameters
request:TimeStampRequest

the originating request.

serialNumber:BigInteger

serial number for the TimeStampToken

genTime:Date

token generation time.

additionalExtensions:Extensions

extra extensions to be added to the response token.

Returns:TimeStampToken

a TimeStampToken

setAccuracyMicrosback to summary
public void setAccuracyMicros(int accuracyMicros)
setAccuracyMillisback to summary
public void setAccuracyMillis(int accuracyMillis)
setAccuracySecondsback to summary
public void setAccuracySeconds(int accuracySeconds)
setLocaleback to summary
public void setLocale(Locale locale)

Set a Locale for time creation - you may need to use this if the default locale doesn't use a Gregorian calender so that the GeneralizedTime produced is compatible with other ASN.1 implementations.

Parameters
locale:Locale

a locale to use for converting system time into a GeneralizedTime.

setOrderingback to summary
public void setOrdering(boolean ordering)
setResolutionback to summary
public void setResolution(int resolution)

Set the resolution of the time stamp - R_SECONDS (the default), R_TENTH_OF_SECONDS, R_MICROSECONDS, R_MILLISECONDS

Parameters
resolution:int

resolution of timestamps to be produced.

setTSAback to summary
public void setTSA(GeneralName tsa)