MySQL 8.0.39
Source Code Documentation
PasswordVault Class Reference

#include <password_vault.h>

Public Member Functions

 PasswordVault ()
 Create an instance of the vault. More...
 
 ~PasswordVault ()
 wipes the contents of the vault cache. More...
 
void update_password (const std::string &section_name, const std::string &password)
 Updates a pair (section name, password) in the vault cache. More...
 
bool get_password (const std::string &section_name, std::string &out_password) const
 Retrieves the password, in clear text, for the given section as is stored in the vault. More...
 
void remove_password (const std::string &section_name)
 Removes the password from the vault for the given section name. More...
 
void store_passwords ()
 Stores the vault cache into persistent storage in encrypted form. More...
 
void clear_passwords ()
 Wipes the contents of the vault file. More...
 

Private Member Functions

void load_passwords ()
 
std::string get_vault_path () const
 
void password_scrambler (std::string &pass)
 

Private Attributes

std::map< std::string, std::string > _passwords
 

Constructor & Destructor Documentation

◆ PasswordVault()

PasswordVault::PasswordVault ( )

Create an instance of the vault.

On creation the vault cache is initialized with the contents of the vault file at APPDATA%/MySQL/MySQL Router/mysql_router_user_data.dat. The passwords are stored in the cache in cleartext.

◆ ~PasswordVault()

PasswordVault::~PasswordVault ( )

wipes the contents of the vault cache.

Member Function Documentation

◆ clear_passwords()

void PasswordVault::clear_passwords ( )

Wipes the contents of the vault file.

NOTE: The delete the vault cache (in memory) created for an instance of PasswordVault is done automatically in the destructor.

◆ get_password()

bool PasswordVault::get_password ( const std::string &  section_name,
std::string &  out_password 
) const

Retrieves the password, in clear text, for the given section as is stored in the vault.

Parameters
section_nameThe name of the configuration section for which to retrieve the password.
out_passwordOutput parameter. The password in clear text if the section name was found in the vault.
Returns
true if a password was retrieved for the given section, false if the section name could not be found in the vault.

◆ get_vault_path()

std::string PasswordVault::get_vault_path ( ) const
private

◆ load_passwords()

void PasswordVault::load_passwords ( )
private

◆ password_scrambler()

void PasswordVault::password_scrambler ( std::string &  pass)
private

◆ remove_password()

void PasswordVault::remove_password ( const std::string &  section_name)

Removes the password from the vault for the given section name.

After executing this method for a fiven section name, the method get_password will return false for the same section name.

Parameters
section_nameThe name of the configuration section for which to remove the password.

◆ store_passwords()

void PasswordVault::store_passwords ( )

Stores the vault cache into persistent storage in encrypted form.

The vault location in persistent storage is APPDATA%/MySQL/MySQL Router/mysql_router_user_data.dat.

◆ update_password()

void PasswordVault::update_password ( const std::string &  section_name,
const std::string &  password 
)

Updates a pair (section name, password) in the vault cache.

If the record for the given section name & password does not exits, it is created. If it exists it is just updated with the new password.

Parameters
section_nameThe name of the configuration section to store in the vault.
passwordThe password, in clear text, of the user in the configuration section to store in the vault.

Member Data Documentation

◆ _passwords

std::map<std::string, std::string> PasswordVault::_passwords
private

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