|
signon
8.40
|
00001 /* 00002 * This file is part of signon 00003 * 00004 * Copyright (C) 2009-2011 Nokia Corporation. 00005 * 00006 * Contact: Aurel Popirtac <ext-aurel.popirtac@nokia.com> 00007 * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> 00008 * 00009 * This library is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU Lesser General Public License 00011 * version 2.1 as published by the Free Software Foundation. 00012 * 00013 * This library is distributed in the hope that it will be useful, but 00014 * WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License along with this library; if not, write to the Free Software 00020 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 00021 * 02110-1301 USA 00022 */ 00023 00024 #ifndef SIGNONSESSIONCORETOOLS_H 00025 #define SIGNONSESSIONCORETOOLS_H 00026 00027 #include <QObject> 00028 #include <QVariantMap> 00029 #include <QDBusMessage> 00030 00031 #include "signonidentityinfo.h" 00032 00033 namespace SignonDaemonNS { 00034 00042 QVariantMap mergeVariantMaps(const QVariantMap &map1, const QVariantMap &map2); 00043 00048 struct StoreOperation { 00049 enum StoreType { 00050 Credentials = 0, 00051 Blob 00052 }; 00053 00054 StoreOperation(const StoreType type); 00055 StoreOperation(const StoreOperation &src); 00056 ~StoreOperation(); 00057 00058 public: 00059 StoreType m_storeType; 00060 SignonIdentityInfo m_info; 00061 //Blob store related 00062 QString m_authMethod; 00063 QVariantMap m_blobData; 00064 }; 00065 00071 struct RequestData 00072 { 00073 RequestData(const QDBusConnection &conn, 00074 const QDBusMessage &msg, 00075 const QVariantMap ¶ms, 00076 const QString &mechanism, 00077 const QString &cancelKey); 00078 00079 RequestData(const RequestData &other); 00080 ~RequestData(); 00081 00082 public: 00083 QDBusConnection m_conn; 00084 QDBusMessage m_msg; 00085 QVariantMap m_params; 00086 QString m_mechanism; 00087 QString m_cancelKey; 00088 }; 00089 00098 class AuthCoreCache: public QObject 00099 { 00100 Q_OBJECT 00101 00102 public: 00103 typedef quint32 IdentityId; 00104 typedef QString AuthMethod; 00105 typedef QList<AuthMethod> AuthMethods; 00106 typedef QPair<IdentityId, AuthMethod> CacheId; 00107 00108 class AuthCache 00109 { 00110 friend class AuthCoreCache; 00111 00112 ~AuthCache(); 00113 00114 public: 00115 AuthCache(); 00116 QString username() const { return m_username; } 00117 QString password() const { return m_password; } 00118 QVariantMap blobData() const { return m_blobData; } 00119 00120 void setUsername(const QString &username) { m_username = username; } 00121 void setPassword(const QString &password) { m_password = password; } 00122 void setBlobData(const QVariantMap &blobData) { m_blobData = blobData; } 00123 00124 bool isEmpty() const; 00125 00126 private: 00127 QString m_username; 00128 QString m_password; 00129 QVariantMap m_blobData; 00130 }; 00131 00132 private: 00133 static AuthCoreCache *m_instance; 00134 AuthCoreCache(QObject *parent = 0); 00135 00136 public: 00137 static AuthCoreCache *instance(QObject *parent = 0); 00138 ~AuthCoreCache(); 00139 00140 AuthCache *data(const IdentityId id) const; 00141 void insert(const CacheId &id, AuthCache *cache); 00142 void clear(); 00143 00144 void authSessionDestroyed(const CacheId &id); 00145 00146 private: 00147 QHash<IdentityId, AuthCache *> m_cache; 00148 QHash<IdentityId, AuthMethods> m_cachingSessionsMethods; 00149 }; 00150 00151 typedef AuthCoreCache::AuthCache AuthCache; 00152 00153 } //SignonDaemonNS 00154 00155 #endif //SIGNONSESSIONCORETOOLS_H