browsing: elangley-scraps
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"
194e6869
#include "generator.h"
21e4960f
#include "sys_unistd.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,
044b2625
const std::string &authorizer_token,
const std::string &reason)
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)) {}
af675d2b
bool validate (const std::string &requester_user_name,
const std::string &authorizer_user_name,
044b2625
const std::string &authorizer_token,
const std::string &reason)
cdf7fd74
{
af675d2b
return delegate_->validate (requester_user_name, authorizer_user_name,
044b2625
authorizer_token, reason);
cdf7fd74
}
a35decfc
static validator create (const directory &directory,
21e4960f
const tokens &token_supplier,
const unistd &unistd);
6c14d27a
};
caf7db60
f757e35b
#endif
0d8b9a17