signon  8.41
signonsessioncoretools.h
Go to the documentation of this file.
1 /*
2  * This file is part of signon
3  *
4  * Copyright (C) 2009-2011 Nokia Corporation.
5  *
6  * Contact: Aurel Popirtac <ext-aurel.popirtac@nokia.com>
7  * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public License
11  * version 2.1 as published by the Free Software Foundation.
12  *
13  * This library is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21  * 02110-1301 USA
22  */
23 
24 #ifndef SIGNONSESSIONCORETOOLS_H
25 #define SIGNONSESSIONCORETOOLS_H
26 
27 #include <QObject>
28 #include <QVariantMap>
29 #include <QDBusMessage>
30 
31 #include "signonidentityinfo.h"
32 
33 namespace SignonDaemonNS {
34 
42 QVariantMap mergeVariantMaps(const QVariantMap &map1, const QVariantMap &map2);
43 
49  enum StoreType {
52  };
53 
54  StoreOperation(const StoreType type);
55  StoreOperation(const StoreOperation &src);
57 
58 public:
61  //Blob store related
62  QString m_authMethod;
63  QVariantMap m_blobData;
64 };
65 
72 {
73  RequestData(const QDBusConnection &conn,
74  const QDBusMessage &msg,
75  const QVariantMap &params,
76  const QString &mechanism,
77  const QString &cancelKey);
78 
79  RequestData(const RequestData &other);
80  ~RequestData();
81 
82 public:
83  QDBusConnection m_conn;
84  QDBusMessage m_msg;
85  QVariantMap m_params;
86  QString m_mechanism;
87  QString m_cancelKey;
88 };
89 
98 class AuthCoreCache: public QObject
99 {
100  Q_OBJECT
101 
102 public:
103  typedef quint32 IdentityId;
104  typedef QString AuthMethod;
105  typedef QList<AuthMethod> AuthMethods;
106  typedef QPair<IdentityId, AuthMethod> CacheId;
107 
108  class AuthCache
109  {
110  friend class AuthCoreCache;
111 
112  ~AuthCache();
113 
114  public:
115  AuthCache();
116  QString username() const { return m_username; }
117  QString password() const { return m_password; }
118  QVariantMap blobData() const { return m_blobData; }
119 
120  void setUsername(const QString &username) { m_username = username; }
121  void setPassword(const QString &password) { m_password = password; }
122  void setBlobData(const QVariantMap &blobData) { m_blobData = blobData; }
123 
124  bool isEmpty() const;
125 
126  private:
127  QString m_username;
128  QString m_password;
129  QVariantMap m_blobData;
130  };
131 
132 private:
133  static AuthCoreCache *m_instance;
134  AuthCoreCache(QObject *parent = 0);
135 
136 public:
137  static AuthCoreCache *instance(QObject *parent = 0);
138  ~AuthCoreCache();
139 
140  AuthCache *data(const IdentityId id) const;
141  void insert(const CacheId &id, AuthCache *cache);
142  void clear();
143 
144  void authSessionDestroyed(const CacheId &id);
145 
146 private:
147  QHash<IdentityId, AuthCache *> m_cache;
148  QHash<IdentityId, AuthMethods> m_cachingSessionsMethods;
149 };
150 
152 
153 } //SignonDaemonNS
154 
155 #endif //SIGNONSESSIONCORETOOLS_H