public class HttpTimeStampTransport extends java.lang.Object implements TimeStampTransport
This transport is used for conveying ASN.1-encoded messages for the Time-Stamp protocol using the HyperText Transfer Protocol. The following two MIME objects are used:
Content-type: application/timestamp-query
<the ASN.1 DER-encoded Time-Stamp Request message>
Content-type: application/timestamp-reply
<the ASN.1 DER-encoded Time-Stamp Response message>
These MIME objects are sent and received over WWW links to provide simple browser-server transport for Time-Stamp messages.
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_RECEIVE_TIMEOUT
By default, the maximum amount of time in milliseconds to spend attempting
to receive a Time-Stamp response from the Time-Stamp Authority.
|
| Constructor and Description |
|---|
HttpTimeStampTransport(java.lang.String url)
Creates an
HttpTimeStampTransport for communicating with a
Time-Stamp Authority at the provided URL. |
HttpTimeStampTransport(java.net.URL url)
Creates an
HttpTimeStampTransport for communicating with a
Time-Stamp Authority at the provided URL. |
| Modifier and Type | Method and Description |
|---|---|
int |
getReceiveTimeout()
Returns the receive timeout.
|
java.net.URL |
getUrl()
Returns the URL of the Time-Stamp Authority.
|
TimeStampResp |
requestTimeStamp(TimeStampReq request)
Sends/Receives a Time-Stamp request/response with the Time-Stamp Authority.
|
void |
setReceiveTimeout(int receiveTimeout)
Sets the receive timeout.
|
public static final int DEFAULT_RECEIVE_TIMEOUT
public HttpTimeStampTransport(java.lang.String url)
throws java.net.MalformedURLException
HttpTimeStampTransport for communicating with a
Time-Stamp Authority at the provided URL.
The URL must indicate that the http protocol is to be used:
http://www.mycompany.com:1234/tsa
url - the URL of the Time-Stamp Authority in string formatjava.net.MalformedURLException - thrown string does not contain a properly formatted URLInvalidArgumentException - thrown if the string is null or represents a URL that is
not an http addresspublic HttpTimeStampTransport(java.net.URL url)
HttpTimeStampTransport for communicating with a
Time-Stamp Authority at the provided URL.
The URL must indicate that the http protocol is to be used:
http://www.mycompany.com:1234/tsa
url - the URL of the Time-Stamp AuthorityInvalidArgumentException - thrown if the string is null or represents a URL that
does not indicate that the http protocol is to be used to contact the
Time-Stamp Authoritypublic TimeStampResp requestTimeStamp(TimeStampReq request) throws java.io.IOException
First, a connection is opened with the Time-Stamp server. Then, the Time-Stamp request provided, is DER encoded and sent to the Time-Stamp Authority in an http 'POST' request. The response that is received from the Time-Stamp Authority is then DER decoded into a Time-Stamp request, and the connection with the Time-Stamp server is closed.
Checks are done to ensure that the response was received in the proper format, and that no errors occurred during the communication with the Time-Stamp Authority.
requestTimeStamp in interface TimeStampTransportrequest - the Time-Stamp requestjava.io.IOException - thrown if an error occurred while communicating with the Time-Stamp
Authoritypublic java.net.URL getUrl()
public void setReceiveTimeout(int receiveTimeout)
throws java.lang.IllegalArgumentException
The receive timeout is the maximum amount of time that will be spent when attempting to receive an entire response from the Time-Stamp Authority.
receiveTimeout - the receive timeout in millisecondsInvalidArgumentException - thrown if the receive timeout provided is less than zerojava.lang.IllegalArgumentExceptionpublic int getReceiveTimeout()
The receive timeout is the maximum amount of time that will be spent when attempting to receive an entire response from the Time-Stamp Authority.