IAIK TSP
version 2.32

iaik.tsp.transport.http
Class TspHttpClient

java.lang.Object
  extended by iaik.tsp.transport.http.TspHttpClient

public class TspHttpClient
extends java.lang.Object

This class provides sending and receiving of TimeStampReq and TimeStampResp over HTTP.

For each instance of TspHttpClient the method sendRequest can be invoked only once!

This client also supports HTTPS Connections. To use HTTPS it will be necessary to configure some properties.
For example, you may wish to set the assigned SSLSocketFactory to use your own TrustManager.
For details please refer to Java JSSE.


Constructor Summary
TspHttpClient(java.net.HttpURLConnection urlConnection)
          Creates a new TspHttpClient to get a time stamp from a time stamp server connected with the given HttpURLConnection.
TspHttpClient(java.net.URL url)
          Creates a new TspHttpClient and opens a connection to the desired host.
 
Method Summary
 TspHttpResponse sendRequest(TimeStampReq request)
          Sends a TimeStampReq to the specified server and receives a TspHttpResponse.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TspHttpClient

public TspHttpClient(java.net.URL url)
              throws java.io.IOException
Creates a new TspHttpClient and opens a connection to the desired host.

For instance:

 URL tsaURL = ...;
 TspHttpClient tspHttpClient = new TspHttpClient(tsaURL);
 TimeStampReq request = ...;
 TspHttpResponse response = tspHttpClient.sendRequest(request);
 ...
 

Parameters:
url - The URL of the TSA server to which the request should be sent to.
Throws:
java.io.IOException - Thrown if any I/O exception occurs.

TspHttpClient

public TspHttpClient(java.net.HttpURLConnection urlConnection)
              throws java.io.IOException
Creates a new TspHttpClient to get a time stamp from a time stamp server connected with the given HttpURLConnection.

The connection to the time stamp server must be already opened, e.g.:

 URL tspUrl = ...;
 HttpURLConnection con = (HttpURLConnection) tspUrl.openConnection();
 con.setInstanceFollowRedirects(true);
 con.setDoOutput(true);
 con.setDoInput(true);
 con.setUseCaches(false);
 con.setDefaultUseCaches(false);
 con.setRequestMethod("POST");
 TspHttpClient tspHttpClient = new TspHttpClient(con);
 TimeStampReq request = ...;
 TspHttpResponse response = tspHttpClient.sendRequest(request);
 ...
 
You may also use this constructor if you want to connect to the TSP server via a proxy, e.g. (when using JDK 1.5 or later):
 URL tspUrl = ...;
 String proxyHost = "...";
 int proxyPort = ...;
 SocketAddress proxyAddr = new InetSocketAddress(proxyHost, proxyPort);
 Proxy proxy = new Proxy(Proxy.Type.SOCKS, proxyAddr);
 HttpURLConnection con = (HttpURLConnection) url.openConnection(proxy);
 ...
 

Parameters:
urlConnection - The (already opened) HttpURLConnection to the TSA server to which the request should be sent to.
Throws:
java.io.IOException - Thrown if any I/O exception occurs.
Method Detail

sendRequest

public TspHttpResponse sendRequest(TimeStampReq request)
                            throws java.io.IOException,
                                   CodingException
Sends a TimeStampReq to the specified server and receives a TspHttpResponse.

Parameters:
request - The TimeStampReq to send.
Returns:
The received TspHttpResponse.
Throws:
java.io.IOException - Thrown if any I/O exception occurs during transport.
CodingException - Thrown if the received TimeStampResp could not be parsed.

This Javadoc may contain text parts from text parts from IETF Internet Standard specifications (see copyright note).

IAIK TSP, © 2002 IAIK, © 2003 - 2014 Stiftung SIC