QGIS API Documentation 3.39.0-Master (d85f3c2a281)
Loading...
Searching...
No Matches
qgsauthconfigurationstorage.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsauthconfigurationstorage.cpp - 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 ***************************************************************************/
17
18QgsAuthConfigurationStorage::QgsAuthConfigurationStorage( const QMap<QString, QVariant> &configuration )
19 : mConfiguration( configuration )
20{
21 // Forward all specific signals to the generic one
22 connect( this, &QgsAuthConfigurationStorage::methodConfigChanged, this, [ this ]
23 {
24 emit storageChanged( id() );
25 } );
26 connect( this, &QgsAuthConfigurationStorage::masterPasswordChanged, this, [ this ]
27 {
28 emit storageChanged( id() );
29 } );
30 connect( this, &QgsAuthConfigurationStorage::authSettingsChanged, this, [ this ]
31 {
32 emit storageChanged( id() );
33 } );
34
35#ifndef QT_NO_SSL
36 connect( this, &QgsAuthConfigurationStorage::certIdentityChanged, this, [ this ]
37 {
38 emit storageChanged( id() );
39 } );
40 connect( this, &QgsAuthConfigurationStorage::certAuthorityChanged, this, [ this ]
41 {
42 emit storageChanged( id() );
43 } );
45 {
46 emit storageChanged( id() );
47 } );
48 connect( this, &QgsAuthConfigurationStorage::sslCertTrustPolicyChanged, this, [ this ]
49 {
50 emit storageChanged( id() );
51 } );
52#endif
53}
54
56{
57 if ( mIsReadOnly != readOnly )
58 {
59 mIsReadOnly = readOnly;
60 emit readOnlyChanged( readOnly );
61 }
62}
63
68
69
71{
72 return mLastError;
73}
74
79
84
86{
87 mLastError = error;
88 emit messageLog( error, loggerTag(), level );
89}
90
92{
93 return mIsEnabled;
94}
95
97{
98 mIsEnabled = enabled;
99}
100
105
106QMap<QString, QVariant> QgsAuthConfigurationStorage::settings() const
107{
108 return mConfiguration;
109}
110
111
113{
114 return tr( "Auth storage %1" ).arg( name() );
115}
116
118{
119 const auto caps { capabilities() };
120 if ( !caps.testFlag( capability ) )
121 {
122 throw QgsNotSupportedException( tr( "Capability %1 is not supported by storage %2" ).arg( qgsEnumValueToKey<Qgis::AuthConfigurationStorageCapability>( capability ), name() ) );
123 }
124}
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
AuthConfigurationStorageCapability
Authentication configuration storage capabilities.
Definition qgis.h:100
QMap< QString, QVariant > mConfiguration
Store the implementation-specific configuration.
void readOnlyChanged(bool readOnly)
Emitted when the storage read-only status was changed.
QString mLastError
Store the last error message.
void certIdentityChanged()
Emitted when the storage cert identity table was changed.
void setCapabilities(Qgis::AuthConfigurationStorageCapabilities capabilities)
Set the capabilities of the storage to capabilities.
virtual void setReadOnly(bool readOnly)
Utility method to unset all editing capabilities.
void methodConfigChanged()
Emitted when the storage method config table was changed.
void setError(const QString &error, Qgis::MessageLevel level=Qgis::MessageLevel::Critical)
Set the last error message to error with message level level.
Qgis::AuthConfigurationStorageCapabilities capabilities() const
Returns the capabilities of the storage.
virtual QString loggerTag() const
Returns the logger tag for the storage.
bool isEnabled() const
Returns true if the storage is enabled.
void setEnabled(bool enabled)
Set the storage enabled status to enabled.
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 masterPasswordChanged()
Emitted when the storage master password table was changed.
QgsAuthConfigurationStorage(const QMap< QString, QVariant > &settings)
Creates a new authentication configuration storage.
void certAuthorityChanged()
Emitted when the storage cert authority table was changed.
bool isEncrypted() const
Returns true if the storage is encrypted.
void messageLog(const QString &message, const QString &tag=QStringLiteral("Authentication"), Qgis::MessageLevel level=Qgis::MessageLevel::Info)
Custom logging signal to relay to console output and QgsMessageLog.
bool mIsEnabled
Store whether the storage is enabled.
void sslCertCustomConfigChanged()
Emitted when the storage ssl cert custom config table was changed.
bool mIsReadOnly
Store whether the storage is read-only.
void authSettingsChanged()
Emitted when the storage auth settings table was changed.
void storageChanged(const QString &id)
Emitted when the storage was updated.
virtual QString lastError() const
Returns the last error message.
bool mIsEncrypted
Store whether the storage is encrypted.
void checkCapability(Qgis::AuthConfigurationStorageCapability capability) const
Utility to check capability and throw QgsNotSupportedException if not supported.
virtual bool isReadOnly() const
Returns true if the storage is read-only, false otherwise.
QMap< QString, QVariant > settings() const
Returns the settings of the storage.
Qgis::AuthConfigurationStorageCapabilities mCapabilities
Store the capabilities of the storage.
Custom exception class which is raised when an operation is not supported.