OpenTTD Source  20241121-master-g67a0fccfad
CombinedAuthenticationClientHandler Class Reference

Handler for combining a number of authentication handlers, where the failure of one of the handlers will retry with another handler. More...

#include <network_crypto_internal.h>

Inheritance diagram for CombinedAuthenticationClientHandler:
NetworkAuthenticationClientHandler NetworkAuthenticationHandler

Public Types

using Handler = std::unique_ptr< NetworkAuthenticationClientHandler >
 The type of the inner handlers.
 
- Public Types inherited from NetworkAuthenticationClientHandler
enum  RequestResult { AWAIT_USER_INPUT , READY_FOR_RESPONSE , INVALID }
 The processing result of receiving a request. More...
 

Public Member Functions

void Add (Handler &&handler)
 Add the given sub-handler to this handler. More...
 
virtual RequestResult ReceiveRequest (struct Packet &p) override
 Read a request from the server. More...
 
virtual bool SendResponse (struct Packet &p) override
 Create the response to send to the server. More...
 
virtual std::string_view GetName () const override
 Get the name of the handler for debug messages. More...
 
virtual NetworkAuthenticationMethod GetAuthenticationMethod () const override
 Get the method this handler is providing functionality for. More...
 
virtual bool ReceiveEnableEncryption (struct Packet &p) override
 Read the request to enable encryption from the server. More...
 
virtual std::unique_ptr< NetworkEncryptionHandlerCreateClientToServerEncryptionHandler () const override
 Create a NetworkEncryptionHandler to encrypt or decrypt messages from the client to the server. More...
 
virtual std::unique_ptr< NetworkEncryptionHandlerCreateServerToClientEncryptionHandler () const override
 Create a NetworkEncryptionHandler to encrypt or decrypt messages from the server to the client. More...
 

Private Attributes

std::vector< Handlerhandlers
 The handlers that we can authenticate with.
 
NetworkAuthenticationClientHandlercurrent_handler = nullptr
 The currently active handler.
 

Additional Inherited Members

- Static Public Member Functions inherited from NetworkAuthenticationClientHandler
static void EnsureValidSecretKeyAndUpdatePublicKey (std::string &secret_key, std::string &public_key)
 Ensures that the given secret key is valid, and when not overwrite it with a valid secret key. More...
 
static std::unique_ptr< NetworkAuthenticationClientHandlerCreate (std::shared_ptr< NetworkAuthenticationPasswordRequestHandler > password_handler, std::string &secret_key, std::string &public_key)
 Create a NetworkAuthenticationClientHandler. More...
 

Detailed Description

Handler for combining a number of authentication handlers, where the failure of one of the handlers will retry with another handler.

For example when authorized keys fail, it can still fall back to a password.

Definition at line 300 of file network_crypto_internal.h.

Member Function Documentation

◆ Add()

void CombinedAuthenticationClientHandler::Add ( Handler &&  handler)
inline

Add the given sub-handler to this handler.

Parameters
handlerThe handler to add.

Definition at line 313 of file network_crypto_internal.h.

◆ CreateClientToServerEncryptionHandler()

virtual std::unique_ptr<NetworkEncryptionHandler> CombinedAuthenticationClientHandler::CreateClientToServerEncryptionHandler ( ) const
inlineoverridevirtual

Create a NetworkEncryptionHandler to encrypt or decrypt messages from the client to the server.

Returns
The handler for the client to server encryption.

Implements NetworkAuthenticationHandler.

Definition at line 322 of file network_crypto_internal.h.

References NetworkAuthenticationHandler::CreateClientToServerEncryptionHandler().

◆ CreateServerToClientEncryptionHandler()

virtual std::unique_ptr<NetworkEncryptionHandler> CombinedAuthenticationClientHandler::CreateServerToClientEncryptionHandler ( ) const
inlineoverridevirtual

Create a NetworkEncryptionHandler to encrypt or decrypt messages from the server to the client.

Returns
The handler for the server to client encryption.

Implements NetworkAuthenticationHandler.

Definition at line 323 of file network_crypto_internal.h.

References NetworkAuthenticationHandler::CreateServerToClientEncryptionHandler().

◆ GetAuthenticationMethod()

NetworkAuthenticationMethod CombinedAuthenticationClientHandler::GetAuthenticationMethod ( ) const
overridevirtual

Get the method this handler is providing functionality for.

Returns
The NetworkAuthenticationMethod.

Implements NetworkAuthenticationHandler.

Definition at line 387 of file network_crypto.cpp.

References current_handler, NetworkAuthenticationHandler::GetAuthenticationMethod(), and NETWORK_AUTH_METHOD_END.

◆ GetName()

std::string_view CombinedAuthenticationClientHandler::GetName ( ) const
overridevirtual

Get the name of the handler for debug messages.

Returns
The name of the handler.

Implements NetworkAuthenticationHandler.

Definition at line 382 of file network_crypto.cpp.

References current_handler, and NetworkAuthenticationHandler::GetName().

Referenced by ReceiveRequest(), and SendResponse().

◆ ReceiveEnableEncryption()

virtual bool CombinedAuthenticationClientHandler::ReceiveEnableEncryption ( struct Packet p)
inlineoverridevirtual

Read the request to enable encryption from the server.

Parameters
pThe request from the server.

Implements NetworkAuthenticationClientHandler.

Definition at line 321 of file network_crypto_internal.h.

References NetworkAuthenticationClientHandler::ReceiveEnableEncryption().

◆ ReceiveRequest()

NetworkAuthenticationClientHandler::RequestResult CombinedAuthenticationClientHandler::ReceiveRequest ( struct Packet p)
overridevirtual

Read a request from the server.

Parameters
pThe packet to read the request from.
Returns
True when valid, otherwise false.

Implements NetworkAuthenticationClientHandler.

Definition at line 361 of file network_crypto.cpp.

References current_handler, Debug, GetName(), handlers, NetworkAuthenticationClientHandler::INVALID, NetworkAuthenticationClientHandler::ReceiveRequest(), and Packet::Recv_uint8().

◆ SendResponse()

bool CombinedAuthenticationClientHandler::SendResponse ( struct Packet p)
overridevirtual

Create the response to send to the server.

Parameters
pThe packet to write the response from.
Returns
True when a valid packet was made, otherwise false.

Implements NetworkAuthenticationClientHandler.

Definition at line 375 of file network_crypto.cpp.

References current_handler, Debug, GetName(), and NetworkAuthenticationClientHandler::SendResponse().


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