WvStreams
wvpam.h
00001 /* -*- Mode: C++ -*-
00002  * Worldvisions Weaver Software:
00003  *   Copyright (C) 1997-2004 Net Integration Technologies, Inc.
00004  *
00005  * A WvStream that authenticates with PAM.  If WvStreams is compiled without
00006  * PAM, it just fails.  Note that if you don't check isok, you can still read
00007  * and write to the stream - in particular, anything written in the
00008  * constructor will go through before authentication begins.
00009  *
00010  * For now, this only works for PAM modules that don't require any user
00011  * interaction (not even a password!), such as ssoya.
00012  */
00013 #ifndef __WVPAM_H
00014 #define __WVPAM_H
00015 
00016 #include "wvstringlist.h"
00017 #include "wvlog.h"
00018 
00019 class WvPamData;
00020 
00021 class WvPam
00022 {
00023 private:
00024     bool init();
00025     WvPamData *d;
00026     WvLog log;
00027     WvString appname;
00028     
00035     bool check_pam_status(WvStringParm step);
00036     
00037 public:
00042     WvPam(WvStringParm svcname);
00043     
00047     WvPam(WvStringParm svcname, WvStringParm rhost,
00048           WvStringParm user = WvString::null,      
00049           WvStringParm password = WvString::null);
00050     
00051     virtual ~WvPam();
00052     
00056     bool authenticate(WvStringParm rhost = WvString::null,
00057                       WvStringParm user = WvString::null, 
00058                       WvStringParm password = WvString::null);
00059     
00064     void getgroups(WvStringList &groups) const;
00065     
00069     WvString getuser() const;
00070     
00074     WvError err;
00075 };
00076 
00077 #endif // __WVPAM_H