E-MailRelay
Classes | Public Member Functions | Static Public Member Functions | List of all members
GAuth::SecretsFile Class Reference

A class to read authentication secrets from file, used by GAuth::Secrets. More...

#include <gsecretsfile.h>

Public Member Functions

 SecretsFile (const G::Path &path, bool auto_reread, const std::string &debug_name)
 Constructor to read "client" and "server" records from the named file. More...
 
bool valid () const
 Returns true if the file path was supplied in the ctor. More...
 
bool containsClientSelector (std::string_view selector) const
 Returns true if the given client account selector is valid. More...
 
bool containsClientSecret (std::string_view selector) const
 Returns true if a client secret is available with the given account selector. More...
 
Secret clientSecret (std::string_view type, std::string_view selector={}) const
 Returns the client id and secret for the given type. More...
 
bool containsServerSecret (std::string_view type, std::string_view id={}) const
 Returns true if a server secret of the given type is available for the particular user or for any user if defaulted. More...
 
Secret serverSecret (std::string_view type, std::string_view id) const
 Returns the server secret for the given id and type. More...
 
std::pair< std::string, std::string > serverTrust (const std::string &address_range) const
 Returns a non-empty trustee name if the server trusts remote clients in the given address range, together with context information. More...
 
std::string path () const
 Returns the file path, as supplied to the ctor. More...
 

Static Public Member Functions

static void check (const std::string &path, bool with_warnings)
 Checks the given file. More...
 

Detailed Description

A class to read authentication secrets from file, used by GAuth::Secrets.

Updates to the file are detected automatically.

Definition at line 47 of file gsecretsfile.h.

Constructor & Destructor Documentation

◆ SecretsFile()

GAuth::SecretsFile::SecretsFile ( const G::Path path,
bool  auto_reread,
const std::string &  debug_name 
)

Constructor to read "client" and "server" records from the named file.

The path is optional; see valid().

Definition at line 36 of file gsecretsfile.cpp.

Member Function Documentation

◆ check()

void GAuth::SecretsFile::check ( const std::string &  path,
bool  with_warnings 
)
static

Checks the given file.

Logs errors and optionally warnings and then throws an exception if there were any errors.

Definition at line 48 of file gsecretsfile.cpp.

◆ clientSecret()

GAuth::Secret GAuth::SecretsFile::clientSecret ( std::string_view  type,
std::string_view  selector = {} 
) const

Returns the client id and secret for the given type.

Returns an in-valid() Secret if no matching client secret having a non-empty id.

Definition at line 315 of file gsecretsfile.cpp.

◆ containsClientSecret()

bool GAuth::SecretsFile::containsClientSecret ( std::string_view  selector) const

Returns true if a client secret is available with the given account selector.

Definition at line 295 of file gsecretsfile.cpp.

◆ containsClientSelector()

bool GAuth::SecretsFile::containsClientSelector ( std::string_view  selector) const

Returns true if the given client account selector is valid.

A special "plain:b = = <selector>" line can make the selector valid without creating a client secret.

Definition at line 290 of file gsecretsfile.cpp.

◆ containsServerSecret()

bool GAuth::SecretsFile::containsServerSecret ( std::string_view  type,
std::string_view  id = {} 
) const

Returns true if a server secret of the given type is available for the particular user or for any user if defaulted.

Definition at line 329 of file gsecretsfile.cpp.

◆ path()

std::string GAuth::SecretsFile::path ( ) const

Returns the file path, as supplied to the ctor.

Definition at line 372 of file gsecretsfile.cpp.

◆ serverSecret()

GAuth::Secret GAuth::SecretsFile::serverSecret ( std::string_view  type,
std::string_view  id 
) const

Returns the server secret for the given id and type.

Returns an in-valid() Secret if no matching server secret.

Definition at line 341 of file gsecretsfile.cpp.

◆ serverTrust()

std::pair< std::string, std::string > GAuth::SecretsFile::serverTrust ( const std::string &  address_range) const

Returns a non-empty trustee name if the server trusts remote clients in the given address range, together with context information.

Definition at line 355 of file gsecretsfile.cpp.

◆ valid()

bool GAuth::SecretsFile::valid ( ) const

Returns true if the file path was supplied in the ctor.

Definition at line 59 of file gsecretsfile.cpp.


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