Package com.itextpdf.signatures
Class TSAClientBouncyCastle
java.lang.Object
com.itextpdf.signatures.TSAClientBouncyCastle
- All Implemented Interfaces:
-
ITSAClient
Time Stamp Authority Client interface implementation using Bouncy Castle org.bouncycastle.tsp package.
Created by Aiken Sam, 2006-11-15, refactored by Martin Brunecky, 07/15/2007 for ease of subclassing.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe default value for the hash algorithmstatic final intThe default value for token size estimation.protected StringHash algorithmprotected intEstimate of the received time stamp tokenprotected ITSAInfoBouncyCastleAn interface that allows you to inspect the timestamp info.protected StringTSA passwordprotected StringURL of the Time Stamp Authorityprotected StringTSA Username -
Constructor Summary
ConstructorsConstructorDescriptionCreates an instance of a TSAClient that will use BouncyCastle.TSAClientBouncyCastle(String url, String username, String password) Creates an instance of a TSAClient that will use BouncyCastle.TSAClientBouncyCastle(String url, String username, String password, int tokSzEstimate, String digestAlgorithm) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionGets the MessageDigest to digest the data imprintbyte[]getTimeStampToken(byte[] imprint) Get RFC 3161 timeStampToken.intGet the token size estimate.Gets the TSA request policy that will be used when retrieving timestamp token.protected byte[]getTSAResponse(byte[] requestBytes) Get timestamp token - communications layervoidsetTSAInfo(ITSAInfoBouncyCastle tsaInfo) voidsetTSAReqPolicy(String tsaReqPolicy) Sets the TSA request policy that will be used when retrieving timestamp token.
-
Field Details
-
DEFAULTHASHALGORITHM
The default value for the hash algorithm- See Also:
-
DEFAULTTOKENSIZE
public static final int DEFAULTTOKENSIZEThe default value for token size estimation.- See Also:
-
tsaURL
URL of the Time Stamp Authority -
tsaUsername
TSA Username -
tsaPassword
TSA password -
tsaInfo
An interface that allows you to inspect the timestamp info. -
tokenSizeEstimate
protected int tokenSizeEstimateEstimate of the received time stamp token -
digestAlgorithm
Hash algorithm
-
-
Constructor Details
-
TSAClientBouncyCastle
Creates an instance of a TSAClient that will use BouncyCastle.- Parameters:
-
url- String - Time Stamp Authority URL (i.e. "http://tsatest1.digistamp.com/TSA")
-
TSAClientBouncyCastle
Creates an instance of a TSAClient that will use BouncyCastle.- Parameters:
-
url- String - Time Stamp Authority URL (i.e. "http://tsatest1.digistamp.com/TSA") -
username- String - user(account) name -
password- String - password
-
TSAClientBouncyCastle
public TSAClientBouncyCastle(String url, String username, String password, int tokSzEstimate, String digestAlgorithm) Constructor. Note the token size estimate is updated by each call, as the token size is not likely to change (as long as we call the same TSA using the same imprint length).- Parameters:
-
url- Time Stamp Authority URL (i.e. "http://tsatest1.digistamp.com/TSA") -
username- user(account) name, optional -
password- password, optional if used in combination with username, the credentials will be used in basic authentication. Use only in combination with a https url to ensure encryption -
tokSzEstimate- estimated size of received time stamp token (DER encoded) -
digestAlgorithm- is a hash algorithm
-
-
Method Details
-
setTSAInfo
- Parameters:
-
tsaInfo- the tsaInfo to set
-
getTokenSizeEstimate
public int getTokenSizeEstimate()Get the token size estimate. Returned value reflects the result of the last succesfull call, padded- Specified by:
-
getTokenSizeEstimatein interfaceITSAClient - Returns:
- an estimate of the token size
-
getTSAReqPolicy
Gets the TSA request policy that will be used when retrieving timestamp token.- Returns:
-
policy id, or
nullif not set
-
setTSAReqPolicy
Sets the TSA request policy that will be used when retrieving timestamp token.- Parameters:
-
tsaReqPolicy- policy id
-
getMessageDigest
Gets the MessageDigest to digest the data imprint- Specified by:
-
getMessageDigestin interfaceITSAClient - Returns:
- the digest algorithm name
- Throws:
-
GeneralSecurityException- if digestAlgorithm doesn't match any known hash algorithm
-
getTimeStampToken
Get RFC 3161 timeStampToken. Method may return null indicating that timestamp should be skipped.- Specified by:
-
getTimeStampTokenin interfaceITSAClient - Parameters:
-
imprint- data imprint to be time-stamped - Returns:
- encoded, TSA signed data of the timeStampToken
- Throws:
-
IOException- if I/O error occurs -
AbstractTSPException- if the TSA response is malformed
-
getTSAResponse
Get timestamp token - communications layer- Parameters:
-
requestBytes- is a byte representation of TSA request - Returns:
- - byte[] - TSA response, raw bytes (RFC 3161 encoded)
- Throws:
-
IOException- if I/O issue occurs
-