18#include "ui_qgsauthmethodplugins.h"
23#include <QTableWidget>
40 mAuthNotifyLayout =
new QVBoxLayout;
41 this->setLayout( mAuthNotifyLayout );
43 mAuthNotifyLayout->addWidget( mAuthNotify );
48 connect( buttonBox, &QDialogButtonBox::rejected,
this, &QDialog::reject );
55void QgsAuthMethodPlugins::setupTable()
57 tblAuthPlugins->setColumnCount( 3 );
58 tblAuthPlugins->verticalHeader()->hide();
59 tblAuthPlugins->horizontalHeader()->setVisible(
true );
60 tblAuthPlugins->setHorizontalHeaderItem( 0,
new QTableWidgetItem( tr(
"Method" ) ) );
61 tblAuthPlugins->setHorizontalHeaderItem( 1,
new QTableWidgetItem( tr(
"Description" ) ) );
62 tblAuthPlugins->setHorizontalHeaderItem( 2,
new QTableWidgetItem( tr(
"Works with" ) ) );
63 tblAuthPlugins->horizontalHeader()->setStretchLastSection(
true );
64 tblAuthPlugins->setAlternatingRowColors(
true );
65 tblAuthPlugins->setColumnWidth( 0, 150 );
66 tblAuthPlugins->setColumnWidth( 1, 300 );
68 tblAuthPlugins->verticalHeader()->setSectionResizeMode( QHeaderView::ResizeToContents );
69 tblAuthPlugins->setSortingEnabled(
true );
70 tblAuthPlugins->setSelectionBehavior( QAbstractItemView::SelectRows );
73void QgsAuthMethodPlugins::populateTable()
78 const auto constAuthMethodKeys = authMethodKeys;
79 for (
const QString &authMethodKey : constAuthMethodKeys )
83 if ( !meta || !method )
85 QgsDebugError( QStringLiteral(
"Load auth method instance FAILED for auth method key (%1)" ).arg( authMethodKey ) );
89 QTableWidgetItem *twi =
new QTableWidgetItem( meta->
key() );
90 twi->setFlags( twi->flags() & ~Qt::ItemIsEditable );
91 tblAuthPlugins->setItem( i, 0, twi );
94 twi->setFlags( twi->flags() & ~Qt::ItemIsEditable );
95 tblAuthPlugins->setItem( i, 1, twi );
98 twi->setFlags( twi->flags() & ~Qt::ItemIsEditable );
99 tblAuthPlugins->setItem( i, 2, twi );
103 tblAuthPlugins->sortItems( 0 );
113 connect( btnCertManager, &QPushButton::clicked,
this, &QgsAuthEditorWidgets::btnCertManager_clicked );
114 connect( btnAuthPlugins, &QPushButton::clicked,
this, &QgsAuthEditorWidgets::btnAuthPlugins_clicked );
117 wdgtConfigEditor->setRelayMessages(
false );
118 wdgtConfigEditor->setShowUtilitiesButton(
false );
119 setupUtilitiesMenu();
123 grpbxManagers->setEnabled(
false );
127void QgsAuthEditorWidgets::btnCertManager_clicked()
130 dlg->setWindowModality( Qt::ApplicationModal );
131 dlg->resize( 750, 500 );
136void QgsAuthEditorWidgets::btnAuthPlugins_clicked()
139 dlg->setWindowModality( Qt::WindowModal );
140 dlg->resize( 675, 500 );
145void QgsAuthEditorWidgets::setupUtilitiesMenu()
148 this, &QgsAuthEditorWidgets::authMessageOut );
151 mActionImportAuthenticationConfigs =
new QAction( tr(
"Import authentication configurations from file" ),
this );
152 mActionExportSelectedAuthenticationConfigs =
new QAction( tr(
"Export selected authentication configurations to file" ),
this );
153 mActionSetMasterPassword =
new QAction( tr(
"Input master password" ),
this );
154 mActionClearCachedMasterPassword =
new QAction( tr(
"Clear cached master password" ),
this );
155 mActionResetMasterPassword =
new QAction( tr(
"Reset master password" ),
this );
156 mActionClearCachedAuthConfigs =
new QAction( tr(
"Clear cached authentication configurations" ),
this );
157 mActionRemoveAuthConfigs =
new QAction( tr(
"Remove all authentication configurations" ),
this );
158 mActionEraseAuthDatabase =
new QAction( tr(
"Erase authentication database" ),
this );
160 mActionClearAccessCacheNow =
new QAction( tr(
"Clear network authentication access cache" ),
this );
161 mActionAutoClearAccessCache =
new QAction( tr(
"Automatically clear network authentication access cache on SSL errors" ),
this );
162 mActionAutoClearAccessCache->setCheckable(
true );
165 mActionPasswordHelperSync =
new QAction( tr(
"Store/update the master password in your %1" )
167 mActionPasswordHelperDelete =
new QAction( tr(
"Clear the master password from your %1" )
169 mActionPasswordHelperEnable =
new QAction( tr(
"Integrate master password with your %1" )
171 mActionPasswordHelperLoggingEnable =
new QAction( tr(
"Enable password helper debug log" ),
this );
173 mActionPasswordHelperEnable->setCheckable(
true );
176 mActionPasswordHelperLoggingEnable->setCheckable(
true );
179 connect( mActionImportAuthenticationConfigs, &QAction::triggered,
this, &QgsAuthEditorWidgets::importAuthenticationConfigs );
180 connect( mActionExportSelectedAuthenticationConfigs, &QAction::triggered,
this, &QgsAuthEditorWidgets::exportSelectedAuthenticationConfigs );
181 connect( mActionSetMasterPassword, &QAction::triggered,
this, &QgsAuthEditorWidgets::setMasterPassword );
182 connect( mActionClearCachedMasterPassword, &QAction::triggered,
this, &QgsAuthEditorWidgets::clearCachedMasterPassword );
183 connect( mActionResetMasterPassword, &QAction::triggered,
this, &QgsAuthEditorWidgets::resetMasterPassword );
184 connect( mActionClearCachedAuthConfigs, &QAction::triggered,
this, &QgsAuthEditorWidgets::clearCachedAuthenticationConfigs );
185 connect( mActionRemoveAuthConfigs, &QAction::triggered,
this, &QgsAuthEditorWidgets::removeAuthenticationConfigs );
186 connect( mActionEraseAuthDatabase, &QAction::triggered,
this, &QgsAuthEditorWidgets::eraseAuthenticationDatabase );
188 connect( mActionPasswordHelperSync, &QAction::triggered,
this, &QgsAuthEditorWidgets::passwordHelperSync );
189 connect( mActionPasswordHelperDelete, &QAction::triggered,
this, &QgsAuthEditorWidgets::passwordHelperDelete );
190 connect( mActionPasswordHelperEnable, &QAction::triggered,
this, &QgsAuthEditorWidgets::passwordHelperEnableTriggered );
191 connect( mActionPasswordHelperLoggingEnable, &QAction::triggered,
this, &QgsAuthEditorWidgets::passwordHelperLoggingEnableTriggered );
193 connect( mActionClearAccessCacheNow, &QAction::triggered,
this, [ = ]
196 messageBar()->
pushSuccess( tr(
"Auth cache cleared" ), tr(
"Network authentication cache has been cleared" ) );
198 connect( mActionAutoClearAccessCache, &QAction::triggered,
this, [ ](
bool checked )
203 mAuthUtilitiesMenu =
new QMenu(
this );
204 mAuthUtilitiesMenu->addAction( mActionSetMasterPassword );
205 mAuthUtilitiesMenu->addAction( mActionClearCachedMasterPassword );
206 mAuthUtilitiesMenu->addAction( mActionResetMasterPassword );
207 mAuthUtilitiesMenu->addSeparator();
208 mAuthUtilitiesMenu->addAction( mActionClearAccessCacheNow );
209 mAuthUtilitiesMenu->addAction( mActionAutoClearAccessCache );
210 mAuthUtilitiesMenu->addSeparator();
211 mAuthUtilitiesMenu->addAction( mActionPasswordHelperEnable );
212 mAuthUtilitiesMenu->addAction( mActionPasswordHelperSync );
213 mAuthUtilitiesMenu->addAction( mActionPasswordHelperDelete );
214 mAuthUtilitiesMenu->addAction( mActionPasswordHelperLoggingEnable );
215 mAuthUtilitiesMenu->addSeparator();
216 mAuthUtilitiesMenu->addAction( mActionClearCachedAuthConfigs );
217 mAuthUtilitiesMenu->addAction( mActionRemoveAuthConfigs );
218 mAuthUtilitiesMenu->addSeparator();
219 mAuthUtilitiesMenu->addAction( mActionImportAuthenticationConfigs );
220 mAuthUtilitiesMenu->addAction( mActionExportSelectedAuthenticationConfigs );
221 mAuthUtilitiesMenu->addSeparator();
222 mAuthUtilitiesMenu->addAction( mActionEraseAuthDatabase );
224 btnAuthUtilities->setMenu( mAuthUtilitiesMenu );
227void QgsAuthEditorWidgets::importAuthenticationConfigs()
232void QgsAuthEditorWidgets::exportSelectedAuthenticationConfigs()
234 if ( !wdgtConfigEditor )
240void QgsAuthEditorWidgets::setMasterPassword()
245void QgsAuthEditorWidgets::clearCachedMasterPassword()
250void QgsAuthEditorWidgets::resetMasterPassword()
255void QgsAuthEditorWidgets::clearCachedAuthenticationConfigs()
260void QgsAuthEditorWidgets::removeAuthenticationConfigs()
265void QgsAuthEditorWidgets::eraseAuthenticationDatabase()
272 const int levelint =
static_cast<int>( level );
276void QgsAuthEditorWidgets::passwordHelperDelete()
281void QgsAuthEditorWidgets::passwordHelperSync()
286void QgsAuthEditorWidgets::passwordHelperEnableTriggered()
292void 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.
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.
static const QString AUTH_PASSWORD_HELPER_DISPLAY_NAME
The display name of the password helper (platform dependent)
const QgsAuthMethodMetadata * authMethodMetadata(const QString &authMethodKey)
Gets authentication method metadata via its key.
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.
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.
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.
This class is a composition of two QSettings instances:
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
#define QgsDebugError(str)