libnick 2024.9.2
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.
 
const std::string & getName () const
 Gets the name of the keyring.
 
bool isSavingToDisk () const
 Gets whether the keyring is saving data to disk.
 
const std::vector< Credential > & getCredentials () const
 Gets all credentials in the keyring.
 
std::optional< CredentialgetCredential (const std::string &name)
 Gets the credential matching the provided name.
 
bool addCredential (const Credential &credential)
 Adds a credential to the keyring.
 
bool updateCredential (const Credential &credential)
 Updates a credential in the keyring.
 
bool deleteCredential (const std::string &name)
 Deletes a credential from the keyring.
 
bool destroy ()
 Destroys the keyring.
 

Detailed Description

A model of a keyring object for managing credentials.

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

Constructor & Destructor Documentation

◆ Keyring()

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

Constructs a Keyring.

If the system credential manager is not available, the object will be functional but will not save any data to disk.

Parameters
nameThe name of the keyring

Member Function Documentation

◆ addCredential()

bool Nickvision::Keyring::Keyring::addCredential ( const Credential & credential)

Adds a credential to the keyring.

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

◆ deleteCredential()

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

Deletes a credential from the keyring.

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

◆ destroy()

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

Destroys the keyring.

This will delete all data in the keyring and put the object in a state where no data can be saved to disk.

Returns
True if successful, else false

◆ getCredential()

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

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

◆ getCredentials()

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

Gets all credentials in the keyring.

Returns
The list of all credentials

◆ getName()

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

Gets the name of the keyring.

Returns
The name of the keyring.

◆ isSavingToDisk()

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

Gets whether the keyring is saving data to disk.

Returns
True if saving data to disk, else false

◆ updateCredential()

bool Nickvision::Keyring::Keyring::updateCredential ( const Credential & credential)

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: