ionflux.org | Impressum

Ionflux::Tools::TCPAuthClient Class Reference
[Network interface]

Authenticated TCP client. More...

#include <TCPAuthClient.hpp>

Inheritance diagram for Ionflux::Tools::TCPAuthClient:

Inheritance graph
[legend]
Collaboration diagram for Ionflux::Tools::TCPAuthClient:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TCPAuthClient ()
 Constructor.
 TCPAuthClient (bool initInteractive)
 Constructor.
 TCPAuthClient (const std::string &initUsername, const std::string &initPassword, bool initInteractive)
 Constructor.
virtual ~TCPAuthClient ()
 Destructor.
virtual void onMessage (TCPRemotePeer &peer)
 Event handler for received messages.
virtual void onInvalidMessage (TCPRemotePeer &peer)
 Event handler for invalid messages.
virtual void broadcast (const std::string &bytes)
 Broadcast bytes.
virtual bool addConnection (const std::string &host, int port, const std::string &connUser, const std::string &connPass)
 Add connection.
virtual void setUsername (const std::string &newUsername)
 Set username.
virtual void setPassword (const std::string &newPassword)
 Set password.
virtual void setCurrentMsgID (unsigned int newCurrentMsgID)
 Set current Message ID.
virtual std::string getUsername ()
 Get username.
virtual void getPassword (std::string &target)
 Get password.
virtual unsigned int getCurrentMsgID ()
 Get current Message ID.

Static Public Attributes

static const std::string MAGIC_WORD = "IFTA"
 Magic word.
static const unsigned int AUTH_VERSION = 0x000001L
 Protocol version.
static const unsigned int AUTH_VERSION_UPPER = 0x000001L
 Protocol version (upper boundary).
static const unsigned int AUTH_VERSION_LOWER = 0x000001L
 Protocol version (lower boundary).
static const int MSGID_HELLO = 101
 Message type ID: HELLO.
static const int MSGID_WELCOME = 201
 Message type ID: WELCOME.
static const int MSGID_AUTH = 102
 Message type ID: AUTH.
static const int MSGID_AUTH_OK = 202
 Message type ID: AUTH_OK.
static const int MSGID_AUTH_FAILED = 401
 Message type ID: AUTH_FAILED.
static const int PS_WAIT_WELCOME = 1
 Protocol state: Wait for WELCOME.
static const int PS_WAIT_AUTH_RESULT = 2
 Protocol state: Wait for AUTH result.
static const int PS_AUTH_OK = 3
 Protocol state: Authentication succeeded.

Protected Member Functions

virtual void onConnect (TCPRemotePeer &peer)
 Event handler for new connections.
virtual void onAuthMessage (TCPRemotePeer &peer)
 Event handler for authenticated messages.
virtual void onAuthOK (TCPRemotePeer &peer)
 Event handler for successful authentication.
virtual void onAuthFailed (TCPRemotePeer &peer)
 Event handler for failed authentication.

Protected Attributes

std::string username
 Username.
std::string password
 Password.
unsigned int currentMsgID
 Current Message ID.

Detailed Description

Authenticated TCP client.

A Message based TCP client supporting a simple authentication protocol.

See misc/ifta.txt for a specification of the authentication protocol.


Constructor & Destructor Documentation

Ionflux::Tools::TCPAuthClient::TCPAuthClient  ) 
 

Constructor.

Construct new TCPAuthClient object.

Ionflux::Tools::TCPAuthClient::TCPAuthClient bool  initInteractive  ) 
 

Constructor.

Construct new TCPAuthClient object.

Parameters:
initInteractive Whether this client should run interactively (i.e. read data from standard input).

Ionflux::Tools::TCPAuthClient::TCPAuthClient const std::string &  initUsername,
const std::string &  initPassword,
bool  initInteractive
 

Constructor.

Construct new TCPAuthClient object.

Parameters:
initUsername Username.
initPassword Password.
initInteractive Whether this client should run interactively (i.e. read data from standard input).

Ionflux::Tools::TCPAuthClient::~TCPAuthClient  )  [virtual]
 

Destructor.

Destruct TCPAuthClient object.


Member Function Documentation

bool Ionflux::Tools::TCPAuthClient::addConnection const std::string &  host,
int  port,
const std::string &  connUser,
const std::string &  connPass
[virtual]
 

Add connection.

Attempts to establish a connection to the specified host and port. On success, the new connection will be maintained by the TCP client.

Parameters:
host Hostname or IP address of the remote host.
port Port to connect to.
connUser Username to use for the connection.
connPass Password to use for the connection.
Returns:
true on success, false otherwise.

void Ionflux::Tools::TCPAuthClient::broadcast const std::string &  bytes  )  [virtual]
 

Broadcast bytes.

Sends the specified byte string to all connected peers.

Parameters:
bytes The bytes to broadcast.

Reimplemented from Ionflux::Tools::TCPMessageClient.

unsigned int Ionflux::Tools::TCPAuthClient::getCurrentMsgID  )  [virtual]
 

Get current Message ID.

Returns:
Current message ID.

void Ionflux::Tools::TCPAuthClient::getPassword std::string &  target  )  [virtual]
 

Get password.

Parameters:
target Buffer in which to store the password.

std::string Ionflux::Tools::TCPAuthClient::getUsername  )  [virtual]
 

Get username.

Returns:
Username.

void Ionflux::Tools::TCPAuthClient::onAuthFailed TCPRemotePeer peer  )  [protected, virtual]
 

Event handler for failed authentication.

This is called when authentication with a peer has failed.

Note:
Override this to implement your own authentication failure handling.
Parameters:
peer The peer which caused the event.

void Ionflux::Tools::TCPAuthClient::onAuthMessage TCPRemotePeer peer  )  [protected, virtual]
 

Event handler for authenticated messages.

This is called whenever a message is received from an authenticated peer. The received message will be available from TCPRemotePeer::getMessage().

Note:
Override this to implement your own authenticated message handling.
Parameters:
peer The peer which caused the event.

void Ionflux::Tools::TCPAuthClient::onAuthOK TCPRemotePeer peer  )  [protected, virtual]
 

Event handler for successful authentication.

This is called when authentication with a peer has succeeded.

Note:
Override this to implement your own authentication success handling.
Parameters:
peer The peer which caused the event.

void Ionflux::Tools::TCPAuthClient::onConnect TCPRemotePeer peer  )  [protected, virtual]
 

Event handler for new connections.

This is called by the main loop whenever a connection to a peer is successfully established.

Note:
Override this to implement your own connection handling.
Parameters:
peer The peer which caused the event.

Reimplemented from Ionflux::Tools::TCPMessageClient.

void Ionflux::Tools::TCPAuthClient::onInvalidMessage TCPRemotePeer peer  )  [virtual]
 

Event handler for invalid messages.

This is called whenever an invalid message is received from a peer.

Note:
Override this to implement your own invalid message handling.
Parameters:
peer The peer which caused the event.

Reimplemented from Ionflux::Tools::TCPMessageClient.

void Ionflux::Tools::TCPAuthClient::onMessage TCPRemotePeer peer  )  [virtual]
 

Event handler for received messages.

This is called whenever a valid message is received from a peer. The received message will be available from TCPRemotePeer::getMessage().

Note:
Override this to implement your own message handling.
Parameters:
peer The peer which caused the event.

Reimplemented from Ionflux::Tools::TCPMessageClient.

void Ionflux::Tools::TCPAuthClient::setCurrentMsgID unsigned int  newCurrentMsgID  )  [virtual]
 

Set current Message ID.

Set new value of current Message ID.

Parameters:
newCurrentMsgID New value of current Message ID.

void Ionflux::Tools::TCPAuthClient::setPassword const std::string &  newPassword  )  [virtual]
 

Set password.

Set new value of password.

Parameters:
newPassword New value of password.

void Ionflux::Tools::TCPAuthClient::setUsername const std::string &  newUsername  )  [virtual]
 

Set username.

Set new value of username.

Parameters:
newUsername New value of username.


Member Data Documentation

const unsigned int Ionflux::Tools::TCPAuthClient::AUTH_VERSION = 0x000001L [static]
 

Protocol version.

const unsigned int Ionflux::Tools::TCPAuthClient::AUTH_VERSION_LOWER = 0x000001L [static]
 

Protocol version (lower boundary).

const unsigned int Ionflux::Tools::TCPAuthClient::AUTH_VERSION_UPPER = 0x000001L [static]
 

Protocol version (upper boundary).

unsigned int Ionflux::Tools::TCPAuthClient::currentMsgID [protected]
 

Current Message ID.

const std::string Ionflux::Tools::TCPAuthClient::MAGIC_WORD = "IFTA" [static]
 

Magic word.

const int Ionflux::Tools::TCPAuthClient::MSGID_AUTH = 102 [static]
 

Message type ID: AUTH.

const int Ionflux::Tools::TCPAuthClient::MSGID_AUTH_FAILED = 401 [static]
 

Message type ID: AUTH_FAILED.

const int Ionflux::Tools::TCPAuthClient::MSGID_AUTH_OK = 202 [static]
 

Message type ID: AUTH_OK.

const int Ionflux::Tools::TCPAuthClient::MSGID_HELLO = 101 [static]
 

Message type ID: HELLO.

const int Ionflux::Tools::TCPAuthClient::MSGID_WELCOME = 201 [static]
 

Message type ID: WELCOME.

std::string Ionflux::Tools::TCPAuthClient::password [protected]
 

Password.

const int Ionflux::Tools::TCPAuthClient::PS_AUTH_OK = 3 [static]
 

Protocol state: Authentication succeeded.

const int Ionflux::Tools::TCPAuthClient::PS_WAIT_AUTH_RESULT = 2 [static]
 

Protocol state: Wait for AUTH result.

const int Ionflux::Tools::TCPAuthClient::PS_WAIT_WELCOME = 1 [static]
 

Protocol state: Wait for WELCOME.

std::string Ionflux::Tools::TCPAuthClient::username [protected]
 

Username.


The documentation for this class was generated from the following files:
Generated on Tue Mar 14 21:10:32 2006 for Ionflux Tools Class Library (iftools) by  doxygen 1.4.6