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. */ |
7699d7ec | #ifndef _CONVERSATION_H #define _CONVERSATION_H |
0b6e39a6 | #include <string> |
caf7db60 | #include <memory> |
0b6e39a6 | |
f46fb7b6 | #include "request.h" |
d4af7e88 | #include "sys_pam.h" |
7699d7ec | |
f46fb7b6 | struct conversation_result { std::string user_name; std::string token; |
c8d91f67 | std::string reason; |
caf7db60 | }; |
12af5aef | struct pam_conv_result { int get_conv_result; int conv_result; std::vector<pam_response *> responses; }; |
f46fb7b6 | class conversation_ifc |
cdf7fd74 | { public: |
4d825470 | virtual ~conversation_ifc() {} |
f46fb7b6 | virtual conversation_result initiate (const pam_request &request) |
cdf7fd74 | { |
f46fb7b6 | return { "", "" }; |
cdf7fd74 | } |
caf7db60 | }; |
8a15acc6 | |
3ae0e083 | class conversation |
cdf7fd74 | { private: |
f46fb7b6 | std::shared_ptr<conversation_ifc> delegate_; |
cdf7fd74 | public: |
f46fb7b6 | conversation (const std::shared_ptr<conversation_ifc> &delegate) : |
b017a4d2 | delegate_ (delegate) {} |
41cda267 | conversation() : conversation (std::make_shared<conversation_ifc>() |
7d075ab4 | ) {} |
f46fb7b6 | conversation_result initiate (const pam_request &request) |
cdf7fd74 | { |
f46fb7b6 | return delegate_->initiate (request); |
cdf7fd74 | } |
da1b9b25 | static conversation create (pam &pam); |
8a15acc6 | }; |
caf7db60 | |
f46fb7b6 | inline conversation wrap (conversation_ifc *delegate) { return conversation (std::shared_ptr<conversation_ifc> (delegate)); }; |
7699d7ec | #endif |