2013-07-29 16:28:45 +04:00
|
|
|
/*
|
|
|
|
* Copyright (C) by Krzesimir Nowak <krzesimir@endocode.com>
|
2013-07-30 12:48:26 +04:00
|
|
|
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
|
2013-07-29 16:28:45 +04:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2014-02-06 16:00:57 +04:00
|
|
|
#include <QSettings>
|
2014-02-25 17:22:01 +04:00
|
|
|
#include <QNetworkReply>
|
2014-03-27 20:58:31 +04:00
|
|
|
#include <QMessageBox>
|
2014-06-17 16:53:06 +04:00
|
|
|
#include <QAuthenticator>
|
2014-05-14 13:11:45 +04:00
|
|
|
#include <QDebug>
|
2013-10-23 16:48:44 +04:00
|
|
|
|
2013-07-30 13:19:22 +04:00
|
|
|
#include "creds/shibbolethcredentials.h"
|
|
|
|
#include "creds/shibboleth/shibbolethwebview.h"
|
2014-05-14 13:11:45 +04:00
|
|
|
#include "creds/shibbolethcredentials.h"
|
2014-03-27 20:58:31 +04:00
|
|
|
#include "shibboleth/shibbolethuserjob.h"
|
2013-08-06 13:50:08 +04:00
|
|
|
#include "creds/credentialscommon.h"
|
2014-02-06 16:00:57 +04:00
|
|
|
|
2014-11-10 01:25:57 +03:00
|
|
|
#include "accessmanager.h"
|
2014-07-11 02:31:24 +04:00
|
|
|
#include "account.h"
|
|
|
|
#include "theme.h"
|
|
|
|
#include "cookiejar.h"
|
2015-01-16 17:18:01 +03:00
|
|
|
#include "syncengine.h"
|
2014-02-06 16:00:57 +04:00
|
|
|
|
2015-02-04 15:03:28 +03:00
|
|
|
#include <keychain.h>
|
2014-02-06 16:00:57 +04:00
|
|
|
|
|
|
|
using namespace QKeychain;
|
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
|
|
|
{
|
|
|
|
|
2013-08-05 19:31:52 +04:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
|
2014-05-13 13:52:46 +04:00
|
|
|
// Not "user" because it has a special meaning for http
|
|
|
|
const char userC[] = "shib_user";
|
2014-05-14 13:11:45 +04:00
|
|
|
const char shibCookieNameC[] = "_shibsession_";
|
2014-03-27 20:58:31 +04:00
|
|
|
|
2013-08-05 19:31:52 +04:00
|
|
|
} // ns
|
|
|
|
|
2013-07-29 16:28:45 +04:00
|
|
|
ShibbolethCredentials::ShibbolethCredentials()
|
2013-11-04 19:36:23 +04:00
|
|
|
: AbstractCredentials(),
|
|
|
|
_url(),
|
2013-07-29 16:28:45 +04:00
|
|
|
_ready(false),
|
2014-02-25 17:22:01 +04:00
|
|
|
_stillValid(false),
|
2014-06-02 19:41:32 +04:00
|
|
|
_fetchJobInProgress(false),
|
2014-05-14 13:11:45 +04:00
|
|
|
_browser(0)
|
2013-07-29 16:28:45 +04:00
|
|
|
{}
|
|
|
|
|
2015-01-16 17:18:01 +03:00
|
|
|
ShibbolethCredentials::ShibbolethCredentials(const QNetworkCookie& cookie)
|
2014-06-24 13:41:29 +04:00
|
|
|
: _ready(true),
|
|
|
|
_stillValid(true),
|
|
|
|
_fetchJobInProgress(false),
|
|
|
|
_browser(0),
|
|
|
|
_shibCookie(cookie)
|
|
|
|
{
|
2015-01-16 17:18:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ShibbolethCredentials::setAccount(Account* account)
|
|
|
|
{
|
|
|
|
AbstractCredentials::setAccount(account);
|
|
|
|
|
2015-01-28 17:15:12 +03:00
|
|
|
// When constructed with a cookie (by the wizard), we usually don't know the
|
|
|
|
// user name yet. Request it now.
|
|
|
|
if (_ready && _user.isEmpty()) {
|
|
|
|
QTimer::singleShot(1234, this, SLOT(slotFetchUser()));
|
2014-06-24 13:41:29 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-06 13:50:08 +04:00
|
|
|
void ShibbolethCredentials::syncContextPreInit(CSYNC* ctx)
|
|
|
|
{
|
|
|
|
csync_set_auth_callback (ctx, handleNeonSSLProblems);
|
|
|
|
}
|
2013-07-29 16:44:54 +04:00
|
|
|
|
2013-08-05 19:31:52 +04:00
|
|
|
QByteArray ShibbolethCredentials::prepareCookieData() const
|
|
|
|
{
|
|
|
|
QString cookiesAsString;
|
2015-01-16 17:18:01 +03:00
|
|
|
QList<QNetworkCookie> cookies = accountCookies(_account);
|
2013-08-05 20:39:26 +04:00
|
|
|
|
2014-05-14 13:11:45 +04:00
|
|
|
foreach(const QNetworkCookie &cookie, cookies) {
|
|
|
|
cookiesAsString += cookie.toRawForm(QNetworkCookie::NameAndValueOnly) + QLatin1String("; ");
|
2013-08-05 19:31:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return cookiesAsString.toLatin1();
|
|
|
|
}
|
|
|
|
|
2013-07-29 16:44:54 +04:00
|
|
|
void ShibbolethCredentials::syncContextPreStart (CSYNC* ctx)
|
2013-07-29 16:28:45 +04:00
|
|
|
{
|
2013-08-05 19:31:52 +04:00
|
|
|
csync_set_module_property(ctx, "session_key", prepareCookieData().data());
|
2013-07-29 16:28:45 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ShibbolethCredentials::changed(AbstractCredentials* credentials) const
|
|
|
|
{
|
2014-05-15 13:12:09 +04:00
|
|
|
ShibbolethCredentials* other(qobject_cast< ShibbolethCredentials* >(credentials));
|
|
|
|
|
|
|
|
if (!other) {
|
|
|
|
return true;
|
|
|
|
}
|
2013-07-29 16:28:45 +04:00
|
|
|
|
2014-05-14 13:11:45 +04:00
|
|
|
if (_shibCookie != other->_shibCookie || _user != other->_user) {
|
2013-07-29 16:28:45 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString ShibbolethCredentials::authType() const
|
|
|
|
{
|
|
|
|
return QString::fromLatin1("shibboleth");
|
|
|
|
}
|
|
|
|
|
2013-11-13 16:59:35 +04:00
|
|
|
QString ShibbolethCredentials::user() const
|
|
|
|
{
|
2014-03-27 20:58:31 +04:00
|
|
|
return _user;
|
2013-11-13 16:59:35 +04:00
|
|
|
}
|
|
|
|
|
2013-07-29 16:28:45 +04:00
|
|
|
QNetworkAccessManager* ShibbolethCredentials::getQNAM() const
|
|
|
|
{
|
2014-11-10 00:30:29 +03:00
|
|
|
QNetworkAccessManager* qnam(new AccessManager);
|
2014-02-25 17:22:01 +04:00
|
|
|
connect(qnam, SIGNAL(finished(QNetworkReply*)),
|
|
|
|
this, SLOT(slotReplyFinished(QNetworkReply*)));
|
2013-07-30 14:56:27 +04:00
|
|
|
return qnam;
|
2013-07-29 16:28:45 +04:00
|
|
|
}
|
|
|
|
|
2014-02-25 17:22:01 +04:00
|
|
|
void ShibbolethCredentials::slotReplyFinished(QNetworkReply* r)
|
|
|
|
{
|
2014-05-28 04:29:14 +04:00
|
|
|
if (!_browser.isNull()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-02-25 17:22:01 +04:00
|
|
|
QVariant target = r->attribute(QNetworkRequest::RedirectionTargetAttribute);
|
|
|
|
if (target.isValid()) {
|
|
|
|
_stillValid = false;
|
|
|
|
qWarning() << Q_FUNC_INFO << "detected redirect, will open Login Window"; // will be done in NetworkJob's finished signal
|
|
|
|
} else {
|
|
|
|
//_stillValid = true; // gets set when reading from keychain or getting it from browser
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-29 16:28:45 +04:00
|
|
|
bool ShibbolethCredentials::ready() const
|
|
|
|
{
|
|
|
|
return _ready;
|
|
|
|
}
|
|
|
|
|
2015-09-05 16:39:22 +03:00
|
|
|
void ShibbolethCredentials::fetchFromKeychain()
|
2013-07-29 16:28:45 +04:00
|
|
|
{
|
2014-06-02 19:41:32 +04:00
|
|
|
if(_fetchJobInProgress) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-03-27 20:58:31 +04:00
|
|
|
if (_user.isEmpty()) {
|
2015-01-16 17:18:01 +03:00
|
|
|
_user = _account->credentialSetting(QLatin1String(userC)).toString();
|
2014-03-27 20:58:31 +04:00
|
|
|
}
|
2013-07-29 16:28:45 +04:00
|
|
|
if (_ready) {
|
2014-06-02 19:41:32 +04:00
|
|
|
_fetchJobInProgress = false;
|
2013-07-29 16:28:45 +04:00
|
|
|
Q_EMIT fetched();
|
|
|
|
} else {
|
2015-01-16 17:18:01 +03:00
|
|
|
_url = _account->url();
|
2014-02-06 16:00:57 +04:00
|
|
|
ReadPasswordJob *job = new ReadPasswordJob(Theme::instance()->appName());
|
2015-06-15 16:04:39 +03:00
|
|
|
job->setSettings(_account->settingsWithGroup(Theme::instance()->appName(), job).release());
|
2014-02-06 16:00:57 +04:00
|
|
|
job->setInsecureFallback(false);
|
2015-01-16 17:18:01 +03:00
|
|
|
job->setKey(keychainKey(_account->url().toString(), "shibAssertion"));
|
2014-02-06 16:00:57 +04:00
|
|
|
connect(job, SIGNAL(finished(QKeychain::Job*)), SLOT(slotReadJobDone(QKeychain::Job*)));
|
|
|
|
job->start();
|
2014-06-02 19:41:32 +04:00
|
|
|
_fetchJobInProgress = true;
|
2013-07-29 16:28:45 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-05 16:39:22 +03:00
|
|
|
void ShibbolethCredentials::askFromUser()
|
|
|
|
{
|
|
|
|
showLoginWindow();
|
|
|
|
}
|
|
|
|
|
2013-11-22 17:01:11 +04:00
|
|
|
bool ShibbolethCredentials::stillValid(QNetworkReply *reply)
|
|
|
|
{
|
|
|
|
Q_UNUSED(reply)
|
2014-02-25 17:22:01 +04:00
|
|
|
return _stillValid;
|
2013-11-22 17:01:11 +04:00
|
|
|
}
|
|
|
|
|
2015-01-16 17:18:01 +03:00
|
|
|
void ShibbolethCredentials::persist()
|
2013-07-29 16:28:45 +04:00
|
|
|
{
|
2015-01-16 17:18:01 +03:00
|
|
|
storeShibCookie(_shibCookie);
|
2014-05-14 13:11:45 +04:00
|
|
|
if (!_user.isEmpty()) {
|
2015-01-16 17:18:01 +03:00
|
|
|
_account->setCredentialSetting(QLatin1String(userC), _user);
|
2014-05-14 13:11:45 +04:00
|
|
|
}
|
2013-07-29 16:28:45 +04:00
|
|
|
}
|
|
|
|
|
2015-01-16 17:18:01 +03:00
|
|
|
void ShibbolethCredentials::invalidateToken()
|
2013-11-23 03:14:02 +04:00
|
|
|
{
|
2015-09-04 23:28:21 +03:00
|
|
|
_ready = false;
|
|
|
|
_fetchJobInProgress = true;
|
|
|
|
|
2015-01-16 17:18:01 +03:00
|
|
|
CookieJar *jar = static_cast<CookieJar*>(_account->networkAccessManager()->cookieJar());
|
2014-11-27 14:19:22 +03:00
|
|
|
|
|
|
|
// Remove the _shibCookie
|
|
|
|
auto cookies = jar->allCookies();
|
|
|
|
for (auto it = cookies.begin(); it != cookies.end(); ) {
|
|
|
|
if (it->name() == _shibCookie.name()) {
|
|
|
|
it = cookies.erase(it);
|
|
|
|
} else {
|
|
|
|
++it;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
jar->setAllCookies(cookies);
|
|
|
|
|
|
|
|
// Clear all other temporary cookies
|
2014-05-28 17:24:14 +04:00
|
|
|
jar->clearSessionCookies();
|
2015-01-16 17:18:01 +03:00
|
|
|
removeShibCookie();
|
2014-02-06 16:00:57 +04:00
|
|
|
_shibCookie = QNetworkCookie();
|
2013-11-23 03:14:02 +04:00
|
|
|
// ### access to ctx missing, but might not be required at all
|
|
|
|
//csync_set_module_property(ctx, "session_key", "");
|
|
|
|
}
|
|
|
|
|
2015-01-16 17:18:01 +03:00
|
|
|
void ShibbolethCredentials::onShibbolethCookieReceived(const QNetworkCookie& shibCookie)
|
2013-07-29 16:28:45 +04:00
|
|
|
{
|
2015-01-16 17:18:01 +03:00
|
|
|
storeShibCookie(shibCookie);
|
2014-05-14 13:11:45 +04:00
|
|
|
_shibCookie = shibCookie;
|
|
|
|
addToCookieJar(shibCookie);
|
2014-03-27 20:58:31 +04:00
|
|
|
|
2015-01-28 17:15:12 +03:00
|
|
|
slotFetchUser();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ShibbolethCredentials::slotFetchUser()
|
|
|
|
{
|
|
|
|
// We must first do a request to webdav so the session is enabled.
|
2014-03-27 20:58:31 +04:00
|
|
|
// (because for some reason we wan't access the API without that.. a bug in the server maybe?)
|
2015-01-16 17:18:01 +03:00
|
|
|
EntityExistsJob* job = new EntityExistsJob(_account->sharedFromThis(), _account->davPath(), this);
|
2015-01-28 17:15:12 +03:00
|
|
|
connect(job, SIGNAL(exists(QNetworkReply*)), this, SLOT(slotFetchUserHelper()));
|
2014-03-27 20:58:31 +04:00
|
|
|
job->setIgnoreCredentialFailure(true);
|
|
|
|
job->start();
|
|
|
|
}
|
|
|
|
|
2015-01-28 17:15:12 +03:00
|
|
|
void ShibbolethCredentials::slotFetchUserHelper()
|
2014-03-27 20:58:31 +04:00
|
|
|
{
|
2015-01-16 17:18:01 +03:00
|
|
|
ShibbolethUserJob *job = new ShibbolethUserJob(_account->sharedFromThis(), this);
|
2014-03-27 20:58:31 +04:00
|
|
|
connect(job, SIGNAL(userFetched(QString)), this, SLOT(slotUserFetched(QString)));
|
|
|
|
job->start();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ShibbolethCredentials::slotUserFetched(const QString &user)
|
|
|
|
{
|
|
|
|
if (_user.isEmpty()) {
|
2015-01-28 17:15:12 +03:00
|
|
|
if (user.isEmpty()) {
|
|
|
|
qDebug() << "Failed to fetch the shibboleth user";
|
|
|
|
}
|
2014-03-27 20:58:31 +04:00
|
|
|
_user = user;
|
|
|
|
} else if (user != _user) {
|
|
|
|
qDebug() << "Wrong user: " << user << "!=" << _user;
|
2014-03-27 21:19:56 +04:00
|
|
|
QMessageBox::warning(_browser, tr("Login Error"), tr("You must sign in as user %1").arg(_user));
|
2015-01-16 17:18:01 +03:00
|
|
|
invalidateToken();
|
|
|
|
showLoginWindow();
|
2014-03-27 20:58:31 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_stillValid = true;
|
|
|
|
_ready = true;
|
2014-06-02 19:41:32 +04:00
|
|
|
_fetchJobInProgress = false;
|
2015-09-05 16:39:22 +03:00
|
|
|
Q_EMIT asked();
|
2013-07-29 16:28:45 +04:00
|
|
|
}
|
|
|
|
|
2014-03-27 20:58:31 +04:00
|
|
|
|
2014-05-28 12:18:57 +04:00
|
|
|
void ShibbolethCredentials::slotBrowserRejected()
|
2013-08-07 16:00:47 +04:00
|
|
|
{
|
|
|
|
_ready = false;
|
2014-06-02 19:41:32 +04:00
|
|
|
_fetchJobInProgress = false;
|
2015-09-05 16:39:22 +03:00
|
|
|
Q_EMIT asked();
|
2013-08-07 16:00:47 +04:00
|
|
|
}
|
|
|
|
|
2014-02-06 16:00:57 +04:00
|
|
|
void ShibbolethCredentials::slotReadJobDone(QKeychain::Job *job)
|
|
|
|
{
|
|
|
|
if (job->error() == QKeychain::NoError) {
|
|
|
|
ReadPasswordJob *readJob = static_cast<ReadPasswordJob*>(job);
|
|
|
|
delete readJob->settings();
|
|
|
|
QList<QNetworkCookie> cookies = QNetworkCookie::parseCookies(readJob->textData().toUtf8());
|
|
|
|
if (cookies.count() > 0) {
|
|
|
|
_shibCookie = cookies.first();
|
2014-05-14 13:11:45 +04:00
|
|
|
addToCookieJar(_shibCookie);
|
2014-02-06 16:00:57 +04:00
|
|
|
}
|
2014-05-14 13:11:45 +04:00
|
|
|
// access
|
2015-06-15 16:04:39 +03:00
|
|
|
job->setSettings(_account->settingsWithGroup(Theme::instance()->appName(), job).release());
|
2014-02-06 16:00:57 +04:00
|
|
|
|
|
|
|
_ready = true;
|
2014-02-25 17:22:01 +04:00
|
|
|
_stillValid = true;
|
2014-06-02 19:41:32 +04:00
|
|
|
_fetchJobInProgress = false;
|
2014-02-06 16:00:57 +04:00
|
|
|
Q_EMIT fetched();
|
2015-09-01 16:37:58 +03:00
|
|
|
} else {
|
|
|
|
_ready = false;
|
|
|
|
_fetchJobInProgress = false;
|
|
|
|
Q_EMIT fetched();
|
2014-02-25 17:22:01 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-16 17:18:01 +03:00
|
|
|
void ShibbolethCredentials::showLoginWindow()
|
2014-02-25 17:22:01 +04:00
|
|
|
{
|
2014-05-14 13:11:45 +04:00
|
|
|
if (!_browser.isNull()) {
|
2014-02-25 17:22:01 +04:00
|
|
|
_browser->activateWindow();
|
|
|
|
_browser->raise();
|
|
|
|
// FIXME On OS X this does not raise properly
|
|
|
|
return;
|
2014-02-06 16:00:57 +04:00
|
|
|
}
|
2014-06-20 17:18:38 +04:00
|
|
|
|
2015-01-16 17:18:01 +03:00
|
|
|
CookieJar *jar = static_cast<CookieJar*>(_account->networkAccessManager()->cookieJar());
|
2014-06-20 17:18:38 +04:00
|
|
|
// When opening a new window clear all the session cookie that might keep the user from logging in
|
|
|
|
// (or the session may already be open in the server, and there will not be redirect asking for the
|
|
|
|
// real long term cookie we want to store)
|
|
|
|
jar->clearSessionCookies();
|
|
|
|
|
2015-01-16 17:18:01 +03:00
|
|
|
_browser = new ShibbolethWebView(_account->sharedFromThis());
|
2015-01-26 17:56:57 +03:00
|
|
|
connect(_browser, SIGNAL(shibbolethCookieReceived(QNetworkCookie)),
|
|
|
|
this, SLOT(onShibbolethCookieReceived(QNetworkCookie)), Qt::QueuedConnection);
|
2014-05-28 12:18:57 +04:00
|
|
|
connect(_browser, SIGNAL(rejected()), this, SLOT(slotBrowserRejected()));
|
2014-02-25 17:22:01 +04:00
|
|
|
|
|
|
|
_browser->show();
|
2014-02-06 16:00:57 +04:00
|
|
|
}
|
|
|
|
|
2015-01-16 17:18:01 +03:00
|
|
|
QList<QNetworkCookie> ShibbolethCredentials::accountCookies(Account* account)
|
2014-05-14 13:11:45 +04:00
|
|
|
{
|
2014-07-28 15:50:24 +04:00
|
|
|
return account->networkAccessManager()->cookieJar()->cookiesForUrl(account->davUrl());
|
2014-05-14 13:11:45 +04:00
|
|
|
}
|
|
|
|
|
2015-01-16 17:18:01 +03:00
|
|
|
QNetworkCookie ShibbolethCredentials::findShibCookie(Account* account, QList<QNetworkCookie> cookies)
|
2014-05-14 13:11:45 +04:00
|
|
|
{
|
|
|
|
if(cookies.isEmpty()) {
|
|
|
|
cookies = accountCookies(account);
|
|
|
|
}
|
|
|
|
|
|
|
|
Q_FOREACH(QNetworkCookie cookie, cookies) {
|
|
|
|
if (cookie.name().startsWith(shibCookieNameC)) {
|
|
|
|
return cookie;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return QNetworkCookie();
|
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray ShibbolethCredentials::shibCookieName()
|
|
|
|
{
|
|
|
|
return QByteArray(shibCookieNameC);
|
|
|
|
}
|
|
|
|
|
2015-01-16 17:18:01 +03:00
|
|
|
void ShibbolethCredentials::storeShibCookie(const QNetworkCookie &cookie)
|
2014-02-06 16:00:57 +04:00
|
|
|
{
|
|
|
|
WritePasswordJob *job = new WritePasswordJob(Theme::instance()->appName());
|
2015-06-15 16:04:39 +03:00
|
|
|
job->setSettings(_account->settingsWithGroup(Theme::instance()->appName(), job).release());
|
2014-02-06 16:00:57 +04:00
|
|
|
// we don't really care if it works...
|
|
|
|
//connect(job, SIGNAL(finished(QKeychain::Job*)), SLOT(slotWriteJobDone(QKeychain::Job*)));
|
2015-01-16 17:18:01 +03:00
|
|
|
job->setKey(keychainKey(_account->url().toString(), "shibAssertion"));
|
2014-02-06 16:00:57 +04:00
|
|
|
job->setTextData(QString::fromUtf8(cookie.toRawForm()));
|
|
|
|
job->start();
|
|
|
|
}
|
|
|
|
|
2015-01-16 17:18:01 +03:00
|
|
|
void ShibbolethCredentials::removeShibCookie()
|
2014-05-14 13:11:45 +04:00
|
|
|
{
|
|
|
|
DeletePasswordJob *job = new DeletePasswordJob(Theme::instance()->appName());
|
2015-06-15 16:04:39 +03:00
|
|
|
job->setSettings(_account->settingsWithGroup(Theme::instance()->appName(), job).release());
|
2015-01-16 17:18:01 +03:00
|
|
|
job->setKey(keychainKey(_account->url().toString(), "shibAssertion"));
|
2014-05-14 13:11:45 +04:00
|
|
|
job->start();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ShibbolethCredentials::addToCookieJar(const QNetworkCookie &cookie)
|
|
|
|
{
|
|
|
|
QList<QNetworkCookie> cookies;
|
|
|
|
cookies << cookie;
|
2015-01-16 17:18:01 +03:00
|
|
|
QNetworkCookieJar *jar = _account->networkAccessManager()->cookieJar();
|
2014-05-14 13:11:45 +04:00
|
|
|
jar->blockSignals(true); // otherwise we'd call ourselves
|
2015-01-16 17:18:01 +03:00
|
|
|
jar->setCookiesFromUrl(cookies, _account->url());
|
2014-05-14 13:11:45 +04:00
|
|
|
jar->blockSignals(false);
|
|
|
|
}
|
|
|
|
|
2014-03-27 20:58:31 +04:00
|
|
|
|
2014-11-10 00:34:07 +03:00
|
|
|
} // namespace OCC
|