Skip to content

Commit 6a7332f

Browse files
committedOct 6, 2015
[auth] Fix #13507; ensure auth widgets are disabled if auth system is
1 parent e933332 commit 6a7332f

31 files changed

+542
-163
lines changed
 

‎src/app/qgisapp.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,8 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
564564
QgsAuthManager::instance()->init( QgsApplication::pluginPath() );
565565
if ( QgsAuthManager::instance()->isDisabled() )
566566
{
567-
QMessageBox::warning( this, tr( "Authentication System" ),
567+
// Don't pass 'this' as parent, or menubar doesn't complete loading of submenus (at least on Mac)
568+
QMessageBox::warning( 0, tr( "Authentication System" ),
568569
QgsAuthManager::instance()->disabledMessage() + "\n\n" +
569570
tr( "Resources authenticating via the system can not be accessed." ) );
570571
}

‎src/core/qgsnetworkaccessmanager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ QNetworkReply *QgsNetworkAccessManager::createRequest( QNetworkAccessManager::Op
172172
#ifndef QT_NO_OPENSSL
173173
bool ishttps = pReq->url().scheme().toLower() == "https";
174174
QgsAuthConfigSslServer servconfig;
175-
if ( ishttps )
175+
if ( ishttps && !QgsAuthManager::instance()->isDisabled() )
176176
{
177177
// check for SSL cert custom config
178178
QString hostport( QString( "%1:%2" )

‎src/gui/auth/qgsauthauthoritieseditor.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,13 @@ QgsAuthAuthoritiesEditor::QgsAuthAuthoritiesEditor( QWidget *parent )
4848
, mDbCaSecItem( 0 )
4949
, mDefaultTrustPolicy( QgsAuthCertUtils::DefaultTrust )
5050
, mUtilitiesMenu( 0 )
51+
, mDisabled( false )
5152
, mActionDefaultTrustPolicy( 0 )
5253
, mActionShowTrustedCAs( 0 )
5354
{
5455
if ( QgsAuthManager::instance()->isDisabled() )
5556
{
57+
mDisabled = true;
5658
mAuthNotifyLayout = new QVBoxLayout;
5759
this->setLayout( mAuthNotifyLayout );
5860
mAuthNotify = new QLabel( QgsAuthManager::instance()->disabledMessage(), this );
@@ -775,7 +777,10 @@ void QgsAuthAuthoritiesEditor::authMessageOut( const QString& message, const QSt
775777

776778
void QgsAuthAuthoritiesEditor::showEvent( QShowEvent * e )
777779
{
778-
treeWidgetCAs->setFocus();
780+
if ( !mDisabled )
781+
{
782+
treeWidgetCAs->setFocus();
783+
}
779784
QWidget::showEvent( e );
780785
}
781786

‎src/gui/auth/qgsauthauthoritieseditor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ class GUI_EXPORT QgsAuthAuthoritiesEditor : public QWidget, private Ui::QgsAuthA
129129
QMap<QgsAuthCertUtils::CertTrustPolicy, QStringList > mCertTrustCache;
130130

131131
QMenu * mUtilitiesMenu;
132+
bool mDisabled;
132133
QAction * mActionDefaultTrustPolicy;
133134
QAction * mActionShowTrustedCAs;
134135
};

‎src/gui/auth/qgsauthcertificateinfo.cpp

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -64,37 +64,49 @@ QgsAuthCertInfo::QgsAuthCertInfo( QSslCertificate cert,
6464
, mGrpCert( 0 )
6565
, mGrpPkey( 0 )
6666
, mGrpExts( 0 )
67+
, mAuthNotifyLayout( 0 )
68+
, mAuthNotify( 0 )
6769
{
68-
setupUi( this );
70+
if ( QgsAuthManager::instance()->isDisabled() )
71+
{
72+
mAuthNotifyLayout = new QVBoxLayout;
73+
this->setLayout( mAuthNotifyLayout );
74+
mAuthNotify = new QLabel( QgsAuthManager::instance()->disabledMessage(), this );
75+
mAuthNotifyLayout->addWidget( mAuthNotify );
76+
}
77+
else
78+
{
79+
setupUi( this );
6980

70-
lblError->setHidden( true );
81+
lblError->setHidden( true );
7182

72-
treeHierarchy->setRootIsDecorated( false );
83+
treeHierarchy->setRootIsDecorated( false );
7384

74-
connect( treeHierarchy, SIGNAL( currentItemChanged( QTreeWidgetItem *, QTreeWidgetItem * ) ),
75-
this, SLOT( currentCertItemChanged( QTreeWidgetItem*, QTreeWidgetItem* ) ) );
85+
connect( treeHierarchy, SIGNAL( currentItemChanged( QTreeWidgetItem *, QTreeWidgetItem * ) ),
86+
this, SLOT( currentCertItemChanged( QTreeWidgetItem*, QTreeWidgetItem* ) ) );
7687

77-
mCaCertsCache = QgsAuthManager::instance()->getCaCertsCache();
88+
mCaCertsCache = QgsAuthManager::instance()->getCaCertsCache();
7889

79-
setUpCertDetailsTree();
90+
setUpCertDetailsTree();
8091

81-
grpbxTrust->setVisible( mManageTrust );
92+
grpbxTrust->setVisible( mManageTrust );
8293

83-
// trust policy is still queried, even if not managing the policy, so public getter will work
84-
mDefaultTrustPolicy = QgsAuthManager::instance()->defaultCertTrustPolicy();
85-
mCurrentTrustPolicy = QgsAuthCertUtils::DefaultTrust;
94+
// trust policy is still queried, even if not managing the policy, so public getter will work
95+
mDefaultTrustPolicy = QgsAuthManager::instance()->defaultCertTrustPolicy();
96+
mCurrentTrustPolicy = QgsAuthCertUtils::DefaultTrust;
8697

87-
bool res;
88-
res = populateQcaCertCollection();
89-
if ( res )
90-
res = setQcaCertificate( cert );
91-
if ( res )
92-
res = populateCertChain();
93-
if ( res )
94-
setCertHierarchy();
98+
bool res;
99+
res = populateQcaCertCollection();
100+
if ( res )
101+
res = setQcaCertificate( cert );
102+
if ( res )
103+
res = populateCertChain();
104+
if ( res )
105+
setCertHierarchy();
95106

96-
connect( cmbbxTrust, SIGNAL( currentIndexChanged( int ) ),
97-
this, SLOT( currentPolicyIndexChanged( int ) ) );
107+
connect( cmbbxTrust, SIGNAL( currentIndexChanged( int ) ),
108+
this, SLOT( currentPolicyIndexChanged( int ) ) );
109+
}
98110
}
99111

100112
QgsAuthCertInfo::~QgsAuthCertInfo()

‎src/gui/auth/qgsauthcertificateinfo.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ class GUI_EXPORT QgsAuthCertInfo : public QWidget, private Ui::QgsAuthCertInfo
126126
QTreeWidgetItem *mGrpPkey;
127127
QTreeWidgetItem *mGrpExts;
128128

129+
QVBoxLayout *mAuthNotifyLayout;
130+
QLabel *mAuthNotify;
129131
};
130132

131133
//////////////// Embed in dialog ///////////////////

‎src/gui/auth/qgsauthcerttrustpolicycombobox.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,14 @@ const QString QgsAuthCertTrustPolicyComboBox::defaultTrustText( QgsAuthCertUtils
113113
{
114114
if ( defaultpolicy == QgsAuthCertUtils::DefaultTrust )
115115
{
116-
defaultpolicy = QgsAuthManager::instance()->defaultCertTrustPolicy();
116+
if ( !QgsAuthManager::instance()->isDisabled() )
117+
{
118+
defaultpolicy = QgsAuthManager::instance()->defaultCertTrustPolicy();
119+
}
120+
else
121+
{
122+
defaultpolicy = QgsAuthCertUtils::Trusted;
123+
}
117124
}
118125
return QString( "%1 (%2)" )
119126
.arg( QgsAuthCertUtils::getCertTrustName( QgsAuthCertUtils::DefaultTrust ) )

‎src/gui/auth/qgsauthconfigeditor.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,13 @@ QgsAuthConfigEditor::QgsAuthConfigEditor( QWidget *parent, bool showUtilities, b
3737
, mActionClearCachedAuthConfigs( 0 )
3838
, mActionRemoveAuthConfigs( 0 )
3939
, mActionEraseAuthDatabase( 0 )
40+
, mDisabled( false )
4041
, mAuthNotifyLayout( 0 )
4142
, mAuthNotify( 0 )
4243
{
4344
if ( QgsAuthManager::instance()->isDisabled() )
4445
{
46+
mDisabled = true;
4547
mAuthNotifyLayout = new QVBoxLayout;
4648
this->setLayout( mAuthNotifyLayout );
4749
mAuthNotify = new QLabel( QgsAuthManager::instance()->disabledMessage(), this );
@@ -166,19 +168,26 @@ void QgsAuthConfigEditor::authMessageOut( const QString& message, const QString&
166168

167169
void QgsAuthConfigEditor::toggleTitleVisibility( bool visible )
168170
{
169-
if ( !QgsAuthManager::instance()->isDisabled() )
171+
if ( !mDisabled )
170172
{
171173
lblAuthConfigDb->setVisible( visible );
172174
}
173175
}
174176

175177
void QgsAuthConfigEditor::setShowUtilitiesButton( bool show )
176178
{
177-
btnAuthUtilities->setVisible( show );
179+
if ( !mDisabled )
180+
{
181+
btnAuthUtilities->setVisible( show );
182+
}
178183
}
179184

180185
void QgsAuthConfigEditor::setRelayMessages( bool relay )
181186
{
187+
if ( mDisabled )
188+
{
189+
return;
190+
}
182191
if ( relay == mRelayMessages )
183192
{
184193
return;

‎src/gui/auth/qgsauthconfigeditor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ class GUI_EXPORT QgsAuthConfigEditor : public QWidget, private Ui::QgsAuthConfig
105105
QAction *mActionRemoveAuthConfigs;
106106
QAction *mActionEraseAuthDatabase;
107107

108+
bool mDisabled;
108109
QVBoxLayout *mAuthNotifyLayout;
109110
QLabel *mAuthNotify;
110111
};

‎src/gui/auth/qgsauthconfigidedit.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ bool QgsAuthConfigIdEdit::validate()
5656
bool curvalid = (( authcfg == mAuthCfgOrig && authcfg.size() == 7 )
5757
|| ( mAllowEmpty && authcfg.size() == 0 ) );
5858

59-
if ( !curvalid && authcfg.size() == 7 && isAlphaNumeric( authcfg ) )
59+
if ( !QgsAuthManager::instance()->isDisabled() && !curvalid && authcfg.size() == 7 && isAlphaNumeric( authcfg ) )
6060
{
6161
curvalid = QgsAuthManager::instance()->configIdUnique( authcfg );
6262
}

‎src/gui/auth/qgsauthconfigselect.cpp

Lines changed: 52 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,13 @@ QgsAuthConfigSelect::QgsAuthConfigSelect( QWidget *parent, const QString &datapr
3333
, mAuthCfg( QString() )
3434
, mDataProvider( dataprovider )
3535
, mConfigs( QgsAuthMethodConfigsMap() )
36+
, mDisabled( false )
3637
, mAuthNotifyLayout( 0 )
3738
, mAuthNotify( 0 )
3839
{
3940
if ( QgsAuthManager::instance()->isDisabled() )
4041
{
42+
mDisabled = true;
4143
mAuthNotifyLayout = new QVBoxLayout;
4244
this->setLayout( mAuthNotifyLayout );
4345
mAuthNotify = new QLabel( QgsAuthManager::instance()->disabledMessage(), this );
@@ -62,7 +64,7 @@ QgsAuthConfigSelect::~QgsAuthConfigSelect()
6264

6365
void QgsAuthConfigSelect::setConfigId( const QString& authcfg )
6466
{
65-
if ( QgsAuthManager::instance()->isDisabled() && mAuthNotify )
67+
if ( mDisabled && mAuthNotify )
6668
{
6769
mAuthNotify->setText( QgsAuthManager::instance()->disabledMessage() + "\n\n" +
6870
tr( "Authentication config id not loaded: %1" ).arg( authcfg ) );
@@ -80,6 +82,11 @@ void QgsAuthConfigSelect::setConfigId( const QString& authcfg )
8082

8183
void QgsAuthConfigSelect::setDataProviderKey( const QString &key )
8284
{
85+
if ( mDisabled )
86+
{
87+
return;
88+
}
89+
8390
mDataProvider = key;
8491
populateConfigSelector();
8592
}
@@ -156,12 +163,20 @@ void QgsAuthConfigSelect::populateConfigSelector()
156163

157164
void QgsAuthConfigSelect::showMessage( const QString &msg )
158165
{
166+
if ( mDisabled )
167+
{
168+
return;
169+
}
159170
leConfigMsg->setText( msg );
160171
frConfigMsg->setVisible( true );
161172
}
162173

163174
void QgsAuthConfigSelect::clearMessage()
164175
{
176+
if ( mDisabled )
177+
{
178+
return;
179+
}
165180
leConfigMsg->clear();
166181
frConfigMsg->setVisible( false );
167182
}
@@ -241,22 +256,36 @@ QgsAuthConfigUriEdit::QgsAuthConfigUriEdit( QWidget *parent, const QString &data
241256
, mAuthCfg( QString() )
242257
, mDataUri( QString() )
243258
, mDataUriOrig( QString() )
259+
, mDisabled( false )
260+
, mAuthNotifyLayout( 0 )
261+
, mAuthNotify( 0 )
244262
{
245-
setupUi( this );
263+
if ( QgsAuthManager::instance()->isDisabled() )
264+
{
265+
mDisabled = true;
266+
mAuthNotifyLayout = new QVBoxLayout;
267+
this->setLayout( mAuthNotifyLayout );
268+
mAuthNotify = new QLabel( QgsAuthManager::instance()->disabledMessage(), this );
269+
mAuthNotifyLayout->addWidget( mAuthNotify );
270+
}
271+
else
272+
{
273+
setupUi( this );
246274

247-
setWindowTitle( tr( "Authentication Config ID String Editor" ) );
275+
setWindowTitle( tr( "Authentication Config ID String Editor" ) );
248276

249-
buttonBox->button( QDialogButtonBox::Close )->setDefault( true );
250-
connect( buttonBox, SIGNAL( rejected() ), this, SLOT( close() ) );
251-
connect( buttonBox, SIGNAL( accepted() ), this, SLOT( saveChanges() ) );
277+
buttonBox->button( QDialogButtonBox::Close )->setDefault( true );
278+
connect( buttonBox, SIGNAL( rejected() ), this, SLOT( close() ) );
279+
connect( buttonBox, SIGNAL( accepted() ), this, SLOT( saveChanges() ) );
252280

253-
connect( buttonBox->button( QDialogButtonBox::Reset ), SIGNAL( clicked() ), this, SLOT( resetChanges() ) );
281+
connect( buttonBox->button( QDialogButtonBox::Reset ), SIGNAL( clicked() ), this, SLOT( resetChanges() ) );
254282

255-
connect( wdgtAuthSelect, SIGNAL( selectedConfigIdChanged( QString ) ), this , SLOT( authCfgUpdated( QString ) ) );
256-
connect( wdgtAuthSelect, SIGNAL( selectedConfigIdRemoved( QString ) ), this , SLOT( authCfgRemoved( QString ) ) );
283+
connect( wdgtAuthSelect, SIGNAL( selectedConfigIdChanged( QString ) ), this , SLOT( authCfgUpdated( QString ) ) );
284+
connect( wdgtAuthSelect, SIGNAL( selectedConfigIdRemoved( QString ) ), this , SLOT( authCfgRemoved( QString ) ) );
257285

258-
wdgtAuthSelect->setDataProviderKey( dataprovider );
259-
setDataSourceUri( datauri );
286+
wdgtAuthSelect->setDataProviderKey( dataprovider );
287+
setDataSourceUri( datauri );
288+
}
260289
}
261290

262291
QgsAuthConfigUriEdit::~QgsAuthConfigUriEdit()
@@ -265,6 +294,10 @@ QgsAuthConfigUriEdit::~QgsAuthConfigUriEdit()
265294

266295
void QgsAuthConfigUriEdit::setDataSourceUri( const QString &datauri )
267296
{
297+
if ( mDisabled )
298+
{
299+
return;
300+
}
268301
if ( datauri.isEmpty() )
269302
return;
270303

@@ -291,11 +324,19 @@ void QgsAuthConfigUriEdit::setDataSourceUri( const QString &datauri )
291324

292325
QString QgsAuthConfigUriEdit::dataSourceUri()
293326
{
327+
if ( mDisabled )
328+
{
329+
return QString();
330+
}
294331
return mDataUri;
295332
}
296333

297334
bool QgsAuthConfigUriEdit::hasConfigID( const QString &txt )
298335
{
336+
if ( QgsAuthManager::instance()->isDisabled() )
337+
{
338+
return false;
339+
}
299340
return QgsAuthManager::instance()->hasConfigId( txt );
300341
}
301342

‎src/gui/auth/qgsauthconfigselect.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ class GUI_EXPORT QgsAuthConfigSelect : public QWidget, private Ui::QgsAuthConfig
8686
QString mDataProvider;
8787
QgsAuthMethodConfigsMap mConfigs;
8888

89+
bool mDisabled;
8990
QVBoxLayout *mAuthNotifyLayout;
9091
QLabel *mAuthNotify;
9192
};
@@ -122,7 +123,7 @@ class GUI_EXPORT QgsAuthConfigUriEdit : public QDialog, private Ui::QgsAuthConfi
122123
/** The returned, possibly edited data source URI */
123124
QString dataSourceUri();
124125

125-
/** Whether a string conatins an authcfg ID */
126+
/** Whether a string contains an authcfg ID */
126127
static bool hasConfigID( const QString &txt );
127128

128129
private slots:
@@ -148,6 +149,10 @@ class GUI_EXPORT QgsAuthConfigUriEdit : public QDialog, private Ui::QgsAuthConfi
148149
QString mAuthCfg;
149150
QString mDataUri;
150151
QString mDataUriOrig;
152+
153+
bool mDisabled;
154+
QVBoxLayout *mAuthNotifyLayout;
155+
QLabel *mAuthNotify;
151156
};
152157

153158
#endif // QGSAUTHCONFIGSELECT_H

‎src/gui/auth/qgsautheditorwidgets.cpp

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,24 @@
3030

3131
QgsAuthMethodPlugins::QgsAuthMethodPlugins( QWidget *parent )
3232
: QDialog( parent )
33+
, mAuthNotifyLayout( 0 )
34+
, mAuthNotify( 0 )
3335
{
34-
setupUi( this );
35-
connect( buttonBox, SIGNAL( rejected() ), this, SLOT( reject() ) );
36+
if ( QgsAuthManager::instance()->isDisabled() )
37+
{
38+
mAuthNotifyLayout = new QVBoxLayout;
39+
this->setLayout( mAuthNotifyLayout );
40+
mAuthNotify = new QLabel( QgsAuthManager::instance()->disabledMessage(), this );
41+
mAuthNotifyLayout->addWidget( mAuthNotify );
42+
}
43+
else
44+
{
45+
setupUi( this );
46+
connect( buttonBox, SIGNAL( rejected() ), this, SLOT( reject() ) );
3647

37-
setupTable();
38-
populateTable();
48+
setupTable();
49+
populateTable();
50+
}
3951
}
4052

4153
QgsAuthMethodPlugins::~QgsAuthMethodPlugins()
@@ -94,9 +106,16 @@ QgsAuthEditorWidgets::QgsAuthEditorWidgets( QWidget *parent )
94106
: QWidget( parent )
95107
{
96108
setupUi( this );
97-
wdgtConfigEditor->setRelayMessages( false );
98-
wdgtConfigEditor->setShowUtilitiesButton( false );
99-
setupUtilitiesMenu();
109+
if ( !QgsAuthManager::instance()->isDisabled() )
110+
{
111+
wdgtConfigEditor->setRelayMessages( false );
112+
wdgtConfigEditor->setShowUtilitiesButton( false );
113+
setupUtilitiesMenu();
114+
}
115+
else
116+
{
117+
grpbxManagers->setEnabled( false );
118+
}
100119
}
101120

102121
QgsAuthEditorWidgets::~QgsAuthEditorWidgets()

‎src/gui/auth/qgsautheditorwidgets.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ class GUI_EXPORT QgsAuthMethodPlugins : public QDialog, private Ui::QgsAuthMetho
4242

4343
private:
4444
void setupTable();
45+
46+
QVBoxLayout *mAuthNotifyLayout;
47+
QLabel *mAuthNotify;
4548
};
4649

4750

‎src/gui/auth/qgsauthidentitieseditor.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@
3232

3333
QgsAuthIdentitiesEditor::QgsAuthIdentitiesEditor( QWidget *parent )
3434
: QWidget( parent )
35+
, mDisabled( false )
3536
, mAuthNotifyLayout( 0 )
3637
, mAuthNotify( 0 )
3738
, mRootCertIdentItem( 0 )
3839
{
3940
if ( QgsAuthManager::instance()->isDisabled() )
4041
{
42+
mDisabled = true;
4143
mAuthNotifyLayout = new QVBoxLayout;
4244
this->setLayout( mAuthNotifyLayout );
4345
mAuthNotify = new QLabel( QgsAuthManager::instance()->disabledMessage(), this );
@@ -389,7 +391,10 @@ void QgsAuthIdentitiesEditor::authMessageOut( const QString& message, const QStr
389391

390392
void QgsAuthIdentitiesEditor::showEvent( QShowEvent * e )
391393
{
392-
treeIdentities->setFocus();
394+
if ( !mDisabled )
395+
{
396+
treeIdentities->setFocus();
397+
}
393398
QWidget::showEvent( e );
394399
}
395400

‎src/gui/auth/qgsauthidentitieseditor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ class GUI_EXPORT QgsAuthIdentitiesEditor : public QWidget, private Ui::QgsAuthId
9494
QgsMessageBar * messageBar();
9595
int messageTimeout();
9696

97+
bool mDisabled;
9798
QVBoxLayout *mAuthNotifyLayout;
9899
QLabel *mAuthNotify;
99100

‎src/gui/auth/qgsauthimportcertdialog.cpp

Lines changed: 65 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -35,48 +35,75 @@ QgsAuthImportCertDialog::QgsAuthImportCertDialog( QWidget *parent ,
3535
: QDialog( parent )
3636
, mFilter( filter )
3737
, mInput( input )
38+
, mDisabled( false )
39+
, mAuthNotifyLayout( 0 )
40+
, mAuthNotify( 0 )
3841
{
39-
setupUi( this );
42+
if ( QgsAuthManager::instance()->isDisabled() )
43+
{
44+
mDisabled = true;
45+
mAuthNotifyLayout = new QVBoxLayout;
46+
this->setLayout( mAuthNotifyLayout );
47+
mAuthNotify = new QLabel( QgsAuthManager::instance()->disabledMessage(), this );
48+
mAuthNotifyLayout->addWidget( mAuthNotify );
49+
}
50+
else
51+
{
52+
setupUi( this );
4053

41-
connect( buttonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
42-
connect( buttonBox, SIGNAL( rejected() ), this, SLOT( reject() ) );
54+
connect( buttonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
55+
connect( buttonBox, SIGNAL( rejected() ), this, SLOT( reject() ) );
4356

44-
connect( teCertText, SIGNAL( textChanged() ), this, SLOT( validateCertificates() ) );
57+
connect( teCertText, SIGNAL( textChanged() ), this, SLOT( validateCertificates() ) );
4558

46-
connect( radioImportFile, SIGNAL( toggled( bool ) ), this, SLOT( updateGui() ) );
47-
connect( radioImportText, SIGNAL( toggled( bool ) ), this, SLOT( updateGui() ) );
59+
connect( radioImportFile, SIGNAL( toggled( bool ) ), this, SLOT( updateGui() ) );
60+
connect( radioImportText, SIGNAL( toggled( bool ) ), this, SLOT( updateGui() ) );
4861

49-
// hide unused widgets
50-
if ( mInput == FileInput )
51-
{
52-
radioImportText->setHidden( true );
53-
teCertText->setHidden( true );
54-
}
55-
else if ( mInput == TextInput )
56-
{
57-
radioImportFile->setHidden( true );
58-
frameImportFile->setHidden( true );
59-
}
62+
// hide unused widgets
63+
if ( mInput == FileInput )
64+
{
65+
radioImportText->setHidden( true );
66+
teCertText->setHidden( true );
67+
}
68+
else if ( mInput == TextInput )
69+
{
70+
radioImportFile->setHidden( true );
71+
frameImportFile->setHidden( true );
72+
}
6073

61-
radioImportFile->setChecked( true );
62-
updateGui();
74+
radioImportFile->setChecked( true );
75+
updateGui();
6376

64-
if ( mFilter == CaFilter )
65-
{
66-
grpbxImportCert->setTitle( tr( "Import Certificate Authorities" ) );
67-
}
77+
if ( mFilter == CaFilter )
78+
{
79+
grpbxImportCert->setTitle( tr( "Import Certificate Authorities" ) );
80+
}
6881

69-
okButton()->setText( tr( "Import" ) );
70-
okButton()->setEnabled( false );
71-
teValidation->setFocus();
82+
okButton()->setText( tr( "Import" ) );
83+
okButton()->setEnabled( false );
84+
teValidation->setFocus();
85+
}
7286
}
7387

7488
QgsAuthImportCertDialog::~QgsAuthImportCertDialog()
7589
{
7690
}
7791

92+
const QList<QSslCertificate> QgsAuthImportCertDialog::certificatesToImport()
93+
{
94+
if ( mDisabled )
95+
{
96+
return QList<QSslCertificate>();
97+
}
98+
return mCerts;
99+
}
100+
78101
const QString QgsAuthImportCertDialog::certFileToImport()
79102
{
103+
if ( mDisabled )
104+
{
105+
return QString();
106+
}
80107
if ( !radioImportFile->isChecked() )
81108
return QString();
82109

@@ -85,6 +112,10 @@ const QString QgsAuthImportCertDialog::certFileToImport()
85112

86113
const QString QgsAuthImportCertDialog::certTextToImport()
87114
{
115+
if ( mDisabled )
116+
{
117+
return QString();
118+
}
88119
if ( !radioImportText->isChecked() )
89120
return QString();
90121

@@ -93,11 +124,19 @@ const QString QgsAuthImportCertDialog::certTextToImport()
93124

94125
bool QgsAuthImportCertDialog::allowInvalidCerts()
95126
{
127+
if ( mDisabled )
128+
{
129+
return false;
130+
}
96131
return chkAllowInvalid->isChecked();
97132
}
98133

99134
QgsAuthCertUtils::CertTrustPolicy QgsAuthImportCertDialog::certTrustPolicy()
100135
{
136+
if ( mDisabled )
137+
{
138+
return QgsAuthCertUtils::DefaultTrust;
139+
}
101140
return cmbbxTrust->trustPolicy();
102141
}
103142

‎src/gui/auth/qgsauthimportcertdialog.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class GUI_EXPORT QgsAuthImportCertDialog : public QDialog, private Ui::QgsAuthIm
6060
~QgsAuthImportCertDialog();
6161

6262
/** Get list of certificate objects to import */
63-
const QList<QSslCertificate> certificatesToImport() { return mCerts; }
63+
const QList<QSslCertificate> certificatesToImport();
6464

6565
/** Get the file path to a certificate to import */
6666
const QString certFileToImport();
@@ -91,6 +91,10 @@ class GUI_EXPORT QgsAuthImportCertDialog : public QDialog, private Ui::QgsAuthIm
9191
QList<QSslCertificate> mCerts;
9292
QgsAuthImportCertDialog::CertFilter mFilter;
9393
QgsAuthImportCertDialog::CertInput mInput;
94+
95+
bool mDisabled;
96+
QVBoxLayout *mAuthNotifyLayout;
97+
QLabel *mAuthNotify;
9498
};
9599

96100
#endif // QGSAUTHIMPORTCERTDIALOG_H

‎src/gui/auth/qgsauthimportidentitydialog.cpp

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,52 @@ QgsAuthImportIdentityDialog::QgsAuthImportIdentityDialog( QgsAuthImportIdentityD
5353
QWidget *parent )
5454
: QDialog( parent )
5555
, mPkiBundle( QgsPkiBundle() )
56+
, mDisabled( false )
57+
, mAuthNotifyLayout( 0 )
58+
, mAuthNotify( 0 )
5659
{
57-
setupUi( this );
58-
connect( buttonBox, SIGNAL( rejected() ), this, SLOT( close() ) );
59-
connect( buttonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
60+
if ( QgsAuthManager::instance()->isDisabled() )
61+
{
62+
mDisabled = true;
63+
mAuthNotifyLayout = new QVBoxLayout;
64+
this->setLayout( mAuthNotifyLayout );
65+
mAuthNotify = new QLabel( QgsAuthManager::instance()->disabledMessage(), this );
66+
mAuthNotifyLayout->addWidget( mAuthNotify );
67+
}
68+
else
69+
{
70+
setupUi( this );
71+
connect( buttonBox, SIGNAL( rejected() ), this, SLOT( close() ) );
72+
connect( buttonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
6073

61-
mIdentityType = identitytype;
74+
mIdentityType = identitytype;
6275

63-
populateIdentityType();
76+
populateIdentityType();
77+
}
6478
}
6579

6680
QgsAuthImportIdentityDialog::~QgsAuthImportIdentityDialog()
6781
{
6882
}
6983

84+
QgsAuthImportIdentityDialog::IdentityType QgsAuthImportIdentityDialog::identityType()
85+
{
86+
if ( mDisabled )
87+
{
88+
return QgsAuthImportIdentityDialog::CertIdentity;
89+
}
90+
return mIdentityType;
91+
}
92+
93+
const QPair<QSslCertificate, QSslKey> QgsAuthImportIdentityDialog::certBundleToImport()
94+
{
95+
if ( mDisabled )
96+
{
97+
return qMakePair( QSslCertificate(), QSslKey() );
98+
}
99+
return mCertBundle;
100+
}
101+
70102
void QgsAuthImportIdentityDialog::populateIdentityType()
71103
{
72104
if ( mIdentityType == CertIdentity )

‎src/gui/auth/qgsauthimportidentitydialog.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ class GUI_EXPORT QgsAuthImportIdentityDialog : public QDialog, private Ui::QgsAu
6464
~QgsAuthImportIdentityDialog();
6565

6666
/** Get identity type */
67-
QgsAuthImportIdentityDialog::IdentityType identityType() { return mIdentityType; }
67+
QgsAuthImportIdentityDialog::IdentityType identityType();
6868

6969
/** Get certificate/key bundle to be imported */
70-
const QPair<QSslCertificate, QSslKey> certBundleToImport() { return mCertBundle; }
70+
const QPair<QSslCertificate, QSslKey> certBundleToImport();
7171

7272
/** Get certificate/key bundle to be imported as a PKI bundle object */
7373
const QgsPkiBundle pkiBundleToImport() { return mPkiBundle; }
@@ -110,6 +110,10 @@ class GUI_EXPORT QgsAuthImportIdentityDialog : public QDialog, private Ui::QgsAu
110110
QgsAuthImportIdentityDialog::IdentityType mIdentityType;
111111
QPair<QSslCertificate, QSslKey> mCertBundle;
112112
QgsPkiBundle mPkiBundle;
113+
114+
bool mDisabled;
115+
QVBoxLayout *mAuthNotifyLayout;
116+
QLabel *mAuthNotify;
113117
};
114118

115119
#endif // QGSAUTHIMPORTIDENTITYDIALOG_H

‎src/gui/auth/qgsauthserverseditor.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@
3030

3131
QgsAuthServersEditor::QgsAuthServersEditor( QWidget *parent )
3232
: QWidget( parent )
33+
, mDisabled( false )
3334
, mAuthNotifyLayout( 0 )
3435
, mAuthNotify( 0 )
3536
, mRootSslConfigItem( 0 )
3637
{
3738
if ( QgsAuthManager::instance()->isDisabled() )
3839
{
40+
mDisabled = true;
3941
mAuthNotifyLayout = new QVBoxLayout;
4042
this->setLayout( mAuthNotifyLayout );
4143
mAuthNotify = new QLabel( QgsAuthManager::instance()->disabledMessage(), this );
@@ -404,7 +406,10 @@ void QgsAuthServersEditor::authMessageOut( const QString& message, const QString
404406

405407
void QgsAuthServersEditor::showEvent( QShowEvent *e )
406408
{
407-
treeServerConfigs->setFocus();
409+
if ( !mDisabled )
410+
{
411+
treeServerConfigs->setFocus();
412+
}
408413
QWidget::showEvent( e );
409414
}
410415

‎src/gui/auth/qgsauthserverseditor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class GUI_EXPORT QgsAuthServersEditor : public QWidget, private Ui::QgsAuthServe
9292
QgsMessageBar * messageBar();
9393
int messageTimeout();
9494

95+
bool mDisabled;
9596
QVBoxLayout *mAuthNotifyLayout;
9697
QLabel *mAuthNotify;
9798

‎src/gui/auth/qgsauthsslconfigwidget.cpp

Lines changed: 150 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,31 +53,63 @@ QgsAuthSslConfigWidget::QgsAuthSslConfigWidget( QWidget *parent,
5353
, mVerifyDepthItem( 0 )
5454
, mVerifyDepthSpnBx( 0 )
5555
, mCanSave( false )
56+
, mDisabled( false )
57+
, mAuthNotifyLayout( 0 )
58+
, mAuthNotify( 0 )
5659
{
57-
setupUi( this );
60+
if ( QgsAuthManager::instance()->isDisabled() )
61+
{
62+
mDisabled = true;
63+
mAuthNotifyLayout = new QVBoxLayout;
64+
this->setLayout( mAuthNotifyLayout );
65+
mAuthNotify = new QLabel( QgsAuthManager::instance()->disabledMessage(), this );
66+
mAuthNotifyLayout->addWidget( mAuthNotify );
67+
}
68+
else
69+
{
70+
setupUi( this );
5871

59-
connect( grpbxSslConfig, SIGNAL( toggled( bool ) ), this, SIGNAL( configEnabledChanged( bool ) ) );
60-
connect( this, SIGNAL( configEnabledChanged( bool ) ), this, SLOT( readyToSave() ) );
61-
connect( this, SIGNAL( hostPortValidityChanged( bool ) ), this, SLOT( readyToSave() ) );
72+
connect( grpbxSslConfig, SIGNAL( toggled( bool ) ), this, SIGNAL( configEnabledChanged( bool ) ) );
73+
connect( this, SIGNAL( configEnabledChanged( bool ) ), this, SLOT( readyToSave() ) );
74+
connect( this, SIGNAL( hostPortValidityChanged( bool ) ), this, SLOT( readyToSave() ) );
6275

63-
setUpSslConfigTree();
76+
setUpSslConfigTree();
6477

65-
lblLoadedConfig->setVisible( false );
66-
lblLoadedConfig->setText( "" );
78+
lblLoadedConfig->setVisible( false );
79+
lblLoadedConfig->setText( "" );
6780

68-
connect( leHost, SIGNAL( textChanged( QString ) ),
69-
this, SLOT( validateHostPortText( QString ) ) );
81+
connect( leHost, SIGNAL( textChanged( QString ) ),
82+
this, SLOT( validateHostPortText( QString ) ) );
7083

71-
if ( !cert.isNull() )
72-
{
73-
setSslCertificate( cert, hostport );
84+
if ( !cert.isNull() )
85+
{
86+
setSslCertificate( cert, hostport );
87+
}
7488
}
7589
}
7690

7791
QgsAuthSslConfigWidget::~QgsAuthSslConfigWidget()
7892
{
7993
}
8094

95+
QGroupBox *QgsAuthSslConfigWidget::certificateGroupBox()
96+
{
97+
if ( mDisabled )
98+
{
99+
return 0;
100+
}
101+
return grpbxCert;
102+
}
103+
104+
QGroupBox *QgsAuthSslConfigWidget::sslConfigGroupBox()
105+
{
106+
if ( mDisabled )
107+
{
108+
return 0;
109+
}
110+
return grpbxSslConfig;
111+
}
112+
81113
// private
82114
QTreeWidgetItem* QgsAuthSslConfigWidget::addRootItem( const QString &label )
83115
{
@@ -171,6 +203,10 @@ void QgsAuthSslConfigWidget::setUpSslConfigTree()
171203
const QgsAuthConfigSslServer QgsAuthSslConfigWidget::sslCustomConfig()
172204
{
173205
QgsAuthConfigSslServer config;
206+
if ( mDisabled )
207+
{
208+
return config;
209+
}
174210
config.setSslCertificate( mCert );
175211
config.setSslHostPort( leHost->text() );
176212
config.setSslProtocol( sslProtocol() );
@@ -180,8 +216,30 @@ const QgsAuthConfigSslServer QgsAuthSslConfigWidget::sslCustomConfig()
180216
return config;
181217
}
182218

219+
const QSslCertificate QgsAuthSslConfigWidget::sslCertificate()
220+
{
221+
if ( mDisabled )
222+
{
223+
return QSslCertificate();
224+
}
225+
return mCert;
226+
}
227+
228+
const QString QgsAuthSslConfigWidget::sslHost()
229+
{
230+
if ( mDisabled )
231+
{
232+
return QString();
233+
}
234+
return leHost->text();
235+
}
236+
183237
void QgsAuthSslConfigWidget::enableSslCustomOptions( bool enable )
184238
{
239+
if ( mDisabled )
240+
{
241+
return;
242+
}
185243
if ( grpbxSslConfig->isCheckable() )
186244
{
187245
grpbxSslConfig->setChecked( enable );
@@ -190,6 +248,10 @@ void QgsAuthSslConfigWidget::enableSslCustomOptions( bool enable )
190248

191249
void QgsAuthSslConfigWidget::setSslCertificate( const QSslCertificate &cert, const QString &hostport )
192250
{
251+
if ( mDisabled )
252+
{
253+
return;
254+
}
193255
if ( cert.isNull() )
194256
{
195257
return;
@@ -224,6 +286,10 @@ void QgsAuthSslConfigWidget::setSslCertificate( const QSslCertificate &cert, con
224286

225287
void QgsAuthSslConfigWidget::loadSslCustomConfig( const QgsAuthConfigSslServer &config )
226288
{
289+
if ( mDisabled )
290+
{
291+
return;
292+
}
227293
resetSslCertConfig();
228294
if ( config.isNull() )
229295
{
@@ -252,6 +318,10 @@ void QgsAuthSslConfigWidget::loadSslCustomConfig( const QgsAuthConfigSslServer &
252318

253319
void QgsAuthSslConfigWidget::saveSslCertConfig()
254320
{
321+
if ( mDisabled )
322+
{
323+
return;
324+
}
255325
if ( !QgsAuthManager::instance()->storeSslCertCustomConfig( sslCustomConfig() ) )
256326
{
257327
QgsDebugMsg( "SSL custom config FAILED to store in authentication database" );
@@ -260,6 +330,10 @@ void QgsAuthSslConfigWidget::saveSslCertConfig()
260330

261331
void QgsAuthSslConfigWidget::resetSslCertConfig()
262332
{
333+
if ( mDisabled )
334+
{
335+
return;
336+
}
263337
mCert.clear();
264338
mConnectionCAs.clear();
265339
leCommonName->clear();
@@ -276,22 +350,38 @@ void QgsAuthSslConfigWidget::resetSslCertConfig()
276350

277351
QSsl::SslProtocol QgsAuthSslConfigWidget::sslProtocol()
278352
{
353+
if ( mDisabled )
354+
{
355+
return QSsl::UnknownProtocol;
356+
}
279357
return ( QSsl::SslProtocol )mProtocolCmbBx->itemData( mProtocolCmbBx->currentIndex() ).toInt();
280358
}
281359

282360
void QgsAuthSslConfigWidget::setSslProtocol( QSsl::SslProtocol protocol )
283361
{
362+
if ( mDisabled )
363+
{
364+
return;
365+
}
284366
int indx( mProtocolCmbBx->findData(( int )protocol ) );
285367
mProtocolCmbBx->setCurrentIndex( indx );
286368
}
287369

288370
void QgsAuthSslConfigWidget::resetSslProtocol()
289371
{
372+
if ( mDisabled )
373+
{
374+
return;
375+
}
290376
mProtocolCmbBx->setCurrentIndex( 0 );
291377
}
292378

293379
void QgsAuthSslConfigWidget::appendSslIgnoreErrors( const QList<QSslError> &errors )
294380
{
381+
if ( mDisabled )
382+
{
383+
return;
384+
}
295385
enableSslCustomOptions( true );
296386

297387
QList<QSslError::SslError> errenums;
@@ -312,6 +402,10 @@ void QgsAuthSslConfigWidget::appendSslIgnoreErrors( const QList<QSslError> &erro
312402

313403
void QgsAuthSslConfigWidget::setSslIgnoreErrorEnums( const QList<QSslError::SslError> &errorenums )
314404
{
405+
if ( mDisabled )
406+
{
407+
return;
408+
}
315409
QList<QSslError> errors;
316410
Q_FOREACH ( QSslError::SslError errorenum, errorenums )
317411
{
@@ -322,6 +416,10 @@ void QgsAuthSslConfigWidget::setSslIgnoreErrorEnums( const QList<QSslError::SslE
322416

323417
void QgsAuthSslConfigWidget::setSslIgnoreErrors( const QList<QSslError> &errors )
324418
{
419+
if ( mDisabled )
420+
{
421+
return;
422+
}
325423
if ( errors.isEmpty() )
326424
{
327425
return;
@@ -345,6 +443,10 @@ void QgsAuthSslConfigWidget::setSslIgnoreErrors( const QList<QSslError> &errors
345443

346444
void QgsAuthSslConfigWidget::resetSslIgnoreErrors()
347445
{
446+
if ( mDisabled )
447+
{
448+
return;
449+
}
348450
for ( int i = 0; i < mIgnoreErrorsItem->childCount(); i++ )
349451
{
350452
mIgnoreErrorsItem->child( i )->setCheckState( 0, Qt::Unchecked );
@@ -354,6 +456,10 @@ void QgsAuthSslConfigWidget::resetSslIgnoreErrors()
354456
const QList<QSslError::SslError> QgsAuthSslConfigWidget::sslIgnoreErrorEnums()
355457
{
356458
QList<QSslError::SslError> errs;
459+
if ( mDisabled )
460+
{
461+
return errs;
462+
}
357463
for ( int i = 0; i < mIgnoreErrorsItem->childCount(); i++ )
358464
{
359465
QTreeWidgetItem *item( mIgnoreErrorsItem->child( i ) );
@@ -367,16 +473,28 @@ const QList<QSslError::SslError> QgsAuthSslConfigWidget::sslIgnoreErrorEnums()
367473

368474
QSslSocket::PeerVerifyMode QgsAuthSslConfigWidget::sslPeerVerifyMode()
369475
{
476+
if ( mDisabled )
477+
{
478+
return QSslSocket::AutoVerifyPeer;
479+
}
370480
return ( QSslSocket::PeerVerifyMode )mVerifyPeerCmbBx->itemData( mVerifyPeerCmbBx->currentIndex() ).toInt();
371481
}
372482

373483
int QgsAuthSslConfigWidget::sslPeerVerifyDepth()
374484
{
485+
if ( mDisabled )
486+
{
487+
return 0;
488+
}
375489
return mVerifyDepthSpnBx->value();
376490
}
377491

378492
void QgsAuthSslConfigWidget::setSslPeerVerify( QSslSocket::PeerVerifyMode mode, int modedepth )
379493
{
494+
if ( mDisabled )
495+
{
496+
return;
497+
}
380498
enableSslCustomOptions( true );
381499

382500
int indx( mVerifyPeerCmbBx->findData(( int )mode ) );
@@ -387,12 +505,20 @@ void QgsAuthSslConfigWidget::setSslPeerVerify( QSslSocket::PeerVerifyMode mode,
387505

388506
void QgsAuthSslConfigWidget::resetSslPeerVerify()
389507
{
508+
if ( mDisabled )
509+
{
510+
return;
511+
}
390512
mVerifyPeerCmbBx->setCurrentIndex( 0 );
391513
mVerifyDepthSpnBx->setValue( 0 );
392514
}
393515

394516
bool QgsAuthSslConfigWidget::readyToSave()
395517
{
518+
if ( mDisabled )
519+
{
520+
return false;
521+
}
396522
bool cansave = ( isEnabled()
397523
&& ( grpbxSslConfig->isCheckable() ? grpbxSslConfig->isChecked() : true )
398524
&& validateHostPort( leHost->text() ) );
@@ -406,6 +532,10 @@ bool QgsAuthSslConfigWidget::readyToSave()
406532

407533
void QgsAuthSslConfigWidget::setSslHost( const QString &host )
408534
{
535+
if ( mDisabled )
536+
{
537+
return;
538+
}
409539
leHost->setText( host );
410540
}
411541

@@ -427,6 +557,10 @@ bool QgsAuthSslConfigWidget::validateHostPort( const QString &txt )
427557

428558
void QgsAuthSslConfigWidget::validateHostPortText( const QString &txt )
429559
{
560+
if ( mDisabled )
561+
{
562+
return;
563+
}
430564
bool valid = validateHostPort( txt );
431565
leHost->setStyleSheet( valid ? QgsAuthGuiUtils::greenTextStyleSheet()
432566
: QgsAuthGuiUtils::redTextStyleSheet() );
@@ -435,6 +569,10 @@ void QgsAuthSslConfigWidget::validateHostPortText( const QString &txt )
435569

436570
void QgsAuthSslConfigWidget::setConfigCheckable( bool checkable )
437571
{
572+
if ( mDisabled )
573+
{
574+
return;
575+
}
438576
grpbxSslConfig->setCheckable( checkable );
439577
if ( !checkable )
440578
{

‎src/gui/auth/qgsauthsslconfigwidget.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,18 @@ class GUI_EXPORT QgsAuthSslConfigWidget : public QWidget, private Ui::QgsAuthSsl
5252
~QgsAuthSslConfigWidget();
5353

5454
/** Access to the certificate's group box widget */
55-
QGroupBox *certificateGroupBox() { return grpbxCert; }
55+
QGroupBox *certificateGroupBox();
5656
/** Access to the SSL configuration's group box widget */
57-
QGroupBox *sslConfigGroupBox() { return grpbxSslConfig; }
57+
QGroupBox *sslConfigGroupBox();
5858

5959
/** Get the SSL configuration */
6060
const QgsAuthConfigSslServer sslCustomConfig();
6161

6262
/** Get the SSL server certificate */
63-
const QSslCertificate sslCertificate() { return mCert; }
63+
const QSslCertificate sslCertificate();
6464

6565
/** Get the host:port to associate with the server certificate */
66-
const QString sslHost() { return leHost->text(); }
66+
const QString sslHost();
6767

6868
/** Get the SSL protocl used for connections */
6969
QSsl::SslProtocol sslProtocol();
@@ -172,6 +172,10 @@ class GUI_EXPORT QgsAuthSslConfigWidget : public QWidget, private Ui::QgsAuthSsl
172172
QSpinBox *mVerifyDepthSpnBx;
173173

174174
bool mCanSave;
175+
176+
bool mDisabled;
177+
QVBoxLayout *mAuthNotifyLayout;
178+
QLabel *mAuthNotify;
175179
};
176180

177181
//////////////// Embed in dialog ///////////////////

‎src/gui/auth/qgsauthsslerrorsdialog.cpp

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,31 @@ QgsAuthSslErrorsDialog::QgsAuthSslErrorsDialog( QNetworkReply *reply,
6464

6565
ignoreButton()->setDefault( false );
6666
abortButton()->setDefault( true );
67-
saveButton()->setEnabled( false );
6867

69-
saveButton()->setText( QString( "%1 && %2" ).arg( saveButton()->text() )
70-
.arg( ignoreButton()->text() ) );
68+
if ( !QgsAuthManager::instance()->isDisabled() )
69+
{
70+
saveButton()->setEnabled( false );
71+
72+
saveButton()->setText( QString( "%1 && %2" ).arg( saveButton()->text() )
73+
.arg( ignoreButton()->text() ) );
7174

72-
grpbxSslConfig->setChecked( false );
73-
grpbxSslConfig->setCollapsed( true );
74-
connect( grpbxSslConfig, SIGNAL( toggled( bool ) ),
75-
this, SLOT( loadUnloadCertificate( bool ) ) );
75+
grpbxSslConfig->setChecked( false );
76+
grpbxSslConfig->setCollapsed( true );
77+
connect( grpbxSslConfig, SIGNAL( toggled( bool ) ),
78+
this, SLOT( loadUnloadCertificate( bool ) ) );
7679

77-
connect( wdgtSslConfig, SIGNAL( readyToSaveChanged( bool ) ),
78-
this, SLOT( widgetReadyToSaveChanged( bool ) ) );
79-
wdgtSslConfig->setConfigCheckable( false );
80-
wdgtSslConfig->certificateGroupBox()->setFlat( true );
80+
connect( wdgtSslConfig, SIGNAL( readyToSaveChanged( bool ) ),
81+
this, SLOT( widgetReadyToSaveChanged( bool ) ) );
82+
wdgtSslConfig->setConfigCheckable( false );
83+
wdgtSslConfig->certificateGroupBox()->setFlat( true );
84+
}
85+
else
86+
{
87+
btnChainInfo->setVisible( false );
88+
btnChainCAs->setVisible( false );
89+
grpbxSslConfig->setVisible( false );
90+
saveButton()->setVisible( false );
91+
}
8192

8293
populateErrorsList();
8394
}
@@ -176,12 +187,15 @@ void QgsAuthSslErrorsDialog::on_buttonBox_clicked( QAbstractButton *button )
176187

177188
void QgsAuthSslErrorsDialog::populateErrorsList()
178189
{
190+
QStringList errs;
191+
errs.reserve( mSslErrors.size() );
179192
Q_FOREACH ( const QSslError &err, mSslErrors )
180193
{
181-
listSslErrors->addItem( QString( "%1: %2" )
182-
.arg( QgsAuthCertUtils::sslErrorEnumString( err.error() ) )
183-
.arg( err.errorString() ) );
194+
errs << QString( "* %1: %2" )
195+
.arg( QgsAuthCertUtils::sslErrorEnumString( err.error() ) )
196+
.arg( err.errorString() );
184197
}
198+
teSslErrors->setPlainText( errs.join( "\n" ) );
185199
}
186200

187201
QPushButton *QgsAuthSslErrorsDialog::ignoreButton()
@@ -208,3 +222,12 @@ void QgsAuthSslErrorsDialog::on_btnChainCAs_clicked()
208222
{
209223
showCertificateChainCAsInfo();
210224
}
225+
226+
void QgsAuthSslErrorsDialog::on_grpbxSslErrors_collapsedStateChanged( bool collapsed )
227+
{
228+
if ( !collapsed && QgsAuthManager::instance()->isDisabled() )
229+
{
230+
btnChainInfo->setVisible( false );
231+
btnChainCAs->setVisible( false );
232+
}
233+
}

‎src/gui/auth/qgsauthsslerrorsdialog.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ class GUI_EXPORT QgsAuthSslErrorsDialog : public QDialog, private Ui::QgsAuthSsl
6666

6767
void on_btnChainCAs_clicked();
6868

69+
void on_grpbxSslErrors_collapsedStateChanged( bool collapsed );
70+
6971
private:
7072
void populateErrorsList();
7173

‎src/gui/auth/qgsauthsslimportdialog.cpp

Lines changed: 52 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -87,47 +87,59 @@ QgsAuthSslImportDialog::QgsAuthSslImportDialog( QWidget *parent )
8787
, mTimer( 0 )
8888
, mSslErrors( QList<QSslError>() )
8989
, mTrustedCAs( QList<QSslCertificate>() )
90+
, mAuthNotifyLayout( 0 )
91+
, mAuthNotify( 0 )
9092
{
91-
setupUi( this );
92-
QStyle *style = QApplication::style();
93-
lblWarningIcon->setPixmap( style->standardIcon( QStyle::SP_MessageBoxWarning ).pixmap( 48, 48 ) );
94-
lblWarningIcon->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
95-
96-
closeButton()->setDefault( false );
97-
saveButton()->setEnabled( false );
98-
99-
leServer->setSelection( 0, leServer->text().size() );
100-
pteSessionStatus->setReadOnly( true );
101-
spinbxTimeout->setValue( 15 );
102-
103-
grpbxServer->setCollapsed( false );
104-
radioServerImport->setChecked( true );
105-
frameServerImport->setEnabled( true );
106-
radioFileImport->setChecked( false );
107-
frameFileImport->setEnabled( false );
108-
109-
connect( radioServerImport, SIGNAL( toggled( bool ) ),
110-
this, SLOT( radioServerImportToggled( bool ) ) );
111-
connect( radioFileImport, SIGNAL( toggled( bool ) ),
112-
this, SLOT( radioFileImportToggled( bool ) ) );
113-
114-
connect( leServer, SIGNAL( textChanged( QString ) ),
115-
this, SLOT( updateEnabledState() ) );
116-
connect( btnConnect, SIGNAL( clicked() ),
117-
this, SLOT( secureConnect() ) );
118-
connect( leServer, SIGNAL( returnPressed() ),
119-
btnConnect, SLOT( click() ) );
120-
121-
connect( buttonBox, SIGNAL( accepted() ),
122-
this, SLOT( accept() ) );
123-
connect( buttonBox, SIGNAL( rejected() ),
124-
this, SLOT( reject() ) );
125-
126-
connect( wdgtSslConfig, SIGNAL( readyToSaveChanged( bool ) ),
127-
this, SLOT( widgetReadyToSaveChanged( bool ) ) );
128-
wdgtSslConfig->setEnabled( false );
129-
130-
mTrustedCAs = QgsAuthManager::instance()->getTrustedCaCertsCache();
93+
if ( QgsAuthManager::instance()->isDisabled() )
94+
{
95+
mAuthNotifyLayout = new QVBoxLayout;
96+
this->setLayout( mAuthNotifyLayout );
97+
mAuthNotify = new QLabel( QgsAuthManager::instance()->disabledMessage(), this );
98+
mAuthNotifyLayout->addWidget( mAuthNotify );
99+
}
100+
else
101+
{
102+
setupUi( this );
103+
QStyle *style = QApplication::style();
104+
lblWarningIcon->setPixmap( style->standardIcon( QStyle::SP_MessageBoxWarning ).pixmap( 48, 48 ) );
105+
lblWarningIcon->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
106+
107+
closeButton()->setDefault( false );
108+
saveButton()->setEnabled( false );
109+
110+
leServer->setSelection( 0, leServer->text().size() );
111+
pteSessionStatus->setReadOnly( true );
112+
spinbxTimeout->setValue( 15 );
113+
114+
grpbxServer->setCollapsed( false );
115+
radioServerImport->setChecked( true );
116+
frameServerImport->setEnabled( true );
117+
radioFileImport->setChecked( false );
118+
frameFileImport->setEnabled( false );
119+
120+
connect( radioServerImport, SIGNAL( toggled( bool ) ),
121+
this, SLOT( radioServerImportToggled( bool ) ) );
122+
connect( radioFileImport, SIGNAL( toggled( bool ) ),
123+
this, SLOT( radioFileImportToggled( bool ) ) );
124+
125+
connect( leServer, SIGNAL( textChanged( QString ) ),
126+
this, SLOT( updateEnabledState() ) );
127+
connect( btnConnect, SIGNAL( clicked() ),
128+
this, SLOT( secureConnect() ) );
129+
connect( leServer, SIGNAL( returnPressed() ),
130+
btnConnect, SLOT( click() ) );
131+
132+
connect( buttonBox, SIGNAL( accepted() ),
133+
this, SLOT( accept() ) );
134+
connect( buttonBox, SIGNAL( rejected() ),
135+
this, SLOT( reject() ) );
136+
137+
connect( wdgtSslConfig, SIGNAL( readyToSaveChanged( bool ) ),
138+
this, SLOT( widgetReadyToSaveChanged( bool ) ) );
139+
wdgtSslConfig->setEnabled( false );
140+
141+
mTrustedCAs = QgsAuthManager::instance()->getTrustedCaCertsCache();
142+
}
131143
}
132144

133145
QgsAuthSslImportDialog::~QgsAuthSslImportDialog()

‎src/gui/auth/qgsauthsslimportdialog.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ class GUI_EXPORT QgsAuthSslImportDialog : public QDialog, private Ui::QgsAuthSsl
128128
QTimer *mTimer;
129129
QList<QSslError> mSslErrors;
130130
QList<QSslCertificate> mTrustedCAs;
131+
132+
QVBoxLayout *mAuthNotifyLayout;
133+
QLabel *mAuthNotify;
131134
};
132135

133136
#endif // QGSAUTHSSLIMPORTDIALOG_H

‎src/gui/auth/qgsauthtrustedcasdialog.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@ QgsAuthTrustedCAsDialog::QgsAuthTrustedCAsDialog( QWidget *parent,
3131
QList<QSslCertificate> trustedCAs )
3232
: QDialog( parent )
3333
, mTrustedCAs( trustedCAs )
34+
, mDisabled( false )
3435
, mAuthNotifyLayout( 0 )
3536
, mAuthNotify( 0 )
3637
, mRootCaSecItem( 0 )
3738
{
3839
if ( QgsAuthManager::instance()->isDisabled() )
3940
{
41+
mDisabled = true;
4042
mAuthNotifyLayout = new QVBoxLayout;
4143
this->setLayout( mAuthNotifyLayout );
4244
mAuthNotify = new QLabel( QgsAuthManager::instance()->disabledMessage(), this );
@@ -315,7 +317,10 @@ void QgsAuthTrustedCAsDialog::authMessageOut( const QString& message, const QStr
315317

316318
void QgsAuthTrustedCAsDialog::showEvent( QShowEvent * e )
317319
{
318-
treeTrustedCAs->setFocus();
320+
if ( !mDisabled )
321+
{
322+
treeTrustedCAs->setFocus();
323+
}
319324
QWidget::showEvent( e );
320325
}
321326

‎src/gui/auth/qgsauthtrustedcasdialog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class GUI_EXPORT QgsAuthTrustedCAsDialog : public QDialog, private Ui::QgsAuthTr
9292
int messageTimeout();
9393

9494
QList<QSslCertificate> mTrustedCAs;
95+
bool mDisabled;
9596
QVBoxLayout *mAuthNotifyLayout;
9697
QLabel *mAuthNotify;
9798

‎src/ui/auth/qgsauthsslerrorsdialog.ui

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,8 @@
102102
<number>6</number>
103103
</property>
104104
<item>
105-
<widget class="QListWidget" name="listSslErrors">
106-
<property name="editTriggers">
107-
<set>QAbstractItemView::NoEditTriggers</set>
108-
</property>
109-
<property name="alternatingRowColors">
110-
<bool>true</bool>
111-
</property>
112-
<property name="wordWrap">
105+
<widget class="QPlainTextEdit" name="teSslErrors">
106+
<property name="readOnly">
113107
<bool>true</bool>
114108
</property>
115109
</widget>
@@ -276,7 +270,7 @@
276270
</customwidgets>
277271
<tabstops>
278272
<tabstop>leUrl</tabstop>
279-
<tabstop>listSslErrors</tabstop>
273+
<tabstop>teSslErrors</tabstop>
280274
<tabstop>btnChainInfo</tabstop>
281275
<tabstop>btnChainCAs</tabstop>
282276
<tabstop>grpbxSslConfig</tabstop>

0 commit comments

Comments
 (0)
Please sign in to comment.