|
Botcraft 26.3
|
#include <Authentifier.hpp>
Public Member Functions | |
| Authentifier () | |
| ~Authentifier () | |
| bool | AuthMicrosoft (const std::string &cache_key) |
| Authentication using a Microsoft account, storing the credentials in the cache file. | |
| bool | AuthMCToken (const std::string &mc_token) |
| Authentication using a minecraft token. | |
| bool | JoinServer (const std::string &server_id, const std::vector< unsigned char > &shared_secret, const std::vector< unsigned char > &server_public_key) const |
| const std::string & | GetPlayerDisplayName () const |
| const std::array< unsigned char, 16 > & | GetPlayerUUID () const |
| RSA * | GetPrivateKey () const |
| const std::string & | GetPublicKey () const |
| const std::string & | GetKeySignature () const |
| long long int | GetKeyTimestamp () const |
| std::vector< unsigned char > | GetMessageSignature (const std::string &message, const int message_sent_index, const ProtocolCraft::UUID &chat_session_uuid, const std::vector< std::vector< unsigned char > > &last_seen, long long int &salt, long long int ×tamp) |
| Compute the signature of a message. | |
Private Member Functions | |
| void | UpdateUUIDBytes () |
| Compute the UUID bytes from the string one. | |
| void | GetPlayerCertificates () |
| Get player certificates using the Minecraft token, throw if failed. | |
Private Attributes | |
| std::string | player_display_name |
| std::string | mc_access_token |
| std::string | mc_player_uuid |
| std::array< unsigned char, 16 > | mc_player_uuid_bytes |
| RSA * | private_key = nullptr |
| std::string | public_key |
| std::string | key_signature |
| long long int | key_timestamp |
| std::mt19937 | rnd |
Definition at line 21 of file Authentifier.hpp.
| Botcraft::Authentifier::Authentifier | ( | ) |
Definition at line 73 of file Authentifier.cpp.
References key_timestamp, mc_player_uuid_bytes, and rnd.
| Botcraft::Authentifier::~Authentifier | ( | ) |
Definition at line 82 of file Authentifier.cpp.
References private_key.
| bool Botcraft::Authentifier::AuthMCToken | ( | const std::string & | mc_token | ) |
Authentication using a minecraft token.
| mc_token | Minecraft token, must be valid |
Definition at line 162 of file Authentifier.cpp.
References GetPlayerCertificates(), LOG_ERROR, LOG_INFO, mc_access_token, mc_player_uuid, player_display_name, and UpdateUUIDBytes().
| bool Botcraft::Authentifier::AuthMicrosoft | ( | const std::string & | cache_key | ) |
Authentication using a Microsoft account, storing the credentials in the cache file.
| cache_key | used as key to identify the credentials in cache file |
Definition at line 95 of file Authentifier.cpp.
References ProtocolCraft::Json::Value::contains(), ProtocolCraft::Json::Value::get_object(), ProtocolCraft::Json::Value::get_string(), GetPlayerCertificates(), ProtocolCraft::Json::Value::is_number(), ProtocolCraft::Json::Value::is_string(), LOG_ERROR, LOG_INFO, LOG_WARNING, mc_access_token, mc_player_uuid, player_display_name, and UpdateUUIDBytes().
| const std::string & Botcraft::Authentifier::GetKeySignature | ( | ) | const |
Definition at line 301 of file Authentifier.cpp.
References key_signature.
| long long int Botcraft::Authentifier::GetKeyTimestamp | ( | ) | const |
Definition at line 306 of file Authentifier.cpp.
References key_timestamp.
| std::vector< unsigned char > Botcraft::Authentifier::GetMessageSignature | ( | const std::string & | message, |
| const int | message_sent_index, | ||
| const ProtocolCraft::UUID & | chat_session_uuid, | ||
| const std::vector< std::vector< unsigned char > > & | last_seen, | ||
| long long int & | salt, | ||
| long long int & | timestamp | ||
| ) |
Compute the signature of a message.
| message | Message to send |
| message_sent_index | Index of the message in this message chain |
| chat_session_uuid | UUID of the chat session, as sent in ServerboundChatSessionUpdatePacket |
| last_seen | Vector of signatures of previously received messages |
| salt | Output salt used to generate the signature |
| timestamp | Output timestamp in ms used to generate the signature |
Definition at line 318 of file Authentifier.cpp.
References LOG_ERROR.
|
private |
Get player certificates using the Minecraft token, throw if failed.
Definition at line 449 of file Authentifier.cpp.
References Botcraft::CheckJsonResponse(), ProtocolCraft::Json::Value::get_string(), key_signature, key_timestamp, LOG_INFO, mc_access_token, Botcraft::POSTRequest(), private_key, and public_key.
Referenced by AuthMCToken(), and AuthMicrosoft().
| const std::string & Botcraft::Authentifier::GetPlayerDisplayName | ( | ) | const |
Definition at line 280 of file Authentifier.cpp.
References player_display_name.
| const std::array< unsigned char, 16 > & Botcraft::Authentifier::GetPlayerUUID | ( | ) | const |
Definition at line 285 of file Authentifier.cpp.
References mc_player_uuid_bytes.
| RSA * Botcraft::Authentifier::GetPrivateKey | ( | ) | const |
Definition at line 291 of file Authentifier.cpp.
References private_key.
| const std::string & Botcraft::Authentifier::GetPublicKey | ( | ) | const |
Definition at line 296 of file Authentifier.cpp.
References public_key.
| bool Botcraft::Authentifier::JoinServer | ( | const std::string & | server_id, |
| const std::vector< unsigned char > & | shared_secret, | ||
| const std::vector< unsigned char > & | server_public_key | ||
| ) | const |
Definition at line 190 of file Authentifier.cpp.
References ProtocolCraft::Json::Value::Dump(), LOG_ERROR, mc_access_token, mc_player_uuid, Botcraft::POSTRequest(), Botcraft::WebRequestResponse::response, Botcraft::WebRequestResponse::status_code, and Botcraft::WebRequestResponse::status_message.
|
private |
Compute the UUID bytes from the string one.
Definition at line 438 of file Authentifier.cpp.
References mc_player_uuid, and mc_player_uuid_bytes.
Referenced by AuthMCToken(), and AuthMicrosoft().
|
private |
Definition at line 103 of file Authentifier.hpp.
Referenced by GetKeySignature(), and GetPlayerCertificates().
|
private |
Definition at line 104 of file Authentifier.hpp.
Referenced by Authentifier(), GetKeyTimestamp(), and GetPlayerCertificates().
|
private |
Definition at line 96 of file Authentifier.hpp.
Referenced by AuthMCToken(), AuthMicrosoft(), GetPlayerCertificates(), and JoinServer().
|
private |
Definition at line 97 of file Authentifier.hpp.
Referenced by AuthMCToken(), AuthMicrosoft(), JoinServer(), and UpdateUUIDBytes().
|
private |
Definition at line 98 of file Authentifier.hpp.
Referenced by Authentifier(), GetPlayerUUID(), and UpdateUUIDBytes().
|
private |
Definition at line 95 of file Authentifier.hpp.
Referenced by AuthMCToken(), AuthMicrosoft(), and GetPlayerDisplayName().
|
private |
Definition at line 101 of file Authentifier.hpp.
Referenced by GetPlayerCertificates(), GetPrivateKey(), and ~Authentifier().
|
private |
Definition at line 102 of file Authentifier.hpp.
Referenced by GetPlayerCertificates(), and GetPublicKey().
|
private |
Definition at line 106 of file Authentifier.hpp.
Referenced by Authentifier().