public class TimeStampTokenUtil
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULTDIGESTALGORITHM |
Constructor and Description |
---|
TimeStampTokenUtil() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
getDigestValue(byte[] dataToBeTimestamped)
Calculates the digest value for the given data using the default digest algorithm SHA-256.
|
static byte[] |
getDigestValue(byte[] dataToBeTimestamped,
java.lang.String digestAlgorithm)
Calculates the digest value for the given data using the specified digest algorithm.
|
static byte[] |
getDigestValue(java.io.InputStream dataToBeTimestamped)
Calculates the digest value for the given data using the default digest algorithm SHA-256.
|
static byte[] |
getDigestValue(java.io.InputStream dataToBeTimestamped,
java.lang.String digestAlgorithm)
Calculates the digest value for the given data using the specified digest algorithm.
|
static iaik.tsp.TimeStampToken |
getTimeStampToken(byte[] imprint,
java.lang.String tsaUrl)
Sends a timestamp request to the given TSA and returns the timestamp token if successful.
|
static iaik.tsp.TimeStampToken |
getTimeStampToken(byte[] imprint,
java.lang.String digestAlgorithm,
java.lang.String tsaUrl,
java.lang.String username,
java.lang.String password)
Sends a timestamp request to the given TSA and returns the timestamp token if successful.
|
static iaik.tsp.TimeStampToken |
getTimeStampTokenWithHashing(byte[] dataToBeTimestamped,
java.lang.String tsaUrl)
Hashes the given data, sends a timestamp request for the resulting imprint to the given TSA and
returns the timestamp token if successful.
|
static iaik.tsp.TimeStampToken |
getTimeStampTokenWithHashing(byte[] dataToBeTimestamped,
java.lang.String digestAlgorithm,
java.lang.String tsaUrl,
java.lang.String username,
java.lang.String password)
Hashes the given data, sends a timestamp request for the resulting imprint to the given TSA and
returns the timestamp token if successful.
|
static iaik.tsp.TimeStampToken |
getTimeStampTokenWithHashing(java.io.InputStream dataToBeTimestamped,
java.lang.String tsaUrl)
Hashes the given data, sends a timestamp request for the resulting imprint to the given TSA and
returns the timestamp token if successful.
|
static iaik.tsp.TimeStampToken |
getTimeStampTokenWithHashing(java.io.InputStream dataToBeTimestamped,
java.lang.String digestAlgorithm,
java.lang.String tsaUrl,
java.lang.String username,
java.lang.String password)
Hashes the given data, sends a timestamp request for the resulting imprint to the given TSA and
returns the timestamp token if successful.
|
static java.lang.String |
getTsaUrl(iaik.x509.X509Certificate certificate)
Extract URL to time stamp authority to be used for creating a time stamp for the signature
time.
|
static void |
verifyTimestamp(iaik.tsp.TimeStampToken token,
iaik.x509.X509Certificate tsa_cert,
byte[] data)
Verifies the given timestamp token.
|
static void |
verifyTimestamp(iaik.tsp.TimeStampToken token,
iaik.x509.X509Certificate tsa_cert,
java.io.InputStream data)
Verifies the given timestamp token.
|
static void |
verifyTimestampNoHashing(iaik.tsp.TimeStampToken token,
iaik.x509.X509Certificate tsa_cert,
byte[] hashedData)
Verifies the given timestamp token.
|
public static final java.lang.String DEFAULTDIGESTALGORITHM
public static iaik.tsp.TimeStampToken getTimeStampToken(byte[] imprint, java.lang.String tsaUrl) throws CmsCadesException, iaik.tsp.TspVerificationException
imprint
- the data imprint (already hashed) to be timestampedtsaUrl
- the URL to the timestamp authority to send the request toCmsCadesException
- if the timestamp request can't be sent or the response is not validiaik.tsp.TspVerificationException
- if signature of timestamp token is invalid or an parsing error occurspublic static iaik.tsp.TimeStampToken getTimeStampToken(byte[] imprint, java.lang.String digestAlgorithm, java.lang.String tsaUrl, java.lang.String username, java.lang.String password) throws CmsCadesException, iaik.tsp.TspVerificationException
imprint
- the data imprint (already hashed) to be timestampeddigestAlgorithm
- the digest algorithm that has been used to create the given imprinttsaUrl
- the URL to the timestamp authority to send the request tousername
- username for authentication at the timestamp authoritypassword
- password for authentication at the timestamp authorityCmsCadesException
- if the timestamp request can't be sent or the response is not validiaik.tsp.TspVerificationException
- if signature of timestamp token is invalid or an parsing error occurspublic static iaik.tsp.TimeStampToken getTimeStampTokenWithHashing(byte[] dataToBeTimestamped, java.lang.String digestAlgorithm, java.lang.String tsaUrl, java.lang.String username, java.lang.String password) throws CmsCadesException, iaik.tsp.TspVerificationException, java.security.NoSuchAlgorithmException
dataToBeTimestamped
- data to be hashed and timestampeddigestAlgorithm
- the digest algorithm that has been used to create the given imprinttsaUrl
- the URL to the timestamp authority to send the request tousername
- username for authentication at the timestamp authoritypassword
- password for authentication at the timestamp authorityCmsCadesException
- if the timestamp request can't be sent or the response is not validiaik.tsp.TspVerificationException
- if signature of timestamp token is invalid or an parsing error occursjava.security.NoSuchAlgorithmException
- if the given digest algorithm is unknownpublic static iaik.tsp.TimeStampToken getTimeStampTokenWithHashing(byte[] dataToBeTimestamped, java.lang.String tsaUrl) throws CmsCadesException, iaik.tsp.TspVerificationException, java.security.NoSuchAlgorithmException
dataToBeTimestamped
- data to be hashed and timestampedtsaUrl
- the URL to the timestamp authority to send the request toCmsCadesException
- if the timestamp request can't be sent or the response is not validiaik.tsp.TspVerificationException
- if signature of timestamp token is invalid or an parsing error occursjava.security.NoSuchAlgorithmException
- if the given digest algorithm is unknownpublic static iaik.tsp.TimeStampToken getTimeStampTokenWithHashing(java.io.InputStream dataToBeTimestamped, java.lang.String digestAlgorithm, java.lang.String tsaUrl, java.lang.String username, java.lang.String password) throws CmsCadesException, iaik.tsp.TspVerificationException, java.security.NoSuchAlgorithmException, java.io.IOException
dataToBeTimestamped
- data to be hashed and timestampeddigestAlgorithm
- the digest algorithm that has been used to create the given imprinttsaUrl
- the URL to the timestamp authority to send the request tousername
- username for authentication at the timestamp authoritypassword
- password for authentication at the timestamp authorityCmsCadesException
- if the timestamp request can't be sent or the response is not validiaik.tsp.TspVerificationException
- if signature of timestamp token is invalid or an parsing error occursjava.security.NoSuchAlgorithmException
- if the given digest algorithm is unknownjava.io.IOException
- if the data can't be readpublic static iaik.tsp.TimeStampToken getTimeStampTokenWithHashing(java.io.InputStream dataToBeTimestamped, java.lang.String tsaUrl) throws CmsCadesException, iaik.tsp.TspVerificationException, java.security.NoSuchAlgorithmException, java.io.IOException
dataToBeTimestamped
- data to be hashed and timestampedtsaUrl
- the URL to the timestamp authority to send the request toCmsCadesException
- if the timestamp request can't be sent or the response is not validiaik.tsp.TspVerificationException
- if signature of timestamp token is invalid or an parsing error occursjava.security.NoSuchAlgorithmException
- if the given digest algorithm is unknownjava.io.IOException
- if the data can't be readpublic static byte[] getDigestValue(byte[] dataToBeTimestamped) throws java.security.NoSuchAlgorithmException
dataToBeTimestamped
- data to be digested for the timestampjava.security.NoSuchAlgorithmException
- if the default digest algorithm is not availablepublic static byte[] getDigestValue(byte[] dataToBeTimestamped, java.lang.String digestAlgorithm) throws java.security.NoSuchAlgorithmException
dataToBeTimestamped
- data to be digested for the timestampdigestAlgorithm
- the digest algorithm, that shall be usedjava.security.NoSuchAlgorithmException
- if the given digest algorithm is unknownpublic static byte[] getDigestValue(java.io.InputStream dataToBeTimestamped) throws java.security.NoSuchAlgorithmException, java.io.IOException
dataToBeTimestamped
- data to be digested for the timestampjava.security.NoSuchAlgorithmException
- if the default digest algorithm is not availablejava.io.IOException
- if an I/O error occurspublic static byte[] getDigestValue(java.io.InputStream dataToBeTimestamped, java.lang.String digestAlgorithm) throws java.security.NoSuchAlgorithmException, java.io.IOException
dataToBeTimestamped
- data to be digested for the timestampdigestAlgorithm
- the digest algorithm, that shall be usedjava.security.NoSuchAlgorithmException
- if the given digest algorithm is unknownjava.io.IOException
- if an I/O error occurspublic static void verifyTimestamp(iaik.tsp.TimeStampToken token, iaik.x509.X509Certificate tsa_cert, byte[] data) throws CmsCadesException, iaik.tsp.TspVerificationException
token
- the timestamp token to be verifiedtsa_cert
- certificate of the time stamp authority to verify the signature valuedata
- data, claimed to be timestampedCmsCadesException
- if timestamped data has been changed or tsa certificate is missingiaik.tsp.TspVerificationException
- if signature of timestamp token is invalid or an parsing error occurspublic static void verifyTimestamp(iaik.tsp.TimeStampToken token, iaik.x509.X509Certificate tsa_cert, java.io.InputStream data) throws CmsCadesException, iaik.tsp.TspVerificationException, java.io.IOException
token
- the timestamp token to be verifiedtsa_cert
- certificate of the time stamp authority to verify the signature valuedata
- data, claimed to be timestampedCmsCadesException
- if timestamped data has been changed or tsa certificate is missingiaik.tsp.TspVerificationException
- if signature of timestamp token is invalid or an parsing error occursjava.io.IOException
- if data stream can't be readpublic static void verifyTimestampNoHashing(iaik.tsp.TimeStampToken token, iaik.x509.X509Certificate tsa_cert, byte[] hashedData) throws CmsCadesException, iaik.tsp.TspVerificationException
token
- the timestamp token to be verifiedtsa_cert
- certificate of the time stamp authority to verify the signature valuehashedData
- imprint (hash) of the data, claimed to be timestampedCmsCadesException
- if timestamped data has been changed or tsa certificate is missingiaik.tsp.TspVerificationException
- if signature of timestamp token is invalid or an parsing error occurspublic static java.lang.String getTsaUrl(iaik.x509.X509Certificate certificate) throws java.security.GeneralSecurityException
certificate
- certificate to extract the URL fromjava.security.GeneralSecurityException
- if the URL can't be extracted