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
|
2013-07-30 12:48:26 +04:00
|
|
|
* the Free Software Foundation; version 2 of the License.
|
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>
|
|
|
|
#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;
|
|
|
|
|
2013-07-29 16:28:45 +04:00
|
|
|
namespace Mirall
|
|
|
|
{
|
|
|
|
|
|
|
|
class ShibbolethWebView;
|
|
|
|
|
2014-04-29 17:30:19 +04:00
|
|
|
class OWNCLOUDSYNC_EXPORT ShibbolethCredentials : public AbstractCredentials
|
2013-07-29 16:28:45 +04:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
ShibbolethCredentials();
|
|
|
|
|
2014-06-24 13:41:29 +04:00
|
|
|
/* create a credidentials for an already connected account */
|
|
|
|
ShibbolethCredentials(const QNetworkCookie &cookie, Account *acc);
|
|
|
|
|
2013-07-29 16:44:54 +04:00
|
|
|
void syncContextPreInit(CSYNC* ctx);
|
|
|
|
void syncContextPreStart(CSYNC* ctx);
|
2013-07-29 16:28:45 +04:00
|
|
|
bool changed(AbstractCredentials* credentials) const;
|
|
|
|
QString authType() const;
|
2013-11-13 16:59:35 +04:00
|
|
|
QString user() const;
|
2013-07-29 16:28:45 +04:00
|
|
|
QNetworkAccessManager* getQNAM() const;
|
|
|
|
bool ready() const;
|
2013-11-04 19:36:23 +04:00
|
|
|
void fetch(Account *account);
|
2013-11-22 17:01:11 +04:00
|
|
|
bool stillValid(QNetworkReply *reply);
|
2013-11-04 19:36:23 +04:00
|
|
|
void persist(Account *account);
|
2013-11-23 03:14:02 +04:00
|
|
|
void invalidateToken(Account *account);
|
2013-07-29 16:28:45 +04:00
|
|
|
|
2014-02-25 17:22:01 +04:00
|
|
|
void showLoginWindow(Account*);
|
|
|
|
|
2014-05-14 13:11:45 +04:00
|
|
|
static QList<QNetworkCookie> accountCookies(Account*);
|
|
|
|
static QNetworkCookie findShibCookie(Account*, QList<QNetworkCookie> cookies = QList<QNetworkCookie>());
|
|
|
|
static QByteArray shibCookieName();
|
|
|
|
|
2013-08-05 19:31:52 +04:00
|
|
|
public Q_SLOTS:
|
2013-11-22 17:01:11 +04:00
|
|
|
void invalidateAndFetch(Account *account);
|
2014-06-17 16:53:06 +04:00
|
|
|
void slotHandleAuthentication(QNetworkReply*,QAuthenticator*);
|
2013-08-05 19:31:52 +04:00
|
|
|
|
2013-07-29 16:28:45 +04:00
|
|
|
private Q_SLOTS:
|
2014-05-14 13:11:45 +04:00
|
|
|
void onShibbolethCookieReceived(const QNetworkCookie&, Account*);
|
2014-05-28 12:18:57 +04:00
|
|
|
void slotBrowserRejected();
|
2013-08-05 19:31:52 +04:00
|
|
|
void onFetched();
|
2014-02-06 16:00:57 +04:00
|
|
|
void slotReadJobDone(QKeychain::Job*);
|
2014-02-25 12:32:31 +04:00
|
|
|
void slotInvalidateAndFetchInvalidateDone(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();
|
2013-07-29 16:28:45 +04:00
|
|
|
|
2013-07-30 14:56:27 +04:00
|
|
|
Q_SIGNALS:
|
|
|
|
void newCookie(const QNetworkCookie& cookie);
|
2013-08-05 19:31:52 +04:00
|
|
|
void invalidatedAndFetched(const QByteArray& cookieData);
|
2013-07-30 14:56:27 +04:00
|
|
|
|
2013-07-29 16:28:45 +04:00
|
|
|
private:
|
2014-02-06 16:00:57 +04:00
|
|
|
void storeShibCookie(const QNetworkCookie &cookie, Account *account);
|
2014-05-14 13:11:45 +04:00
|
|
|
void removeShibCookie(Account *account);
|
|
|
|
void addToCookieJar(const QNetworkCookie &cookie);
|
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-06-02 19:41:32 +04:00
|
|
|
bool _fetchJobInProgress;
|
2014-05-14 13:11:45 +04:00
|
|
|
QPointer<ShibbolethWebView> _browser;
|
|
|
|
QNetworkCookie _shibCookie;
|
2014-03-27 20:58:31 +04:00
|
|
|
QString _user;
|
2013-07-29 16:28:45 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // ns Mirall
|
|
|
|
|
|
|
|
#endif
|