AlexBonazzi f3eefc0ff5 Patch level : 12.0 no patch
Files correlati     : libraries
Commento            :

aggiunto ssa
2019-01-15 11:48:23 +01:00

90 lines
2.7 KiB
C++

#ifndef AUTH_H
#define AUTH_H
#include "stdafx.h"
#include "prodotto.h"
#include "infoUtente.h"
#include "ssaerr.h"
#define SSA_REL "2.2"
#define TAG_SSA "<SSA"
#define ATTR_REL "rel"
#define TAG_CLIMAC "<CLIMAC"
#define TAG_MAC "<MAC"
#define ATTR_ADDR "addr"
#define ATTR_DESCRI "descri"
#define TAG_PRODOTTO "<PRODOTTO"
#define ATTR_NUM_SERIE "numero-serie"
#define ATTR_PIVA "piva"
#define TAG_MODULO "<MODULO"
#define ATTR_NOME "nome"
#define ATTR_DATA_SCAD "data-scad"
#define ATTR_NUM_ABIL "num-abilitazioni"
#define ATTR_CURR_USER "curr-users"
#define TAG_UTENTE "<UTENTE"
#define ATTR_LAST_PING "last-ping"
#define AUTH_EXT "ssa"
#define CLIENT_EXT "ssax"
class Auth
{
public:
static bool generaFileClient(const char* nome, const char* prodotto);
static bool generaLicenze();
static string decrypt(string fileName);
private:
static string getSSARelTAG();
static string generaMACAddressTAG();
static bool generaLicenza(string fileClient);
static string estraiAttr(const string& s, const char * attr);
static int estraiIntAttr(const string& s, const char * attr);
private:
bool m_loaded;
map<string, Prodotto*> m_prodotti; //[nome_prodotto, Prodotto] Prodotti configurati
map<string, InfoUtente*> m_utenti; //[idClient, InfoUtente] Utenti connessi
string m_id;
public:
Auth();
bool caricaFileLicenze();
bool isLoaded() { return m_loaded; }
int VerificaModulo(const char* prodotto, const char* modulo);
int VerificaModulo(const char* prodotto, const char* modulo, const char* piva);
int Login(const char* idClient, const char* prodotto);
int Login(const char* idClient, const char* prodotto, const char* piva);
int ApriModulo(const char* idClient, const char* modulo);
int ChiudiModulo(const char* idClient, const char* modulo);
int Logout(const char* idClient, const char* prodotto);
int Ping(const char* idClient);
int AttivaLicenza(const char* file);
int GetXMLProdottiConfigurati(char* buf, int bufSize);
int GetXMLUtentiCorrenti(char* buf, int bufSize);
int GetId(char* buf, int bufSize);
int GetNumeroSerie(const char* prodotto);
int DataScadenza(const char* prodotto, const char* modulo);
int NumMaxUtenti(const char* prodotto, const char* modulo);
private:
bool caricaFileLicenze(string fileName);
bool verificaRequisitiHW(string hwTag);
void addProdotto(Prodotto* p);
Prodotto* getProdottoDaNomeModulo(const char* modulo);
bool verificaExpDate(const char* date);
string dumpProdotti();
string dumpUtenti();
void logoutUtentiScaduti();
int ChiudiModulo(const char* idClient, const char* modulo, bool logout);
bool iequals(const string& a, const string& b);
map<string, Prodotto*>::iterator findProdottoIC(const char * strToFind);
};
#endif