QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
qgsauthmethod.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsauthmethod.h
3 ---------------------
4 begin : September 1, 2015
5 copyright : (C) 2015 by Boundless Spatial, Inc. USA
6 author : Larry Shaffer
7 email : lshaffer at boundlessgeo dot com
8 ***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16
17#ifndef QGSAUTHMETHOD_H
18#define QGSAUTHMETHOD_H
19
20#include "qgsconfig.h"
21
22#include "qgis_core.h"
23#include "qgis_sip.h"
24
25#include <QFlags>
26#include <QNetworkReply>
27#include <QNetworkRequest>
28#include <QObject>
29#include <QRecursiveMutex>
30#include <QStringList>
31#include <QUrl>
32
34
39class CORE_EXPORT QgsAuthMethod : public QObject
40{
41 Q_OBJECT
42
43 public:
44
54 {
55 // TODO: Figure out all different authentication expansions current layer providers use
62 };
63 Q_DECLARE_FLAGS( Expansions, Expansion )
64
65
66 virtual QString key() const = 0;
67
69 virtual QString description() const = 0;
70
72 virtual QString displayDescription() const = 0;
73
75 int version() const { return mVersion; }
76
77
78#ifdef HAVE_GUI
79 SIP_IF_FEATURE( HAVE_GUI )
80
81
85 virtual QWidget *editWidget( QWidget *parent ) const;
87#endif
88
95
100 QStringList supportedDataProviders() const { return mDataProviders; }
101
110 virtual bool updateNetworkRequest( QNetworkRequest &request, const QString &authcfg,
111 const QString &dataprovider = QString() )
112 {
113 Q_UNUSED( request )
114 Q_UNUSED( authcfg )
115 Q_UNUSED( dataprovider )
116 return true; // noop
117 }
118
127 virtual bool updateNetworkReply( QNetworkReply *reply, const QString &authcfg,
128 const QString &dataprovider = QString() )
129 {
130 Q_UNUSED( reply )
131 Q_UNUSED( authcfg )
132 Q_UNUSED( dataprovider )
133 return true; // noop
134 }
135
144 virtual bool updateDataSourceUriItems( QStringList &connectionItems, const QString &authcfg,
145 const QString &dataprovider = QString() )
146 {
147 Q_UNUSED( connectionItems )
148 Q_UNUSED( authcfg )
149 Q_UNUSED( dataprovider )
150 return true; // noop
151 }
152
161 virtual bool updateNetworkProxy( QNetworkProxy &proxy, const QString &authcfg,
162 const QString &dataprovider = QString() )
163 {
164 Q_UNUSED( proxy )
165 Q_UNUSED( authcfg )
166 Q_UNUSED( dataprovider )
167 return true; // noop
168 }
169
176 virtual void clearCachedConfig( const QString &authcfg ) = 0;
177
182 virtual void updateMethodConfig( QgsAuthMethodConfig &mconfig ) = 0;
183
184 protected:
185
190 explicit QgsAuthMethod();
191
193 static QString authMethodTag() { return QObject::tr( "Authentication method" ); }
194
197
199 void setExpansions( QgsAuthMethod::Expansions expansions ) { mExpansions = expansions; }
201 void setDataProviders( const QStringList &dataproviders ) { mDataProviders = dataproviders; }
202
204 QStringList mDataProviders;
205 int mVersion = 0;
206 QRecursiveMutex mMutex;
207};
209
210typedef QHash<QString, QgsAuthMethod *> QgsAuthMethodsMap;
211
212#endif // QGSAUTHMETHOD_H
Configuration storage class for authentication method configurations.
Abstract base class for authentication method plugins.
virtual QString description() const =0
A non-translated short description representing the auth method for use in debug output and About dia...
QRecursiveMutex mMutex
int version() const
Increment this if method is significantly updated, allow updater code to be written for previously st...
virtual bool updateNetworkProxy(QNetworkProxy &proxy, const QString &authcfg, const QString &dataprovider=QString())
Update proxy settings with authentication components.
virtual bool updateNetworkRequest(QNetworkRequest &request, const QString &authcfg, const QString &dataprovider=QString())
Update a network request with authentication components.
QStringList mDataProviders
QgsAuthMethod::Expansions supportedExpansions() const
Flags that represent the update points (where authentication configurations are expanded) supported b...
virtual QString displayDescription() const =0
Translatable display version of the 'description()'.
void setExpansions(QgsAuthMethod::Expansions expansions)
Sets the support expansions (points in providers where the authentication is injected) of the auth me...
QStringList supportedDataProviders() const
The data providers that the method supports, allowing for filtering out authcfgs that are not applica...
virtual void clearCachedConfig(const QString &authcfg)=0
Clear any cached configuration.
virtual void updateMethodConfig(QgsAuthMethodConfig &mconfig)=0
Update an authentication configuration in place.
QgsAuthMethod()
Construct a default authentication method.
QgsAuthMethod::Expansions mExpansions
void setVersion(int version)
Sets the version of the auth method (useful for future upgrading).
virtual bool updateNetworkReply(QNetworkReply *reply, const QString &authcfg, const QString &dataprovider=QString())
Update a network reply with authentication components.
virtual bool updateDataSourceUriItems(QStringList &connectionItems, const QString &authcfg, const QString &dataprovider=QString())
Update data source connection items with authentication components.
static QString authMethodTag()
Tag signifying that this is an authentcation method (e.g. for use as title in message log panel outpu...
virtual QString key() const =0
A non-translated short name representing the auth method.
QFlags< Expansion > Expansions
void setDataProviders(const QStringList &dataproviders)
Sets list of data providers this auth method supports.
Expansion
Flags that represent the update points (where authentication configurations are expanded) supported b...
#define SIP_ENUM_BASETYPE(type)
Definition qgis_sip.h:275
#define SIP_IF_FEATURE(feature)
Definition qgis_sip.h:189
#define SIP_END
Definition qgis_sip.h:216
QHash< QString, QgsAuthMethod * > QgsAuthMethodsMap
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsProjectionSelectionWidget::CrsOptions)