E-MailRelay
gsaslserversecrets.h
Go to the documentation of this file.
1//
2// Copyright (C) 2001-2024 Graeme Walker <graeme_walker@users.sourceforge.net>
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16// ===
17///
18/// \file gsaslserversecrets.h
19///
20
21#ifndef GAUTH_SASL_SERVER_SECRETS_H
22#define GAUTH_SASL_SERVER_SECRETS_H
23
24#include "gdef.h"
25#include "gsecret.h"
26#include "gstringview.h"
27#include <string>
28#include <utility>
29
30namespace GAuth
31{
32 class SaslServerSecrets ;
33}
34
35//| \class GAuth::SaslServerSecrets
36/// An interface used by GAuth::SaslServer to obtain authentication secrets.
37/// \see GAuth::Secret
38///
40{
41public:
42 virtual ~SaslServerSecrets() = default ;
43 ///< Destructor.
44
45 virtual bool valid() const = 0 ;
46 ///< Returns true if the secrets are valid.
47
48 virtual Secret serverSecret( std::string_view type , std::string_view id ) const = 0 ;
49 ///< Returns the server secret for the given client id.
50 ///< The type is "plain" or the CRAM hash algorithm.
51 ///< Returns an invalid secret if not found.
52
53 virtual std::pair<std::string,std::string> serverTrust( const std::string & address_range ) const = 0 ;
54 ///< Returns a non-empty trustee name if the server trusts
55 ///< the given address range (eg. "192.168.0.0/24"), together
56 ///< with context information for logging purposes.
57
58 virtual std::string source() const = 0 ;
59 ///< Returns the source identifier (eg. file name).
60
61 virtual bool contains( std::string_view type , std::string_view id ) const = 0 ;
62 ///< Returns true if there is a secret of the given type
63 ///< either for one user in particular or for any user if
64 ///< the id is empty.
65} ;
66
67#endif
An interface used by GAuth::SaslServer to obtain authentication secrets.
virtual Secret serverSecret(std::string_view type, std::string_view id) const =0
Returns the server secret for the given client id.
virtual bool valid() const =0
Returns true if the secrets are valid.
virtual std::pair< std::string, std::string > serverTrust(const std::string &address_range) const =0
Returns a non-empty trustee name if the server trusts the given address range (eg.
virtual bool contains(std::string_view type, std::string_view id) const =0
Returns true if there is a secret of the given type either for one user in particular or for any user...
virtual std::string source() const =0
Returns the source identifier (eg. file name).
virtual ~SaslServerSecrets()=default
Destructor.
Encapsulates a userid/shared-secret/hash-function tuple from the secrets file.
Definition: gsecret.h:44
SASL authentication classes.
Definition: gcram.cpp:38