IAIK TSP
version 2.32

iaik.tsp.transport.ssl
Class TspSSLClientSocket

java.lang.Object
  extended by java.net.Socket
      extended by iaik.security.ssl.SSLSocket
          extended by iaik.tsp.transport.ssl.TspSSLClientSocket
All Implemented Interfaces:
SSLCommunication

public class TspSSLClientSocket
extends SSLSocket

This class extends the SSLSocket to provide sending and
receiving of TimeStampReq and TimeStampResp over SSL.

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:
SSLSocket

Constructor Summary
TspSSLClientSocket(java.net.Socket proxySocket, java.lang.String host, int port, int timeOut, SSLContext context)
          Creates a new TspSSLClientSocket and connects it to the specified port number on the named host via the given proxy.
TspSSLClientSocket(java.lang.String host, int port, int timeOut, SSLContext context)
          Creates a new TspSSLClientSocket 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 iaik.security.ssl.SSLSocket
close, getActiveCipherSuite, getActiveCompressionMethod, getActiveExtensions, getActiveProtocolVersion, getClientSupportedCipherSuites, getClientSupportedCompressionMethods, getContext, getInetAddress, getInputStream, getLocalAddress, getLocalPort, getOutputStream, getPeerCertificateChain, getPeerExtensions, getPeerSupportedCipherSuiteList, getPeerSupportedCompressionMethods, getPort, getPSKIdentity, getSession, getSoLinger, getSoTimeout, getTcpNoDelay, getTransport, getUseClientMode, init, isServer, renegotiate, setAutoHandshake, setDebugStream, setDebugStream, setSoLinger, setSoTimeout, setTcpNoDelay, setUseClientMode, shutdown, startHandshake
 
Methods inherited from class java.net.Socket
bind, connect, connect, getChannel, getKeepAlive, getLocalSocketAddress, getOOBInline, getReceiveBufferSize, getRemoteSocketAddress, getReuseAddress, getSendBufferSize, getTrafficClass, isBound, isClosed, isConnected, isInputShutdown, isOutputShutdown, sendUrgentData, setKeepAlive, setOOBInline, setPerformancePreferences, setReceiveBufferSize, setReuseAddress, setSendBufferSize, setSocketImplFactory, setTrafficClass, shutdownInput, shutdownOutput, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TspSSLClientSocket

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

For instance:

 String tsaHost = "...";
 int tsaPort = ...;
 int timeOut = ...;
 
 //create new Tsp SSL client socket
 SSLClientContext clientContext = ...;
 TspSSLClientSocket socket = new TspSSLClientSocket(tsaHost, tsaPort, timeOut, context);
 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.
context - The SSLContext to be used.
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.

TspSSLClientSocket

public TspSSLClientSocket(java.net.Socket proxySocket,
                          java.lang.String host,
                          int port,
                          int timeOut,
                          SSLContext context)
                   throws java.net.UnknownHostException,
                          java.io.IOException
Creates a new TspSSLClientSocket and connects it to the specified port number on the named host via the given proxy.

For instance, when using JDK 1.5 or later, a Proxy object may be used to create the proxy socket, e.g.:

 String proxyHost = "...";
 int proxyPort = ...;
 SocketAddress proxyAddr = new InetSocketAddress(proxyHost, proxyPort);
 Proxy proxy = new Proxy(Proxy.Type.SOCKS, proxyAddr);
 Socket proxySocket = new Socket(proxy);
 proxySocket.setSoTimeout(30000);
 String tsaHost = "...";
 int tsaPort = ...;
 InetSocketAddress tsaAddr = new InetSocketAddress(tsaHost, tsaPort);
 proxySocket.connect(tsaAddr);
 
 //create new Tsp SSL client socket
 SSLClientContext clientContext = ...;
 TspSSLClientSocket socket = new TspSSLClientSocket(proxySocket, tsaHost, tsaPort, 60000, context);
 TimeStampReq request = ...;
 TspTcpIpResponse response = socket.sendRequest(request);
 ...
 

Parameters:
proxySocket - The proxy socket used to connect to the tsa server.
host - The TSA host name.
port - The TSA port number.
timeOut - Enable/disable SO_TIMEOUT with the specified timeout, in milliseconds. A timeout of zero is interpreted as an infinite timeout.
context - The SSLContext to be used.
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.
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