Package eu.europa.esig.dss.spi.x509.tsp
Class KeyEntityTSPSource
java.lang.Object
eu.europa.esig.dss.spi.x509.tsp.KeyEntityTSPSource
- All Implemented Interfaces:
TSPSource,Serializable
- Direct Known Subclasses:
PKITSPSource
TSPSource implementation allowing to configure issuance of a time-stamp using a local
KeyStore- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDefault constructor instantiating empty configuration of the KeyEntityTSPSourceKeyEntityTSPSource(byte[] ksContent, String ksType, char[] ksPassword, String alias, char[] keyEntryPassword) Constructor instantiating the key store content and key entry dataKeyEntityTSPSource(File ksFile, String ksType, char[] ksPassword, String alias, char[] keyEntryPassword) Constructor instantiating the key store File and key entry dataKeyEntityTSPSource(InputStream ksIs, String ksType, char[] ksPassword, String alias, char[] keyEntryPassword) Constructor instantiating the key store InputStream and key entry dataKeyEntityTSPSource(String ksPath, String ksType, char[] ksPassword, String alias, char[] keyEntryPassword) Constructor instantiating the key store path location and key entry dataKeyEntityTSPSource(KeyStore keyStore, String alias, char[] keyEntryPassword) Constructor instantiating the key store and key entry dataKeyEntityTSPSource(PrivateKey privateKey, CertificateToken certificateToken, List<CertificateToken> certificateChain) Constructor to instantiate KeyEntityTSPSource with the givenPrivateKeyand the correspondingcertificateTokenandcertificateChainKeyEntityTSPSource(PrivateKey privateKey, X509Certificate certificate, List<X509Certificate> certificateChain) Constructor to instantiate KeyEntityTSPSource with the givenPrivateKeyand the correspondingcertificateandcertificateChain -
Method Summary
Modifier and TypeMethodDescriptionprotected org.bouncycastle.tsp.TimeStampResponsebuildResponse(org.bouncycastle.tsp.TimeStampResponseGenerator responseGenerator, org.bouncycastle.tsp.TimeStampRequest request, BigInteger timeStampSerialNumber, Date productionTime) Generates a time-stamp responseprotected org.bouncycastle.tsp.TimeStampRequestcreateRequest(DigestAlgorithm digestAlgorithm, byte[] digest) Creates a request for a time-stamp token generationprotected org.bouncycastle.tsp.TimeStampResponsegenerateResponse(org.bouncycastle.tsp.TimeStampRequest request, DigestAlgorithm digestAlgorithm) This method generates a timestamp responseprotected DateGets the production time of the time-stampprotected SignatureAlgorithmReturns the target signature algorithm to be used to time-stamp generationprotected org.bouncycastle.cms.CMSAttributeTableGeneratorgetSignedAttributeGenerator(Date getTime) Returns generator for signed attributes of a time-stampprotected TimestampBinarygetTimestampBinary(org.bouncycastle.tsp.TimeStampResponse response) Returns time-stamp binary from the obtainedresponsegetTimeStampResponse(DigestAlgorithm digestAlgorithm, byte[] digest) Gets a TimeStampResponse relevant to the provided digestprotected BigIntegerGenerates a serial number of the produced timestamp tokenprotected org.bouncycastle.tsp.TimeStampResponseGeneratorinitResponseGenerator(DigestAlgorithm digestAlgorithm, Date getTime) This method initializes theTimeStampResponseGeneratorvoidsetAcceptedDigestAlgorithms(Collection<DigestAlgorithm> digestAlgorithms) Sets a collection of digest algorithms to be accepted within timestamp request Default: SHA-224, SHA-256, SHA-384, SHA-512voidsetCertificate(X509Certificate certificate) Sets a time-stamp issuer certificatevoidsetCertificateChain(List<X509Certificate> certificateChain) Sets a certificate chain to be embedded within the time-stamp tokenvoidsetDigestAlgorithm(DigestAlgorithm digestAlgorithm) Sets the digest algorithm of the signature of the generated time-stamp token Default: DigestAlgorithm.SHA256voidsetEncryptionAlgorithm(EncryptionAlgorithm encryptionAlgorithm) Sets the encryption algorithm to be used on time-stamp's signature generation.voidsetMaskGenerationFunction(MaskGenerationFunction maskGenerationFunction) Deprecated.since DSS 6.1.voidsetPrivateKey(PrivateKey privateKey) Sets the private key used to sign the time-stamp tokenvoidsetProductionTime(Date productionTime) Sets a production time of the timestamp.voidsetTsaPolicy(String tsaPolicy) Sets the TSA policy NOTE: The property is mandatory for TimeStampToken generation.
-
Field Details
-
productionTime
The static production date of the timestamp
-
-
Constructor Details
-
KeyEntityTSPSource
protected KeyEntityTSPSource()Default constructor instantiating empty configuration of the KeyEntityTSPSource -
KeyEntityTSPSource
public KeyEntityTSPSource(byte[] ksContent, String ksType, char[] ksPassword, String alias, char[] keyEntryPassword) Constructor instantiating the key store content and key entry data- Parameters:
ksContent- byte array representing the key store contentksType-Stringrepresenting the type of the key storeksPassword- char array representing a password from the key storealias-Stringalias of the key entry to be used for timestamp signingkeyEntryPassword- char array representing a password from the key entry
-
KeyEntityTSPSource
public KeyEntityTSPSource(String ksPath, String ksType, char[] ksPassword, String alias, char[] keyEntryPassword) throws IOException Constructor instantiating the key store path location and key entry data- Parameters:
ksPath-Stringrepresenting the path to the key storeksType-Stringrepresenting the type of the key storeksPassword- char array representing a password from the key storealias-Stringalias of the key entry to be used for timestamp signingkeyEntryPassword- char array representing a password from the key entry- Throws:
IOException- if not able to load the key store file
-
KeyEntityTSPSource
public KeyEntityTSPSource(File ksFile, String ksType, char[] ksPassword, String alias, char[] keyEntryPassword) throws IOException Constructor instantiating the key store File and key entry data- Parameters:
ksFile-Filekey store fileksType-Stringrepresenting the type of the key storeksPassword- char array representing a password from the key storealias-Stringalias of the key entry to be used for timestamp signingkeyEntryPassword- char array representing a password from the key entry- Throws:
IOException- if not able to load the key store file
-
KeyEntityTSPSource
public KeyEntityTSPSource(InputStream ksIs, String ksType, char[] ksPassword, String alias, char[] keyEntryPassword) Constructor instantiating the key store InputStream and key entry data- Parameters:
ksIs-InputStreamrepresenting the key store contentksType-Stringrepresenting the type of the key storeksPassword- char array representing a password from the key storealias-Stringalias of the key entry to be used for timestamp signingkeyEntryPassword- char array representing a password from the key entry
-
KeyEntityTSPSource
Constructor instantiating the key store and key entry data -
KeyEntityTSPSource
public KeyEntityTSPSource(PrivateKey privateKey, CertificateToken certificateToken, List<CertificateToken> certificateChain) Constructor to instantiate KeyEntityTSPSource with the givenPrivateKeyand the correspondingcertificateTokenandcertificateChain- Parameters:
privateKey-PrivateKeyrepresenting a key t be used to sing the time-stamp tokencertificateToken-CertificateTokenrepresenting a time-stamp issuer certificate associated with theprivateKeycertificateChain- a list ofCertificateTokens representing a certificate chain forcertificateTokento be added within the time-stamp
-
KeyEntityTSPSource
public KeyEntityTSPSource(PrivateKey privateKey, X509Certificate certificate, List<X509Certificate> certificateChain) Constructor to instantiate KeyEntityTSPSource with the givenPrivateKeyand the correspondingcertificateandcertificateChain- Parameters:
privateKey-PrivateKeyrepresenting a key t be used to sing the time-stamp tokencertificate-X509Certificaterepresenting a time-stamp issuer certificate associated with theprivateKeycertificateChain- a list ofX509Certificates representing a certificate chain forcertificateTokento be added within the time-stamp
-
-
Method Details
-
setPrivateKey
Sets the private key used to sign the time-stamp token- Parameters:
privateKey-PrivateKey
-
setCertificate
Sets a time-stamp issuer certificate- Parameters:
certificate-X509Certificate
-
setCertificateChain
Sets a certificate chain to be embedded within the time-stamp token- Parameters:
certificateChain- a list ofCertificateTokens
-
setTsaPolicy
-
setAcceptedDigestAlgorithms
Sets a collection of digest algorithms to be accepted within timestamp request Default: SHA-224, SHA-256, SHA-384, SHA-512- Parameters:
digestAlgorithms- a collection ofDigestAlgorithms
-
getProductionTime
-
setProductionTime
-
setDigestAlgorithm
Sets the digest algorithm of the signature of the generated time-stamp token Default: DigestAlgorithm.SHA256- Parameters:
digestAlgorithm-DigestAlgorithm
-
setEncryptionAlgorithm
Sets the encryption algorithm to be used on time-stamp's signature generation. NOTE: the encryptionAlgorithm, when defined, shall be compatible with the encryption algorithm used by the target key!- Parameters:
encryptionAlgorithm-EncryptionAlgorithm
-
setMaskGenerationFunction
Deprecated.since DSS 6.1. Please usesetEncryptionAlgorithmmethod to specify RSA (none MGF) or RSASSA-PSS (MGF1) algorithmSets the mask generation function to be applied on a time-stamp signing. NOTE: the mask generation function should be compatible with the given encryption algorithm!- Parameters:
maskGenerationFunction-MaskGenerationFunction
-
getTimeStampResponse
Description copied from interface:TSPSourceGets a TimeStampResponse relevant to the provided digest- Specified by:
getTimeStampResponsein interfaceTSPSource- Parameters:
digestAlgorithm- the used digest algorithmdigest- the computed digest to be timestamped- Returns:
TimestampBinarybinary of a signed timestamp token
-
createRequest
protected org.bouncycastle.tsp.TimeStampRequest createRequest(DigestAlgorithm digestAlgorithm, byte[] digest) Creates a request for a time-stamp token generation- Parameters:
digestAlgorithm-DigestAlgorithmto be used to compute hash to be time-stampeddigest- byte array representing hash to be time-stamped- Returns:
TimeStampRequest
-
getSignatureAlgorithm
Returns the target signature algorithm to be used to time-stamp generation- Returns:
Stringsignature algorithm name
-
generateResponse
protected org.bouncycastle.tsp.TimeStampResponse generateResponse(org.bouncycastle.tsp.TimeStampRequest request, DigestAlgorithm digestAlgorithm) throws org.bouncycastle.tsp.TSPException This method generates a timestamp response- Parameters:
request-TimeStampRequestdigestAlgorithm-DigestAlgorithmused to generate the time-stamp- Returns:
TimeStampResponse- Throws:
org.bouncycastle.tsp.TSPException- if an error occurs during the timestamp response generation
-
initResponseGenerator
protected org.bouncycastle.tsp.TimeStampResponseGenerator initResponseGenerator(DigestAlgorithm digestAlgorithm, Date getTime) This method initializes theTimeStampResponseGenerator- Parameters:
digestAlgorithm-DigestAlgorithmused to generate the message-imprintgetTime-Dateproduction time of the time-stamp- Returns:
TimeStampResponseGenerator
-
getSignedAttributeGenerator
-
buildResponse
protected org.bouncycastle.tsp.TimeStampResponse buildResponse(org.bouncycastle.tsp.TimeStampResponseGenerator responseGenerator, org.bouncycastle.tsp.TimeStampRequest request, BigInteger timeStampSerialNumber, Date productionTime) throws org.bouncycastle.tsp.TSPException Generates a time-stamp response- Parameters:
responseGenerator-TimeStampResponseGeneratorrequest-TimeStampRequesttimeStampSerialNumber-BigIntegerproductionTime-Daterepresenting a time-stamp's generation time- Returns:
TimeStampResponse- Throws:
org.bouncycastle.tsp.TSPException- if an error occurs on time-stamp generation
-
getTimeStampSerialNumber
Generates a serial number of the produced timestamp token- Returns:
BigIntegerserial number
-
getTimestampBinary
protected TimestampBinary getTimestampBinary(org.bouncycastle.tsp.TimeStampResponse response) throws IOException Returns time-stamp binary from the obtainedresponse- Parameters:
response-TimeStampResponse- Returns:
TimestampBinary- Throws:
IOException- if en error occurs on time-stamp binaries extraction
-