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. */ |
92b68213 | #ifndef _VALIDATOR_H #define _VALIDATOR_H |
f757e35b | #include <string> |
16ade8ba | #include <memory> |
f757e35b | |
3c673060 | #include "user.h" |
9af49688 | #include "token.h" |
3c673060 | |
cdf7fd74 | class validator_ifc { public: virtual ~validator_ifc() {} |
6ff7d0a7 | virtual bool validate (const std::string &requester_user_name, const std::string &authorizer_user_name, const std::string &authorizer_token) |
cdf7fd74 | { return false; } |
caf7db60 | }; |
3ae0e083 | class validator |
cdf7fd74 | { private: std::shared_ptr<validator_ifc> delegate_; public: |
b017a4d2 | validator (const std::shared_ptr<validator_ifc> &delegate) : delegate_ (delegate) {} validator() : validator (std::shared_ptr<validator_ifc> (new validator_ifc)) {} |
6ff7d0a7 | bool validate (const std::string &requester_user_name, const std::string &authorizer_user_name, const std::string &authorizer_token) |
cdf7fd74 | { |
6ff7d0a7 | return delegate_->validate (requester_user_name, authorizer_user_name, authorizer_token); |
cdf7fd74 | } |
a35decfc | static validator create (const directory &directory, const user_token_supplier &token_supplier); |
6c14d27a | }; |
caf7db60 | |
f757e35b | #endif |
92957308 |