OpenTTD Source: CombinedAuthenticationServerHandler Class Reference

OpenTTD Source 15.0-beta1

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

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

## Additional Inherited Members
Static Public Member Functions inherited from NetworkAuthenticationServerHandler
static std::unique_ptr< NetworkAuthenticationServerHandler > | Create (const NetworkAuthenticationPasswordProvider *password_provider, const NetworkAuthenticationAuthorizedKeyHandler *authorized_key_handler, NetworkAuthenticationMethodMask client_supported_method_mask=~static_cast< NetworkAuthenticationMethodMask >(0))
| Create a NetworkAuthenticationServerHandler.

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

## ◆ Handler

using CombinedAuthenticationServerHandler::Handler = std::unique_ptr<NetworkAuthenticationServerHandler>

The type of the inner handlers.

Definition at line 332 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

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

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

  p | The packet to read the response from.

Returns
  The `ResponseResult` describing the result.

Implements NetworkAuthenticationServerHandler.

Definition at line 413 of file network_crypto.cpp.

References CanBeUsed(), Debug, GetName(), handlers, NetworkAuthenticationServerHandler::NOT_AUTHENTICATED, and NetworkAuthenticationServerHandler::RETRY_NEXT_METHOD.

## ◆ SendEnableEncryption()

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

Create the request to enable encryption to the client.

Parameters

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

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

## Field Documentation

## ◆ handlers

std::vector<Handler> CombinedAuthenticationServerHandler::handlers
| private

The handlers that we can (still) authenticate with.

Definition at line 335 of file network_crypto_internal.h.

Referenced by Add(), CanBeUsed(), GetAuthenticationMethod(), GetName(), ReceiveResponse(), and SendRequest().

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

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