18 #include "ui_qgsauthmethodplugins.h"
23 #include <QTableWidget>
25 #include "qgssettings.h"
39 mAuthNotifyLayout =
new QVBoxLayout;
40 this->setLayout( mAuthNotifyLayout );
42 mAuthNotifyLayout->addWidget( mAuthNotify );
47 connect( buttonBox, &QDialogButtonBox::rejected,
this, &QDialog::reject );
54 void QgsAuthMethodPlugins::setupTable()
56 tblAuthPlugins->setColumnCount( 3 );
57 tblAuthPlugins->verticalHeader()->hide();
58 tblAuthPlugins->horizontalHeader()->setVisible(
true );
59 tblAuthPlugins->setHorizontalHeaderItem( 0,
new QTableWidgetItem( tr(
"Method" ) ) );
60 tblAuthPlugins->setHorizontalHeaderItem( 1,
new QTableWidgetItem( tr(
"Description" ) ) );
61 tblAuthPlugins->setHorizontalHeaderItem( 2,
new QTableWidgetItem( tr(
"Works with" ) ) );
62 tblAuthPlugins->horizontalHeader()->setStretchLastSection(
true );
63 tblAuthPlugins->setAlternatingRowColors(
true );
64 tblAuthPlugins->setColumnWidth( 0, 150 );
65 tblAuthPlugins->setColumnWidth( 1, 300 );
67 tblAuthPlugins->verticalHeader()->setSectionResizeMode( QHeaderView::ResizeToContents );
68 tblAuthPlugins->setSortingEnabled(
true );
69 tblAuthPlugins->setSelectionBehavior( QAbstractItemView::SelectRows );
72 void QgsAuthMethodPlugins::populateTable()
77 for ( QgsAuthMethodsMap::const_iterator it = authmethods.constBegin(); it != authmethods.constEnd(); ++it, i++ )
85 QTableWidgetItem *twi =
new QTableWidgetItem( authmethod->key() );
86 twi->setFlags( twi->flags() & ~Qt::ItemIsEditable );
87 tblAuthPlugins->setItem( i, 0, twi );
89 twi =
new QTableWidgetItem( authmethod->displayDescription() );
90 twi->setFlags( twi->flags() & ~Qt::ItemIsEditable );
91 tblAuthPlugins->setItem( i, 1, twi );
93 twi =
new QTableWidgetItem( authmethod->supportedDataProviders().join( QLatin1String(
", " ) ) );
94 twi->setFlags( twi->flags() & ~Qt::ItemIsEditable );
95 tblAuthPlugins->setItem( i, 2, twi );
97 tblAuthPlugins->sortItems( 0 );
107 connect( btnCertManager, &QPushButton::clicked,
this, &QgsAuthEditorWidgets::btnCertManager_clicked );
108 connect( btnAuthPlugins, &QPushButton::clicked,
this, &QgsAuthEditorWidgets::btnAuthPlugins_clicked );
111 wdgtConfigEditor->setRelayMessages(
false );
112 wdgtConfigEditor->setShowUtilitiesButton(
false );
113 setupUtilitiesMenu();
117 grpbxManagers->setEnabled(
false );
121 void QgsAuthEditorWidgets::btnCertManager_clicked()
124 dlg->setWindowModality( Qt::ApplicationModal );
125 dlg->resize( 750, 500 );
130 void QgsAuthEditorWidgets::btnAuthPlugins_clicked()
133 dlg->setWindowModality( Qt::WindowModal );
134 dlg->resize( 675, 500 );
139 void QgsAuthEditorWidgets::setupUtilitiesMenu()
142 this, &QgsAuthEditorWidgets::authMessageOut );
145 mActionImportAuthenticationConfigs =
new QAction( tr(
"Import authentication configurations from file" ),
this );
146 mActionExportSelectedAuthenticationConfigs =
new QAction( tr(
"Export selected authentication configurations to file" ),
this );
147 mActionSetMasterPassword =
new QAction( tr(
"Input master password" ),
this );
148 mActionClearCachedMasterPassword =
new QAction( tr(
"Clear cached master password" ),
this );
149 mActionResetMasterPassword =
new QAction( tr(
"Reset master password" ),
this );
150 mActionClearCachedAuthConfigs =
new QAction( tr(
"Clear cached authentication configurations" ),
this );
151 mActionRemoveAuthConfigs =
new QAction( tr(
"Remove all authentication configurations" ),
this );
152 mActionEraseAuthDatabase =
new QAction( tr(
"Erase authentication database" ),
this );
154 mActionClearAccessCacheNow =
new QAction( tr(
"Clear network authentication access cache" ),
this );
155 mActionAutoClearAccessCache =
new QAction( tr(
"Automatically clear network authentication access cache on SSL errors" ),
this );
156 mActionAutoClearAccessCache->setCheckable(
true );
157 mActionAutoClearAccessCache->setChecked( QgsSettings().value( QStringLiteral(
"clear_auth_cache_on_errors" ),
true, QgsSettings::Section::Auth ).toBool( ) );
159 mActionPasswordHelperSync =
new QAction( tr(
"Store/update the master password in your %1" )
161 mActionPasswordHelperDelete =
new QAction( tr(
"Clear the master password from your %1" )
163 mActionPasswordHelperEnable =
new QAction( tr(
"Integrate master password with your %1" )
165 mActionPasswordHelperLoggingEnable =
new QAction( tr(
"Enable password helper debug log" ),
this );
167 mActionPasswordHelperEnable->setCheckable(
true );
170 mActionPasswordHelperLoggingEnable->setCheckable(
true );
173 connect( mActionImportAuthenticationConfigs, &QAction::triggered,
this, &QgsAuthEditorWidgets::importAuthenticationConfigs );
174 connect( mActionExportSelectedAuthenticationConfigs, &QAction::triggered,
this, &QgsAuthEditorWidgets::exportSelectedAuthenticationConfigs );
175 connect( mActionSetMasterPassword, &QAction::triggered,
this, &QgsAuthEditorWidgets::setMasterPassword );
176 connect( mActionClearCachedMasterPassword, &QAction::triggered,
this, &QgsAuthEditorWidgets::clearCachedMasterPassword );
177 connect( mActionResetMasterPassword, &QAction::triggered,
this, &QgsAuthEditorWidgets::resetMasterPassword );
178 connect( mActionClearCachedAuthConfigs, &QAction::triggered,
this, &QgsAuthEditorWidgets::clearCachedAuthenticationConfigs );
179 connect( mActionRemoveAuthConfigs, &QAction::triggered,
this, &QgsAuthEditorWidgets::removeAuthenticationConfigs );
180 connect( mActionEraseAuthDatabase, &QAction::triggered,
this, &QgsAuthEditorWidgets::eraseAuthenticationDatabase );
182 connect( mActionPasswordHelperSync, &QAction::triggered,
this, &QgsAuthEditorWidgets::passwordHelperSync );
183 connect( mActionPasswordHelperDelete, &QAction::triggered,
this, &QgsAuthEditorWidgets::passwordHelperDelete );
184 connect( mActionPasswordHelperEnable, &QAction::triggered,
this, &QgsAuthEditorWidgets::passwordHelperEnableTriggered );
185 connect( mActionPasswordHelperLoggingEnable, &QAction::triggered,
this, &QgsAuthEditorWidgets::passwordHelperLoggingEnableTriggered );
187 connect( mActionClearAccessCacheNow, &QAction::triggered,
this, [ = ]
190 messageBar()->
pushSuccess( tr(
"Auth cache cleared" ), tr(
"Network authentication cache has been cleared" ) );
192 connect( mActionAutoClearAccessCache, &QAction::triggered,
this, [ ](
bool checked )
194 QgsSettings().setValue( QStringLiteral(
"clear_auth_cache_on_errors" ), checked, QgsSettings::Section::Auth );
197 mAuthUtilitiesMenu =
new QMenu(
this );
198 mAuthUtilitiesMenu->addAction( mActionSetMasterPassword );
199 mAuthUtilitiesMenu->addAction( mActionClearCachedMasterPassword );
200 mAuthUtilitiesMenu->addAction( mActionResetMasterPassword );
201 mAuthUtilitiesMenu->addSeparator();
202 mAuthUtilitiesMenu->addAction( mActionClearAccessCacheNow );
203 mAuthUtilitiesMenu->addAction( mActionAutoClearAccessCache );
204 mAuthUtilitiesMenu->addSeparator();
205 mAuthUtilitiesMenu->addAction( mActionPasswordHelperEnable );
206 mAuthUtilitiesMenu->addAction( mActionPasswordHelperSync );
207 mAuthUtilitiesMenu->addAction( mActionPasswordHelperDelete );
208 mAuthUtilitiesMenu->addAction( mActionPasswordHelperLoggingEnable );
209 mAuthUtilitiesMenu->addSeparator();
210 mAuthUtilitiesMenu->addAction( mActionClearCachedAuthConfigs );
211 mAuthUtilitiesMenu->addAction( mActionRemoveAuthConfigs );
212 mAuthUtilitiesMenu->addSeparator();
213 mAuthUtilitiesMenu->addAction( mActionImportAuthenticationConfigs );
214 mAuthUtilitiesMenu->addAction( mActionExportSelectedAuthenticationConfigs );
215 mAuthUtilitiesMenu->addSeparator();
216 mAuthUtilitiesMenu->addAction( mActionEraseAuthDatabase );
218 btnAuthUtilities->setMenu( mAuthUtilitiesMenu );
221 void QgsAuthEditorWidgets::importAuthenticationConfigs()
226 void QgsAuthEditorWidgets::exportSelectedAuthenticationConfigs()
228 if ( !wdgtConfigEditor )
234 void QgsAuthEditorWidgets::setMasterPassword()
239 void QgsAuthEditorWidgets::clearCachedMasterPassword()
244 void QgsAuthEditorWidgets::resetMasterPassword()
249 void QgsAuthEditorWidgets::clearCachedAuthenticationConfigs()
254 void QgsAuthEditorWidgets::removeAuthenticationConfigs()
259 void QgsAuthEditorWidgets::eraseAuthenticationDatabase()
266 int levelint =
static_cast<int>( level );
270 void QgsAuthEditorWidgets::passwordHelperDelete()
275 void QgsAuthEditorWidgets::passwordHelperSync()
280 void QgsAuthEditorWidgets::passwordHelperEnableTriggered()
286 void 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.
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.
static void passwordHelperSync(QgsMessageBar *msgbar)
Store master password into the wallet.
MessageLevel
Message log level (mirrors that of QgsMessageLog, so it can also output there)
void messageOut(const QString &message, const QString &tag=QgsAuthManager::AUTH_MAN_TAG, QgsAuthManager::MessageLevel level=QgsAuthManager::INFO) const
Custom logging signal to relay to console output and QgsMessageLog.
static const QString AUTH_PASSWORD_HELPER_DISPLAY_NAME
The display name of the password helper (platform dependent)
Dialog for viewing available authentication method plugins.
QgsAuthMethodPlugins(QWidget *parent=nullptr)
Construct a dialog for viewing available authentication method plugins.
Abstract base class for authentication method plugins.
A bar for displaying non-blocking messages to the user.
void pushMessage(const QString &text, Qgis::MessageLevel level=Qgis::MessageLevel::Info, int duration=-1)
A convenience method for pushing a message with the specified text to the bar.
void pushSuccess(const QString &title, const QString &message)
Pushes a success message with default timeout to the message bar.
static QgsNetworkAccessManager * instance(Qt::ConnectionType connectionType=Qt::BlockingQueuedConnection)
Returns a pointer to the active QgsNetworkAccessManager for the current thread.
QHash< QString, QgsAuthMethod * > QgsAuthMethodsMap