|
IAIK TSP version 2.32 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object iaik.tsp.transport.http.TspHttpClient
public class TspHttpClient
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 |
---|
public TspHttpClient(java.net.URL url) throws java.io.IOException
For instance:
URL tsaURL = ...; TspHttpClient tspHttpClient = new TspHttpClient(tsaURL); TimeStampReq request = ...; TspHttpResponse response = tspHttpClient.sendRequest(request); ...
url
- The URL
of the TSA server to which the request should be sent to.
java.io.IOException
- Thrown if any I/O exception occurs.public TspHttpClient(java.net.HttpURLConnection urlConnection) throws java.io.IOException
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); ...
urlConnection
- The (already opened) HttpURLConnection
to the TSA server
to which the request should be sent to.
java.io.IOException
- Thrown if any I/O exception occurs.Method Detail |
---|
public TspHttpResponse sendRequest(TimeStampReq request) throws java.io.IOException, CodingException
TimeStampReq
to the specified server and receives a
TspHttpResponse
.
request
- The TimeStampReq
to send.
TspHttpResponse
.
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). | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |