Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | Related Pages

ConnectionTLS Class Reference

This is an implementation of a TLS/SSL connection. More...

#include <connectiontls.h>

Inherits TLSHandler, ConnectionBase, and ConnectionDataHandler.

Inheritance diagram for ConnectionTLS:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 ConnectionTLS (ConnectionBase *conn, ConnectionDataHandler *cdh, const LogSink &log)
virtual ~ConnectionTLS ()
virtual ConnectionError connect ()
virtual ConnectionError recv (int timeout=-1)
virtual bool send (const std::string &data)
virtual ConnectionError receive ()
virtual void disconnect ()
virtual void cleanup ()
virtual void getStatistics (int &totalIn, int &totalOut)
virtual void handleReceivedData (const ConnectionBase *connection, const std::string &data)
virtual void handleConnect (const ConnectionBase *connection)
virtual void handleDisconnect (const ConnectionBase *connection, ConnectionError reason)
virtual ConnectionBasenewInstance () const
virtual void handleEncryptedData (const TLSBase *, const std::string &data)
virtual void handleDecryptedData (const TLSBase *, const std::string &data)
virtual void handleHandshakeResult (const TLSBase *base, bool success, CertInfo &certinfo)

Detailed Description

This is an implementation of a TLS/SSL connection.

Usage:

 Client *c = new Client( ... );
 c->setConnectionImpl( new ConnectionTLS( c,
                                new ConnectionTCP( c->logInstance(), server, port ),
                                c->logInstance()) );

Due to the need for handshaking data to be sent/received before the connection is fully established, be sure not to use the connection until ConnectionDataHandler::handleConnect() of the specified ConnectionDataHandler is called.

Author:
Matthew Wild <mwild1@gmail.com>
Since:
1.0

Definition at line 46 of file connectiontls.h.


Constructor & Destructor Documentation

ConnectionTLS ConnectionBase conn,
ConnectionDataHandler cdh,
const LogSink log
 

Constructs a new ConnectionTLS object.

Parameters:
conn A transport connection. It should be configured to connect to the server and port you wish to make the encrypted connection to. ConnectionTLS will own the transport connection and delete it in its destructor.
cdh The ConnectionDataHandler that will be notified of events from this connection
logInstance The log target. Obtain it from ClientBase::logInstance().

Definition at line 20 of file connectiontls.cpp.

~ConnectionTLS  )  [virtual]
 

Virtual Destructor.

Definition at line 29 of file connectiontls.cpp.


Member Function Documentation

void cleanup  )  [virtual]
 

This function is called after a disconnect to clean up internal state. It is also called by ConnectionBase's destructor.

Reimplemented from ConnectionBase.

Definition at line 98 of file connectiontls.cpp.

ConnectionError connect  )  [virtual]
 

Used to initiate the connection.

Returns:
Returns the connection state.

Implements ConnectionBase.

Definition at line 36 of file connectiontls.cpp.

void disconnect  )  [virtual]
 

Disconnects an established connection. NOOP if no active connection exists.

Implements ConnectionBase.

Definition at line 89 of file connectiontls.cpp.

void getStatistics int &  totalIn,
int &  totalOut
[virtual]
 

Returns current connection statistics.

Parameters:
totalIn The total number of bytes received.
totalOut The total number of bytes sent.

Implements ConnectionBase.

Definition at line 103 of file connectiontls.cpp.

void handleConnect const ConnectionBase connection  )  [virtual]
 

This function is called when e.g. the raw TCP connection was established.

Parameters:
connection The connection.

Implements ConnectionDataHandler.

Definition at line 124 of file connectiontls.cpp.

void handleDecryptedData const TLSBase ,
const std::string &  data
[virtual]
 

Reimplement this function to receive decrypted data from a TLSBase implementation.

Parameters:
base The encryption implementation which called this function.
data The decrypted data (e.g. to parse).

Implements TLSHandler.

Definition at line 150 of file connectiontls.cpp.

void handleDisconnect const ConnectionBase connection,
ConnectionError  reason
[virtual]
 

This connection is called when e.g. the raw TCP connection was closed.

Parameters:
connection The connection.
reason The reason for the disconnect.

Implements ConnectionDataHandler.

Definition at line 133 of file connectiontls.cpp.

void handleEncryptedData const TLSBase ,
const std::string &  data
[virtual]
 

Reimplement this function to receive encrypted data from a TLSBase implementation.

Parameters:
base The encryption implementation which called this function.
data The encrypted data (e.g. to send over the wire).

Implements TLSHandler.

Definition at line 143 of file connectiontls.cpp.

void handleHandshakeResult const TLSBase base,
bool  success,
CertInfo certinfo
[virtual]
 

Reimplement this function to receive the result of a TLS handshake.

Parameters:
base The encryption implementation which called this function.
success Whether or not the handshake was successful.
certinfo Information about the server's certificate.

Implements TLSHandler.

Definition at line 163 of file connectiontls.cpp.

void handleReceivedData const ConnectionBase connection,
const std::string &  data
[virtual]
 

This function is called for received from the underlying transport.

Parameters:
connection The connection that received the data.
data The data received.

Implements ConnectionDataHandler.

Definition at line 118 of file connectiontls.cpp.

ConnectionBase * newInstance  )  const [virtual]
 

This function returns a new instance of the current ConnectionBase-derived object. The idea is to be able to 'clone' ConnectionBase-derived objects without knowing of what type they are exactly.

Returns:
A new Connection* instance.

Implements ConnectionBase.

Definition at line 108 of file connectiontls.cpp.

ConnectionError receive  )  [virtual]
 

Use this function to put the connection into 'receive mode', i.e. this function returns only when the connection is terminated.

Returns:
Returns a value indicating the disconnection reason.

Implements ConnectionBase.

Definition at line 81 of file connectiontls.cpp.

ConnectionError recv int  timeout = -1  )  [virtual]
 

Use this periodically to receive data from the socket and to feed the parser.

Parameters:
timeout The timeout to use for select in microseconds. Default of -1 means blocking.
Returns:
The state of the connection.

Implements ConnectionBase.

Definition at line 50 of file connectiontls.cpp.

bool send const std::string &  data  )  [virtual]
 

Use this function to send a string of data over the wire. The function returns only after all data has been sent.

Parameters:
data The data to send.
Returns:
True if the data has been sent (no guarantee of receipt), false in case of an error.

Implements ConnectionBase.

Definition at line 64 of file connectiontls.cpp.


The documentation for this class was generated from the following files:
Generated on Tue Apr 22 15:10:14 2008 for gloox by  doxygen 1.4.1