E-MailRelay
gsaslserverpam.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2001-2018 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 gsaslserverpam.h
19 ///
20 
21 #ifndef G_SASL_SERVER_PAM_H
22 #define G_SASL_SERVER_PAM_H
23 
24 #include "gdef.h"
25 #include "gvalid.h"
26 #include "gsecrets.h"
27 #include "gsaslserver.h"
28 #include "gexception.h"
29 #include "gaddress.h"
30 #include "gstrings.h"
31 #include "gpath.h"
32 #include <map>
33 #include <memory>
34 
35 namespace GAuth
36 {
37  class SaslServerPamImp ;
38  class SaslServerPam ;
39 }
40 
41 /// \class GAuth::SaslServerPam
42 /// An implementation of the SaslServer interface using PAM as
43 /// the authentication mechanism.
44 ///
45 /// This class tries to match up the PAM interface with the SASL server
46 /// interface. The match is not perfect; only single-challenge PAM mechanisms
47 /// are supported, the PAM delay feature is not implemented, and PAM sessions
48 /// are not part of the SASL interface.
49 ///
51 {
52 public:
53  SaslServerPam( const SaslServerSecrets & , bool allow_apop ) ;
54  ///< Constructor.
55 
56  virtual ~SaslServerPam() ;
57  ///< Destructor.
58 
59  virtual bool requiresEncryption() const override ;
60  ///< Override from GAuth::SaslServer.
61 
62  virtual bool active() const override ;
63  ///< Override from GAuth::SaslServer.
64 
65  virtual std::string mechanisms( char sep = ' ' ) const override ;
66  ///< Override from GAuth::SaslServer.
67 
68  virtual bool init( const std::string & mechanism ) override ;
69  ///< Override from GAuth::SaslServer.
70 
71  virtual std::string mechanism() const override ;
72  ///< Override from GAuth::SaslServer.
73 
74  virtual bool mustChallenge() const override ;
75  ///< Override from GAuth::SaslServer.
76 
77  virtual std::string initialChallenge() const override ;
78  ///< Override from GAuth::SaslServer.
79 
80  virtual std::string apply( const std::string & response , bool & done ) override ;
81  ///< Override from GAuth::SaslServer.
82 
83  virtual bool authenticated() const override ;
84  ///< Override from GAuth::SaslServer.
85 
86  virtual std::string id() const override ;
87  ///< Override from GAuth::SaslServer.
88 
89  virtual bool trusted( const GNet::Address & ) const override ;
90  ///< Override from GAuth::SaslServer.
91 
92 private:
93  SaslServerPam( const SaslServerPam & ) ;
94  void operator=( const SaslServerPam & ) ;
95 
96 private:
97  SaslServerPamImp * m_imp ;
98 } ;
99 
100 #endif
virtual std::string initialChallenge() const override
Override from GAuth::SaslServer.
virtual std::string id() const override
Override from GAuth::SaslServer.
virtual bool init(const std::string &mechanism) override
Override from GAuth::SaslServer.
The GNet::Address class encapsulates a TCP/UDP transport address.
Definition: gaddress.h:54
virtual bool requiresEncryption() const override
Override from GAuth::SaslServer.
virtual bool authenticated() const override
Override from GAuth::SaslServer.
virtual bool active() const override
Override from GAuth::SaslServer.
An interface used by GAuth::SaslServer to obtain authentication secrets.
virtual ~SaslServerPam()
Destructor.
virtual std::string mechanism() const override
Override from GAuth::SaslServer.
An interface for implementing the server-side SASL challenge/response concept.
Definition: gsaslserver.h:67
A private implementation class used by GAuth::SaslServerPam.
virtual std::string apply(const std::string &response, bool &done) override
Override from GAuth::SaslServer.
An implementation of the SaslServer interface using PAM as the authentication mechanism.
SaslServerPam(const SaslServerSecrets &, bool allow_apop)
Constructor.
virtual bool trusted(const GNet::Address &) const override
Override from GAuth::SaslServer.
virtual bool mustChallenge() const override
Override from GAuth::SaslServer.
virtual std::string mechanisms(char sep= ' ') const override
Override from GAuth::SaslServer.
SASL authentication classes.
Definition: gcram.h:30