Package com.lowagie.text.pdf
Class TSAClientBouncyCastle
- java.lang.Object
-
- com.lowagie.text.pdf.TSAClientBouncyCastle
-
- All Implemented Interfaces:
TSAClient
public class TSAClientBouncyCastle extends java.lang.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 private java.lang.String
digestName
private java.lang.String
policy
private java.net.Proxy
proxy
protected int
tokSzEstimate
Estimate of the received time stamp tokenprotected java.lang.String
tsaPassword
TSA passwordprotected java.lang.String
tsaURL
URL of the Time Stamp Authorityprotected java.lang.String
tsaUsername
TSA Username
-
Constructor Summary
Constructors Constructor Description TSAClientBouncyCastle(java.lang.String url)
Creates an instance of a TSAClient that will use BouncyCastle.TSAClientBouncyCastle(java.lang.String url, java.lang.String username, java.lang.String password)
Creates an instance of a TSAClient that will use BouncyCastle.TSAClientBouncyCastle(java.lang.String url, java.lang.String username, java.lang.String password, int tokSzEstimate)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getDigestName()
java.security.MessageDigest
getMessageDigest()
Get the MessageDigest.java.lang.String
getPolicy()
Gets Policy OID of TSA request.java.net.Proxy
getProxy()
Proxy object used for URL connections.protected byte[]
getTimeStampToken(byte[] imprint)
Get timestamp token - Bouncy Castle request encoding / decoding layerbyte[]
getTimeStampToken(PdfPKCS7 caller, byte[] imprint)
Get RFC 3161 timeStampToken.int
getTokenSizeEstimate()
Get the token size estimate.int
getTokSzEstimate()
java.lang.String
getTsaPassword()
protected byte[]
getTSAResponse(byte[] requestBytes)
Get timestamp token - communications layerjava.lang.String
getTsaURL()
java.lang.String
getTsaUsername()
private static boolean
isNotEmpty(java.lang.String arg)
void
setDigestName(java.lang.String hashAlgorithm)
void
setPolicy(java.lang.String policy)
Sets Policy OID of TSA request.void
setProxy(java.net.Proxy aProxy)
Sets Proxy which will be used for URL connection.
-
-
-
Field Detail
-
tsaURL
protected java.lang.String tsaURL
URL of the Time Stamp Authority
-
tsaUsername
protected java.lang.String tsaUsername
TSA Username
-
tsaPassword
protected java.lang.String tsaPassword
TSA password
-
tokSzEstimate
protected int tokSzEstimate
Estimate of the received time stamp token
-
proxy
private java.net.Proxy proxy
-
policy
private java.lang.String policy
-
digestName
private java.lang.String digestName
-
-
Constructor Detail
-
TSAClientBouncyCastle
public TSAClientBouncyCastle(java.lang.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(java.lang.String url, java.lang.String username, java.lang.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(java.lang.String url, java.lang.String username, java.lang.String password, int tokSzEstimate)
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
-
isNotEmpty
private static boolean isNotEmpty(java.lang.String arg)
-
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
-
getMessageDigest
public java.security.MessageDigest getMessageDigest() throws java.security.GeneralSecurityException
Get the MessageDigest. Default algorithm `SHA-1` used as per algorithm used without tsaClient- Specified by:
getMessageDigest
in interfaceTSAClient
- Returns:
- SHA-1 MessageDigest
- Throws:
java.security.GeneralSecurityException
- a security problem- See Also:
(upto 1.3.11) or check status of https://github.com/LibrePDF/OpenPDF/issues/320
-
getTimeStampToken
public byte[] getTimeStampToken(PdfPKCS7 caller, byte[] imprint) throws java.lang.Exception
Get RFC 3161 timeStampToken. Method may return null indicating that timestamp should be skipped.- Specified by:
getTimeStampToken
in interfaceTSAClient
- Parameters:
caller
- PdfPKCS7 - calling PdfPKCS7 instance (in case caller needs it)imprint
- byte[] - data imprint to be time-stamped- Returns:
- byte[] - encoded, TSA signed data of the timeStampToken
- Throws:
java.lang.Exception
- - TSA request failed- See Also:
TSAClient.getTimeStampToken(com.lowagie.text.pdf.PdfPKCS7, byte[])
-
getTimeStampToken
protected byte[] getTimeStampToken(byte[] imprint) throws java.lang.Exception
Get timestamp token - Bouncy Castle request encoding / decoding layer- Parameters:
imprint
- a byte array containing the imprint- Returns:
- the timestamp token
- Throws:
java.lang.Exception
- on error
-
getTSAResponse
protected byte[] getTSAResponse(byte[] requestBytes) throws java.lang.Exception
Get timestamp token - communications layer- Parameters:
requestBytes
- the request bytes- Returns:
- - byte[] - TSA response, raw bytes (RFC 3161 encoded)
- Throws:
java.lang.Exception
- on error
-
getProxy
public java.net.Proxy getProxy()
Proxy object used for URL connections.- Returns:
- Proxy object
-
setProxy
public void setProxy(java.net.Proxy aProxy)
Sets Proxy which will be used for URL connection.- Parameters:
aProxy
- Proxy to set
-
getPolicy
public java.lang.String getPolicy()
Gets Policy OID of TSA request.
-
setPolicy
public void setPolicy(java.lang.String policy)
Sets Policy OID of TSA request.- Parameters:
policy
- oid
-
getTsaURL
public java.lang.String getTsaURL()
-
getTsaUsername
public java.lang.String getTsaUsername()
-
getTsaPassword
public java.lang.String getTsaPassword()
-
getTokSzEstimate
public int getTokSzEstimate()
-
getDigestName
public java.lang.String getDigestName()
-
setDigestName
public void setDigestName(java.lang.String hashAlgorithm)
-
-