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() {} |
b017a4d2 | virtual bool validate (const std::string &user_name, const std::string &token) |
cdf7fd74 | { return false; } |
caf7db60 | }; |
cdf7fd74 | class validator : public validator_ifc { 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)) {} bool validate (const std::string &user_name, const std::string &token) |
cdf7fd74 | { |
b017a4d2 | return delegate_->validate (user_name, token); |
cdf7fd74 | } |
6c14d27a | }; |
caf7db60 | |
28855478 | validator create_validator (const directory &directory, |
3a7bcdbe | const user_token_supplier &token_supplier); |
f757e35b | #endif |
92957308 |