1#ifndef AUTHENTICATION_MANAGER_H
2#define AUTHENTICATION_MANAGER_H
58 bool VerifyPassword(
const QString &frequency,
const QString &provided_password);
73 static QString
CreateAuthResponse(
bool success,
const QString &error_message = QString());
82 bool StoreSession(
const QString &frequency,
const QString &client_id,
const QString &session_token);
91 bool ValidateSession(
const QString &session_token,
const QString &frequency);
void DeactivateClientSessions(const QString &client_id)
Marks all sessions associated with a specific client ID as inactive.
Definition authentication_manager.cpp:132
static QString CreateAuthResponse(bool success, const QString &error_message=QString())
Creates a JSON response string indicating the result of an authentication attempt....
Definition authentication_manager.cpp:69
void CleanupExpiredSessions()
Removes session information for sessions older than 24 hours.
Definition authentication_manager.cpp:148
void RemovePassword(const QString &frequency)
Removes the password associated with a specific frequency.
Definition authentication_manager.cpp:63
AuthenticationManager(QObject *parent=nullptr)
Private constructor to enforce the singleton pattern.
Definition authentication_manager.h:131
QMap< QString, QString > wavelength_passwords_
Map storing salted and hashed passwords associated with frequencies. Key: Frequency identifier (QStri...
Definition authentication_manager.h:155
QMap< QString, SessionInfo > sessions_
Map storing active session information. Key: Session token (QString). Value: SessionInfo struct conta...
Definition authentication_manager.h:162
void RegisterPassword(const QString &frequency, const QString &password)
Registers or updates the password for a specific frequency.
Definition authentication_manager.cpp:18
AuthenticationManager & operator=(const AuthenticationManager &)=delete
Deleted assignment operator to prevent assignment.
void DeactivateFrequencySessions(const QString &frequency)
Marks all sessions associated with a specific frequency as inactive.
Definition authentication_manager.cpp:140
bool VerifyPassword(const QString &frequency, const QString &provided_password)
Verifies if the provided password matches the stored password for a given frequency.
Definition authentication_manager.cpp:31
static QString GenerateSessionToken()
Generates a cryptographically secure session token. Uses a combination of UUID and timestamp,...
Definition authentication_manager.cpp:12
static QString GenerateClientId()
Generates a unique client identifier.
Definition authentication_manager.cpp:8
bool StoreSession(const QString &frequency, const QString &client_id, const QString &session_token)
Stores information about a newly established client session.
Definition authentication_manager.cpp:85
~AuthenticationManager() override=default
Private destructor.
static AuthenticationManager * GetInstance()
Gets the singleton instance of the AuthenticationManager.
Definition authentication_manager.h:27
void DeactivateSession(const QString &session_token)
Marks a specific session as inactive.
Definition authentication_manager.cpp:126
AuthenticationManager(const AuthenticationManager &)=delete
Deleted copy constructor to prevent copying.
bool ValidateSession(const QString &session_token, const QString &frequency)
Validates an existing session token for a specific frequency. Checks if the token exists,...
Definition authentication_manager.cpp:98
Structure holding information about an active client session.
Definition authentication_manager.h:120
bool is_active
Flag indicating if the session is currently active.
Definition authentication_manager.h:124
QString frequency
The frequency the session is associated with.
Definition authentication_manager.h:122
QString client_id
Unique identifier of the client holding the session.
Definition authentication_manager.h:121
QDateTime timestamp
Timestamp when the session was created or last validated.
Definition authentication_manager.h:123