IAIK TSP
version 2.32

iaik.tsp.transport.tcpip
Class TspClientSocket

java.lang.Object
  extended by java.net.Socket
      extended by iaik.tsp.transport.tcpip.TspClientSocket

public class TspClientSocket
extends java.net.Socket

This class extends the Socket to provide sending and
receiving of TimeStampReq and TimeStampResp.

The protocol basically assumes a listener process on a TSA that can accept TSA messages on a well-defined port (default IP port number 318).

In the RFC 3161 are five different response formats defined:

The negligible types pollRep, negPollRep and partialMsgRep are not supported!

See Also:
Socket

Constructor Summary
TspClientSocket(java.net.Proxy proxy)
          Creates a new TspClientSocket and connects it to the specified port number on the named host via the given Proxy.
TspClientSocket(java.lang.String host, int port, int timeOut)
          Creates a new TspClientSocket and connects it to the specified port number on the named host.
 
Method Summary
 TspTcpIpResponse sendRequest(TimeStampReq request)
          Sends a TimeStampReq to the specified server and receives a TspTcpIpResponse.
 
Methods inherited from class java.net.Socket
bind, close, connect, connect, getChannel, getInetAddress, getInputStream, getKeepAlive, getLocalAddress, getLocalPort, getLocalSocketAddress, getOOBInline, getOutputStream, getPort, getReceiveBufferSize, getRemoteSocketAddress, getReuseAddress, getSendBufferSize, getSoLinger, getSoTimeout, getTcpNoDelay, getTrafficClass, isBound, isClosed, isConnected, isInputShutdown, isOutputShutdown, sendUrgentData, setKeepAlive, setOOBInline, setPerformancePreferences, setReceiveBufferSize, setReuseAddress, setSendBufferSize, setSocketImplFactory, setSoLinger, setSoTimeout, setTcpNoDelay, setTrafficClass, shutdownInput, shutdownOutput, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TspClientSocket

public TspClientSocket(java.lang.String host,
                       int port,
                       int timeOut)
                throws java.net.UnknownHostException,
                       java.io.IOException
Creates a new TspClientSocket and connects it to the specified port number on the named host.

For instance:

 String tsaHost = "...";
 int tsaPort = ...;
 int timeOut = ...;
 TspClientSocket socket = new TspClientSocket(String tsaHost, tsaPort, timeOut);
 ...
 TimeStampReq request = ...;
 TspTcpIpResponse response = socket.sendRequest(request);
 ...
 

Parameters:
host - The host name.
port - The port number.
timeOut - Enable/disable SO_TIMEOUT with the specified timeout, in milliseconds. A timeout of zero is interpreted as an infinite timeout.
Throws:
java.net.UnknownHostException - Thrown to indicate that the IP address of a host could not be determined.
java.io.IOException - If an I/O error occurs when creating the socket.

TspClientSocket

public TspClientSocket(java.net.Proxy proxy)
Creates a new TspClientSocket and connects it to the specified port number on the named host via the given Proxy.

When using JDK 1.5 or later a Proxy object may be used to specify the proxy through which the connection should be established, e.g.:

 String proxyHost = "...";
 int proxyPort = ...;
 SocketAddress proxyAddr = new InetSocketAddress(proxyHost, proxyPort);
 Proxy proxy = new Proxy(Proxy.Type.SOCKS, proxyAddr);
 TspClientSocket socket = new TspClientSocket(proxy);
 String tsaHost = "...";
 int tsaPort = ...;
 InetSocketAddress tspAddr = new InetSocketAddress(tsaHost, tsaPort);
 socket.connect(tspAddr);
 ...
 TimeStampReq request = ...;
 TspTcpIpResponse response = socket.sendRequest(request);
 ...
 

Parameters:
proxy - The proxy used to connect to the tsa server.
Since:
JDK 1.5
Method Detail

sendRequest

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

Parameters:
request - The TimeStampReq to send.
Returns:
The received TspTcpIpResponse.
Throws:
java.io.IOException - Thrown if any I/O exception occurs during transport.
TspTcpIpFormatException - Thrown if the received message is neither a finalMsgRep nor an errorMsgRep.
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