// // Created by ioachim on 18.05.2025. // #include "Autoritate.h" Autoritate& Autoritate::operator=(const Autoritate& frate) { if(this != &frate) { autoritateID = frate.autoritateID; nume = frate.nume; passHash = frate.passHash; } return *this; } std::ostream& operator <<(std::ostream& os, const Autoritate& user){ os << "ID: " << user.autoritateID << "\nNume: " << user.nume << "\nDosar: "; os << "\n"; return os; } bool Autoritate::tryLogin(std::string _pass) { if (hashString(_pass) == passHash) { return true; } return false; } bool Autoritate::changePassword(std::string _pass, std::string _newpass) { if (hashString(_pass) == passHash) { passHash = hashString(_pass); return true; } return false; } std::string Autoritate::getName() { return nume; } void Autoritate::emiteAnexa(Document* _doc, std::string _anex) { if (_doc->origineAnexa == nullptr) { Document::Anexa* ax = new Document::Anexa(); _doc->origineAnexa = ax; ax->continut = _anex; ax->doc = _doc; ax->idAnexa = hashString(ax->exportAnexa()); ax->urm = nullptr; return; } Document::Anexa* ax = _doc->origineAnexa; while (ax->urm != nullptr) { ax = ax->urm; } ax->urm = new Document::Anexa(); ax->urm->continut = _anex; ax->urm->doc = _doc; ax->urm->idAnexa = hashString(ax->urm->exportAnexa()); ax->urm->urm = nullptr; } Autoritate::~Autoritate() { } Document* Autoritate::emiteDocument(std::string _nume, std::string _continut, User* _Titular, Zi* _data_emitere, Zi* _data_expirare) { try { Document* doc = new Document(); doc->origineAnexa = nullptr; doc->Continut = _continut; if (_Titular == nullptr) { throw 404; } doc->Titular = _Titular; doc->Emitator = this; doc->dataEmitere = _data_emitere; doc->dataExpirare = _data_expirare; doc->titlu = _nume; return doc; }catch (int errorCode) { std::cout << "ERROR: " << errorCode << std::endl; } }