QGIS API Documentation
3.6.0-Noosa (5873452)
|
Interface for requesting credentials in QGIS in GUI independent way. More...
#include <qgscredentials.h>
Public Member Functions | |
virtual | ~QgsCredentials ()=default |
Destructor. More... | |
bool | get (const QString &realm, QString &username, QString &password, const QString &message=QString()) |
Requests credentials for the specified realm. More... | |
bool | getMasterPassword (QString &password, bool stored=false) |
Q_DECL_DEPRECATED void | lock () |
Lock the instance against access from multiple threads. More... | |
Q_DECL_DEPRECATED QMutex * | mutex () |
Returns pointer to mutex. More... | |
void | put (const QString &realm, const QString &username, const QString &password) |
Stores the correct username and password for the specified realm. More... | |
Q_DECL_DEPRECATED void | unlock () |
Unlock the instance after being locked. More... | |
Static Public Member Functions | |
static QgsCredentials * | instance () |
retrieves instance More... | |
Protected Member Functions | |
QgsCredentials ()=default | |
Constructor for QgsCredentials. More... | |
virtual bool | request (const QString &realm, QString &username, QString &password, const QString &message=QString())=0 |
request a password More... | |
virtual bool | requestMasterPassword (QString &password, bool stored=false)=0 |
request a master password More... | |
void | setInstance (QgsCredentials *instance) |
register instance More... | |
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
Definition at line 41 of file qgscredentials.h.
|
virtualdefault |
Destructor.
|
protecteddefault |
Constructor for QgsCredentials.
bool QgsCredentials::get | ( | const QString & | realm, |
QString & | username, | ||
QString & | password, | ||
const QString & | message = QString() |
||
) |
Requests credentials for the specified realm.
If existing credentials exist for the given realm, these will be returned. Otherwise the credential handler will prompt for the correct username and password.
The retrieved or user-entered details will be stored in username and password.
Optionally, a specific message can be used to advise users of the context for the credentials request.
Definition at line 41 of file qgscredentials.cpp.
bool QgsCredentials::getMasterPassword | ( | QString & | password, |
bool | stored = false |
||
) |
Definition at line 82 of file qgscredentials.cpp.
|
static |
retrieves instance
Definition at line 33 of file qgscredentials.cpp.
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.
Definition at line 92 of file qgscredentials.cpp.
|
inline |
Returns pointer to mutex.
Definition at line 102 of file qgscredentials.h.
void QgsCredentials::put | ( | const QString & | realm, |
const QString & | username, | ||
const QString & | password | ||
) |
Stores the correct username and password for the specified realm.
These values will be used for all future calls to get() for the same realm, without requesting users to re-enter them. It is the caller's responsibility to ensure that only valid username and password combinations are used with this method.
Definition at line 73 of file qgscredentials.cpp.
|
protectedpure virtual |
request a password
Implemented in QgsCredentialsConsole, QgsCredentialsNone, and QgsCredentialDialog.
|
protectedpure virtual |
request a master password
Implemented in QgsCredentialsConsole, QgsCredentialsNone, and QgsCredentialDialog.
|
protected |
register instance
Definition at line 23 of file qgscredentials.cpp.
void QgsCredentials::unlock | ( | ) |
Unlock the instance after being locked.
Definition at line 97 of file qgscredentials.cpp.