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

0 commit comments

Comments
 (0)