gpopsecrets.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2001-2013 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 // ===
20 
21 #ifndef G_POP_SECRETS_H
22 #define G_POP_SECRETS_H
23 
24 #include "gdef.h"
25 #include "gpop.h"
26 #include "gsecrets.h"
27 #include "gsaslserver.h"
28 #include "gpath.h"
29 #include "gexception.h"
30 #include <iostream>
31 #include <map>
32 
34 namespace GPop
35 {
36  class Secrets ;
37  class SecretsImp ;
38 }
39 
45 {
46 public:
47  G_EXCEPTION( OpenError , "cannot open pop secrets file" ) ;
48 
49  static std::string defaultPath() ;
51 
52  explicit Secrets( const std::string & storage_path = defaultPath() ) ;
56 
57  virtual ~Secrets() ;
59 
60  std::string path() const ;
62 
63  virtual bool valid() const ;
66 
67  virtual std::string source() const ;
71 
72  virtual std::string secret( const std::string & mechanism , const std::string & id ) const ;
77 
78  bool contains( const std::string & mechanism ) const ;
81 
82 private:
83  Secrets( const Secrets & ) ; // not implemented
84  void operator=( const Secrets & ) ; // not implemented
85 
86 private:
87  SecretsImp * m_imp ;
88 } ;
89 
90 #endif
91 
A simple interface to a store of secrets as used in authentication.
Definition: gpopsecrets.h:44
bool contains(const std::string &mechanism) const
Returns true if there is one or more secrets using the given mechanism.
Definition: gpopsecrets.cpp:73
Secrets(const std::string &storage_path=defaultPath())
Constructor.
Definition: gpopsecrets.cpp:43
A private pimple-pattern implementation class used by GPop::Secrets.
Definition: gpopsecrets.cpp:30
virtual ~Secrets()
Destructor.
Definition: gpopsecrets.cpp:48
virtual std::string secret(const std::string &mechanism, const std::string &id) const
Returns the given user's secret.
Definition: gpopsecrets.cpp:68
virtual bool valid() const
Returns true.
Definition: gpopsecrets.cpp:63
#define G_EXCEPTION(class_name, description)
define as a function rather than a type if optimising for size
Definition: gexception.h:93
std::string path() const
Returns the storage path.
Definition: gpopsecrets.cpp:53
POP3 classes.
An interface used by GAuth::SaslServer to obtain authentication secrets.
Definition: gsaslserver.h:81
static std::string defaultPath()
Returns the default path.
virtual std::string source() const
Returns the storage path, as passed in to the constructor.
Definition: gpopsecrets.cpp:58