2015-05-11 00:18:22 +02:00
|
|
|
#ifndef LOGIC_H
|
|
|
|
#define LOGIC_H
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
#include <string>
|
|
|
|
#include <fstream>
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "epaper.h"
|
|
|
|
#include "door.h"
|
|
|
|
#include "logger.h"
|
|
|
|
|
|
|
|
class Logic
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
static Logic &get();
|
|
|
|
~Logic();
|
|
|
|
|
2015-05-12 03:49:26 +02:00
|
|
|
int parseRequest(const std::string &str);
|
|
|
|
void createNewToken(const bool stillValid);
|
2015-05-11 00:18:22 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
Logic();
|
|
|
|
|
|
|
|
void _lock();
|
|
|
|
void _unlock();
|
|
|
|
|
|
|
|
bool _checkToken(const std::string &token);
|
|
|
|
bool _checkLDAP(const std::string &user, const std::string &password);
|
2015-05-12 01:28:02 +02:00
|
|
|
bool _checkIP(const std::string &ip);
|
2015-05-11 00:18:22 +02:00
|
|
|
|
|
|
|
|
|
|
|
const Logger &_logger;
|
|
|
|
Door &_door;
|
|
|
|
Epaper &_epaper;
|
|
|
|
|
|
|
|
using Token = uint64_t;
|
|
|
|
|
|
|
|
Token _curToken;
|
|
|
|
bool _prevValid = { false };
|
|
|
|
Token _prevToken;
|
|
|
|
|
|
|
|
|
|
|
|
const static std::string _lockPagePrefix;
|
|
|
|
const static std::string _fifoLocation;
|
2015-05-11 20:40:26 +02:00
|
|
|
const static std::string _bindDN;
|
|
|
|
const static std::string _ldapServer;
|
2015-05-12 01:28:02 +02:00
|
|
|
const static std::string _allowedIpPrefix;
|
2015-05-11 00:18:22 +02:00
|
|
|
|
|
|
|
static constexpr int _tokenTimeout = TOKEN_TIMEOUT;
|
|
|
|
|
|
|
|
enum {LOCKED, UNLOCKED} _state = { LOCKED };
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|