libnick 2025.9.1
A cross-platform base for native Nickvision applications.
Loading...
Searching...
No Matches
Nickvision::Keyring::Keyring Class Reference

A model of a keyring object for managing credentials. More...

#include <keyring.h>

Public Member Functions

 Keyring (const std::string &name)
 Constructs a Keyring.
 
 Keyring (const Keyring &)=delete
 
 Keyring (Keyring &&other) noexcept
 Constructs a Keyring via move.
 
const std::string & getName () const noexcept
 Gets the name of the keyring.
 
bool isSavingToDisk () const noexcept
 Gets whether the keyring is saving data to disk.
 
const std::vector< Credential > & getAll () const noexcept
 Gets all credentials in the keyring.
 
std::optional< Credentialget (const std::string &name) noexcept
 Gets the credential matching the provided name.
 
bool add (const Credential &credential) noexcept
 Adds a credential to the keyring.
 
bool update (const Credential &credential) noexcept
 Updates a credential in the keyring.
 
bool remove (const std::string &name) noexcept
 Deletes a credential from the keyring.
 
bool destroy () noexcept
 Destroys the keyring.
 
Keyringoperator= (const Keyring &)=delete
 
Keyringoperator= (Keyring &&other) noexcept
 Assigns a Keyring via move.
 

Detailed Description

A model of a keyring object for managing credentials.

The keyring is an sqlite database, encrypted with a password stored in the system's credential manager.

Constructor & Destructor Documentation

◆ Keyring() [1/3]

Nickvision::Keyring::Keyring::Keyring ( const std::string & name)

Constructs a Keyring.

If the system credential manager is not available, an in-memory database will be used (credentials will not be saved to disk).

Parameters
nameThe name of the keyring
Exceptions
std::runtime_errorThrown if error in database operations

◆ Keyring() [2/3]

Nickvision::Keyring::Keyring::Keyring ( const Keyring & )
delete

◆ Keyring() [3/3]

Nickvision::Keyring::Keyring::Keyring ( Keyring && other)
noexcept

Constructs a Keyring via move.

Parameters
otherThe Keyring to move

Member Function Documentation

◆ add()

bool Nickvision::Keyring::Keyring::add ( const Credential & credential)
noexcept

Adds a credential to the keyring.

Parameters
credentialThe credential to add
Returns
True if successful, else false

◆ destroy()

bool Nickvision::Keyring::Keyring::destroy ( )
noexcept

Destroys the keyring.

This will delete all data in the keyring and remove it from the system.

The object should not be used after as all methods will return false.

Returns
True if successful, else false

◆ get()

std::optional< Credential > Nickvision::Keyring::Keyring::get ( const std::string & name)
noexcept

Gets the credential matching the provided name.

Parameters
nameThe name of the credential
Returns
The credential matching the name, std::nullopt if no matching credential found

◆ getAll()

const std::vector< Credential > & Nickvision::Keyring::Keyring::getAll ( ) const
noexcept

Gets all credentials in the keyring.

Returns
The list of all credentials

◆ getName()

const std::string & Nickvision::Keyring::Keyring::getName ( ) const
noexcept

Gets the name of the keyring.

Returns
The name of the keyring.

◆ isSavingToDisk()

bool Nickvision::Keyring::Keyring::isSavingToDisk ( ) const
noexcept

Gets whether the keyring is saving data to disk.

Returns
True if saving data to disk, else false

◆ operator=() [1/2]

Keyring & Nickvision::Keyring::Keyring::operator= ( const Keyring & )
delete

◆ operator=() [2/2]

Keyring & Nickvision::Keyring::Keyring::operator= ( Keyring && other)
noexcept

Assigns a Keyring via move.

Parameters
otherThe Keyring to move

◆ remove()

bool Nickvision::Keyring::Keyring::remove ( const std::string & name)
noexcept

Deletes a credential from the keyring.

Parameters
nameThe name of the credential to delete
Returns
True if successful, else false

◆ update()

bool Nickvision::Keyring::Keyring::update ( const Credential & credential)
noexcept

Updates a credential in the keyring.

Parameters
credentialThe credential to update
Returns
True if successful, else false

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