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
-
Constructor Summary
ModifierConstructorDescriptionprotected
Default 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 givenPrivateKey
and the correspondingcertificateToken
andcertificateChain
KeyEntityTSPSource
(PrivateKey privateKey, X509Certificate certificate, List<X509Certificate> certificateChain) Constructor to instantiate KeyEntityTSPSource with the givenPrivateKey
and the correspondingcertificate
andcertificateChain
-
Method Summary
Modifier and TypeMethodDescriptionprotected org.bouncycastle.tsp.TimeStampResponse
buildResponse
(org.bouncycastle.tsp.TimeStampResponseGenerator responseGenerator, org.bouncycastle.tsp.TimeStampRequest request, BigInteger timeStampSerialNumber, Date productionTime) Generates a time-stamp responseprotected org.bouncycastle.tsp.TimeStampRequest
createRequest
(DigestAlgorithm digestAlgorithm, byte[] digest) Creates a request for a time-stamp token generationprotected org.bouncycastle.tsp.TimeStampResponse
generateResponse
(org.bouncycastle.tsp.TimeStampRequest request, DigestAlgorithm digestAlgorithm) This method generates a timestamp responseprotected Date
Gets the production time of the time-stampprotected SignatureAlgorithm
Returns the target signature algorithm to be used to time-stamp generationprotected org.bouncycastle.cms.CMSAttributeTableGenerator
getSignedAttributeGenerator
(Date getTime) Returns generator for signed attributes of a time-stampprotected TimestampBinary
getTimestampBinary
(org.bouncycastle.tsp.TimeStampResponse response) Returns time-stamp binary from the obtainedresponse
getTimeStampResponse
(DigestAlgorithm digestAlgorithm, byte[] digest) Gets a TimeStampResponse relevant to the provided digestprotected BigInteger
Generates a serial number of the produced timestamp tokenprotected org.bouncycastle.tsp.TimeStampResponseGenerator
initResponseGenerator
(DigestAlgorithm digestAlgorithm, Date getTime) This method initializes theTimeStampResponseGenerator
void
setAcceptedDigestAlgorithms
(Collection<DigestAlgorithm> digestAlgorithms) Sets a collection of digest algorithms to be accepted within timestamp request Default: SHA-224, SHA-256, SHA-384, SHA-512void
setCertificate
(X509Certificate certificate) Sets a time-stamp issuer certificatevoid
setCertificateChain
(List<X509Certificate> certificateChain) Sets a certificate chain to be embedded within the time-stamp tokenvoid
setDigestAlgorithm
(DigestAlgorithm digestAlgorithm) Sets the digest algorithm of the signature of the generated time-stamp token Default: DigestAlgorithm.SHA256void
setEncryptionAlgorithm
(EncryptionAlgorithm encryptionAlgorithm) Sets the encryption algorithm to be used on time-stamp's signature generation.void
setMaskGenerationFunction
(MaskGenerationFunction maskGenerationFunction) Deprecated.since DSS 6.1.void
setPrivateKey
(PrivateKey privateKey) Sets the private key used to sign the time-stamp tokenvoid
setProductionTime
(Date productionTime) Sets a production time of the timestamp.void
setTsaPolicy
(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
-String
representing the type of the key storeksPassword
- char array representing a password from the key storealias
-String
alias 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
-String
representing the path to the key storeksType
-String
representing the type of the key storeksPassword
- char array representing a password from the key storealias
-String
alias 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
-File
key store fileksType
-String
representing the type of the key storeksPassword
- char array representing a password from the key storealias
-String
alias 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
-InputStream
representing the key store contentksType
-String
representing the type of the key storeksPassword
- char array representing a password from the key storealias
-String
alias 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 givenPrivateKey
and the correspondingcertificateToken
andcertificateChain
- Parameters:
privateKey
-PrivateKey
representing a key t be used to sing the time-stamp tokencertificateToken
-CertificateToken
representing a time-stamp issuer certificate associated with theprivateKey
certificateChain
- a list ofCertificateToken
s representing a certificate chain forcertificateToken
to be added within the time-stamp
-
KeyEntityTSPSource
public KeyEntityTSPSource(PrivateKey privateKey, X509Certificate certificate, List<X509Certificate> certificateChain) Constructor to instantiate KeyEntityTSPSource with the givenPrivateKey
and the correspondingcertificate
andcertificateChain
- Parameters:
privateKey
-PrivateKey
representing a key t be used to sing the time-stamp tokencertificate
-X509Certificate
representing a time-stamp issuer certificate associated with theprivateKey
certificateChain
- a list ofX509Certificate
s representing a certificate chain forcertificateToken
to 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 ofCertificateToken
s
-
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 ofDigestAlgorithm
s
-
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 usesetEncryptionAlgorithm
method 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:TSPSource
Gets a TimeStampResponse relevant to the provided digest- Specified by:
getTimeStampResponse
in interfaceTSPSource
- Parameters:
digestAlgorithm
- the used digest algorithmdigest
- the computed digest to be timestamped- Returns:
TimestampBinary
binary 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
-DigestAlgorithm
to 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:
String
signature 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
-TimeStampRequest
digestAlgorithm
-DigestAlgorithm
used 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
-DigestAlgorithm
used to generate the message-imprintgetTime
-Date
production 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
-TimeStampResponseGenerator
request
-TimeStampRequest
timeStampSerialNumber
-BigInteger
productionTime
-Date
representing 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:
BigInteger
serial 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
-