QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
Loading...
Searching...
No Matches
qgsauthconfigurationstorage.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsauthconfigurationstorage.h - QgsAuthConfigurationStorage
3
4 ---------------------
5 begin : 20.6.2024
6 copyright : (C) 2024 by Alessandro Pasotti
7 email : elpaso at itopen dot it
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#ifndef QGSAUTHCONFIGURATIONSTORAGE_H
17#define QGSAUTHCONFIGURATIONSTORAGE_H
18
19
20#include "qgis_sip.h"
21#include "qgis_core.h"
22#include "qgis.h"
23#include "qgsauthconfig.h"
24#include "qgsauthcertutils.h"
25#include "qgsexception.h"
26
27#include <QString>
28#include <QObject>
29
30
36class CORE_EXPORT QgsAuthConfigurationStorage: public QObject
37{
38 Q_OBJECT
39
40 public:
41
45 struct CORE_EXPORT MasterPasswordConfig
46 {
47 QString salt;
48 QString civ;
49 QString hash;
50 };
51
55 struct CORE_EXPORT SettingParameter
56 {
57 QString name;
58 QString description;
59 QVariant::Type type;
60 };
61
66 QgsAuthConfigurationStorage( const QMap<QString, QVariant> &settings );
67
69
74 virtual QString name() const = 0;
75
81 virtual QString type() const = 0;
82
87 virtual QString description() const = 0;
88
93 virtual QString id() const = 0;
94
103 virtual bool initialize() { return true; }
104
108 virtual QString lastError() const;
109
114 virtual bool isReady() const = 0;
115
120
124 QMap<QString, QVariant> settings() const;
125
129 virtual QList<QgsAuthConfigurationStorage::SettingParameter> settingsParameters() const = 0;
130
134 bool isEncrypted() const;
135
139 bool isEnabled() const;
140
145 void setEnabled( bool enabled );
146
147
152 virtual void setReadOnly( bool readOnly );
153
158 virtual bool isReadOnly() const;
159
165 virtual QgsAuthMethodConfigsMap authMethodConfigs( const QStringList &allowedMethods = QStringList() ) const SIP_THROW( QgsNotSupportedException ) = 0;
166
175 virtual QgsAuthMethodConfigsMap authMethodConfigsWithPayload( ) const SIP_THROW( QgsNotSupportedException ) = 0;
176
185 virtual QgsAuthMethodConfig loadMethodConfig( const QString &id, QString &payload SIP_OUT, bool full = false ) const SIP_THROW( QgsNotSupportedException ) = 0;
186
194 virtual bool storeMethodConfig( const QgsAuthMethodConfig &config, const QString &payload ) SIP_THROW( QgsNotSupportedException ) = 0;
195
201 virtual bool removeMethodConfig( const QString &id ) SIP_THROW( QgsNotSupportedException ) = 0;
202
209 virtual bool methodConfigExists( const QString &id ) const SIP_THROW( QgsNotSupportedException ) = 0;
210
218 virtual bool storeAuthSetting( const QString &key, const QString &value ) SIP_THROW( QgsNotSupportedException ) = 0;
219
226 virtual QString loadAuthSetting( const QString &key ) const SIP_THROW( QgsNotSupportedException ) = 0;
227
234 virtual bool removeAuthSetting( const QString &key ) SIP_THROW( QgsNotSupportedException ) = 0;
235
242 virtual bool authSettingExists( const QString &key ) const SIP_THROW( QgsNotSupportedException ) = 0;
243
244#ifndef QT_NO_SSL
245
253 virtual bool storeCertIdentity( const QSslCertificate &cert, const QString &keyPem ) SIP_THROW( QgsNotSupportedException ) = 0;
254
261 virtual bool removeCertIdentity( const QSslCertificate &cert ) SIP_THROW( QgsNotSupportedException ) = 0;
262
269 virtual const QSslCertificate loadCertIdentity( const QString &id ) const SIP_THROW( QgsNotSupportedException ) = 0;
270
277 virtual const QPair<QSslCertificate, QString> loadCertIdentityBundle( const QString &id ) const SIP_THROW( QgsNotSupportedException ) = 0;
278
284 virtual const QList<QSslCertificate> certIdentities() const SIP_THROW( QgsNotSupportedException ) = 0;
285
291 virtual QStringList certIdentityIds() const SIP_THROW( QgsNotSupportedException ) = 0;
292
299 virtual bool certIdentityExists( const QString &id ) const SIP_THROW( QgsNotSupportedException ) = 0;
300
307 virtual bool removeCertIdentity( const QString &id ) SIP_THROW( QgsNotSupportedException ) = 0;
308
315 virtual bool storeSslCertCustomConfig( const QgsAuthConfigSslServer &config ) SIP_THROW( QgsNotSupportedException ) = 0;
316
324 virtual const QgsAuthConfigSslServer loadSslCertCustomConfig( const QString &id, const QString &hostport ) const SIP_THROW( QgsNotSupportedException ) = 0;
325
332 virtual const QgsAuthConfigSslServer loadSslCertCustomConfigByHost( const QString &hostport ) const SIP_THROW( QgsNotSupportedException ) = 0;
333
339 virtual const QList<QgsAuthConfigSslServer> sslCertCustomConfigs() const SIP_THROW( QgsNotSupportedException ) = 0;
340
346 virtual QStringList sslCertCustomConfigIds() const SIP_THROW( QgsNotSupportedException ) = 0;
347
355 virtual bool sslCertCustomConfigExists( const QString &id, const QString &hostport ) SIP_THROW( QgsNotSupportedException ) = 0;
356
364 virtual bool removeSslCertCustomConfig( const QString &id, const QString &hostport ) SIP_THROW( QgsNotSupportedException ) = 0;
365
372 virtual bool storeCertAuthority( const QSslCertificate &cert ) SIP_THROW( QgsNotSupportedException ) = 0;
373
379 virtual QStringList certAuthorityIds() const SIP_THROW( QgsNotSupportedException ) = 0;
380
387 virtual const QSslCertificate loadCertAuthority( const QString &id ) const SIP_THROW( QgsNotSupportedException ) = 0;
388
395 virtual bool certAuthorityExists( const QSslCertificate &cert ) const SIP_THROW( QgsNotSupportedException ) = 0;
396
403 virtual bool removeCertAuthority( const QSslCertificate &cert ) SIP_THROW( QgsNotSupportedException ) = 0;
404
410 virtual const QMap<QString, QgsAuthCertUtils::CertTrustPolicy> caCertsPolicy() const SIP_THROW( QgsNotSupportedException ) = 0;
411
417 virtual const QList<QSslCertificate> caCerts() const SIP_THROW( QgsNotSupportedException ) = 0;
418
426 virtual bool storeCertTrustPolicy( const QSslCertificate &cert, QgsAuthCertUtils::CertTrustPolicy policy ) SIP_THROW( QgsNotSupportedException ) = 0;
427
434 virtual QgsAuthCertUtils::CertTrustPolicy loadCertTrustPolicy( const QSslCertificate &cert ) const SIP_THROW( QgsNotSupportedException ) = 0;
435
442 virtual bool removeCertTrustPolicy( const QSslCertificate &cert ) SIP_THROW( QgsNotSupportedException ) = 0;
443
450 virtual bool certTrustPolicyExists( const QSslCertificate &cert ) const SIP_THROW( QgsNotSupportedException ) = 0;
451
452#endif
453
459 virtual const QList<QgsAuthConfigurationStorage::MasterPasswordConfig> masterPasswords( ) const SIP_THROW( QgsNotSupportedException ) = 0;
460
467 virtual bool storeMasterPassword( const QgsAuthConfigurationStorage::MasterPasswordConfig &config ) SIP_THROW( QgsNotSupportedException ) = 0;
468
474 virtual bool clearMasterPasswords() SIP_THROW( QgsNotSupportedException ) = 0;
475
481 virtual bool erase() SIP_THROW( QgsNotSupportedException ) = 0;
482
489 virtual bool clearMethodConfigs() SIP_THROW( QgsNotSupportedException ) = 0;
490
491
492 signals:
493
501 void messageLog( const QString &message, const QString &tag = QStringLiteral( "Authentication" ), Qgis::MessageLevel level = Qgis::MessageLevel::Info );
502
510 void storageChanged( const QString &id );
511
515 void methodConfigChanged( );
516
520 void masterPasswordChanged();
521
525 void authSettingsChanged();
526
530 void readOnlyChanged( bool readOnly );
531
532
533#ifndef QT_NO_SSL
534
539
544
549
554
555#endif
556
557 protected:
558
562 void setCapabilities( Qgis::AuthConfigurationStorageCapabilities capabilities );
563
567 void setError( const QString &error, Qgis::MessageLevel level = Qgis::MessageLevel::Critical );
568
573 void checkCapability( Qgis::AuthConfigurationStorageCapability capability ) const SIP_SKIP;
574
579 virtual QString loggerTag() const;
580
584 QMap<QString, QVariant> mConfiguration;
585
590
594 mutable QString mLastError;
595
599 bool mIsEncrypted = true;
600
604 bool mIsEnabled = true;
605
609 bool mIsReadOnly = false;
610
611};
612
613#endif // QGSAUTHCONFIGURATIONSTORAGE_H
The Qgis class provides global constants for use throughout the application.
Definition qgis.h:54
QFlags< AuthConfigurationStorageCapability > AuthConfigurationStorageCapabilities
Authentication configuration storage capabilities.
Definition qgis.h:145
MessageLevel
Level for messages This will be used both for message log and message bar in application.
Definition qgis.h:154
@ Critical
Critical/error message.
Definition qgis.h:157
AuthConfigurationStorageCapability
Authentication configuration storage capabilities.
Definition qgis.h:100
Utilities for working with certificates and keys.
Configuration container for SSL server connection exceptions or overrides.
Abstract class that defines the interface for all authentication configuration storage implementation...
QMap< QString, QVariant > mConfiguration
Store the implementation-specific configuration.
QString mLastError
Store the last error message.
virtual QString description() const =0
Returns a human readable localized description of the storage implementation (e.g.
void certIdentityChanged()
Emitted when the storage cert identity table was changed.
virtual QgsAuthMethodConfigsMap authMethodConfigs(const QStringList &allowedMethods=QStringList()) const =0
Returns a mapping of authentication configurations available from this storage.
virtual bool removeCertIdentity(const QSslCertificate &cert)=0
Remove a certificate identity from the storage.
virtual bool isReady() const =0
Returns true is the storage is ready to be used.
virtual QString type() const =0
Returns the type of the storage implementation.
virtual bool initialize()
Initializes the storage.
virtual const QList< QSslCertificate > certIdentities() const =0
certIdentities get certificate identities
virtual QList< QgsAuthConfigurationStorage::SettingParameter > settingsParameters() const =0
Returns a list of the settings accepted by the storage.
virtual const QSslCertificate loadCertIdentity(const QString &id) const =0
certIdentity get a certificate identity by id (sha hash)
virtual bool storeCertIdentity(const QSslCertificate &cert, const QString &keyPem)=0
Store a certificate identity in the storage.
virtual QString name() const =0
Returns a human readable localized short name of the storage implementation (e.g "SQLite").
void sslCertTrustPolicyChanged()
Emitted when the storage ssl cert trust policy table was changed.
void certAuthorityChanged()
Emitted when the storage cert authority table was changed.
void sslCertCustomConfigChanged()
Emitted when the storage ssl cert custom config table was changed.
virtual const QPair< QSslCertificate, QString > loadCertIdentityBundle(const QString &id) const =0
Returns a certificate identity bundle by id (sha hash).
virtual QString id() const =0
Returns the unique identifier of the storage object.
virtual const QList< QgsAuthConfigurationStorage::MasterPasswordConfig > masterPasswords() const =0
Returns the list of (encrypted) master passwords stored in the database.
Qgis::AuthConfigurationStorageCapabilities mCapabilities
Store the capabilities of the storage.
Configuration storage class for authentication method configurations.
Custom exception class which is raised when an operation is not supported.
#define SIP_SKIP
Definition qgis_sip.h:126
#define SIP_OUT
Definition qgis_sip.h:58
#define SIP_THROW(name,...)
Definition qgis_sip.h:203
QHash< QString, QgsAuthMethodConfig > QgsAuthMethodConfigsMap
Structure that holds the (encrypted) master password elements.