QgsCredentials class

Interface for requesting credentials in QGIS in GUI independent way.

This class provides abstraction of a dialog for requesting credentials to the user. By default QgsCredentials will be used if not overridden with other credential creator function.

QGIS application uses QgsCredentialDialog class for displaying a dialog to the user.

Object deletes itself when it's not needed anymore. Children should use signal destroyed() to be notified of the deletion

Derived classes

class QgsCredentialDialog
A generic dialog for requesting credentials.
class QgsCredentialsConsole
Implementation of credentials interface for the console.
class QgsCredentialsNone
Default implementation of credentials interface.

Public static functions

static auto instance() -> QgsCredentials*
retrieves instance

Constructors, destructors, conversion operators

~QgsCredentials() defaulted virtual
Destructor.
QgsCredentials() protected defaulted
Constructor for QgsCredentials.

Public functions

void lock()
Lock the instance against access from multiple threads.
auto mutex() -> QMutex*
Returns pointer to mutex.
void unlock()
Unlock the instance after being locked.

Protected functions

auto request(const QString& realm, QString& username, QString& password, const QString& message = QString()) -> bool pure virtual
request a password
auto requestMasterPassword(QString& password, bool stored = false) -> bool pure virtual
request a master password
void setInstance(QgsCredentials* instance)
register instance

Function documentation

void QgsCredentials::lock()

Lock the instance against access from multiple threads.

This does not really lock access to get/put methds, it will just prevent other threads to lock the instance and continue the execution. When the class is used from non-GUI threads, they should call lock() before the get/put calls to avoid race conditions.

QMutex* QgsCredentials::mutex()

Returns pointer to mutex.

void QgsCredentials::unlock()

Unlock the instance after being locked.