mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-22 21:15:55 +03:00
Start with persisting credentials
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
parent
356f9b4831
commit
6b43d80c01
4 changed files with 121 additions and 0 deletions
|
@ -102,6 +102,7 @@ set(client_SRCS
|
|||
creds/credentialsfactory.cpp
|
||||
creds/httpcredentialsgui.cpp
|
||||
creds/oauth.cpp
|
||||
creds/webflowcredentials.cpp
|
||||
wizard/postfixlineedit.cpp
|
||||
wizard/abstractcredswizardpage.cpp
|
||||
wizard/owncloudadvancedsetuppage.cpp
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#ifndef NO_SHIBBOLETH
|
||||
#include "creds/shibbolethcredentials.h"
|
||||
#endif
|
||||
#include "creds/webflowcredentials.h"
|
||||
|
||||
namespace OCC {
|
||||
|
||||
|
@ -39,6 +40,8 @@ namespace CredentialsFactory {
|
|||
} else if (type == "shibboleth") {
|
||||
return new ShibbolethCredentials;
|
||||
#endif
|
||||
} else if (type == "webflow") {
|
||||
return new WebFlowCredentials;
|
||||
} else {
|
||||
qCWarning(lcGuiCredentials, "Unknown credentials type: %s", qPrintable(type));
|
||||
return new DummyCredentials;
|
||||
|
|
74
src/gui/creds/webflowcredentials.cpp
Normal file
74
src/gui/creds/webflowcredentials.cpp
Normal file
|
@ -0,0 +1,74 @@
|
|||
#include "webflowcredentials.h"
|
||||
|
||||
#include <keychain.h>
|
||||
|
||||
#include "accessmanager.h"
|
||||
#include "account.h"
|
||||
#include "theme.h"
|
||||
|
||||
using namespace QKeychain;
|
||||
|
||||
namespace OCC {
|
||||
|
||||
WebFlowCredentials::WebFlowCredentials()
|
||||
: _ready(false)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
WebFlowCredentials::WebFlowCredentials(const QString &user, const QString &password, const QSslCertificate &certificate, const QSslKey &key)
|
||||
: _user(user)
|
||||
, _password(password)
|
||||
, _clientSslKey(key)
|
||||
, _clientSslCertificate(certificate)
|
||||
, _ready(true)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QString WebFlowCredentials::authType() const {
|
||||
return QString::fromLatin1("webflow");
|
||||
}
|
||||
|
||||
QString WebFlowCredentials::user() const {
|
||||
return _user;
|
||||
}
|
||||
|
||||
QNetworkAccessManager *WebFlowCredentials::createQNAM() const {
|
||||
AccessManager *qnam = new AccessManager();
|
||||
return qnam;
|
||||
}
|
||||
|
||||
bool WebFlowCredentials::ready() const {
|
||||
|
||||
}
|
||||
|
||||
void WebFlowCredentials::fetchFromKeychain() {
|
||||
|
||||
}
|
||||
void WebFlowCredentials::askFromUser() {
|
||||
|
||||
}
|
||||
|
||||
bool WebFlowCredentials::stillValid(QNetworkReply *reply) {
|
||||
|
||||
}
|
||||
|
||||
void WebFlowCredentials::persist() {
|
||||
//TODO: Add ssl cert and key storing
|
||||
WritePasswordJob *job = new WritePasswordJob(Theme::instance()->appName());
|
||||
job->setInsecureFallback(false);
|
||||
job->setKey(keychainKey(_account->url().toString(), _user, _account->id()));
|
||||
job->setTextData(_password);
|
||||
job->start();
|
||||
}
|
||||
|
||||
void WebFlowCredentials::invalidateToken() {
|
||||
|
||||
}
|
||||
|
||||
void WebFlowCredentials::forgetSensitiveData(){
|
||||
|
||||
}
|
||||
|
||||
}
|
43
src/gui/creds/webflowcredentials.h
Normal file
43
src/gui/creds/webflowcredentials.h
Normal file
|
@ -0,0 +1,43 @@
|
|||
#ifndef WEBFLOWCREDENTIALS_H
|
||||
#define WEBFLOWCREDENTIALS_H
|
||||
|
||||
#include <QSslCertificate>
|
||||
#include <QSslKey>
|
||||
|
||||
#include "creds/abstractcredentials.h"
|
||||
|
||||
namespace OCC {
|
||||
|
||||
class WebFlowCredentials : public AbstractCredentials
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit WebFlowCredentials();
|
||||
WebFlowCredentials(const QString &user, const QString &password, const QSslCertificate &certificate = QSslCertificate(), const QSslKey &key = QSslKey());
|
||||
|
||||
QString authType() const Q_DECL_OVERRIDE;
|
||||
QString user() const Q_DECL_OVERRIDE;
|
||||
QNetworkAccessManager *createQNAM() const Q_DECL_OVERRIDE;
|
||||
|
||||
bool ready() const Q_DECL_OVERRIDE;
|
||||
|
||||
void fetchFromKeychain() Q_DECL_OVERRIDE;
|
||||
void askFromUser() Q_DECL_OVERRIDE;
|
||||
|
||||
bool stillValid(QNetworkReply *reply) Q_DECL_OVERRIDE;
|
||||
void persist() Q_DECL_OVERRIDE;
|
||||
void invalidateToken() Q_DECL_OVERRIDE;
|
||||
void forgetSensitiveData() Q_DECL_OVERRIDE;
|
||||
|
||||
private:
|
||||
QString _user;
|
||||
QString _password;
|
||||
QSslKey _clientSslKey;
|
||||
QSslCertificate _clientSslCertificate;
|
||||
|
||||
bool _ready;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // WEBFLOWCREDENTIALS_H
|
Loading…
Reference in a new issue