Skip to content

Commit

Permalink
[api][auth] Removed get prefix from all getters in auth manager
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Oct 27, 2017
1 parent 6829a92 commit d64529f
Show file tree
Hide file tree
Showing 19 changed files with 344 additions and 167 deletions.
24 changes: 24 additions & 0 deletions doc/api_break.dox
Expand Up @@ -539,6 +539,30 @@ QgsAuthManager {#qgis_api_break_3_0_QgsAuthManager}
- scheduledAuthDbErase() was renamed to scheduledAuthDatabaseErase()
- setScheduledAuthDbErase() was renamed to setScheduledAuthDatabaseErase()
- setScheduledAuthDbEraseRequestEmitted() was renamed to setScheduledAuthDatabaseEraseRequestEmitted()
- getAuthSetting() was renamed to authSetting()
- getCertIdentity() was renamed to certIdentity()
- getCertIdentityBundle() was renamed to certIdentityBundle()
- getCertIdentityBundleToPem() was renamed to certIdentityBundleToPem()
- getCertIdentities() was renamed to certIdentities()
- getCertIdentityIds() was renamed to certIdentityIds()
- getSslCertCustomConfig() was renamed to sslCertCustomConfig()
- getSslCertCustomConfigByHost() was renamed to sslCertCustomConfigByHost()
- getSslCertCustomConfigs() was renamed to sslCertCustomConfigs()
- getIgnoredSslErrorCache() was renamed to ignoredSslErrorCache()
- getCertAuthority() was renamed to certAuthority()
- getSystemRootCAs() was renamed to systemRootCAs()
- getExtraFileCAs() was renamed to extraFileCAs()
- getDatabaseCAs() was renamed to databaseCAs()
- getMappedDatabaseCAs() was renamed to mappedDatabaseCAs()
- getCaCertsCache() was renamed to caCertsCache()
- getCertTrustPolicy() was renamed to certTrustPolicy()
- getCertificateTrustPolicy() was renamed to certificateTrustPolicy()
- getCertTrustCache() was renamed to certTrustCache()
- getTrustedCaCerts() was renamed to trustedCaCerts()
- getUntrustedCaCerts() was renamed to untrustedCaCerts()
- getTrustedCaCertsCache() was renamed to trustedCaCertsCache()
- getTrustedCaCertsPemText() was renamed to trustedCaCertsPemText()



QgsAuthMethod {#qgis_api_break_3_0_QgsAuthMethod}
Expand Down
143 changes: 98 additions & 45 deletions python/core/auth/qgsauthmanager.sip
Expand Up @@ -374,9 +374,14 @@ Store an authentication setting (stored as string via QVariant( value ).toString
:rtype: bool
%End

QVariant getAuthSetting( const QString &key, const QVariant &defaultValue = QVariant(), bool decrypt = false );
%Docstring
Get an authentication setting (retrieved as string and returned as QVariant( QString ))
QVariant authSetting( const QString &key, const QVariant &defaultValue = QVariant(), bool decrypt = false );
%Docstring
authSetting get an authentication setting (retrieved as string and returned as QVariant( QString ))
\param key setting key
\param defaultValue
\param decrypt if the value needs decrypted
:return: QVariant( QString ) authentication setting
.. versionadded:: 3.0
:rtype: QVariant
%End

Expand Down Expand Up @@ -405,28 +410,39 @@ Store a certificate identity
:rtype: bool
%End

const QSslCertificate getCertIdentity( const QString &id );
const QSslCertificate certIdentity( const QString &id );
%Docstring
Get a certificate identity by id (sha hash)
certIdentity get a certificate identity by ``id`` (sha hash)
\param id sha hash of the cert
:return: the certificate
.. versionadded:: 3.0
:rtype: QSslCertificate
%End


const QStringList getCertIdentityBundleToPem( const QString &id );
const QStringList certIdentityBundleToPem( const QString &id );
%Docstring
Get a certificate identity bundle by id (sha hash) returned as PEM text
certIdentityBundleToPem get a certificate identity bundle by ``id`` (sha hash) returned as PEM text
\param id sha hash
:return: a list of strings
.. versionadded:: 3.0
:rtype: list of str
%End

const QList<QSslCertificate> getCertIdentities();
const QList<QSslCertificate> certIdentities();
%Docstring
Get certificate identities
certIdentities get certificate identities
:return: list of certificates
.. versionadded:: 3.0
:rtype: list of QSslCertificate
%End

QStringList getCertIdentityIds() const;

QStringList certIdentityIds() const;
%Docstring
Get list of certificate identity ids from database
certIdentityIds get list of certificate identity ids from database
:return: list of certificate ids
.. versionadded:: 3.0
:rtype: list of str
%End

Expand All @@ -449,21 +465,30 @@ Store an SSL certificate custom config
:rtype: bool
%End

const QgsAuthConfigSslServer getSslCertCustomConfig( const QString &id, const QString &hostport );
const QgsAuthConfigSslServer sslCertCustomConfig( const QString &id, const QString &hostport );
%Docstring
Get an SSL certificate custom config by id (sha hash) and host:port
sslCertCustomConfig get an SSL certificate custom config by ``id`` (sha hash) and ``hostport`` (host:port)
\param id sha hash
\param hostport string host:port
:return: a SSL certificate custom config
.. versionadded:: 3.0
:rtype: QgsAuthConfigSslServer
%End

const QgsAuthConfigSslServer getSslCertCustomConfigByHost( const QString &hostport );
const QgsAuthConfigSslServer sslCertCustomConfigByHost( const QString &hostport );
%Docstring
Get an SSL certificate custom config by host:port
sslCertCustomConfigByHost get an SSL certificate custom config by ``hostport`` (host:port)
\param hostport host:port
:return: a SSL certificate custom config
.. versionadded:: 3.0
:rtype: QgsAuthConfigSslServer
%End

const QList<QgsAuthConfigSslServer> getSslCertCustomConfigs();
const QList<QgsAuthConfigSslServer> sslCertCustomConfigs();
%Docstring
Get SSL certificate custom configs
sslCertCustomConfigs get SSL certificate custom configs
:return: list of SSL certificate custom config
.. versionadded:: 3.0
:rtype: list of QgsAuthConfigSslServer
%End

Expand Down Expand Up @@ -516,9 +541,13 @@ Store a certificate authority
:rtype: bool
%End

const QSslCertificate getCertAuthority( const QString &id );

const QSslCertificate certAuthority( const QString &id );
%Docstring
Get a certificate authority by id (sha hash)
certAuthority get a certificate authority by ``id`` (sha hash)
\param id sha hash
:return: a certificate
.. versionadded:: 3.0
:rtype: QSslCertificate
%End

Expand All @@ -534,27 +563,35 @@ Remove a certificate authority
:rtype: bool
%End

const QList<QSslCertificate> getSystemRootCAs();
const QList<QSslCertificate> systemRootCAs();
%Docstring
Get root system certificate authorities
systemRootCAs get root system certificate authorities
:return: list of certificate authorities
.. versionadded:: 3.0
:rtype: list of QSslCertificate
%End

const QList<QSslCertificate> getExtraFileCAs();
const QList<QSslCertificate> extraFileCAs();
%Docstring
Get extra file-based certificate authorities
extraFileCAs extra file-based certificate authorities
:return: list of certificate authorities
.. versionadded:: 3.0
:rtype: list of QSslCertificate
%End

const QList<QSslCertificate> getDatabaseCAs();
const QList<QSslCertificate> databaseCAs();
%Docstring
Get database-stored certificate authorities
databaseCAs get database-stored certificate authorities
:return: list of certificate authorities
.. versionadded:: 3.0
:rtype: list of QSslCertificate
%End

const QMap<QString, QSslCertificate> getMappedDatabaseCAs();
const QMap<QString, QSslCertificate> mappedDatabaseCAs();
%Docstring
Get sha1-mapped database-stored certificate authorities
mappedDatabaseCAs get sha1-mapped database-stored certificate authorities
:return: sha1-mapped certificate authorities
.. versionadded:: 3.0
:rtype: QMap<str, QSslCertificate>
%End

Expand All @@ -571,10 +608,12 @@ Store user trust value for a certificate
:rtype: bool
%End

QgsAuthCertUtils::CertTrustPolicy getCertTrustPolicy( const QSslCertificate &cert );
QgsAuthCertUtils::CertTrustPolicy certTrustPolicy( const QSslCertificate &cert );
%Docstring
Get a whether certificate is trusted by user
:return: DefaultTrust if certificate sha not in trust table, i.e. follows default trust policy
certTrustPolicy get whether certificate ``cert`` is trusted by user
\param cert
:return: DefaultTrust if certificate sha not in trust table, i.e. follows default trust policy
.. versionadded:: 3.0
:rtype: QgsAuthCertUtils.CertTrustPolicy
%End

Expand All @@ -590,9 +629,12 @@ Remove a certificate authority
:rtype: bool
%End

QgsAuthCertUtils::CertTrustPolicy getCertificateTrustPolicy( const QSslCertificate &cert );
QgsAuthCertUtils::CertTrustPolicy certificateTrustPolicy( const QSslCertificate &cert );
%Docstring
Get trust policy for a particular certificate
certificateTrustPolicy get trust policy for a particular certificate ``cert``
\param cert
:return: DefaultTrust if certificate sha not in trust table, i.e. follows default trust policy
.. versionadded:: 3.0
:rtype: QgsAuthCertUtils.CertTrustPolicy
%End

Expand All @@ -608,9 +650,11 @@ Get the default certificate trust policy perferred by user
:rtype: QgsAuthCertUtils.CertTrustPolicy
%End

const QMap<QgsAuthCertUtils::CertTrustPolicy, QStringList > getCertTrustCache();
const QMap<QgsAuthCertUtils::CertTrustPolicy, QStringList > certTrustCache();
%Docstring
Get cache of certificate sha1s, per trust policy
certTrustCache get cache of certificate sha1s, per trust policy
:return: trust-policy-mapped certificate sha1s
.. versionadded:: 3.0
:rtype: QMap<QgsAuthCertUtils.CertTrustPolicy, list of str >
%End

Expand All @@ -620,15 +664,20 @@ Rebuild certificate authority cache
:rtype: bool
%End

const QList<QSslCertificate> getTrustedCaCerts( bool includeinvalid = false );
const QList<QSslCertificate> trustedCaCerts( bool includeinvalid = false );
%Docstring
Get list of all trusted CA certificates
trustedCaCerts get list of all trusted CA certificates
\param includeinvalid whether invalid certs needs to be returned
:return: list of certificates
.. versionadded:: 3.0
:rtype: list of QSslCertificate
%End

const QList<QSslCertificate> getUntrustedCaCerts( QList<QSslCertificate> trustedCAs = QList<QSslCertificate>() );
const QList<QSslCertificate> untrustedCaCerts( QList<QSslCertificate> trustedCAs = QList<QSslCertificate>() );
%Docstring
Get list of all untrusted CA certificates
untrustedCaCerts get list of untrusted certificate authorities
:return: list of certificates
.. versionadded:: 3.0
:rtype: list of QSslCertificate
%End

Expand All @@ -638,15 +687,19 @@ Rebuild trusted certificate authorities cache
:rtype: bool
%End

const QList<QSslCertificate> getTrustedCaCertsCache();
const QList<QSslCertificate> trustedCaCertsCache();
%Docstring
Get cache of trusted certificate authorities, ready for network connections
trustedCaCertsCache cache of trusted certificate authorities, ready for network connections
:return: list of certificates
.. versionadded:: 3.0
:rtype: list of QSslCertificate
%End

const QByteArray getTrustedCaCertsPemText();
const QByteArray trustedCaCertsPemText();
%Docstring
Get concatenated string of all trusted CA certificates
trustedCaCertsPemText get concatenated string of all trusted CA certificates
:return: bye array with all PEM encoded trusted CAs
.. versionadded:: 3.0
:rtype: QByteArray
%End

Expand Down Expand Up @@ -701,9 +754,9 @@ The display name of the Authentication Manager
%Docstring
Custom logging signal to inform the user about master password <-> password manager interactions
@see QgsMessageLog
@param message Message to send
@param tag Associated tag (title)
@param level Message log level
\param message Message to send
\param tag Associated tag (title)
\param level Message log level
%End


Expand Down
2 changes: 1 addition & 1 deletion src/app/qgisapp.cpp
Expand Up @@ -12672,7 +12672,7 @@ void QgisApp::namSslErrors( QNetworkReply *reply, const QList<QSslError> &errors
QString digest( QgsAuthCertUtils::shaHexForCert( reply->sslConfiguration().peerCertificate() ) );
QString dgsthostport( QStringLiteral( "%1:%2" ).arg( digest, hostport ) );

const QHash<QString, QSet<QSslError::SslError> > &errscache( QgsApplication::authManager()->getIgnoredSslErrorCache() );
const QHash<QString, QSet<QSslError::SslError> > &errscache( QgsApplication::authManager()->ignoredSslErrorCache() );

if ( errscache.contains( dgsthostport ) )
{
Expand Down
2 changes: 1 addition & 1 deletion src/auth/identcert/qgsauthidentcertedit.cpp
Expand Up @@ -75,7 +75,7 @@ void QgsAuthIdentCertEdit::populateIdentityComboBox()
{
cmbIdentityCert->addItem( tr( "Select identity..." ), "" );

QList<QSslCertificate> certs( QgsApplication::authManager()->getCertIdentities() );
QList<QSslCertificate> certs( QgsApplication::authManager()->certIdentities() );
if ( !certs.isEmpty() )
{
cmbIdentityCert->setIconSize( QSize( 26, 22 ) );
Expand Down
4 changes: 2 additions & 2 deletions src/auth/identcert/qgsauthidentcertmethod.cpp
Expand Up @@ -144,7 +144,7 @@ bool QgsAuthIdentCertMethod::updateDataSourceUriItems( QStringList &connectionIt
// save CAs to temp file
QString caFilePath = QgsAuthCertUtils::pemTextToTempFile(
pkiTempFileBase.arg( QUuid::createUuid().toString() ),
QgsApplication::authManager()->getTrustedCaCertsPemText() );
QgsApplication::authManager()->trustedCaCertsPemText() );
if ( caFilePath.isEmpty() )
{
return false;
Expand Down Expand Up @@ -246,7 +246,7 @@ QgsPkiConfigBundle *QgsAuthIdentCertMethod::getPkiConfigBundle( const QString &a
}

// get identity from database
QPair<QSslCertificate, QSslKey> cibundle( QgsApplication::authManager()->getCertIdentityBundle( mconfig.config( QStringLiteral( "certid" ) ) ) );
QPair<QSslCertificate, QSslKey> cibundle( QgsApplication::authManager()->certIdentityBundle( mconfig.config( QStringLiteral( "certid" ) ) ) );

// init client cert
// Note: if this is not valid, no sense continuing
Expand Down
6 changes: 3 additions & 3 deletions src/auth/pkipaths/qgsauthpkipathsmethod.cpp
Expand Up @@ -161,17 +161,17 @@ bool QgsAuthPkiPathsMethod::updateDataSourceUriItems( QStringList &connectionIte
{
if ( pkibundle->config().config( QStringLiteral( "addrootca" ), QStringLiteral( "false" ) ) == QStringLiteral( "true" ) )
{
cas = QgsAuthCertUtils::casMerge( QgsApplication::authManager()->getTrustedCaCerts(), pkibundle->caChain() );
cas = QgsAuthCertUtils::casMerge( QgsApplication::authManager()->trustedCaCerts(), pkibundle->caChain() );
}
else
{
cas = QgsAuthCertUtils::casMerge( QgsApplication::authManager()->getTrustedCaCerts(),
cas = QgsAuthCertUtils::casMerge( QgsApplication::authManager()->trustedCaCerts(),
QgsAuthCertUtils::casRemoveSelfSigned( pkibundle->caChain() ) );
}
}
else
{
cas = QgsApplication::authManager()->getTrustedCaCerts();
cas = QgsApplication::authManager()->trustedCaCerts();
}

// save CAs to temp file
Expand Down
6 changes: 3 additions & 3 deletions src/auth/pkipkcs12/qgsauthpkcs12method.cpp
Expand Up @@ -161,17 +161,17 @@ bool QgsAuthPkcs12Method::updateDataSourceUriItems( QStringList &connectionItems
{
if ( pkibundle->config().config( QStringLiteral( "addrootca" ), QStringLiteral( "false" ) ) == QStringLiteral( "true" ) )
{
cas = QgsAuthCertUtils::casMerge( QgsApplication::authManager()->getTrustedCaCerts(), pkibundle->caChain() );
cas = QgsAuthCertUtils::casMerge( QgsApplication::authManager()->trustedCaCerts(), pkibundle->caChain() );
}
else
{
cas = QgsAuthCertUtils::casMerge( QgsApplication::authManager()->getTrustedCaCerts(),
cas = QgsAuthCertUtils::casMerge( QgsApplication::authManager()->trustedCaCerts(),
QgsAuthCertUtils::casRemoveSelfSigned( pkibundle->caChain() ) );
}
}
else
{
cas = QgsApplication::authManager()->getTrustedCaCerts();
cas = QgsApplication::authManager()->trustedCaCerts();
}

// save CAs to temp file
Expand Down
6 changes: 3 additions & 3 deletions src/core/auth/qgsauthcertutils.cpp
Expand Up @@ -947,9 +947,9 @@ QList<QgsAuthCertUtils::CertUsageType> QgsAuthCertUtils::certificateUsageTypes(

// ask QCA what it thinks about potential usages
QCA::CertificateCollection trustedCAs(
qtCertsToQcaCollection( QgsApplication::authManager()->getTrustedCaCertsCache() ) );
qtCertsToQcaCollection( QgsApplication::authManager()->trustedCaCertsCache() ) );
QCA::CertificateCollection untrustedCAs(
qtCertsToQcaCollection( QgsApplication::authManager()->getUntrustedCaCerts() ) );
qtCertsToQcaCollection( QgsApplication::authManager()->untrustedCaCerts() ) );

QCA::Validity v_any;
v_any = qcacert.validate( trustedCAs, untrustedCAs, QCA::UsageAny, QCA::ValidateAll );
Expand Down Expand Up @@ -1251,7 +1251,7 @@ QList<QSslError> QgsAuthCertUtils::validateCertChain( const QList<QSslCertificat
for ( const auto &cert : certificateChain )
{
bool untrusted = false;
for ( const auto &untrustedCert : QgsApplication::authManager()->getUntrustedCaCerts() )
for ( const auto &untrustedCert : QgsApplication::authManager()->untrustedCaCerts() )
{
if ( cert.digest( ) == untrustedCert.digest( ) )
{
Expand Down

0 comments on commit d64529f

Please sign in to comment.