- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

gpam.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_PAM_H
22 #define G_PAM_H
23
24 #include "gdef.h"
25 #include "gexception.h"
26 #include <string>
27 #include <vector>
28
30 namespace G
31 {
32 class Pam ;
33 class PamImp ;
34 }
35
58 class G::Pam
59 {
60 public:
62 struct Item
63 {
64 const std::string in_type ; // "password", "prompt", "error", "info"
65 const std::string in ; // password prompt, non-password prompt, error text, infomation message, etc
66 std::string out ; // password, or whatever was prompted for
67 bool out_defined ; // to be set to true if 'out' is assigned
68 } ;
69 typedef std::vector<Item> ItemArray ;
70
72 class Error : public G::Exception
73 {
74 public: int m_pam_error ;
75 public: Error( const std::string & op , int pam_error ) ;
76 public: Error( const std::string & op , int pam_error , const char * ) ;
77 } ;
78
79 Pam( const std::string & app , const std::string & user , bool silent ) ;
81
82 virtual ~Pam() ;
84
85 bool authenticate( bool require_token ) ;
92
93 std::string name() const ;
97
98 void checkAccount( bool require_token ) ;
101
102 void establishCredentials() ;
105
106 void openSession() ;
108
109 void closeSession() ;
111
112 void deleteCredentials() ;
114
115 void reinitialiseCredentials() ;
117
118 void refreshCredentials() ;
120
121 virtual void converse( ItemArray & ) = 0 ;
138
139 virtual void delay( unsigned int usec ) = 0 ;
154
155 private:
156 Pam( const Pam & ) ; // not implemented
157 void operator=( const Pam & ) ; // not implemented
158
159 private:
160 PamImp * m_imp ;
161 } ;
162
163 #endif
164
G::Pam::Item::out
std::string out
Definition: gpam.h:66
G::Pam::converse
virtual void converse(ItemArray &)=0
Called to pass a message to the user, or request a password etc.
G::Pam::Error::Error
Error(const std::string &op, int pam_error)
Definition: gpam.cpp:27
G::Pam::closeSession
void closeSession()
Closes a session.
Definition: gpam_linux.cpp:385
G::Pam::Item::in_type
const std::string in_type
Definition: gpam.h:64
G::Pam::name
std::string name() const
Returns the authenticated user name.
Definition: gpam_linux.cpp:418
G::Pam::refreshCredentials
void refreshCredentials()
Refreshes credentials.
Definition: gpam_linux.cpp:401
G::Pam::checkAccount
void checkAccount(bool require_token)
Does "account management", checking that the authenticated user is currently allowed to use the syste...
Definition: gpam_linux.cpp:367
G::Pam::Item::out_defined
bool out_defined
Definition: gpam.h:67
G::Pam::reinitialiseCredentials
void reinitialiseCredentials()
Reinitialises credentials.
Definition: gpam_linux.cpp:396
G::Pam::ItemArray
std::vector< Item > ItemArray
Definition: gpam.h:69
G::Pam::openSession
void openSession()
Starts a session.
Definition: gpam_linux.cpp:379
G::Pam::Error
An exception class used by G::Pam.
Definition: gpam.h:72
G::Pam::establishCredentials
void establishCredentials()
Embues the authenticated user with their credentials, such as "tickets" in the form of environment va...
Definition: gpam_linux.cpp:373
G::Pam::Item
A structure used by G::Pam to hold conversation items.
Definition: gpam.h:62
G::Pam::authenticate
bool authenticate(bool require_token)
Authenticates the user.
Definition: gpam_linux.cpp:361
G
Low-level classes.
G::Pam::Pam
Pam(const std::string &app, const std::string &user, bool silent)
Constructor.
Definition: gpam_linux.cpp:351
G::Pam::delay
virtual void delay(unsigned int usec)=0
Called when the pam library wants the application to introduce a delay to prevent brute-force attacks...
Definition: gpam_linux.cpp:406
G::PamImp
A pimple-pattern implementation class for Pam.
Definition: gpam_linux.cpp:60
gexception.h
G::Exception
A general-purpose exception class derived from std::exception and containing a std::string.
Definition: gexception.h:44
G::Pam::~Pam
virtual ~Pam()
Destructor.
Definition: gpam_linux.cpp:356
G::Pam::deleteCredentials
void deleteCredentials()
Deletes credentials.
Definition: gpam_linux.cpp:391
G::Pam::Item::in
const std::string in
Definition: gpam.h:65
G::Pam::Error::m_pam_error
int m_pam_error
Definition: gpam.h:74
G::Pam
A thin abstract interface to the system PAM library.
Definition: gpam.h:58