libDwmAuth-0.3.6
Dwm::Auth::PublicKeysFile Class Reference

Encapsulates a file containing public keys in a format similar to (but not the same as) an ssh authorized_keys file. More...

#include <DwmAuthPublicKeysFile.hh>

Public Types

typedef std::map< std::string, Ed25519::PublicKey > Map
 

Public Member Functions

 PublicKeysFile ()
 Constructor.
 
 PublicKeysFile (const PublicKeysFile &pkf)=default
 Copy constructor.
 
bool Load (const std::string &fileName)
 Loads the public keys from the file at the given path fileName. More...
 
bool AddKey (const std::string &name, const Ed25519::PublicKey &key)
 Adds a key with the given name to the contained map of keys. More...
 
bool AddKey (const std::string &name, const std::string &base64str)
 
bool RemoveKey (const std::string &name)
 Removes the key with the given name from the contained map of keys. More...
 
bool Save (const std::string &fileName, int perms=0644) const
 Saves the contained map of keys to the file with the given fileName with permissions @perms. More...
 
bool Find (const std::string &name, Ed25519::PublicKey &key) const
 Searches the keys for the one with the given name. More...
 
const Map & Keys () const
 Returns a const reference to the contained public keys.
 

Detailed Description

Encapsulates a file containing public keys in a format similar to (but not the same as) an ssh authorized_keys file.

Member Function Documentation

◆ AddKey()

bool Dwm::Auth::PublicKeysFile::AddKey ( const std::string &  name,
const Ed25519::PublicKey &  key 
)

Adds a key with the given name to the contained map of keys.

Returns true on success, false on failure. Does NOT save to disk; you must call Save() to save to disk.

◆ Find()

bool Dwm::Auth::PublicKeysFile::Find ( const std::string &  name,
Ed25519::PublicKey &  key 
) const

Searches the keys for the one with the given name.

Returns true and fills key on success, returns false on failure.

◆ Load()

bool Dwm::Auth::PublicKeysFile::Load ( const std::string &  fileName)

Loads the public keys from the file at the given path fileName.

Returns true on success, false on failure.

◆ RemoveKey()

bool Dwm::Auth::PublicKeysFile::RemoveKey ( const std::string &  name)

Removes the key with the given name from the contained map of keys.

Returns true on success, false on failure. Does NOT save to disk; you must call Save() to save to disk.

◆ Save()

bool Dwm::Auth::PublicKeysFile::Save ( const std::string &  fileName,
int  perms = 0644 
) const

Saves the contained map of keys to the file with the given fileName with permissions @perms.

Returns true on success, false on failure.


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