QGIS API Documentation 3.41.0-Master (af5edcb665c)
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#include "moc_qgsauthconfigurationstorage.cpp"
18
19QgsAuthConfigurationStorage::QgsAuthConfigurationStorage( const QMap<QString, QVariant> &configuration )
20 : mConfiguration( configuration )
21{
22 // Forward all specific signals to the generic one
23 connect( this, &QgsAuthConfigurationStorage::methodConfigChanged, this, [ this ]
24 {
25 emit storageChanged( id() );
26 } );
27 connect( this, &QgsAuthConfigurationStorage::masterPasswordChanged, this, [ this ]
28 {
29 emit storageChanged( id() );
30 } );
31 connect( this, &QgsAuthConfigurationStorage::authSettingsChanged, this, [ this ]
32 {
33 emit storageChanged( id() );
34 } );
35
36#ifndef QT_NO_SSL
37 connect( this, &QgsAuthConfigurationStorage::certIdentityChanged, this, [ this ]
38 {
39 emit storageChanged( id() );
40 } );
41 connect( this, &QgsAuthConfigurationStorage::certAuthorityChanged, this, [ this ]
42 {
43 emit storageChanged( id() );
44 } );
46 {
47 emit storageChanged( id() );
48 } );
49 connect( this, &QgsAuthConfigurationStorage::sslCertTrustPolicyChanged, this, [ this ]
50 {
51 emit storageChanged( id() );
52 } );
53#endif
54}
55
57{
58 if ( mIsReadOnly != readOnly )
59 {
60 mIsReadOnly = readOnly;
61 emit readOnlyChanged( readOnly );
62 }
63}
64
69
70
72{
73 return mLastError;
74}
75
80
85
87{
88 mLastError = error;
89 emit messageLog( error, loggerTag(), level );
90}
91
93{
94 return mIsEnabled;
95}
96
98{
99 mIsEnabled = enabled;
100}
101
106
107QMap<QString, QVariant> QgsAuthConfigurationStorage::settings() const
108{
109 return mConfiguration;
110}
111
112
114{
115 return tr( "Auth storage %1" ).arg( name() );
116}
117
119{
120 const auto caps { capabilities() };
121 if ( !caps.testFlag( capability ) )
122 {
123 throw QgsNotSupportedException( tr( "Capability %1 is not supported by storage %2" ).arg( qgsEnumValueToKey<Qgis::AuthConfigurationStorageCapability>( capability ), name() ) );
124 }
125}
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.