Package com.itextpdf.text.pdf.security
Class TSAClientBouncyCastle
- java.lang.Object
-
- com.itextpdf.text.pdf.security.TSAClientBouncyCastle
-
- All Implemented Interfaces:
TSAClient
public class TSAClientBouncyCastle extends Object implements TSAClient
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.
- Since:
- 2.1.6
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULTHASHALGORITHM
The default value for the hash algorithmstatic int
DEFAULTTOKENSIZE
The default value for the hash algorithmprotected String
digestAlgorithm
Hash algorithmprotected int
tokenSizeEstimate
Estimate of the received time stamp tokenprotected TSAInfoBouncyCastle
tsaInfo
An interface that allows you to inspect the timestamp info.protected String
tsaPassword
TSA passwordprotected String
tsaURL
URL of the Time Stamp Authorityprotected String
tsaUsername
TSA Username
-
Constructor Summary
Constructors Constructor Description TSAClientBouncyCastle(String url)
Creates 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MessageDigest
getMessageDigest()
Gets the MessageDigest to digest the data imprintbyte[]
getTimeStampToken(byte[] imprint)
Get RFC 3161 timeStampToken.int
getTokenSizeEstimate()
Get the token size estimate.String
getTSAReqPolicy()
protected byte[]
getTSAResponse(byte[] requestBytes)
Get timestamp token - communications layervoid
setTSAInfo(TSAInfoBouncyCastle tsaInfo)
void
setTSAReqPolicy(String tsaReqPolicy)
-
-
-
Field Detail
-
tsaURL
protected String tsaURL
URL of the Time Stamp Authority
-
tsaUsername
protected String tsaUsername
TSA Username
-
tsaPassword
protected String tsaPassword
TSA password
-
tsaInfo
protected TSAInfoBouncyCastle tsaInfo
An interface that allows you to inspect the timestamp info.
-
DEFAULTTOKENSIZE
public static final int DEFAULTTOKENSIZE
The default value for the hash algorithm- See Also:
- Constant Field Values
-
tokenSizeEstimate
protected int tokenSizeEstimate
Estimate of the received time stamp token
-
DEFAULTHASHALGORITHM
public static final String DEFAULTHASHALGORITHM
The default value for the hash algorithm- See Also:
- Constant Field Values
-
digestAlgorithm
protected String digestAlgorithm
Hash algorithm
-
-
Constructor Detail
-
TSAClientBouncyCastle
public TSAClientBouncyCastle(String url)
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
public TSAClientBouncyCastle(String url, String username, String password)
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) namepassword
- 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
- String - Time Stamp Authority URL (i.e. "http://tsatest1.digistamp.com/TSA")username
- String - user(account) namepassword
- String - passwordtokSzEstimate
- int - estimated size of received time stamp token (DER encoded)
-
-
Method Detail
-
setTSAInfo
public void setTSAInfo(TSAInfoBouncyCastle tsaInfo)
- 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:
getTokenSizeEstimate
in interfaceTSAClient
- Returns:
- an estimate of the token size
-
getTSAReqPolicy
public String getTSAReqPolicy()
-
setTSAReqPolicy
public void setTSAReqPolicy(String tsaReqPolicy)
-
getMessageDigest
public MessageDigest getMessageDigest() throws GeneralSecurityException
Gets the MessageDigest to digest the data imprint- Specified by:
getMessageDigest
in interfaceTSAClient
- Returns:
- the digest algorithm name
- Throws:
GeneralSecurityException
-
getTimeStampToken
public byte[] getTimeStampToken(byte[] imprint) throws IOException, org.bouncycastle.tsp.TSPException
Get RFC 3161 timeStampToken. Method may return null indicating that timestamp should be skipped.- Specified by:
getTimeStampToken
in interfaceTSAClient
- Parameters:
imprint
- data imprint to be time-stamped- Returns:
- encoded, TSA signed data of the timeStampToken
- Throws:
IOException
org.bouncycastle.tsp.TSPException
-
getTSAResponse
protected byte[] getTSAResponse(byte[] requestBytes) throws IOException
Get timestamp token - communications layer- Returns:
- - byte[] - TSA response, raw bytes (RFC 3161 encoded)
- Throws:
IOException
-
-