QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
qgscredentials.h
Go to the documentation of this file.
1
/***************************************************************************
2
qgscredentials.h - interface for requesting credentials
3
----------------------
4
begin : February 2010
5
copyright : (C) 2010 by Juergen E. Fischer
6
email : jef at norbit dot de
7
***************************************************************************
8
* *
9
* This program is free software; you can redistribute it and/or modify *
10
* it under the terms of the GNU General Public License as published by *
11
* the Free Software Foundation; either version 2 of the License, or *
12
* (at your option) any later version. *
13
* *
14
***************************************************************************/
15
16
17
#ifndef QGSCREDENTIALS_H
18
#define QGSCREDENTIALS_H
19
20
#include "qgis_core.h"
21
#include "
qgis_sip.h
"
22
23
#include <QMap>
24
#include <QMutex>
25
#include <QObject>
26
#include <QPair>
27
#include <QString>
28
45
class
CORE_EXPORT
QgsCredentials
46
{
47
public
:
48
virtual
~QgsCredentials
() =
default
;
49
65
bool
get
(
const
QString &realm, QString &username
SIP_INOUT
, QString &password
SIP_INOUT
,
const
QString &message = QString(),
bool
requestCredentials =
true
);
66
76
void
put
(
const
QString &realm,
const
QString &username,
const
QString &password );
77
78
bool
getMasterPassword
( QString &password
SIP_INOUT
,
bool
stored =
false
);
79
81
static
QgsCredentials
*
instance
();
82
88
void
lock
();
89
93
void
unlock
();
94
98
QMutex *
mutex
() {
return
&mAuthMutex; }
99
100
protected
:
101
QgsCredentials
() =
default
;
102
104
virtual
bool
request
(
const
QString &realm, QString &username
SIP_INOUT
, QString &password
SIP_INOUT
,
const
QString &message = QString() ) = 0;
105
107
virtual
bool
requestMasterPassword
( QString &password
SIP_INOUT
,
bool
stored =
false
) = 0;
108
110
void
setInstance
(
QgsCredentials
*
instance
);
111
112
private
:
113
Q_DISABLE_COPY(
QgsCredentials
)
114
115
#ifdef SIP_RUN
116
QgsCredentials
(
const
QgsCredentials
& );
117
#endif
118
120
QMap< QString, QPair<QString, QString> > mCredentialCache;
121
123
static
QgsCredentials
*sInstance;
124
126
QMutex mAuthMutex;
127
129
QMutex mCacheMutex;
130
};
131
132
139
class
CORE_EXPORT
QgsCredentialsNone
:
public
QObject,
public
QgsCredentials
140
{
141
Q_OBJECT
142
143
public
:
144
QgsCredentialsNone
();
145
146
signals:
148
void
destroyed
();
149
150
protected
:
151
bool
request
(
const
QString &realm, QString &username
SIP_INOUT
, QString &password
SIP_INOUT
,
const
QString &message = QString() )
override
;
152
bool
requestMasterPassword
( QString &password
SIP_INOUT
,
bool
stored =
false
)
override
;
153
};
154
155
164
class
CORE_EXPORT
QgsCredentialsConsole
:
public
QObject,
public
QgsCredentials
165
{
166
Q_OBJECT
167
168
public
:
169
QgsCredentialsConsole
();
170
171
signals:
173
void
destroyed
();
174
175
protected
:
176
bool
request
(
const
QString &realm, QString &username
SIP_INOUT
, QString &password
SIP_INOUT
,
const
QString &message = QString() )
override
;
177
bool
requestMasterPassword
( QString &password
SIP_INOUT
,
bool
stored =
false
)
override
;
178
};
179
180
#endif
QgsCredentialsConsole::requestMasterPassword
bool requestMasterPassword(QString &password, bool stored=false) override
request a master password
Definition
qgscredentials.cpp:152
QgsCredentialsConsole::QgsCredentialsConsole
QgsCredentialsConsole()
Definition
qgscredentials.cpp:131
QgsCredentialsConsole::request
bool request(const QString &realm, QString &username, QString &password, const QString &message=QString()) override
request a password
Definition
qgscredentials.cpp:136
QgsCredentialsConsole::destroyed
void destroyed()
signals that object will be destroyed and shouldn't be used anymore
QgsCredentialsNone::requestMasterPassword
bool requestMasterPassword(QString &password, bool stored=false) override
request a master password
Definition
qgscredentials.cpp:121
QgsCredentialsNone::destroyed
void destroyed()
signals that object will be destroyed and shouldn't be used anymore
QgsCredentialsNone::request
bool request(const QString &realm, QString &username, QString &password, const QString &message=QString()) override
request a password
Definition
qgscredentials.cpp:112
QgsCredentialsNone::QgsCredentialsNone
QgsCredentialsNone()
Definition
qgscredentials.cpp:107
QgsCredentials::mutex
QMutex * mutex()
Returns pointer to mutex.
Definition
qgscredentials.h:98
QgsCredentials::requestMasterPassword
virtual bool requestMasterPassword(QString &password, bool stored=false)=0
request a master password
QgsCredentials::setInstance
void setInstance(QgsCredentials *instance)
register instance
Definition
qgscredentials.cpp:30
QgsCredentials::instance
static QgsCredentials * instance()
retrieves instance
Definition
qgscredentials.cpp:40
QgsCredentials::lock
void lock()
Lock the instance against access from multiple threads.
Definition
qgscredentials.cpp:93
QgsCredentials::get
bool get(const QString &realm, QString &username, QString &password, const QString &message=QString(), bool requestCredentials=true)
Requests credentials for the specified realm.
Definition
qgscredentials.cpp:48
QgsCredentials::QgsCredentials
QgsCredentials()=default
QgsCredentials::getMasterPassword
bool getMasterPassword(QString &password, bool stored=false)
Definition
qgscredentials.cpp:83
QgsCredentials::~QgsCredentials
virtual ~QgsCredentials()=default
QgsCredentials::unlock
void unlock()
Unlock the instance after being locked.
Definition
qgscredentials.cpp:98
QgsCredentials::put
void put(const QString &realm, const QString &username, const QString &password)
Stores the correct username and password for the specified realm.
Definition
qgscredentials.cpp:76
QgsCredentials::request
virtual bool request(const QString &realm, QString &username, QString &password, const QString &message=QString())=0
request a password
qgis_sip.h
SIP_INOUT
#define SIP_INOUT
Definition
qgis_sip.h:78
Generated on
for QGIS API Documentation by
1.17.0