17#include "ui_qgsauthmethodplugins.h"
31#include <QTableWidget>
34#include "moc_qgsautheditorwidgets.cpp"
42 mAuthNotifyLayout =
new QVBoxLayout;
43 this->setLayout( mAuthNotifyLayout );
45 mAuthNotifyLayout->addWidget( mAuthNotify );
50 connect( buttonBox, &QDialogButtonBox::rejected,
this, &QDialog::reject );
57void QgsAuthMethodPlugins::setupTable()
59 tblAuthPlugins->setColumnCount( 3 );
60 tblAuthPlugins->verticalHeader()->hide();
61 tblAuthPlugins->horizontalHeader()->setVisible(
true );
62 tblAuthPlugins->setHorizontalHeaderItem( 0,
new QTableWidgetItem( tr(
"Method" ) ) );
63 tblAuthPlugins->setHorizontalHeaderItem( 1,
new QTableWidgetItem( tr(
"Description" ) ) );
64 tblAuthPlugins->setHorizontalHeaderItem( 2,
new QTableWidgetItem( tr(
"Works with" ) ) );
65 tblAuthPlugins->horizontalHeader()->setStretchLastSection(
true );
66 tblAuthPlugins->setAlternatingRowColors(
true );
67 tblAuthPlugins->setColumnWidth( 0, 150 );
68 tblAuthPlugins->setColumnWidth( 1, 300 );
70 tblAuthPlugins->verticalHeader()->setSectionResizeMode( QHeaderView::ResizeToContents );
71 tblAuthPlugins->setSortingEnabled(
true );
72 tblAuthPlugins->setSelectionBehavior( QAbstractItemView::SelectRows );
75void QgsAuthMethodPlugins::populateTable()
80 const auto constAuthMethodKeys = authMethodKeys;
81 for (
const QString &authMethodKey : constAuthMethodKeys )
85 if ( !meta || !method )
87 QgsDebugError( QStringLiteral(
"Load auth method instance FAILED for auth method key (%1)" ).arg( authMethodKey ) );
91 QTableWidgetItem *twi =
new QTableWidgetItem( meta->
key() );
92 twi->setFlags( twi->flags() & ~Qt::ItemIsEditable );
93 tblAuthPlugins->setItem( i, 0, twi );
96 twi->setFlags( twi->flags() & ~Qt::ItemIsEditable );
97 tblAuthPlugins->setItem( i, 1, twi );
100 twi->setFlags( twi->flags() & ~Qt::ItemIsEditable );
101 tblAuthPlugins->setItem( i, 2, twi );
105 tblAuthPlugins->sortItems( 0 );
114 connect( btnCertManager, &QPushButton::clicked,
this, &QgsAuthEditorWidgets::btnCertManager_clicked );
115 connect( btnAuthPlugins, &QPushButton::clicked,
this, &QgsAuthEditorWidgets::btnAuthPlugins_clicked );
118 wdgtConfigEditor->setRelayMessages(
false );
119 wdgtConfigEditor->setShowUtilitiesButton(
false );
120 setupUtilitiesMenu();
124 grpbxManagers->setEnabled(
false );
128void QgsAuthEditorWidgets::btnCertManager_clicked()
131 dlg->setWindowModality( Qt::ApplicationModal );
132 dlg->resize( 750, 500 );
137void QgsAuthEditorWidgets::btnAuthPlugins_clicked()
139 QgsAuthMethodPlugins *dlg =
new QgsAuthMethodPlugins(
this );
140 dlg->setWindowModality( Qt::WindowModal );
141 dlg->resize( 675, 500 );
146void QgsAuthEditorWidgets::setupUtilitiesMenu()
153 mActionImportAuthenticationConfigs =
new QAction( tr(
"Import Authentication Configurations from File…" ),
this );
154 mActionExportSelectedAuthenticationConfigs =
new QAction( tr(
"Export Selected Authentication Configurations to File…" ),
this );
155 mActionSetMasterPassword =
new QAction( tr(
"Input Master Password…" ),
this );
156 mActionClearCachedMasterPassword =
new QAction( tr(
"Clear Cached Master Password" ),
this );
157 mActionResetMasterPassword =
new QAction( tr(
"Reset Master Password…" ),
this );
158 mActionClearCachedAuthConfigs =
new QAction( tr(
"Clear Cached Authentication Configurations" ),
this );
159 mActionRemoveAuthConfigs =
new QAction( tr(
"Remove all Authentication Configurations…" ),
this );
160 mActionEraseAuthDatabase =
new QAction( tr(
"Erase Authentication Database…" ),
this );
162 mActionClearAccessCacheNow =
new QAction( tr(
"Clear Network Authentication Access Cache" ),
this );
163 mActionAutoClearAccessCache =
new QAction( tr(
"Automatically Clear Network Authentication Access Cache on SSL Errors" ),
this );
164 mActionAutoClearAccessCache->setCheckable(
true );
165 mActionAutoClearAccessCache->setChecked( QgsSettings().value( QStringLiteral(
"clear_auth_cache_on_errors" ),
true,
QgsSettings::Section::Auth ).toBool() );
169 mActionPasswordHelperLoggingEnable =
new QAction( tr(
"Enable Password Helper Debug Log" ),
this );
171 mActionPasswordHelperEnable->setCheckable(
true );
174 mActionPasswordHelperLoggingEnable->setCheckable(
true );
179 connect( mActionImportAuthenticationConfigs, &QAction::triggered,
this, &QgsAuthEditorWidgets::importAuthenticationConfigs );
180 connect( mActionResetMasterPassword, &QAction::triggered,
this, &QgsAuthEditorWidgets::resetMasterPassword );
181 connect( mActionRemoveAuthConfigs, &QAction::triggered,
this, &QgsAuthEditorWidgets::removeAuthenticationConfigs );
182 connect( mActionEraseAuthDatabase, &QAction::triggered,
this, &QgsAuthEditorWidgets::eraseAuthenticationDatabase );
186 mActionImportAuthenticationConfigs->setEnabled(
false );
187 mActionResetMasterPassword->setEnabled(
false );
188 mActionRemoveAuthConfigs->setEnabled(
false );
189 mActionEraseAuthDatabase->setEnabled(
false );
192 connect( mActionExportSelectedAuthenticationConfigs, &QAction::triggered,
this, &QgsAuthEditorWidgets::exportSelectedAuthenticationConfigs );
193 connect( mActionSetMasterPassword, &QAction::triggered,
this, &QgsAuthEditorWidgets::setMasterPassword );
194 connect( mActionClearCachedMasterPassword, &QAction::triggered,
this, &QgsAuthEditorWidgets::clearCachedMasterPassword );
195 connect( mActionClearCachedAuthConfigs, &QAction::triggered,
this, &QgsAuthEditorWidgets::clearCachedAuthenticationConfigs );
197 connect( mActionPasswordHelperDelete, &QAction::triggered,
this, &QgsAuthEditorWidgets::passwordHelperDelete );
198 connect( mActionPasswordHelperEnable, &QAction::triggered,
this, &QgsAuthEditorWidgets::passwordHelperEnableTriggered );
199 connect( mActionPasswordHelperLoggingEnable, &QAction::triggered,
this, &QgsAuthEditorWidgets::passwordHelperLoggingEnableTriggered );
201 connect( mActionClearAccessCacheNow, &QAction::triggered,
this, [
this] {
203 messageBar()->clearWidgets();
204 messageBar()->pushSuccess( tr(
"Auth cache cleared" ), tr(
"Network authentication cache has been cleared" ) );
206 connect( mActionAutoClearAccessCache, &QAction::triggered,
this, [](
bool checked ) {
210 mAuthUtilitiesMenu =
new QMenu(
this );
211 mAuthUtilitiesMenu->addAction( mActionSetMasterPassword );
212 mAuthUtilitiesMenu->addAction( mActionClearCachedMasterPassword );
213 mAuthUtilitiesMenu->addAction( mActionResetMasterPassword );
214 mAuthUtilitiesMenu->addSeparator();
215 mAuthUtilitiesMenu->addAction( mActionClearAccessCacheNow );
216 mAuthUtilitiesMenu->addAction( mActionAutoClearAccessCache );
217 mAuthUtilitiesMenu->addSeparator();
218 mAuthUtilitiesMenu->addAction( mActionPasswordHelperEnable );
219 mAuthUtilitiesMenu->addAction( mActionPasswordHelperDelete );
220 mAuthUtilitiesMenu->addAction( mActionPasswordHelperLoggingEnable );
221 mAuthUtilitiesMenu->addSeparator();
222 mAuthUtilitiesMenu->addAction( mActionClearCachedAuthConfigs );
223 mAuthUtilitiesMenu->addAction( mActionRemoveAuthConfigs );
224 mAuthUtilitiesMenu->addSeparator();
225 mAuthUtilitiesMenu->addAction( mActionImportAuthenticationConfigs );
226 mAuthUtilitiesMenu->addAction( mActionExportSelectedAuthenticationConfigs );
227 mAuthUtilitiesMenu->addSeparator();
228 mAuthUtilitiesMenu->addAction( mActionEraseAuthDatabase );
230 btnAuthUtilities->setMenu( mAuthUtilitiesMenu );
233void QgsAuthEditorWidgets::importAuthenticationConfigs()
238void QgsAuthEditorWidgets::exportSelectedAuthenticationConfigs()
240 if ( !wdgtConfigEditor )
246void QgsAuthEditorWidgets::setMasterPassword()
251void QgsAuthEditorWidgets::clearCachedMasterPassword()
256void QgsAuthEditorWidgets::resetMasterPassword()
261void QgsAuthEditorWidgets::clearCachedAuthenticationConfigs()
266void QgsAuthEditorWidgets::removeAuthenticationConfigs()
271void QgsAuthEditorWidgets::eraseAuthenticationDatabase()
276void QgsAuthEditorWidgets::authMessageLog(
const QString &message,
const QString &authtag,
Qgis::MessageLevel level )
278 messageBar()->clearWidgets();
279 messageBar()->pushMessage( authtag, message, level );
282void QgsAuthEditorWidgets::passwordHelperDelete()
287void QgsAuthEditorWidgets::passwordHelperEnableTriggered()
293void QgsAuthEditorWidgets::passwordHelperLoggingEnableTriggered()
MessageLevel
Level for messages This will be used both for message log and message bar in application.
static QgsAuthManager * authManager()
Returns the application's authentication manager instance.
Dialog wrapper for widget to manage available certificate editors.
virtual bool isReadOnly() const
Returns true if the storage is read-only, false otherwise.
static void importAuthenticationConfigs(QgsMessageBar *msgbar)
Import authentication configurations from a XML file.
static void exportSelectedAuthenticationConfigs(QStringList authenticationConfigIds, QgsMessageBar *msgbar)
Exports selected authentication configurations to a XML file.
static void resetMasterPassword(QgsMessageBar *msgbar, QWidget *parent=nullptr)
Reset the cached master password, updating its hash in authentication database and resetting all exis...
static void clearCachedMasterPassword(QgsMessageBar *msgbar)
Clear the currently cached master password (not its hash in database).
static void passwordHelperEnable(bool enabled, QgsMessageBar *msgbar)
Sets password helper enabled (enable/disable).
static void clearCachedAuthenticationConfigs(QgsMessageBar *msgbar)
Clear all cached authentication configs for session.
static void passwordHelperLoggingEnable(bool enabled, QgsMessageBar *msgbar, int timeout=0)
Sets password helper logging enabled (enable/disable).
static void eraseAuthenticationDatabase(QgsMessageBar *msgbar, QWidget *parent=nullptr)
Completely clear out the authentication database (configs and master password).
static void removeAuthenticationConfigs(QgsMessageBar *msgbar, QWidget *parent=nullptr)
Remove all authentication configs.
static void setMasterPassword(QgsMessageBar *msgbar)
Sets the cached master password (and verifies it if its hash is in authentication database).
static void passwordHelperDelete(QgsMessageBar *msgbar, QWidget *parent=nullptr)
Remove master password from wallet.
QgsAuthConfigurationStorageDb * defaultDbStorage() const
Transitional proxy to the first ready storage of database type.
void messageLog(const QString &message, const QString &tag=QgsAuthManager::AUTH_MAN_TAG, Qgis::MessageLevel level=Qgis::MessageLevel::Info) const
Custom logging signal to relay to console output and QgsMessageLog.
QgsAuthMethod * authMethod(const QString &authMethodKey)
Gets authentication method from the config/provider cache via its key.
QStringList authMethodsKeys(const QString &dataprovider=QString())
Gets keys of supported authentication methods.
const QgsAuthMethodMetadata * authMethodMetadata(const QString &authMethodKey)
Gets authentication method metadata via its key.
static QString passwordHelperDisplayName(bool titleCase=false)
Returns a translated display name of the password helper (platform dependent).
QgsAuthMethodPlugins(QWidget *parent=nullptr)
Construct a dialog for viewing available authentication method plugins.
QStringList supportedDataProviders() const
The data providers that the method supports, allowing for filtering out authcfgs that are not applica...
A bar for displaying non-blocking messages to the user.
static QgsNetworkAccessManager * instance(Qt::ConnectionType connectionType=Qt::BlockingQueuedConnection)
Returns a pointer to the active QgsNetworkAccessManager for the current thread.
#define QgsDebugError(str)