QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
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:
53 {
54 // TODO: Figure out all different authentication expansions current layer providers use
61 };
62 Q_DECLARE_FLAGS( Expansions, Expansion )
63
64
65 virtual QString key() const = 0;
66
68 virtual QString description() const = 0;
69
71 virtual QString displayDescription() const = 0;
72
74 int version() const { return mVersion; }
75
76
77#ifdef HAVE_GUI
78 SIP_IF_FEATURE( HAVE_GUI )
79
80
84 virtual QWidget *editWidget( QWidget *parent ) const;
86#endif
87
97
102 QStringList supportedDataProviders() const { return mDataProviders; }
103
112 virtual bool updateNetworkRequest( QNetworkRequest &request, const QString &authcfg, const QString &dataprovider = QString() )
113 {
114 Q_UNUSED( request )
115 Q_UNUSED( authcfg )
116 Q_UNUSED( dataprovider )
117 return true; // noop
118 }
119
128 virtual bool updateNetworkReply( QNetworkReply *reply, const QString &authcfg, 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, const QString &dataprovider = QString() )
145 {
146 Q_UNUSED( connectionItems )
147 Q_UNUSED( authcfg )
148 Q_UNUSED( dataprovider )
149 return true; // noop
150 }
151
160 virtual bool updateNetworkProxy( QNetworkProxy &proxy, const QString &authcfg, const QString &dataprovider = QString() )
161 {
162 Q_UNUSED( proxy )
163 Q_UNUSED( authcfg )
164 Q_UNUSED( dataprovider )
165 return true; // noop
166 }
167
174 virtual void clearCachedConfig( const QString &authcfg ) = 0;
175
180 virtual void updateMethodConfig( QgsAuthMethodConfig &mconfig ) = 0;
181
182 protected:
187 explicit QgsAuthMethod();
188
190 static QString authMethodTag() { return QObject::tr( "Authentication method" ); }
191
194
196 void setExpansions( QgsAuthMethod::Expansions expansions ) { mExpansions = expansions; }
198 void setDataProviders( const QStringList &dataproviders ) { mDataProviders = dataproviders; }
199
201 QStringList mDataProviders;
202 int mVersion = 0;
203 QRecursiveMutex mMutex;
204};
206
207typedef QHash<QString, QgsAuthMethod *> QgsAuthMethodsMap;
208
209#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:274
#define SIP_IF_FEATURE(feature)
Definition qgis_sip.h:188
#define SIP_END
Definition qgis_sip.h:215
QHash< QString, QgsAuthMethod * > QgsAuthMethodsMap
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsProjectionSelectionWidget::CrsOptions)