[Pkg-owncloud-commits] [owncloud-client] 15/484: Get rid of ShibbolethRefresher
Sandro Knauß
hefee-guest at moszumanska.debian.org
Wed Dec 16 00:37:03 UTC 2015
This is an automated email from the git hooks/post-receive script.
hefee-guest pushed a commit to branch master
in repository owncloud-client.
commit 94a57fe8d52dc8e44d6598b16204a307818a0a4a
Author: Jocelyn Turcotte <jturcotte at woboq.com>
Date: Fri Sep 4 22:28:21 2015 +0200
Get rid of ShibbolethRefresher
This is only for neon and not necessary if we want to show a notification
instead of a login window when the network reports invalid credentials.
---
src/gui/CMakeLists.txt | 1 -
src/gui/creds/shibboleth/shibbolethrefresher.cpp | 55 -----------------
src/gui/creds/shibboleth/shibbolethrefresher.h | 53 -----------------
src/gui/creds/shibbolethcredentials.cpp | 76 +-----------------------
src/gui/creds/shibbolethcredentials.h | 6 --
src/libsync/creds/abstractcredentials.h | 2 +-
test/CMakeLists.txt | 1 -
7 files changed, 4 insertions(+), 190 deletions(-)
diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt
index 0327470..6a20a78 100644
--- a/src/gui/CMakeLists.txt
+++ b/src/gui/CMakeLists.txt
@@ -72,7 +72,6 @@ set(client_SRCS
creds/httpcredentialsgui.cpp
creds/shibbolethcredentials.cpp
creds/shibboleth/shibbolethwebview.cpp
- creds/shibboleth/shibbolethrefresher.cpp
creds/shibboleth/shibbolethuserjob.cpp
wizard/abstractcredswizardpage.cpp
wizard/owncloudadvancedsetuppage.cpp
diff --git a/src/gui/creds/shibboleth/shibbolethrefresher.cpp b/src/gui/creds/shibboleth/shibbolethrefresher.cpp
deleted file mode 100644
index 6c38ef9..0000000
--- a/src/gui/creds/shibboleth/shibbolethrefresher.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) by Krzesimir Nowak <krzesimir at 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
- * the Free Software Foundation; version 2 of the License.
- *
- * 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.
- */
-
-#include <QEventLoop>
-
-#include "account.h"
-#include "creds/shibboleth/shibbolethrefresher.h"
-#include "creds/shibbolethcredentials.h"
-
-namespace OCC
-{
-
-ShibbolethRefresher::ShibbolethRefresher(AccountPtr account, ShibbolethCredentials* creds, CSYNC* csync_ctx, QObject* parent)
- : QObject(parent),
- _account(account),
- _creds(creds),
- _csync_ctx(csync_ctx)
-{}
-
-void ShibbolethRefresher::refresh()
-{
- QEventLoop loop;
-
- connect(_creds, SIGNAL(invalidatedAndFetched(QByteArray)),
- this, SLOT(onInvalidatedAndFetched(QByteArray)));
- connect(_creds, SIGNAL(invalidatedAndFetched(QByteArray)),
- &loop, SLOT(quit()));
- QMetaObject::invokeMethod(_creds, "invalidateAndFetch",Qt::QueuedConnection,
- Q_ARG(AccountPtr, _account));
- loop.exec();
- disconnect(_creds, SIGNAL(invalidatedAndFetched(QByteArray)),
- &loop, SLOT(quit()));
-}
-
-void ShibbolethRefresher::onInvalidatedAndFetched(const QByteArray& cookies)
-{
- // "cookies" is const and its data() return const void*. We want just void*.
- QByteArray myCookies(cookies);
-
- disconnect(_creds, SIGNAL(invalidatedAndFetched(QByteArray)),
- this, SLOT(onInvalidatedAndFetched(QByteArray)));
- csync_set_module_property(_csync_ctx, "session_key", myCookies.data());
-}
-
-} // namespace OCC
diff --git a/src/gui/creds/shibboleth/shibbolethrefresher.h b/src/gui/creds/shibboleth/shibbolethrefresher.h
deleted file mode 100644
index 2e5a7ae..0000000
--- a/src/gui/creds/shibboleth/shibbolethrefresher.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) by Krzesimir Nowak <krzesimir at 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
- * the Free Software Foundation; version 2 of the License.
- *
- * 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_REFRESHER_H
-#define MIRALL_CREDS_SHIBBOLETH_REFRESHER_H
-
-#include <QObject>
-
-#include <csync.h>
-
-class QByteArray;
-
-namespace OCC
-{
-
-class Account;
-class ShibbolethCredentials;
-
-/**
- * @brief The ShibbolethRefresher class
- * @ingroup gui
- */
-class ShibbolethRefresher : public QObject
-{
- Q_OBJECT
-
-public:
- ShibbolethRefresher(AccountPtr account, ShibbolethCredentials* creds, CSYNC* csync_ctx, QObject* parent = 0);
-
- void refresh();
-
-private Q_SLOTS:
- void onInvalidatedAndFetched(const QByteArray& cookieData);
-
-private:
- AccountPtr _account;
- ShibbolethCredentials* _creds;
- CSYNC* _csync_ctx;
-};
-
-} // namespace OCC
-
-#endif
diff --git a/src/gui/creds/shibbolethcredentials.cpp b/src/gui/creds/shibbolethcredentials.cpp
index c65f71b..2c6e80d 100644
--- a/src/gui/creds/shibbolethcredentials.cpp
+++ b/src/gui/creds/shibbolethcredentials.cpp
@@ -12,7 +12,6 @@
* for more details.
*/
-#include <QMutex>
#include <QSettings>
#include <QNetworkReply>
#include <QMessageBox>
@@ -21,7 +20,6 @@
#include "creds/shibbolethcredentials.h"
#include "creds/shibboleth/shibbolethwebview.h"
-#include "creds/shibboleth/shibbolethrefresher.h"
#include "creds/shibbolethcredentials.h"
#include "shibboleth/shibbolethuserjob.h"
#include "creds/credentialscommon.h"
@@ -47,39 +45,6 @@ namespace
const char userC[] = "shib_user";
const char shibCookieNameC[] = "_shibsession_";
-int shibboleth_redirect_callback(CSYNC* csync_ctx,
- const char* uri)
-{
- if (!csync_ctx || !uri) {
- return 1;
- }
-
- const QString qurl(QString::fromLatin1(uri));
- QRegExp shibbolethyWords ("SAML|wayf");
-
- shibbolethyWords.setCaseSensitivity (Qt::CaseInsensitive);
- if (!qurl.contains(shibbolethyWords)) {
- return 1;
- }
-
- SyncEngine* engine = reinterpret_cast<SyncEngine*>(csync_get_userdata(csync_ctx));
- AccountPtr account = engine->account();
- ShibbolethCredentials* creds = qobject_cast<ShibbolethCredentials*>(account->credentials());
- if (!creds) {
- qDebug() << "Not a Shibboleth creds instance!";
- return 1;
- }
-
- QMutex mutex;
- QMutexLocker locker(&mutex);
- ShibbolethRefresher refresher(account, creds, csync_ctx);
-
- // blocks
- refresher.refresh();
-
- return creds->ready() ? 0 : 1;
-}
-
} // ns
ShibbolethCredentials::ShibbolethCredentials()
@@ -132,12 +97,7 @@ QByteArray ShibbolethCredentials::prepareCookieData() const
void ShibbolethCredentials::syncContextPreStart (CSYNC* ctx)
{
- typedef int (*csync_owncloud_redirect_callback_t)(CSYNC* ctx, const char* uri);
-
- csync_owncloud_redirect_callback_t cb = shibboleth_redirect_callback;
-
csync_set_module_property(ctx, "session_key", prepareCookieData().data());
- csync_set_module_property(ctx, "redirect_callback", &cb);
}
bool ShibbolethCredentials::changed(AbstractCredentials* credentials) const
@@ -232,9 +192,11 @@ void ShibbolethCredentials::persist()
}
}
-// only used by Application::slotLogout(). Use invalidateAndFetch for normal usage
void ShibbolethCredentials::invalidateToken()
{
+ _ready = false;
+ _fetchJobInProgress = true;
+
CookieJar *jar = static_cast<CookieJar*>(_account->networkAccessManager()->cookieJar());
// Remove the _shibCookie
@@ -311,38 +273,6 @@ void ShibbolethCredentials::slotBrowserRejected()
Q_EMIT fetched();
}
-void ShibbolethCredentials::invalidateAndFetch()
-{
- _ready = false;
- _fetchJobInProgress = true;
-
- // delete the credentials, then in the slot fetch them again (which will trigger browser)
- DeletePasswordJob *job = new DeletePasswordJob(Theme::instance()->appName());
- job->setSettings(_account->settingsWithGroup(Theme::instance()->appName(), job).release());
- connect(job, SIGNAL(finished(QKeychain::Job*)), SLOT(slotInvalidateAndFetchInvalidateDone(QKeychain::Job*)));
- job->setKey(keychainKey(_account->url().toString(), "shibAssertion"));
- job->start();
-}
-
-void ShibbolethCredentials::slotInvalidateAndFetchInvalidateDone(QKeychain::Job*)
-{
- connect (this, SIGNAL(fetched()),
- this, SLOT(onFetched()));
- _fetchJobInProgress = false;
- // small hack to support the ShibbolethRefresher hack
- // we already rand fetch() with a valid account object,
- // and hence know the url on refresh
- fetch();
-}
-
-void ShibbolethCredentials::onFetched()
-{
- disconnect (this, SIGNAL(fetched()),
- this, SLOT(onFetched()));
-
- Q_EMIT invalidatedAndFetched(prepareCookieData());
-}
-
void ShibbolethCredentials::slotReadJobDone(QKeychain::Job *job)
{
if (job->error() == QKeychain::NoError) {
diff --git a/src/gui/creds/shibbolethcredentials.h b/src/gui/creds/shibbolethcredentials.h
index 4248038..f4cbd45 100644
--- a/src/gui/creds/shibbolethcredentials.h
+++ b/src/gui/creds/shibbolethcredentials.h
@@ -66,15 +66,10 @@ public:
static QNetworkCookie findShibCookie(Account *, QList<QNetworkCookie> cookies = QList<QNetworkCookie>());
static QByteArray shibCookieName();
-public Q_SLOTS:
- void invalidateAndFetch() Q_DECL_OVERRIDE;
-
private Q_SLOTS:
void onShibbolethCookieReceived(const QNetworkCookie&);
void slotBrowserRejected();
- void onFetched();
void slotReadJobDone(QKeychain::Job*);
- void slotInvalidateAndFetchInvalidateDone(QKeychain::Job*);
void slotReplyFinished(QNetworkReply*);
void slotUserFetched(const QString& user);
void slotFetchUser();
@@ -82,7 +77,6 @@ private Q_SLOTS:
Q_SIGNALS:
void newCookie(const QNetworkCookie& cookie);
- void invalidatedAndFetched(const QByteArray& cookieData);
private:
void storeShibCookie(const QNetworkCookie &cookie);
diff --git a/src/libsync/creds/abstractcredentials.h b/src/libsync/creds/abstractcredentials.h
index 658f4f4..e19156d 100644
--- a/src/libsync/creds/abstractcredentials.h
+++ b/src/libsync/creds/abstractcredentials.h
@@ -54,7 +54,7 @@ public:
virtual void persist() = 0;
/** Invalidates auth token, or password for basic auth */
virtual void invalidateToken() = 0;
- virtual void invalidateAndFetch() {
+ void invalidateAndFetch() {
invalidateToken();
fetch();
}
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 9a1cb2f..19dc280 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -50,7 +50,6 @@ list(APPEND FolderMan_SRC ../src/gui/accountstate.cpp )
#list(APPEND FolderMan_SRC ../src/gui/creds/shibbolethcredentials.cpp )
#list(APPEND FolderMan_SRC ../src/gui/creds/credentialsfactory.cpp )
#list(APPEND FolderMan_SRC ../src/gui/creds/shibboleth/shibbolethuserjob.cpp )
-#list(APPEND FolderMan_SRC ../src/gui/creds/shibboleth/shibbolethrefresher.cpp )
#list(APPEND FolderMan_SRC ../src/gui/creds/shibboleth/shibbolethwebview.cpp )
#list(APPEND FolderMan_SRC ../src/gui/creds/httpcredentialsgui.cpp )
#list(APPEND FolderMan_SRC ../src/gui/sslerrordialog.cpp )
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git
More information about the Pkg-owncloud-commits
mailing list