19 #include <QTextStream>
28 QgsDebugMsg( QStringLiteral(
"already registered an instance of QgsCredentials" ) );
42 bool QgsCredentials::get(
const QString &realm, QString &username, QString &password,
const QString &message )
45 const QMutexLocker locker( &mCacheMutex );
46 if ( mCredentialCache.contains( realm ) )
48 const QPair<QString, QString> credentials = mCredentialCache.take( realm );
49 username = credentials.first;
50 password = credentials.second;
51 QgsDebugMsgLevel( QStringLiteral(
"retrieved realm:%1 username:%2" ).arg( realm, username ), 2 );
53 if ( !password.isNull() )
58 if (
request( realm, username, password, message ) )
60 QgsDebugMsgLevel( QStringLiteral(
"requested realm:%1 username:%2" ).arg( realm, username ), 2 );
72 const QMutexLocker locker( &mCacheMutex );
73 QgsDebugMsgLevel( QStringLiteral(
"inserting realm:%1 username:%2" ).arg( realm, username ), 2 );
74 mCredentialCache.insert( realm, QPair<QString, QString>( username, password ) );
109 Q_UNUSED( username );
110 Q_UNUSED( password );
117 Q_UNUSED( password );
132 QTextStream in( stdin, QIODevice::ReadOnly );
133 QTextStream out( stdout, QIODevice::WriteOnly );
135 #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
136 out <<
"credentials for " << realm << endl;
138 out <<
"credentials for " << realm << Qt::endl;
140 if ( !message.isEmpty() )
141 #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
142 out <<
"message: " << message << endl;
144 out <<
"message: " << message << Qt::endl;
158 QTextStream in( stdin, QIODevice::ReadOnly );
159 QTextStream out( stdout, QIODevice::WriteOnly );
161 const QString msg( stored ?
"Master password for authentication configs: " :
"Set master password for authentication configs: " );