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 );
55 void 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 );
73 void QgsAuthMethodPlugins::populateTable()
78 const auto constAuthMethodKeys = authMethodKeys;
79 for (
const QString &authMethodKey : constAuthMethodKeys )
83 if ( !meta || !method )
85 QgsDebugMsg( 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 );
127 void QgsAuthEditorWidgets::btnCertManager_clicked()
130 dlg->setWindowModality( Qt::ApplicationModal );
131 dlg->resize( 750, 500 );
136 void QgsAuthEditorWidgets::btnAuthPlugins_clicked()
139 dlg->setWindowModality( Qt::WindowModal );
140 dlg->resize( 675, 500 );
145 void 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 );
163 mActionAutoClearAccessCache->setChecked(
QgsSettings().value( QStringLiteral(
"clear_auth_cache_on_errors" ),
true, QgsSettings::Section::Auth ).toBool( ) );
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 )
200 QgsSettings().
setValue( QStringLiteral(
"clear_auth_cache_on_errors" ), checked, QgsSettings::Section::Auth );
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 );
227 void QgsAuthEditorWidgets::importAuthenticationConfigs()
232 void QgsAuthEditorWidgets::exportSelectedAuthenticationConfigs()
234 if ( !wdgtConfigEditor )
240 void QgsAuthEditorWidgets::setMasterPassword()
245 void QgsAuthEditorWidgets::clearCachedMasterPassword()
250 void QgsAuthEditorWidgets::resetMasterPassword()
255 void QgsAuthEditorWidgets::clearCachedAuthenticationConfigs()
260 void QgsAuthEditorWidgets::removeAuthenticationConfigs()
265 void QgsAuthEditorWidgets::eraseAuthenticationDatabase()
272 const int levelint =
static_cast<int>( level );
276 void QgsAuthEditorWidgets::passwordHelperDelete()
281 void QgsAuthEditorWidgets::passwordHelperSync()
286 void QgsAuthEditorWidgets::passwordHelperEnableTriggered()
292 void QgsAuthEditorWidgets::passwordHelperLoggingEnableTriggered()