MySQL 9.1.0
Source Code Documentation
KeyringInfo Class Reference

KeyringInfo class encapsulates loading and storing master key using master-key-reader and master-key-writer. More...

#include <keyring_info.h>

Public Member Functions

 KeyringInfo (bool verbose=true) noexcept
 Default constructor. More...
 
 KeyringInfo (const std::string &keyring_file, const std::string &master_key_file)
 Constructs KeyringInfo and assigns keyring file and master key file. More...
 
void set_keyring_file (const std::string &keyring_file)
 
const std::string & get_keyring_file () const noexcept
 
void set_master_key_file (const std::string &master_key_file)
 
const std::string & get_master_key_file () const noexcept
 
void set_master_key_reader (const std::string &master_key_reader)
 
const std::string & get_master_key_reader () const noexcept
 
void set_master_key_writer (const std::string &master_key_writer)
 
const std::string & get_master_key_writer () const noexcept
 
void set_master_key (const std::string &master_key)
 
const std::string & get_master_key () const noexcept
 
void init (mysql_harness::Config &config)
 Initializes KeyringInfo using data read from Config. More...
 
bool read_master_key () noexcept
 Reads master key using master_key_reader_;. More...
 
bool write_master_key () const noexcept
 Writes master key using master_key_writer_;. More...
 
void generate_master_key () noexcept
 
void add_router_id_to_env (uint32_t router_id) const
 Adds ROUTER_ID variable to environment. More...
 
bool use_master_key_external_facility () const noexcept
 Checks if master-key-reader/master-key-writer should be used to load/store master key. More...
 
bool use_master_key_file () const noexcept
 Checks if mysqlrouter.key and keyring files should be used to store master key. More...
 
void validate_master_key () const
 Checks if master key is correct: it cannot be empty, and cannot be longer than mysql_harness::kMaxKeyringKeyLength. More...
 
std::string get_keyring_file (const mysql_harness::Config &config) const
 Returns path to keyring file based on data read from config or bootstrap directory. More...
 

Private Attributes

std::string keyring_file_
 The path to keyring file. More...
 
std::string master_key_file_
 The path to master key file, empty if master key file is not used. More...
 
std::string master_key_reader_
 The path to master-key-reader that is used to read master key. More...
 
std::string master_key_writer_
 The path to master-key-writer that is used to store master key. More...
 
std::string master_key_
 The master key that is used to encode/decode keyring content. More...
 
std::chrono::milliseconds rw_timeout_ = std::chrono::milliseconds(30000)
 The maximum time to write master key using master-key-writer or read master key using master-key-fetcher. More...
 
bool verbose_ = true
 If true then log verbose error messages. More...
 

Detailed Description

KeyringInfo class encapsulates loading and storing master key using master-key-reader and master-key-writer.

Constructor & Destructor Documentation

◆ KeyringInfo() [1/2]

KeyringInfo::KeyringInfo ( bool  verbose = true)
inlinenoexcept

Default constructor.

Parameters
verboseIF true then log verbose error messages

◆ KeyringInfo() [2/2]

KeyringInfo::KeyringInfo ( const std::string &  keyring_file,
const std::string &  master_key_file 
)
inline

Constructs KeyringInfo and assigns keyring file and master key file.

Parameters
keyring_fileThe path to keyring file
master_key_fileThe path to master key file

Member Function Documentation

◆ add_router_id_to_env()

void KeyringInfo::add_router_id_to_env ( uint32_t  router_id) const

Adds ROUTER_ID variable to environment.

Exceptions
SetRouterIdEnvVariableErrorif adding ROUTER_ID to environment fails.

◆ generate_master_key()

void KeyringInfo::generate_master_key ( )
noexcept

◆ get_keyring_file() [1/2]

const std::string & KeyringInfo::get_keyring_file ( ) const
inlinenoexcept

◆ get_keyring_file() [2/2]

std::string KeyringInfo::get_keyring_file ( const mysql_harness::Config config) const

Returns path to keyring file based on data read from config or bootstrap directory.

Returns
The path to keyring file

◆ get_master_key()

const std::string & KeyringInfo::get_master_key ( ) const
inlinenoexcept

◆ get_master_key_file()

const std::string & KeyringInfo::get_master_key_file ( ) const
inlinenoexcept

◆ get_master_key_reader()

const std::string & KeyringInfo::get_master_key_reader ( ) const
inlinenoexcept

◆ get_master_key_writer()

const std::string & KeyringInfo::get_master_key_writer ( ) const
inlinenoexcept

◆ init()

void KeyringInfo::init ( mysql_harness::Config config)

Initializes KeyringInfo using data read from Config.

It initializes keyring_file, master_key_file_, master_key_reader_ and master_key_writer.

Parameters
configThe Config that is used to initialize KeyringInfo

◆ read_master_key()

bool KeyringInfo::read_master_key ( )
noexcept

Reads master key using master_key_reader_;.

Returns
true if successfully read master key, false otherwise.

◆ set_keyring_file()

void KeyringInfo::set_keyring_file ( const std::string &  keyring_file)
inline

◆ set_master_key()

void KeyringInfo::set_master_key ( const std::string &  master_key)
inline

◆ set_master_key_file()

void KeyringInfo::set_master_key_file ( const std::string &  master_key_file)
inline

◆ set_master_key_reader()

void KeyringInfo::set_master_key_reader ( const std::string &  master_key_reader)
inline

◆ set_master_key_writer()

void KeyringInfo::set_master_key_writer ( const std::string &  master_key_writer)
inline

◆ use_master_key_external_facility()

bool KeyringInfo::use_master_key_external_facility ( ) const
noexcept

Checks if master-key-reader/master-key-writer should be used to load/store master key.

Returns
true if master-key-reader/master-key-writer should be used to load/store master key, false otherwise.

◆ use_master_key_file()

bool KeyringInfo::use_master_key_file ( ) const
noexcept

Checks if mysqlrouter.key and keyring files should be used to store master key.

Returns
true if master key should be used to store master key, false otherwise.

◆ validate_master_key()

void KeyringInfo::validate_master_key ( ) const

Checks if master key is correct: it cannot be empty, and cannot be longer than mysql_harness::kMaxKeyringKeyLength.

Exceptions
std::runtime_errorif master key is empty or is longer than mysql_harness::kMaxKeyringKeyLength

◆ write_master_key()

bool KeyringInfo::write_master_key ( ) const
noexcept

Writes master key using master_key_writer_;.

Returns
true if write was successful, false otherwise.

Member Data Documentation

◆ keyring_file_

std::string KeyringInfo::keyring_file_
private

The path to keyring file.

◆ master_key_

std::string KeyringInfo::master_key_
private

The master key that is used to encode/decode keyring content.

◆ master_key_file_

std::string KeyringInfo::master_key_file_
private

The path to master key file, empty if master key file is not used.

◆ master_key_reader_

std::string KeyringInfo::master_key_reader_
private

The path to master-key-reader that is used to read master key.

◆ master_key_writer_

std::string KeyringInfo::master_key_writer_
private

The path to master-key-writer that is used to store master key.

◆ rw_timeout_

std::chrono::milliseconds KeyringInfo::rw_timeout_ = std::chrono::milliseconds(30000)
private

The maximum time to write master key using master-key-writer or read master key using master-key-fetcher.

◆ verbose_

bool KeyringInfo::verbose_ = true
private

If true then log verbose error messages.


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