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

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...
 

Detailed Description

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.

Definition at line 41 of file gsecret.h.

Constructor & Destructor Documentation

◆ Secret()

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.

Member Function Documentation

◆ check()

std::string GAuth::Secret::check ( const std::string &  secret,
const std::string &  secret_encoding,
const std::string &  id,
bool  id_encoding_xtext 
)
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.

◆ id()

std::string GAuth::Secret::id ( ) const

Returns the associated identity. Throws if not valid().

Definition at line 115 of file gsecret.cpp.

◆ info()

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.

◆ key()

std::string GAuth::Secret::key ( ) const

Returns the key. Throws if not valid().

Definition at line 104 of file gsecret.cpp.

◆ masked()

bool GAuth::Secret::masked ( ) const

Returns true if key() is masked.

Definition at line 110 of file gsecret.cpp.

◆ maskType()

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.

◆ none() [1/2]

GAuth::Secret GAuth::Secret::none ( )
static

Factory function that returns a secret that is not valid() and has an empty id().

Definition at line 94 of file gsecret.cpp.

◆ none() [2/2]

GAuth::Secret GAuth::Secret::none ( const std::string &  id)
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.

◆ valid()

bool GAuth::Secret::valid ( ) const

Returns true if the secret is valid.

Definition at line 99 of file gsecret.cpp.


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