Skip to content
API Documentation
BastionGuard™
LeakCheckWorker Class Reference

#include <LeakCheckWorker.hpp>

Public Types

using LogFn = std::function<void(const std::string&)>

Public Member Functions

 LeakCheckWorker (const std::string &email, LogFn logger)
void run ()

Private Attributes

std::string email
LogFn log

Detailed Description

Definition at line 26 of file LeakCheckWorker.hpp.

Member Typedef Documentation

◆ LogFn

using LeakCheckWorker::LogFn = std::function<void(const std::string&)>

Definition at line 28 of file LeakCheckWorker.hpp.

Constructor & Destructor Documentation

◆ LeakCheckWorker()

LeakCheckWorker::LeakCheckWorker ( const std::string & email,
LogFn logger )

Definition at line 32 of file LeakCheckWorker.cpp.

35: email(e),
36 log(std::move(logger))
37{
38}

References email, and log.

Member Function Documentation

◆ run()

void LeakCheckWorker::run ( )

Definition at line 40 of file LeakCheckWorker.cpp.

41{
42 log(_("Normalizzazione identità…"));
43
44
45 const std::string emailHash =
47
48 LeakDatabase db;
49 db.ensureIdentity(emailHash);
50
51 LeakAggregator aggregator;
52
53 const std::string hibpApiKey =
55
56 const bool hibpEnabled = !hibpApiKey.empty();
57
58 if (hibpEnabled) {
59 aggregator.addProvider(
60 std::make_unique<HibpProvider>(hibpApiKey));
61 log(_("Fonte attiva: HIBP (copertura completa)"));
62 } else {
63 log(_("⚠ HIBP non configurato"));
64 log(_(" Uso LeakCheck (copertura limitata)"));
65 }
66
67 aggregator.addProvider(
68 std::make_unique<LeakCheckProvider>());
69
70
71 std::vector<LeakRecord> results;
72
73 try {
74 results = aggregator.queryAll(email);
75 }
76 catch (const std::exception& ex) {
77 log(std::string(_("❌ Errore durante la verifica: ")) + ex.what());
78 return;
79 }
80
81 if (results.empty()) {
82 log(_("✔ Nessuna violazione rilevata."));
83 return;
84 }
85
86}
#define _(s)
static std::string sha256(const std::string &input)
Definition HashUtil.cpp:27
static std::string hibpApiKey()
void addProvider(std::unique_ptr< ILeakProvider > provider)
std::vector< LeakRecord > queryAll(const std::string &email)
void ensureIdentity(const std::string &emailHash)

References _, LeakAggregator::addProvider(), email, LeakDatabase::ensureIdentity(), IdentityLeakConfig::hibpApiKey(), log, LeakAggregator::queryAll(), and HashUtil::sha256().

Referenced by IdentityLeakPage::onCheckClicked().

Member Data Documentation

◆ email

std::string LeakCheckWorker::email
private

Definition at line 36 of file LeakCheckWorker.hpp.

Referenced by LeakCheckWorker(), and run().

◆ log

LogFn LeakCheckWorker::log
private

Definition at line 37 of file LeakCheckWorker.hpp.

Referenced by LeakCheckWorker(), and run().


The documentation for this class was generated from the following files: