git.fiddlerwoaroof.com
dual_control.h
7684972a
 /* Copyright (C) CJ Affiliate
  *
  * You may use, distribute and modify this code under  the
  * terms of the  GNU General Public License  version 2  or
  * later.
  *
  * You should have received a copy of the license with this
  * file. If not, you will find a copy in the "LICENSE" file
  * at https://github.com/cjdev/dual-control.
  */
 
bcf6f3d1
 /* PAM handlers class interface. The methods on the dual control class
  * correspond directly to the specified PAM handler entrypoints.
  *
  * See "dual_control_integrate.cc"
  */
 
e56d3c56
 #ifndef _DUAL_CONTROL_H
 #define _DUAL_CONTROL_H
 
 #include <memory>
 
a71244c0
 #include "request.h"
caf7db60
 #include "validator.h"
 #include "conversation.h"
47f9faed
 #include "logger.h"
f30736f9
 #include "session.h"
caf7db60
 
a71244c0
 struct dual_control_configuration {
f2407c60
     class validator validator;
     class conversation conversation;
     class logger logger;
f30736f9
     class sessions sessions;
a71244c0
 };
 
cdf7fd74
 class dual_control_ifc
 {
 public:
     virtual ~dual_control_ifc() {}
a71244c0
     virtual int authenticate (const pam_request &request);
     virtual int setcred (const pam_request &request);
e56d3c56
 };
4a1812fd
 
3ae0e083
 class dual_control
a71244c0
 {
 private:
     std::shared_ptr<dual_control_ifc> delegate_;
 public:
     dual_control (std::shared_ptr<dual_control_ifc> delegate) : delegate_
         (delegate) {}
41cda267
     dual_control() : dual_control (std::make_shared<dual_control_ifc>
                                        ()) {}
a71244c0
     int authenticate (const pam_request &request)
     {
         return delegate_->authenticate (request);
     }
     int setcred (const pam_request &request)
     {
         return delegate_->setcred (request);
     }
58902985
     static dual_control create (const dual_control_configuration
a35decfc
                                 &configuration);
a71244c0
 
caf7db60
 };
a71244c0
 
e56d3c56
 #endif