21#ifndef G_AUTH_SECRETS_FILE_H
22#define G_AUTH_SECRETS_FILE_H
50 G_EXCEPTION( Error ,
tx(
"invalid secrets file") )
51 G_EXCEPTION( OpenError ,
tx(
"cannot read secrets file") )
53 static void check(
const std::string &
path ,
bool with_warnings ) ;
88 std::pair<std::string,std::string>
serverTrust(
const std::string & address_range )
const ;
93 std::string
path()
const ;
97 using MapOfSecrets = std::map<std::string,Secret> ;
98 using MapOfInt = std::map<std::string,unsigned int> ;
99 using SetOfStrings = std::set<std::string> ;
100 using Diagnostic = std::tuple<bool,unsigned long,std::string> ;
101 using Diagnostics = std::vector<Diagnostic> ;
102 using TrustMap = std::map<std::string,std::pair<std::string,int>> ;
106 SetOfStrings m_server_types ;
107 MapOfInt m_selectors ;
108 TrustMap m_trust_map ;
109 Diagnostics m_diagnostics ;
110 std::size_t m_errors {0U} ;
115 void reread()
const ;
117 bool containsClientSecretImp( std::string_view ,
bool )
const ;
118 static Contents readContents(
const G::Path & ) ;
119 static Contents readContents( std::istream & ) ;
120 static void processLine( Contents & ,
121 unsigned int , std::string_view side , std::string_view , std::string_view ,
122 std::string_view , std::string_view ) ;
123 static void showDiagnostics(
const Contents & c ,
const G::Path & ,
const std::string & debug_name ,
bool with_warnings ) ;
124 static void addWarning( Contents & ,
unsigned int , std::string_view , std::string_view = {} ) ;
125 static void addError( Contents & ,
unsigned int , std::string_view , std::string_view = {} ) ;
126 static std::string join( std::string_view , std::string_view ) ;
127 static std::string_view canonicalView( std::string_view encoding_type ) ;
128 static std::string serverKey(
const std::string & ,
const std::string & ) ;
129 static std::string serverKey( std::string_view , std::string_view ) ;
130 static std::string clientKey( std::string_view , std::string_view ) ;
132 static std::string lineContext(
unsigned int ) ;
137 std::string m_debug_name ;
139 Contents m_contents ;
Encapsulates a userid/shared-secret/hash-function tuple from the secrets file.
A class to read authentication secrets from file, used by GAuth::Secrets.
Secret serverSecret(std::string_view type, std::string_view id) const
Returns the server secret for the given id and type.
bool containsClientSecret(std::string_view selector) const
Returns true if a client secret is available with the given account selector.
static void check(const std::string &path, bool with_warnings)
Checks the given file.
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 use...
Secret clientSecret(std::string_view type, std::string_view selector={}) const
Returns the client id and secret for the given type.
bool valid() const
Returns true if the file path was supplied in the ctor.
std::string path() const
Returns the file path, as supplied to the ctor.
bool containsClientSelector(std::string_view selector) const
Returns true if the given client account selector is valid.
SecretsFile(const G::Path &path, bool auto_reread, const std::string &debug_name)
Constructor to read "client" and "server" records from the named file.
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,...
A Path object represents a file system path.
Represents a unix-epoch time with microsecond resolution.
SASL authentication classes.
constexpr const char * tx(const char *p) noexcept
A briefer alternative to G::gettext_noop().