RakNet  4.0
Public Member Functions | List of all members
RakNet::TwoWayAuthentication Class Reference

Implements two way authentication. More...

#include <TwoWayAuthentication.h>

Inheritance diagram for RakNet::TwoWayAuthentication:
RakNet::PluginInterface2

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)
 
- Public Member Functions inherited from RakNet::PluginInterface2
virtual void OnAttach (void)
 Called when the interface is attached.
 
virtual void OnDetach (void)
 Called when the interface is detached.
 
virtual void OnRakPeerStartup (void)
 Called when RakPeer is initialized.
 
virtual void OnNewConnection (const SystemAddress &systemAddress, RakNetGUID rakNetGUID, bool isIncoming)
 
virtual void OnFailedConnectionAttempt (Packet *packet, PI2_FailedConnectionAttemptReason failedConnectionAttemptReason)
 
virtual bool UsesReliabilityLayer (void) const
 
virtual void OnDirectSocketSend (const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress)
 
virtual void OnDirectSocketReceive (const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress)
 
virtual void OnReliabilityLayerNotification (const char *errorMessage, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress, bool isError)
 
virtual void OnInternalPacket (InternalPacket *internalPacket, unsigned frameNumber, SystemAddress remoteSystemAddress, RakNet::TimeMS time, int isSend)
 
virtual void OnAck (unsigned int messageNumber, SystemAddress remoteSystemAddress, RakNet::TimeMS time)
 
virtual void OnPushBackPacket (const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress)
 

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

Note
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.

Parameters
[in]identifierA unique identifier representing this password. This is transmitted in plaintext and should be considered insecure
[in]passwordThe password to add
Returns
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.

Parameters
[in]identifierA unique identifier representing this password. This is transmitted in plaintext and should be considered insecure
Returns
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

Parameters
[in]systemAddressThe system whose connection was closed
[in]rakNetGuidThe guid of the specified system
[in]lostConnectionReasonHow 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.

Parameters
[in]packetthe packet that is being returned to the user
Returns
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: