OpenTTD Source: CombinedAuthenticationClientHandler Class Reference

OpenTTD Source 15.0-beta1

Public Types | Public Member Functions | Private Attributes
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:

## 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.
virtual RequestResult | ReceiveRequest (struct Packet &p) override
| Read a request from the server.
virtual bool | SendResponse (struct Packet &p) override
| Create the response to send to the server.
virtual std::string_view | GetName () const override
| Get the name of the handler for debug messages.
virtual NetworkAuthenticationMethod | GetAuthenticationMethod () const override
| Get the method this handler is providing functionality for.
virtual bool | ReceiveEnableEncryption (struct Packet &p) override
| Read the request to enable encryption from the server.
virtual std::unique_ptr< NetworkEncryptionHandler > | CreateClientToServerEncryptionHandler () const override
| Create a NetworkEncryptionHandler to encrypt or decrypt messages from the client to the server.
virtual std::unique_ptr< NetworkEncryptionHandler > | CreateServerToClientEncryptionHandler () const override
| Create a NetworkEncryptionHandler to encrypt or decrypt messages from the server to the client.

## Private Attributes
std::vector< Handler > | handlers
| The handlers that we can authenticate with.
NetworkAuthenticationClientHandler * | current_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< NetworkAuthenticationClientHandler > | Create (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

using CombinedAuthenticationClientHandler::Handler = std::unique_ptr<NetworkAuthenticationClientHandler>

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

  handler | The 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

  p | The 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

  p | The 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

  p | The 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().

## 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:

- src/network/network_crypto_internal.h
- src/network/network_crypto.cpp