Bouncy Castle Cryptography 1.46

org.bouncycastle.crypto.tls
Class TlsProtocolHandler

java.lang.Object
  extended by org.bouncycastle.crypto.tls.TlsProtocolHandler

public class TlsProtocolHandler
extends java.lang.Object

An implementation of all high level protocols in TLS 1.0.


Constructor Summary
TlsProtocolHandler(java.io.InputStream is, java.io.OutputStream os)
           
TlsProtocolHandler(java.io.InputStream is, java.io.OutputStream os, java.security.SecureRandom sr)
           
 
Method Summary
protected  void assertEmpty(java.io.ByteArrayInputStream is)
          Make sure the InputStream is now empty.
 void close()
          Closes this connection.
 void connect(CertificateVerifyer verifyer)
          Deprecated. use version taking TlsClient
 void connect(TlsClient tlsClient)
          Connects to the remote system using client authentication
protected  void flush()
           
 java.io.InputStream getInputStream()
           
 java.io.OutputStream getOutputStream()
           
protected  void processData(short protocol, byte[] buf, int offset, int len)
           
protected  int readApplicationData(byte[] buf, int offset, int len)
          Read data from the network.
protected  void writeData(byte[] buf, int offset, int len)
          Send some application data to the remote system.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TlsProtocolHandler

public TlsProtocolHandler(java.io.InputStream is,
                          java.io.OutputStream os)

TlsProtocolHandler

public TlsProtocolHandler(java.io.InputStream is,
                          java.io.OutputStream os,
                          java.security.SecureRandom sr)
Method Detail

processData

protected void processData(short protocol,
                           byte[] buf,
                           int offset,
                           int len)
                    throws java.io.IOException
Throws:
java.io.IOException

connect

public void connect(CertificateVerifyer verifyer)
             throws java.io.IOException
Deprecated. use version taking TlsClient

Connects to the remote system.

Parameters:
verifyer - Will be used when a certificate is received to verify that this certificate is accepted by the client.
Throws:
java.io.IOException - If handshake was not successful.

connect

public void connect(TlsClient tlsClient)
             throws java.io.IOException
Connects to the remote system using client authentication

Parameters:
tlsClient -
Throws:
java.io.IOException - If handshake was not successful.

readApplicationData

protected int readApplicationData(byte[] buf,
                                  int offset,
                                  int len)
                           throws java.io.IOException
Read data from the network. The method will return immediately, if there is still some data left in the buffer, or block until some application data has been read from the network.

Parameters:
buf - The buffer where the data will be copied to.
offset - The position where the data will be placed in the buffer.
len - The maximum number of bytes to read.
Returns:
The number of bytes read.
Throws:
java.io.IOException - If something goes wrong during reading data.

writeData

protected void writeData(byte[] buf,
                         int offset,
                         int len)
                  throws java.io.IOException
Send some application data to the remote system.

The method will handle fragmentation internally.

Parameters:
buf - The buffer with the data.
offset - The position in the buffer where the data is placed.
len - The length of the data.
Throws:
java.io.IOException - If something goes wrong during sending.

getOutputStream

public java.io.OutputStream getOutputStream()
Returns:
An OutputStream which can be used to send data.

getInputStream

public java.io.InputStream getInputStream()
Returns:
An InputStream which can be used to read data.

close

public void close()
           throws java.io.IOException
Closes this connection.

Throws:
java.io.IOException - If something goes wrong during closing.

assertEmpty

protected void assertEmpty(java.io.ByteArrayInputStream is)
                    throws java.io.IOException
Make sure the InputStream is now empty. Fail otherwise.

Parameters:
is - The InputStream to check.
Throws:
java.io.IOException - If is is not empty.

flush

protected void flush()
              throws java.io.IOException
Throws:
java.io.IOException

Bouncy Castle Cryptography 1.46