OpenTTD Source
20241121-master-g67a0fccfad
|
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< 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. More... | |
virtual RequestResult | ReceiveRequest (struct Packet &p) override |
Read a request from the server. More... | |
virtual bool | SendResponse (struct Packet &p) override |
Create the response to send to the server. 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 | ReceiveEnableEncryption (struct Packet &p) override |
Read the request to enable encryption from the server. More... | |
virtual std::unique_ptr< NetworkEncryptionHandler > | CreateClientToServerEncryptionHandler () const override |
Create a NetworkEncryptionHandler to encrypt or decrypt messages from the client to the server. More... | |
virtual std::unique_ptr< NetworkEncryptionHandler > | CreateServerToClientEncryptionHandler () const override |
Create a NetworkEncryptionHandler to encrypt or decrypt messages from the server to the client. More... | |
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. More... | |
static std::unique_ptr< NetworkAuthenticationClientHandler > | Create (std::shared_ptr< NetworkAuthenticationPasswordRequestHandler > password_handler, std::string &secret_key, std::string &public_key) |
Create a NetworkAuthenticationClientHandler. More... | |
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.
|
inline |
Add the given sub-handler to this handler.
handler | The handler to add. |
Definition at line 313 of file network_crypto_internal.h.
|
inlineoverridevirtual |
Create a NetworkEncryptionHandler to encrypt or decrypt messages from the client to the server.
Implements NetworkAuthenticationHandler.
Definition at line 322 of file network_crypto_internal.h.
References NetworkAuthenticationHandler::CreateClientToServerEncryptionHandler().
|
inlineoverridevirtual |
Create a NetworkEncryptionHandler to encrypt or decrypt messages from the server to the client.
Implements NetworkAuthenticationHandler.
Definition at line 323 of file network_crypto_internal.h.
References NetworkAuthenticationHandler::CreateServerToClientEncryptionHandler().
|
overridevirtual |
Get the method this handler is providing functionality for.
NetworkAuthenticationMethod
. Implements NetworkAuthenticationHandler.
Definition at line 387 of file network_crypto.cpp.
References current_handler, NetworkAuthenticationHandler::GetAuthenticationMethod(), and NETWORK_AUTH_METHOD_END.
|
overridevirtual |
Get the name of the handler for debug messages.
Implements NetworkAuthenticationHandler.
Definition at line 382 of file network_crypto.cpp.
References current_handler, and NetworkAuthenticationHandler::GetName().
Referenced by ReceiveRequest(), and SendResponse().
|
inlineoverridevirtual |
Read the request to enable encryption from the server.
p | The request from the server. |
Implements NetworkAuthenticationClientHandler.
Definition at line 321 of file network_crypto_internal.h.
References NetworkAuthenticationClientHandler::ReceiveEnableEncryption().
|
overridevirtual |
Read a request from the server.
p | The packet to read the request from. |
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().
|
overridevirtual |
Create the response to send to the server.
p | The packet to write the response from. |
Implements NetworkAuthenticationClientHandler.
Definition at line 375 of file network_crypto.cpp.
References current_handler, Debug, GetName(), and NetworkAuthenticationClientHandler::SendResponse().