RakNet::TwoWayAuthentication Class Reference

Implements two way authentication. More...

#include <TwoWayAuthentication.h>

Inheritance diagram for RakNet::TwoWayAuthentication:


List of all members.

Public Member Functions

bool AddPassword (RakNet::RakString identifier, RakNet::RakString password)
 Adds a password to the list of passwords the system will accept.
bool Challenge (RakNet::RakString identifier, AddressOrGUID remoteSystem)
 Challenge another system for the specified identifier.
void Clear (void)
 Free all memory.
virtual void Update (void)
 Update is called every time a packet is checked for .
virtual PluginReceiveResult OnReceive (Packet *packet)
virtual void OnRakPeerShutdown (void)
 Called when RakPeer is shutdown.
virtual void OnClosedConnection (const SystemAddress &systemAddress, RakNetGUID rakNetGUID, PI2_LostConnectionReason lostConnectionReason)

Detailed Description

Implements two way authentication.

Given two systems, each of whom known a common password / identifier pair, verify the password without transmitting it This can be used to determine what permissions are should be allowed to the other system If the other system should not send any data until authentication passes, you can use the MessageFilter plugin for this. Call MessageFilter::SetAllowMessageID() including ID_TWO_WAY_AUTHENTICATION_NEGOTIATION when doing so. Also attach MessageFilter first in the list of plugins

If other systems challenges us, and fails, you will get ID_TWO_WAY_AUTHENTICATION_INCOMING_CHALLENGE_FAILED.

Member Function Documentation

bool RakNet::TwoWayAuthentication::AddPassword ( RakNet::RakString  identifier,
RakNet::RakString  password 

Adds a password to the list of passwords the system will accept.

Each password, which is secret and not transmitted, is identified by identifier. identifier is transmitted in plaintext with the request. It is only needed because the system supports multiple password. It is used to only hash against once password on the remote system, rather than having to hash against every known password.

[in] identifier A unique identifier representing this password. This is transmitted in plaintext and should be considered insecure
[in] password The password to add
True on success, false on identifier==password, either identifier or password is blank, or identifier is already in use

bool RakNet::TwoWayAuthentication::Challenge ( RakNet::RakString  identifier,
AddressOrGUID  remoteSystem 

Challenge another system for the specified identifier.

After calling Challenge, you will get back ID_TWO_WAY_AUTHENTICATION_SUCCESS, ID_TWO_WAY_AUTHENTICATION_OUTGOING_CHALLENGE_TIMEOUT, or ID_TWO_WAY_AUTHENTICATION_OUTGOING_CHALLENGE_FAILED ID_TWO_WAY_AUTHENTICATION_SUCCESS will be returned if and only if the other system has called AddPassword() with the same identifier pair as this system.

[in] identifier A unique identifier representing this password. This is transmitted in plaintext and should be considered insecure
True on success, false on remote system not connected, or identifier not previously added with AddPassword()

virtual void RakNet::TwoWayAuthentication::OnClosedConnection ( const SystemAddress systemAddress,
RakNetGUID  rakNetGUID,
PI2_LostConnectionReason  lostConnectionReason 
) [virtual]

Called when a connection is dropped because the user called RakPeer::CloseConnection() for a particular system

[in] systemAddress The system whose connection was closed
[in] rakNetGuid The guid of the specified system
[in] lostConnectionReason How the connection was closed: manually, connection lost, or notification of disconnection

Reimplemented from RakNet::PluginInterface2.

virtual PluginReceiveResult RakNet::TwoWayAuthentication::OnReceive ( Packet packet  )  [virtual]

OnReceive is called for every packet.

[in] packet the packet that is being returned to the user
True to allow the game and other plugins to get this message, false to absorb it

Reimplemented from RakNet::PluginInterface2.

The documentation for this class was generated from the following file:

Generated on Wed Feb 1 13:33:48 2012 for RakNet by  doxygen