OpenTTD Source  20240919-master-gdf0233f4c2
CombinedAuthenticationServerHandler 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 CombinedAuthenticationServerHandler:
NetworkAuthenticationServerHandler NetworkAuthenticationHandler

Public Types

using Handler = std::unique_ptr< NetworkAuthenticationServerHandler >
 The type of the inner handlers.
 
- Public Types inherited from NetworkAuthenticationServerHandler
enum  ResponseResult { AUTHENTICATED, NOT_AUTHENTICATED, RETRY_NEXT_METHOD }
 The processing result of receiving a response. More...
 

Public Member Functions

void Add (Handler &&handler)
 Add the given sub-handler to this handler, if the handler can be used (e.g. More...
 
virtual void SendRequest (struct Packet &p) override
 Create the request to send to the client. More...
 
virtual ResponseResult ReceiveResponse (struct Packet &p) override
 Read the response from the client. 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 CanBeUsed () const override
 Checks whether this handler can be used with the current configuration. More...
 
virtual std::string GetPeerPublicKey () const override
 Get the public key the peer provided during the authentication. More...
 
virtual void SendEnableEncryption (struct Packet &p) override
 Create the request to enable encryption to the client. 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 (still) authenticate with.
 

Additional Inherited Members

- Static Public Member Functions inherited from NetworkAuthenticationServerHandler
static std::unique_ptr< NetworkAuthenticationServerHandlerCreate (const NetworkAuthenticationPasswordProvider *password_provider, const NetworkAuthenticationAuthorizedKeyHandler *authorized_key_handler, NetworkAuthenticationMethodMask client_supported_method_mask=~static_cast< NetworkAuthenticationMethodMask >(0))
 Create a NetworkAuthenticationServerHandler. 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 330 of file network_crypto_internal.h.

Member Function Documentation

◆ Add()

void CombinedAuthenticationServerHandler::Add ( CombinedAuthenticationServerHandler::Handler &&  handler)

Add the given sub-handler to this handler, if the handler can be used (e.g.

there are authorized keys or there is a password).

Parameters
handlerThe handler to add.

Definition at line 397 of file network_crypto.cpp.

References handlers.

◆ CanBeUsed()

bool CombinedAuthenticationServerHandler::CanBeUsed ( ) const
overridevirtual

Checks whether this handler can be used with the current configuration.

For example when there is no password, the handler cannot be used.

Returns
True when this handler can be used.

Implements NetworkAuthenticationServerHandler.

Definition at line 434 of file network_crypto.cpp.

References handlers.

Referenced by GetAuthenticationMethod(), and GetName().

◆ CreateClientToServerEncryptionHandler()

virtual std::unique_ptr<NetworkEncryptionHandler> CombinedAuthenticationServerHandler::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 349 of file network_crypto_internal.h.

◆ CreateServerToClientEncryptionHandler()

virtual std::unique_ptr<NetworkEncryptionHandler> CombinedAuthenticationServerHandler::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 350 of file network_crypto_internal.h.

◆ GetAuthenticationMethod()

NetworkAuthenticationMethod CombinedAuthenticationServerHandler::GetAuthenticationMethod ( ) const
overridevirtual

Get the method this handler is providing functionality for.

Returns
The NetworkAuthenticationMethod.

Implements NetworkAuthenticationHandler.

Definition at line 429 of file network_crypto.cpp.

References CanBeUsed(), handlers, and NETWORK_AUTH_METHOD_END.

◆ GetName()

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

Get the name of the handler for debug messages.

Returns
The name of the handler.

Implements NetworkAuthenticationHandler.

Definition at line 424 of file network_crypto.cpp.

References CanBeUsed(), and handlers.

Referenced by ReceiveResponse(), and SendRequest().

◆ GetPeerPublicKey()

virtual std::string CombinedAuthenticationServerHandler::GetPeerPublicKey ( ) const
inlineoverridevirtual

Get the public key the peer provided during the authentication.

Returns
The hexadecimal string representation of the peer's public key.

Implements NetworkAuthenticationServerHandler.

Definition at line 347 of file network_crypto_internal.h.

◆ ReceiveResponse()

NetworkAuthenticationServerHandler::ResponseResult CombinedAuthenticationServerHandler::ReceiveResponse ( struct Packet p)
overridevirtual

Read the response from the client.

Parameters
pThe packet to read the response from.
Returns
The ResponseResult describing the result.

Implements NetworkAuthenticationServerHandler.

Definition at line 413 of file network_crypto.cpp.

References Debug, and GetName().

◆ SendEnableEncryption()

virtual void CombinedAuthenticationServerHandler::SendEnableEncryption ( struct Packet p)
inlineoverridevirtual

Create the request to enable encryption to the client.

Parameters
pThe packet to write the enable encryption request to.

Implements NetworkAuthenticationServerHandler.

Definition at line 348 of file network_crypto_internal.h.

◆ SendRequest()

void CombinedAuthenticationServerHandler::SendRequest ( struct Packet p)
overridevirtual

Create the request to send to the client.

Parameters
pThe packet to write the request to.

Implements NetworkAuthenticationServerHandler.

Definition at line 405 of file network_crypto.cpp.

References Debug, GetName(), handlers, and Packet::Send_uint8().


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