2013-07-29 16:28:45 +04:00
|
|
|
/*
|
|
|
|
* Copyright (C) by Krzesimir Nowak <krzesimir@endocode.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
2016-10-25 12:00:07 +03:00
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
2013-07-29 16:28:45 +04:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MIRALL_CREDS_SHIBBOLETH_CREDENTIALS_H
|
|
|
|
#define MIRALL_CREDS_SHIBBOLETH_CREDENTIALS_H
|
|
|
|
|
2013-08-06 18:17:55 +04:00
|
|
|
#include <QList>
|
2017-05-09 15:24:11 +03:00
|
|
|
#include <QLoggingCategory>
|
2013-08-06 18:17:55 +04:00
|
|
|
#include <QMap>
|
2013-07-29 16:28:45 +04:00
|
|
|
#include <QNetworkCookie>
|
2013-08-06 18:17:55 +04:00
|
|
|
#include <QUrl>
|
2014-05-14 13:11:45 +04:00
|
|
|
#include <QPointer>
|
2013-07-29 16:28:45 +04:00
|
|
|
|
2013-07-30 13:19:22 +04:00
|
|
|
#include "creds/abstractcredentials.h"
|
2013-07-29 16:28:45 +04:00
|
|
|
|
2014-02-06 16:00:57 +04:00
|
|
|
namespace QKeychain {
|
|
|
|
class Job;
|
|
|
|
}
|
|
|
|
|
2014-06-17 16:53:06 +04:00
|
|
|
class QAuthenticator;
|
|
|
|
|
2014-11-10 00:34:07 +03:00
|
|
|
namespace OCC {
|
2013-07-29 16:28:45 +04:00
|
|
|
|
2017-05-09 15:24:11 +03:00
|
|
|
Q_DECLARE_LOGGING_CATEGORY(lcShibboleth)
|
|
|
|
|
2013-07-29 16:28:45 +04:00
|
|
|
class ShibbolethWebView;
|
|
|
|
|
2015-06-29 19:56:09 +03:00
|
|
|
/**
|
|
|
|
* @brief The ShibbolethCredentials class
|
|
|
|
* @ingroup gui
|
2015-06-26 18:07:47 +03:00
|
|
|
*/
|
2015-06-18 11:24:40 +03:00
|
|
|
class ShibbolethCredentials : public AbstractCredentials
|
2013-07-29 16:28:45 +04:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
ShibbolethCredentials();
|
|
|
|
|
2015-10-05 07:21:19 +03:00
|
|
|
/* create credentials for an already connected account */
|
2015-01-16 17:18:01 +03:00
|
|
|
ShibbolethCredentials(const QNetworkCookie &cookie);
|
2014-06-24 13:41:29 +04:00
|
|
|
|
2018-11-11 13:09:29 +03:00
|
|
|
void setAccount(Account *account) override;
|
|
|
|
QString authType() const override;
|
|
|
|
QString user() const override;
|
|
|
|
QNetworkAccessManager *createQNAM() const override;
|
|
|
|
bool ready() const override;
|
|
|
|
void fetchFromKeychain() override;
|
|
|
|
void askFromUser() override;
|
|
|
|
bool stillValid(QNetworkReply *reply) override;
|
|
|
|
void persist() override;
|
|
|
|
void invalidateToken() override;
|
|
|
|
void forgetSensitiveData() override;
|
2013-07-29 16:28:45 +04:00
|
|
|
|
2015-01-16 17:18:01 +03:00
|
|
|
void showLoginWindow();
|
2014-02-25 17:22:01 +04:00
|
|
|
|
2015-01-16 17:18:01 +03:00
|
|
|
static QList<QNetworkCookie> accountCookies(Account *);
|
|
|
|
static QNetworkCookie findShibCookie(Account *, QList<QNetworkCookie> cookies = QList<QNetworkCookie>());
|
2014-05-14 13:11:45 +04:00
|
|
|
static QByteArray shibCookieName();
|
|
|
|
|
2013-07-29 16:28:45 +04:00
|
|
|
private Q_SLOTS:
|
2015-01-16 17:18:01 +03:00
|
|
|
void onShibbolethCookieReceived(const QNetworkCookie &);
|
2014-05-28 12:18:57 +04:00
|
|
|
void slotBrowserRejected();
|
2014-02-06 16:00:57 +04:00
|
|
|
void slotReadJobDone(QKeychain::Job *);
|
2014-02-25 17:22:01 +04:00
|
|
|
void slotReplyFinished(QNetworkReply *);
|
2014-03-27 20:58:31 +04:00
|
|
|
void slotUserFetched(const QString &user);
|
|
|
|
void slotFetchUser();
|
2015-01-28 17:15:12 +03:00
|
|
|
void slotFetchUserHelper();
|
2013-07-29 16:28:45 +04:00
|
|
|
|
2013-07-30 14:56:27 +04:00
|
|
|
Q_SIGNALS:
|
|
|
|
void newCookie(const QNetworkCookie &cookie);
|
|
|
|
|
2013-07-29 16:28:45 +04:00
|
|
|
private:
|
2015-01-16 17:18:01 +03:00
|
|
|
void storeShibCookie(const QNetworkCookie &cookie);
|
|
|
|
void removeShibCookie();
|
2014-05-14 13:11:45 +04:00
|
|
|
void addToCookieJar(const QNetworkCookie &cookie);
|
2017-09-12 18:15:22 +03:00
|
|
|
|
|
|
|
/// Reads data from keychain, progressing to slotReadJobDone
|
|
|
|
void fetchFromKeychainHelper();
|
|
|
|
|
2013-11-04 19:36:23 +04:00
|
|
|
QUrl _url;
|
2013-08-05 19:31:52 +04:00
|
|
|
QByteArray prepareCookieData() const;
|
|
|
|
|
2013-07-29 16:28:45 +04:00
|
|
|
bool _ready;
|
2014-02-25 17:22:01 +04:00
|
|
|
bool _stillValid;
|
2014-05-14 13:11:45 +04:00
|
|
|
QPointer<ShibbolethWebView> _browser;
|
|
|
|
QNetworkCookie _shibCookie;
|
2014-03-27 20:58:31 +04:00
|
|
|
QString _user;
|
2017-09-12 18:15:22 +03:00
|
|
|
bool _keychainMigration;
|
2013-07-29 16:28:45 +04:00
|
|
|
};
|
|
|
|
|
2014-11-10 00:34:07 +03:00
|
|
|
} // namespace OCC
|
2013-07-29 16:28:45 +04:00
|
|
|
|
|
|
|
#endif
|