QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
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
102 virtual bool initialize() { return true; }
103
107 virtual QString lastError() const;
108
113 virtual bool isReady() const = 0;
114
119
123 QMap<QString, QVariant> settings() const;
124
128 virtual QList<QgsAuthConfigurationStorage::SettingParameter> settingsParameters() const = 0;
129
133 bool isEncrypted() const;
134
138 bool isEnabled() const;
139
144 void setEnabled( bool enabled );
145
146
151 virtual void setReadOnly( bool readOnly );
152
157 virtual bool isReadOnly() const;
158
164 virtual QgsAuthMethodConfigsMap authMethodConfigs( const QStringList &allowedMethods = QStringList() ) const SIP_THROW( QgsNotSupportedException ) = 0;
165
174 virtual QgsAuthMethodConfigsMap authMethodConfigsWithPayload( ) const SIP_THROW( QgsNotSupportedException ) = 0;
175
184 virtual QgsAuthMethodConfig loadMethodConfig( const QString &id, QString &payload SIP_OUT, bool full = false ) const SIP_THROW( QgsNotSupportedException ) = 0;
185
193 virtual bool storeMethodConfig( const QgsAuthMethodConfig &config, const QString &payload ) SIP_THROW( QgsNotSupportedException ) = 0;
194
200 virtual bool removeMethodConfig( const QString &id ) SIP_THROW( QgsNotSupportedException ) = 0;
201
208 virtual bool methodConfigExists( const QString &id ) const SIP_THROW( QgsNotSupportedException ) = 0;
209
217 virtual bool storeAuthSetting( const QString &key, const QString &value ) SIP_THROW( QgsNotSupportedException ) = 0;
218
225 virtual QString loadAuthSetting( const QString &key ) const SIP_THROW( QgsNotSupportedException ) = 0;
226
233 virtual bool removeAuthSetting( const QString &key ) SIP_THROW( QgsNotSupportedException ) = 0;
234
241 virtual bool authSettingExists( const QString &key ) const SIP_THROW( QgsNotSupportedException ) = 0;
242
243#ifndef QT_NO_SSL
244
252 virtual bool storeCertIdentity( const QSslCertificate &cert, const QString &keyPem ) SIP_THROW( QgsNotSupportedException ) = 0;
253
260 virtual bool removeCertIdentity( const QSslCertificate &cert ) SIP_THROW( QgsNotSupportedException ) = 0;
261
268 virtual const QSslCertificate loadCertIdentity( const QString &id ) const SIP_THROW( QgsNotSupportedException ) = 0;
269
276 virtual const QPair<QSslCertificate, QString> loadCertIdentityBundle( const QString &id ) const SIP_THROW( QgsNotSupportedException ) = 0;
277
283 virtual const QList<QSslCertificate> certIdentities() const SIP_THROW( QgsNotSupportedException ) = 0;
284
290 virtual QStringList certIdentityIds() const SIP_THROW( QgsNotSupportedException ) = 0;
291
298 virtual bool certIdentityExists( const QString &id ) const SIP_THROW( QgsNotSupportedException ) = 0;
299
306 virtual bool removeCertIdentity( const QString &id ) SIP_THROW( QgsNotSupportedException ) = 0;
307
314 virtual bool storeSslCertCustomConfig( const QgsAuthConfigSslServer &config ) SIP_THROW( QgsNotSupportedException ) = 0;
315
323 virtual const QgsAuthConfigSslServer loadSslCertCustomConfig( const QString &id, const QString &hostport ) const SIP_THROW( QgsNotSupportedException ) = 0;
324
331 virtual const QgsAuthConfigSslServer loadSslCertCustomConfigByHost( const QString &hostport ) const SIP_THROW( QgsNotSupportedException ) = 0;
332
338 virtual const QList<QgsAuthConfigSslServer> sslCertCustomConfigs() const SIP_THROW( QgsNotSupportedException ) = 0;
339
345 virtual QStringList sslCertCustomConfigIds() const SIP_THROW( QgsNotSupportedException ) = 0;
346
354 virtual bool sslCertCustomConfigExists( const QString &id, const QString &hostport ) SIP_THROW( QgsNotSupportedException ) = 0;
355
363 virtual bool removeSslCertCustomConfig( const QString &id, const QString &hostport ) SIP_THROW( QgsNotSupportedException ) = 0;
364
371 virtual bool storeCertAuthority( const QSslCertificate &cert ) SIP_THROW( QgsNotSupportedException ) = 0;
372
378 virtual QStringList certAuthorityIds() const SIP_THROW( QgsNotSupportedException ) = 0;
379
386 virtual const QSslCertificate loadCertAuthority( const QString &id ) const SIP_THROW( QgsNotSupportedException ) = 0;
387
394 virtual bool certAuthorityExists( const QSslCertificate &cert ) const SIP_THROW( QgsNotSupportedException ) = 0;
395
402 virtual bool removeCertAuthority( const QSslCertificate &cert ) SIP_THROW( QgsNotSupportedException ) = 0;
403
409 virtual const QMap<QString, QgsAuthCertUtils::CertTrustPolicy> caCertsPolicy() const SIP_THROW( QgsNotSupportedException ) = 0;
410
416 virtual const QList<QSslCertificate> caCerts() const SIP_THROW( QgsNotSupportedException ) = 0;
417
425 virtual bool storeCertTrustPolicy( const QSslCertificate &cert, QgsAuthCertUtils::CertTrustPolicy policy ) SIP_THROW( QgsNotSupportedException ) = 0;
426
433 virtual QgsAuthCertUtils::CertTrustPolicy loadCertTrustPolicy( const QSslCertificate &cert ) const SIP_THROW( QgsNotSupportedException ) = 0;
434
441 virtual bool removeCertTrustPolicy( const QSslCertificate &cert ) SIP_THROW( QgsNotSupportedException ) = 0;
442
449 virtual bool certTrustPolicyExists( const QSslCertificate &cert ) const SIP_THROW( QgsNotSupportedException ) = 0;
450
451#endif
452
458 virtual const QList<QgsAuthConfigurationStorage::MasterPasswordConfig> masterPasswords( ) const SIP_THROW( QgsNotSupportedException ) = 0;
459
466 virtual bool storeMasterPassword( const QgsAuthConfigurationStorage::MasterPasswordConfig &config ) SIP_THROW( QgsNotSupportedException ) = 0;
467
473 virtual bool clearMasterPasswords() SIP_THROW( QgsNotSupportedException ) = 0;
474
480 virtual bool erase() SIP_THROW( QgsNotSupportedException ) = 0;
481
488 virtual bool clearMethodConfigs() SIP_THROW( QgsNotSupportedException ) = 0;
489
490
491 signals:
492
500 void messageLog( const QString &message, const QString &tag = QStringLiteral( "Authentication" ), Qgis::MessageLevel level = Qgis::MessageLevel::Info );
501
509 void storageChanged( const QString &id );
510
514 void methodConfigChanged( );
515
519 void masterPasswordChanged();
520
524 void authSettingsChanged();
525
529 void readOnlyChanged( bool readOnly );
530
531
532#ifndef QT_NO_SSL
533
538
543
548
553
554#endif
555
556 protected:
557
561 void setCapabilities( Qgis::AuthConfigurationStorageCapabilities capabilities );
562
566 void setError( const QString &error, Qgis::MessageLevel level = Qgis::MessageLevel::Critical );
567
572 void checkCapability( Qgis::AuthConfigurationStorageCapability capability ) const SIP_SKIP;
573
578 virtual QString loggerTag() const;
579
583 QMap<QString, QVariant> mConfiguration;
584
589
593 mutable QString mLastError;
594
598 bool mIsEncrypted = true;
599
603 bool mIsEnabled = true;
604
608 bool mIsReadOnly = false;
609
610};
611
612#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.