mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2025-05-20 07:26:58 -04:00
Credentials autocompleting (secure version) (#179)
This commit is contained in:
@@ -9,9 +9,12 @@
|
||||
#include <plog/Log.h>
|
||||
#include <QWebEngineProfile>
|
||||
#include <QWebEngineCookieStore>
|
||||
#include <keychain.h>
|
||||
|
||||
#include "gphelper.h"
|
||||
|
||||
using namespace QKeychain;
|
||||
|
||||
QNetworkAccessManager* gpclient::helper::networkManager = new QNetworkAccessManager;
|
||||
|
||||
QNetworkReply* gpclient::helper::createRequest(QString url, QByteArray params)
|
||||
@@ -138,3 +141,38 @@ void gpclient::helper::settings::clear()
|
||||
|
||||
QWebEngineProfile::defaultProfile()->cookieStore()->deleteAllCookies();
|
||||
}
|
||||
|
||||
|
||||
bool gpclient::helper::settings::secureSave(const QString &key, const QString &value) {
|
||||
WritePasswordJob job( QLatin1String("gpclient") );
|
||||
job.setAutoDelete( false );
|
||||
job.setKey( key );
|
||||
job.setTextData( value );
|
||||
QEventLoop loop;
|
||||
job.connect( &job, SIGNAL(finished(QKeychain::Job*)), &loop, SLOT(quit()) );
|
||||
job.start();
|
||||
loop.exec();
|
||||
if ( job.error() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool gpclient::helper::settings::secureGet(const QString &key, QString &value) {
|
||||
ReadPasswordJob job( QLatin1String("gpclient") );
|
||||
job.setAutoDelete( false );
|
||||
job.setKey( key );
|
||||
QEventLoop loop;
|
||||
job.connect( &job, SIGNAL(finished(QKeychain::Job*)), &loop, SLOT(quit()) );
|
||||
job.start();
|
||||
loop.exec();
|
||||
|
||||
const QString pw = job.textData();
|
||||
if ( job.error() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
value = pw;
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user