19 #include <QTextStream>
27 QgsDebugMsg( QStringLiteral(
"already registered an instance of QgsCredentials" ) );
41 bool QgsCredentials::get(
const QString &realm, QString &username, QString &password,
const QString &message )
44 QMutexLocker locker( &mCacheMutex );
45 if ( mCredentialCache.contains( realm ) )
47 QPair<QString, QString> credentials = mCredentialCache.take( realm );
48 username = credentials.first;
49 password = credentials.second;
50 QgsDebugMsgLevel( QStringLiteral(
"retrieved realm:%1 username:%2" ).arg( realm, username ), 2 );
52 if ( !password.isNull() )
57 if (
request( realm, username, password, message ) )
59 QgsDebugMsgLevel( QStringLiteral(
"requested realm:%1 username:%2" ).arg( realm, username ), 2 );
71 QMutexLocker locker( &mCacheMutex );
72 QgsDebugMsgLevel( QStringLiteral(
"inserting realm:%1 username:%2" ).arg( realm, username ), 2 );
73 mCredentialCache.insert( realm, QPair<QString, QString>( username, password ) );
108 Q_UNUSED( username );
109 Q_UNUSED( password );
116 Q_UNUSED( password );
131 QTextStream in( stdin, QIODevice::ReadOnly );
132 QTextStream out( stdout, QIODevice::WriteOnly );
134 #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
135 out <<
"credentials for " << realm << endl;
137 out <<
"credentials for " << realm << Qt::endl;
139 if ( !message.isEmpty() )
140 #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
141 out <<
"message: " << message << endl;
143 out <<
"message: " << message << Qt::endl;
157 QTextStream in( stdin, QIODevice::ReadOnly );
158 QTextStream out( stdout, QIODevice::WriteOnly );
160 QString msg( stored ?
"Master password for authentication configs: " :
"Set master password for authentication configs: " );