OpenTTD Source 20241224-master-gee860a5c8e
|
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>
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. | |
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.
using CombinedAuthenticationServerHandler::Handler = std::unique_ptr<NetworkAuthenticationServerHandler> |
The type of the inner handlers.
Definition at line 332 of file network_crypto_internal.h.
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).
handler | The handler to add. |
Definition at line 397 of file network_crypto.cpp.
References handlers.
|
overridevirtual |
Checks whether this handler can be used with the current configuration.
For example when there is no password, the handler cannot be used.
Implements NetworkAuthenticationServerHandler.
Definition at line 434 of file network_crypto.cpp.
References handlers.
Referenced by GetAuthenticationMethod(), GetName(), and ReceiveResponse().
|
inlineoverridevirtual |
Create a NetworkEncryptionHandler to encrypt or decrypt messages from the client to the server.
Implements NetworkAuthenticationHandler.
Definition at line 349 of file network_crypto_internal.h.
|
inlineoverridevirtual |
Create a NetworkEncryptionHandler to encrypt or decrypt messages from the server to the client.
Implements NetworkAuthenticationHandler.
Definition at line 350 of file network_crypto_internal.h.
|
overridevirtual |
Get the method this handler is providing functionality for.
NetworkAuthenticationMethod
. Implements NetworkAuthenticationHandler.
Definition at line 429 of file network_crypto.cpp.
References CanBeUsed(), handlers, and NETWORK_AUTH_METHOD_END.
|
overridevirtual |
Get the name of the handler for debug messages.
Implements NetworkAuthenticationHandler.
Definition at line 424 of file network_crypto.cpp.
References CanBeUsed(), and handlers.
Referenced by ReceiveResponse(), and SendRequest().
|
inlineoverridevirtual |
Get the public key the peer provided during the authentication.
Implements NetworkAuthenticationServerHandler.
Definition at line 347 of file network_crypto_internal.h.
|
overridevirtual |
Read the response from the client.
p | The packet to read the response from. |
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.
|
inlineoverridevirtual |
Create the request to enable encryption to the client.
p | The packet to write the enable encryption request to. |
Implements NetworkAuthenticationServerHandler.
Definition at line 348 of file network_crypto_internal.h.
|
overridevirtual |
Create the request to send to the client.
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().
|
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().