18 #include "ui_qgsauthmethodplugins.h" 23 #include <QTableWidget> 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( QStringLiteral(
", " ) ) );
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 mActionSetMasterPassword =
new QAction( tr(
"Input master password" ),
this );
146 mActionClearCachedMasterPassword =
new QAction( tr(
"Clear cached master password" ),
this );
147 mActionResetMasterPassword =
new QAction( tr(
"Reset master password" ),
this );
148 mActionClearCachedAuthConfigs =
new QAction( tr(
"Clear cached authentication configurations" ),
this );
149 mActionRemoveAuthConfigs =
new QAction( tr(
"Remove all authentication configurations" ),
this );
150 mActionEraseAuthDatabase =
new QAction( tr(
"Erase authentication database" ),
this );
152 mActionClearAccessCacheNow =
new QAction( tr(
"Clear network authentication access cache" ),
this );
153 mActionAutoClearAccessCache =
new QAction( tr(
"Automatically clear network authentication access cache on SSL errors" ),
this );
154 mActionAutoClearAccessCache->setCheckable(
true );
155 mActionAutoClearAccessCache->setChecked(
QgsSettings().value( QStringLiteral(
"clear_auth_cache_on_errors" ),
true, QgsSettings::Section::Auth ).toBool( ) );
157 mActionPasswordHelperSync =
new QAction( tr(
"Store/update the master password in your %1" )
159 mActionPasswordHelperDelete =
new QAction( tr(
"Clear the master password from your %1" )
161 mActionPasswordHelperEnable =
new QAction( tr(
"Integrate master password with your %1" )
163 mActionPasswordHelperLoggingEnable =
new QAction( tr(
"Enable password helper debug log" ),
this );
165 mActionPasswordHelperEnable->setCheckable(
true );
168 mActionPasswordHelperLoggingEnable->setCheckable(
true );
171 connect( mActionSetMasterPassword, &QAction::triggered,
this, &QgsAuthEditorWidgets::setMasterPassword );
172 connect( mActionClearCachedMasterPassword, &QAction::triggered,
this, &QgsAuthEditorWidgets::clearCachedMasterPassword );
173 connect( mActionResetMasterPassword, &QAction::triggered,
this, &QgsAuthEditorWidgets::resetMasterPassword );
174 connect( mActionClearCachedAuthConfigs, &QAction::triggered,
this, &QgsAuthEditorWidgets::clearCachedAuthenticationConfigs );
175 connect( mActionRemoveAuthConfigs, &QAction::triggered,
this, &QgsAuthEditorWidgets::removeAuthenticationConfigs );
176 connect( mActionEraseAuthDatabase, &QAction::triggered,
this, &QgsAuthEditorWidgets::eraseAuthenticationDatabase );
178 connect( mActionPasswordHelperSync, &QAction::triggered,
this, &QgsAuthEditorWidgets::passwordHelperSync );
179 connect( mActionPasswordHelperDelete, &QAction::triggered,
this, &QgsAuthEditorWidgets::passwordHelperDelete );
180 connect( mActionPasswordHelperEnable, &QAction::triggered,
this, &QgsAuthEditorWidgets::passwordHelperEnableTriggered );
181 connect( mActionPasswordHelperLoggingEnable, &QAction::triggered,
this, &QgsAuthEditorWidgets::passwordHelperLoggingEnableTriggered );
183 connect( mActionClearAccessCacheNow, &QAction::triggered,
this, [ = ]
186 messageBar()->
pushSuccess( tr(
"Auth cache cleared" ), tr(
"Network authentication cache has been cleared" ) );
188 connect( mActionAutoClearAccessCache, &QAction::triggered,
this, [ ](
bool checked )
190 QgsSettings().
setValue( QStringLiteral(
"clear_auth_cache_on_errors" ), checked, QgsSettings::Section::Auth );
193 mAuthUtilitiesMenu =
new QMenu(
this );
194 mAuthUtilitiesMenu->addAction( mActionSetMasterPassword );
195 mAuthUtilitiesMenu->addAction( mActionClearCachedMasterPassword );
196 mAuthUtilitiesMenu->addAction( mActionResetMasterPassword );
197 mAuthUtilitiesMenu->addSeparator();
198 mAuthUtilitiesMenu->addAction( mActionClearAccessCacheNow );
199 mAuthUtilitiesMenu->addAction( mActionAutoClearAccessCache );
200 mAuthUtilitiesMenu->addSeparator();
201 mAuthUtilitiesMenu->addAction( mActionPasswordHelperEnable );
202 mAuthUtilitiesMenu->addAction( mActionPasswordHelperSync );
203 mAuthUtilitiesMenu->addAction( mActionPasswordHelperDelete );
204 mAuthUtilitiesMenu->addAction( mActionPasswordHelperLoggingEnable );
205 mAuthUtilitiesMenu->addSeparator();
206 mAuthUtilitiesMenu->addAction( mActionClearCachedAuthConfigs );
207 mAuthUtilitiesMenu->addAction( mActionRemoveAuthConfigs );
208 mAuthUtilitiesMenu->addSeparator();
209 mAuthUtilitiesMenu->addAction( mActionEraseAuthDatabase );
211 btnAuthUtilities->setMenu( mAuthUtilitiesMenu );
214 void QgsAuthEditorWidgets::setMasterPassword()
219 void QgsAuthEditorWidgets::clearCachedMasterPassword()
224 void QgsAuthEditorWidgets::resetMasterPassword()
229 void QgsAuthEditorWidgets::clearCachedAuthenticationConfigs()
234 void QgsAuthEditorWidgets::removeAuthenticationConfigs()
239 void QgsAuthEditorWidgets::eraseAuthenticationDatabase()
246 int levelint = ( int )level;
250 void QgsAuthEditorWidgets::passwordHelperDelete()
255 void QgsAuthEditorWidgets::passwordHelperSync()
260 void QgsAuthEditorWidgets::passwordHelperEnableTriggered()
266 void QgsAuthEditorWidgets::passwordHelperLoggingEnableTriggered()
276 int QgsAuthEditorWidgets::messageTimeout()
279 return settings.
value( QStringLiteral(
"qgis/messageTimeout" ), 5 ).toInt();
static void resetMasterPassword(QgsMessageBar *msgbar, int timeout=0, QWidget *parent=nullptr)
Reset the cached master password, updating its hash in authentication database and resetting all exis...
static void eraseAuthenticationDatabase(QgsMessageBar *msgbar, int timeout=0, QWidget *parent=nullptr)
Completely clear out the authentication database (configs and master password)
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.
Dialog for viewing available authentication method plugins.
This class is a composition of two QSettings instances:
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
static void clearCachedMasterPassword(QgsMessageBar *msgbar, int timeout=0)
Clear the currently cached master password (not its hash in database)
static void removeAuthenticationConfigs(QgsMessageBar *msgbar, int timeout=0, QWidget *parent=nullptr)
Remove all authentication configs.
A bar for displaying non-blocking messages to the user.
static void setMasterPassword(QgsMessageBar *msgbar, int timeout=0)
Sets the cached master password (and verifies it if its hash is in authentication database) ...
MessageLevel
Level for messages This will be used both for message log and message bar in application.
void pushSuccess(const QString &title, const QString &message)
Pushes a success message with default timeout to the message bar.
MessageLevel
Message log level (mirrors that of QgsMessageLog, so it can also output there)
static const QString AUTH_PASSWORD_HELPER_DISPLAY_NAME
The display name of the password helper (platform dependent)
static void passwordHelperLoggingEnable(bool enabled, QgsMessageBar *msgbar, int timeout=0)
Sets password helper logging enabled (enable/disable)
static void clearCachedAuthenticationConfigs(QgsMessageBar *msgbar, int timeout=0)
Clear all cached authentication configs for session.
Dialog wrapper for widget to manage available certificate editors.
QgsAuthMethodPlugins(QWidget *parent=nullptr)
Construct a dialog for viewing available authentication method plugins.
void pushMessage(const QString &text, Qgis::MessageLevel level=Qgis::Info, int duration=5)
convenience method for pushing a message to the bar
static void passwordHelperEnable(bool enabled, QgsMessageBar *msgbar, int timeout=0)
Sets password helper enabled (enable/disable)
static QgsAuthManager * authManager()
Returns the application's authentication manager instance.
static QgsNetworkAccessManager * instance(Qt::ConnectionType connectionType=Qt::BlockingQueuedConnection)
Returns a pointer to the active QgsNetworkAccessManager for the current thread.
static void passwordHelperSync(QgsMessageBar *msgbar, int timeout=0)
Store master password into the wallet.
Abstract base class for authentication method plugins.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
QHash< QString, QgsAuthMethod * > QgsAuthMethodsMap
static void passwordHelperDelete(QgsMessageBar *msgbar, int timeout=0, QWidget *parent=nullptr)
Remove master password from wallet.