18 #include "ui_qgsauthtrustedcasdialog.h"
20 #include <QPushButton>
33 , mTrustedCAs( trustedCAs )
35 , mAuthNotifyLayout( 0 )
45 mAuthNotifyLayout->
addWidget( mAuthNotify );
63 btnGroupByOrg->setChecked(
false );
66 btnGroupByOrg->setChecked( sortbyval.
toBool() );
68 populateCaCertsView();
85 void QgsAuthTrustedCAsDialog::setupCaCertsTree()
87 treeTrustedCAs->setColumnCount( 3 );
88 treeTrustedCAs->setHeaderLabels(
91 <<
tr(
"Expiry Date" ) );
92 treeTrustedCAs->setColumnWidth( 0, 300 );
93 treeTrustedCAs->setColumnWidth( 1, 75 );
99 (
int )QgsAuthTrustedCAsDialog::Section );
101 mRootCaSecItem->
setFlags( Qt::ItemIsEnabled );
103 treeTrustedCAs->insertTopLevelItem( 0, mRootCaSecItem );
114 void QgsAuthTrustedCAsDialog::populateCaCertsView()
123 populateCaCertsSection( mRootCaSecItem, mTrustedCAs, QgsAuthTrustedCAsDialog::CaCert );
127 QgsAuthTrustedCAsDialog::CaType catype )
129 if ( btnGroupByOrg->isChecked() )
131 appendCertsToGroup( certs, catype, item );
135 appendCertsToItem( certs, catype, item );
140 QgsAuthTrustedCAsDialog::CaType catype,
143 if ( certs.
size() < 1 )
148 parent = treeTrustedCAs->currentItem();
156 for ( ; it != orgcerts.
constEnd(); ++it )
160 ( int )QgsAuthTrustedCAsDialog::OrgName ) );
162 grpitem->setFlags( Qt::ItemIsEnabled );
163 grpitem->setExpanded(
true );
165 QBrush orgb( grpitem->foreground( 0 ) );
167 grpitem->setForeground( 0, orgb );
168 QFont grpf( grpitem->font( 0 ) );
170 grpitem->setFont( 0, grpf );
172 appendCertsToItem( it.
value(), catype, grpitem );
179 QgsAuthTrustedCAsDialog::CaType catype,
182 if ( certs.
size() < 1 )
187 parent = treeTrustedCAs->currentItem();
211 item->
setData( 0, Qt::UserRole,
id );
227 if ( !cacertscache.contains( digest ) )
229 QgsDebugMsg(
"Certificate Authority not in CA certs cache" );
236 dlg->setWindowModality( Qt::WindowModal );
237 dlg->resize( 675, 500 );
244 Q_UNUSED( selected );
245 Q_UNUSED( deselected );
249 void QgsAuthTrustedCAsDialog::checkSelection()
252 if ( treeTrustedCAs->selectionModel()->selection().length() > 0 )
256 switch (( QgsAuthTrustedCAsDialog::CaType )item->
type() )
258 case QgsAuthTrustedCAsDialog::CaCert:
266 btnInfoCa->setEnabled( iscert );
269 void QgsAuthTrustedCAsDialog::handleDoubleClick(
QTreeWidgetItem *item,
int col )
274 switch (( QgsAuthTrustedCAsDialog::CaType )item->
type() )
276 case QgsAuthTrustedCAsDialog::Section:
279 case QgsAuthTrustedCAsDialog::OrgName:
288 showCertInfo( item );
292 void QgsAuthTrustedCAsDialog::on_btnInfoCa_clicked()
294 if ( treeTrustedCAs->selectionModel()->selection().length() > 0 )
297 handleDoubleClick( item, 0 );
301 void QgsAuthTrustedCAsDialog::on_btnGroupByOrg_toggled(
bool checked )
305 authMessageOut(
QObject::tr(
"Could not store sort by preference" ),
309 populateCaCertsView();
314 int levelint = ( int )level;
322 treeTrustedCAs->setFocus();
332 int QgsAuthTrustedCAsDialog::messageTimeout()
335 return settings.
value(
"/qgis/messageTimeout", 5 ).
toInt();
void pushMessage(const QString &text, MessageLevel level=INFO, int duration=0)
convenience method for pushing a message to the bar
QString toString(Qt::DateFormat format) const
static QgsAuthManager * instance()
Enforce singleton pattern.
static void setItemBold_(QTreeWidgetItem *item)
static QIcon getThemeIcon(const QString &theName)
Helper to get a theme icon.
const_iterator constBegin() const
A bar for displaying non-blocking messages to the user.
void showEvent(QShowEvent *e) override
Overridden widget show event.
QString tr(const char *sourceText, const char *disambiguation, int n)
QVariant getAuthSetting(const QString &key, const QVariant &defaultValue=QVariant(), bool decrypt=false)
Get an authentication setting (retrieved as string and returned as QVariant( QString )) ...
void setBold(bool enable)
static QColor redColor()
Red color representing invalid, untrusted, etc.
Dialog wrapper for widget displaying detailed info on a certificate and its hierarchical trust chain...
int toInt(bool *ok) const
const_iterator constEnd() const
MessageLevel
Message log level (mirrors that of QgsMessageLog, so it can also output there)
const QList< QSslCertificate > getTrustedCaCerts(bool includeinvalid=false)
Get list of all trusted CA certificates.
void setItalic(bool enable)
const Key key(const T &value) const
static QString shaHexForCert(const QSslCertificate &cert, bool formatted=false)
Get the sha1 hash for certificate.
QVariant value(const QString &key, const QVariant &defaultValue) const
QByteArray serialNumber() const
QDateTime expiryDate() const
QgsAuthTrustedCAsDialog(QWidget *parent=0, const QList< QSslCertificate > &trustedCAs=QList< QSslCertificate >())
Construct a dialog that will list the trusted Certificate Authorities.
~QgsAuthTrustedCAsDialog()
static QMap< QString, QList< QSslCertificate > > certsGroupedByOrg(const QList< QSslCertificate > &certs)
Map certificates to their oraganization.
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
static void removeChildren_(QTreeWidgetItem *item)
void setColor(const QColor &color)
static QString resolvedCertName(const QSslCertificate &cert, bool issuer=false)
Get the general name via RFC 5280 resolution.
const T value(const Key &key) const