E-MailRelay
|
Encapsulates a shared secret from the secrets file plus the associated userid. More...
#include <gsecret.h>
Public Member Functions | |
Secret (const std::string &secret, const std::string &secret_encoding, const std::string &id, bool id_encoding_xtext, const std::string &context=std::string()) | |
Constructor used by the SecretsFile class. More... | |
bool | valid () const |
Returns true if the secret is valid. More... | |
std::string | key () const |
Returns the key. Throws if not valid(). More... | |
bool | masked () const |
Returns true if key() is masked. More... | |
std::string | maskType () const |
Returns the masking function name, such as "MD5", or the empty string if not masked(). More... | |
std::string | id () const |
Returns the associated identity. Throws if not valid(). More... | |
std::string | info (const std::string &id=std::string()) const |
Returns information for logging, excluding anything sensitive. More... | |
Static Public Member Functions | |
static std::string | check (const std::string &secret, const std::string &secret_encoding, const std::string &id, bool id_encoding_xtext) |
Does a non-throwing check of the constructor parameters, returning an error message or the empty string. More... | |
static Secret | none (const std::string &id) |
Factory function that returns a secret that is not valid(), as used by the SecretsFile class. More... | |
static Secret | none () |
Factory function that returns a secret that is not valid() and has an empty id(). More... | |
Encapsulates a shared secret from the secrets file plus the associated userid.
A secret is usually a plaintext shared key, but it may be masked by a hash function. If masked then it can only be verified by an hmac operation using the matching hash function. However, the hmac hash function must be capable of accepting an intermediate hash state, and this is might only be available for md5.
GAuth::Secret::Secret | ( | const std::string & | secret, |
const std::string & | secret_encoding, | ||
const std::string & | id, | ||
bool | id_encoding_xtext, | ||
const std::string & | context = std::string() |
||
) |
Constructor used by the SecretsFile class.
Throws on error, including if the encodings are invalid.
Definition at line 41 of file gsecret.cpp.
|
static |
Does a non-throwing check of the constructor parameters, returning an error message or the empty string.
Definition at line 69 of file gsecret.cpp.
std::string GAuth::Secret::id | ( | ) | const |
Returns the associated identity. Throws if not valid().
Definition at line 115 of file gsecret.cpp.
std::string GAuth::Secret::info | ( | const std::string & | id = std::string() | ) | const |
Returns information for logging, excluding anything sensitive.
The secret may be in-valid().
Definition at line 127 of file gsecret.cpp.
std::string GAuth::Secret::key | ( | ) | const |
Returns the key. Throws if not valid().
Definition at line 104 of file gsecret.cpp.
bool GAuth::Secret::masked | ( | ) | const |
Returns true if key() is masked.
Definition at line 110 of file gsecret.cpp.
std::string GAuth::Secret::maskType | ( | ) | const |
Returns the masking function name, such as "MD5", or the empty string if not masked().
Throws if not valid().
Definition at line 121 of file gsecret.cpp.
|
static |
Factory function that returns a secret that is not valid() and has an empty id().
Definition at line 94 of file gsecret.cpp.
|
static |
Factory function that returns a secret that is not valid(), as used by the SecretsFile class.
Definition at line 89 of file gsecret.cpp.
bool GAuth::Secret::valid | ( | ) | const |
Returns true if the secret is valid.
Definition at line 99 of file gsecret.cpp.