public class

TlsProtocolHandler

extends Object
java.lang.Object
   ↳ org.bouncycastle.crypto.tls.TlsProtocolHandler

Class Overview

An implementation of all high level protocols in TLS 1.0.

Summary

Public Constructors
TlsProtocolHandler(InputStream is, OutputStream os)
TlsProtocolHandler(InputStream is, OutputStream os, SecureRandom sr)
Public Methods
void close()
Closes this connection.
void connect(CertificateVerifyer verifyer)
This method is deprecated. use version taking TlsClient
void connect(TlsClient tlsClient)
Connects to the remote system using client authentication
InputStream getInputStream()
OutputStream getOutputStream()
Protected Methods
void assertEmpty(ByteArrayInputStream is)
Make sure the InputStream is now empty.
void flush()
void processData(short protocol, byte[] buf, int offset, int len)
int readApplicationData(byte[] buf, int offset, int len)
Read data from the network.
void writeData(byte[] buf, int offset, int len)
Send some application data to the remote system.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public TlsProtocolHandler (InputStream is, OutputStream os)

public TlsProtocolHandler (InputStream is, OutputStream os, SecureRandom sr)

Public Methods

public void close ()

Closes this connection.

Throws
IOException If something goes wrong during closing.

public void connect (CertificateVerifyer verifyer)

This method is 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
IOException If handshake was not successful.

public void connect (TlsClient tlsClient)

Connects to the remote system using client authentication

Throws
IOException If handshake was not successful.

public InputStream getInputStream ()

Returns
  • An InputStream which can be used to read data.

public OutputStream getOutputStream ()

Returns
  • An OutputStream which can be used to send data.

Protected Methods

protected void assertEmpty (ByteArrayInputStream is)

Make sure the InputStream is now empty. Fail otherwise.

Parameters
is The InputStream to check.
Throws
IOException If is is not empty.

protected void flush ()

Throws
IOException

protected void processData (short protocol, byte[] buf, int offset, int len)

Throws
IOException

protected int readApplicationData (byte[] buf, int offset, int len)

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
IOException If something goes wrong during reading data.

protected void writeData (byte[] buf, int offset, int len)

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
IOException If something goes wrong during sending.