OpenTTD Source 20260206-master-g4d4e37dbf1
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 class  RequestResult : uint8_t { AwaitUserInput , ReadyForResponse , Invalid }
 The processing result of receiving a request. More...

Public Member Functions

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

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.
static std::unique_ptr< NetworkAuthenticationClientHandlerCreate (std::shared_ptr< NetworkAuthenticationPasswordRequestHandler > password_handler, std::string &secret_key, std::string &public_key)
 Create a NetworkAuthenticationClientHandler.

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 Typedef Documentation

◆ Handler

The type of the inner handlers.

Definition at line 302 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()

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()

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, and 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.

Referenced by ReceiveRequest(), and SendResponse().

◆ ReceiveEnableEncryption()

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, 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, and GetName().

Field Documentation

◆ current_handler

NetworkAuthenticationClientHandler* CombinedAuthenticationClientHandler::current_handler = nullptr
private

The currently active handler.

Definition at line 306 of file network_crypto_internal.h.

Referenced by GetAuthenticationMethod(), GetName(), ReceiveRequest(), and SendResponse().

◆ handlers

std::vector<Handler> CombinedAuthenticationClientHandler::handlers
private

The handlers that we can authenticate with.

Definition at line 305 of file network_crypto_internal.h.

Referenced by ReceiveRequest().


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