E-MailRelay
gpopauth.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 gpopauth.h
19 ///
20 
21 #ifndef G_POP_AUTH_H
22 #define G_POP_AUTH_H
23 
24 #include "gdef.h"
25 #include "gpop.h"
26 #include "gpopsecrets.h"
27 
28 namespace GPop
29 {
30  class Auth ;
31  class AuthImp ;
32 }
33 
34 /// \class GPop::Auth
35 /// An authenticator interface for POP3 sessions that is a very
36 /// thin veneer over GSmtp::SaslServer.
37 /// \see RFC-2222
38 ///
40 {
41 public:
42  explicit Auth( const Secrets & ) ;
43  ///< Constructor. Defaults to the APOP mechanism so that
44  ///< challenge() returns the APOP initial challege to go
45  ///< into the POP3 greeting.
46 
47  ~Auth() ;
48  ///< Destructor.
49 
50  bool valid() const ;
51  ///< Returns true if the secrets are valid.
52 
53  bool init( const std::string & mechanism ) ;
54  ///< Initialises or reinitialises with the specified
55  ///< mechanism. Returns false if not a supported mechanism.
56  ///< Updates the initial challenge() string as appropriate.
57 
58  bool mustChallenge() const ;
59  ///< Returns true if the init()ialised mechanism requires
60  ///< an initial challenge. Returns false if (in effect)
61  ///< the mechanism and the authetication can be supplied
62  ///< together.
63 
64  std::string challenge() ;
65  ///< Returns an initial challenge appropriate to
66  ///< the current mechanism.
67 
68  bool authenticated( const std::string & rsp1 , const std::string & rsp2 ) ;
69  ///< Authenticates a one-step (APOP,PLAIN) or two-step (LOGIN)
70  ///< challenge-response sequence. Both steps in a two-step
71  ///< mechanism are done in one call to this method. The
72  ///< second parameter use used only if the current
73  ///< mechanism is a two-step mechanism. The second-step
74  ///< challenge itself is not accessible, which only really
75  ///< makes sense for a LOGIN password prompt, since it is
76  ///< a fixed string.
77  ///<
78  ///< Returns true if authenticated.
79 
80  std::string id() const ;
81  ///< Returns the authenticated user id.
82  ///< Precondition: authenticated()
83 
84  std::string mechanisms() const ;
85  ///< Returns a space-separated list of standard, supported
86  ///< SASL mechanisms (so not including APOP).
87 
88  bool sensitive() const ;
89  ///< Returns true if the implementation requires
90  ///< authentication to be restricted to encrypted
91  ///< transports.
92 
93 private:
94  Auth( const Auth & ) ;
95  void operator=( const Auth & ) ;
96 
97 private:
98  AuthImp * m_imp ;
99 } ;
100 
101 #endif
A simple interface to a store of secrets as used in authentication.
Definition: gpopsecrets.h:43
std::string mechanisms() const
Returns a space-separated list of standard, supported SASL mechanisms (so not including APOP)...
Definition: gpopauth.cpp:166
bool mustChallenge() const
Returns true if the init()ialised mechanism requires an initial challenge.
Definition: gpopauth.cpp:151
bool init(const std::string &mechanism)
Initialises or reinitialises with the specified mechanism.
Definition: gpopauth.cpp:141
std::string challenge()
Returns an initial challenge appropriate to the current mechanism.
Definition: gpopauth.cpp:156
std::string id() const
Returns the authenticated user id.
Definition: gpopauth.cpp:161
bool sensitive() const
Returns true if the implementation requires authentication to be restricted to encrypted transports...
Definition: gpopauth.cpp:171
bool authenticated(const std::string &rsp1, const std::string &rsp2)
Authenticates a one-step (APOP,PLAIN) or two-step (LOGIN) challenge-response sequence.
Definition: gpopauth.cpp:146
A private pimple-pattern implementation class used by GPop::Auth.
Definition: gpopauth.cpp:30
~Auth()
Destructor.
Definition: gpopauth.cpp:131
An authenticator interface for POP3 sessions that is a very thin veneer over GSmtp::SaslServer.
Definition: gpopauth.h:39
bool valid() const
Returns true if the secrets are valid.
Definition: gpopauth.cpp:136
POP3 classes.
Definition: gpopauth.h:28
Auth(const Secrets &)
Constructor.
Definition: gpopauth.cpp:126