My Project
identity.h
1 /*
2  * This file is part of signon
3  *
4  * Copyright (C) 2009-2010 Nokia Corporation.
5  * Copyright (C) 2012-2016 Canonical Ltd.
6  *
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  */
28 #ifndef IDENTITY_H
29 #define IDENTITY_H
30 
31 #include <QObject>
32 #include <QByteArray>
33 #include <QMap>
34 #include <QString>
35 #include <QStringList>
36 #include <QVariant>
37 #include <QPointer>
38 
39 #include "libsignoncommon.h"
40 #include "authsession.h"
41 #include "identityinfo.h"
42 #include "signonerror.h"
43 
44 #define SSO_NEW_IDENTITY 0
45 
46 namespace SignOn {
47 
48 typedef QPointer<AuthSession> AuthSessionP;
49 
57 class SIGNON_EXPORT Identity: public QObject
58 {
59  Q_OBJECT
60  Q_DISABLE_COPY(Identity)
61 
62  friend class IdentityImpl;
63 
64 public:
71  UnknownError = 1,
73  InternalServerError = 2,
74  InternalCommunicationError = 3,
76  PermissionDeniedError = 4,
79  IdentityErr = 200, /* placeholder to rearrange
80  enumeration. */
81  MethodNotAvailableError,
83  NotFoundError,
90  CredentialsNotAvailableError
91  };
92 
93 protected:
97  Identity(const quint32 id = SSO_NEW_IDENTITY,
98  QObject *parent = 0);
99 
100 public:
110  static Identity *newIdentity(const IdentityInfo &info = IdentityInfo(),
111  QObject *parent = 0);
112 
122  static Identity *existingIdentity(const quint32 id, QObject *parent = 0);
123 
127  virtual ~Identity();
128 
135  quint32 id() const;
136 
147  void queryAvailableMethods();
148 
157  AuthSessionP createSession(const QString &methodName);
158 
164  void destroySession(const AuthSessionP &session);
165 
181  void requestCredentialsUpdate(const QString &message = QString());
182 
203  void storeCredentials(const IdentityInfo &info = IdentityInfo());
204 
217  void remove();
218 
231  void addReference(const QString &reference = QString());
232 
245  void removeReference(const QString &reference = QString());
246 
260  void queryInfo();
261 
275  void verifyUser(const QString &message = QString());
276 
290  void verifyUser(const QVariantMap &params);
291 
303  void verifySecret(const QString &secret);
304 
317  void signOut();
318 
319 Q_SIGNALS:
320 
331  void error(const SignOn::Error &err);
332 
339  void methodsAvailable(const QStringList &methods);
340 
346  void credentialsStored(const quint32 id);
347 
353  void referenceAdded();
354 
360  void referenceRemoved();
361 
366  void info(const SignOn::IdentityInfo &info);
367 
372  void userVerified(const bool valid);
373 
378  void secretVerified(const bool valid);
379 
383  void signedOut();
384 
388  void removed();
389 
390 private:
391  class IdentityImpl *impl;
392 };
393 
394 } // namespace SignOn
395 
396 #endif /* IDENTITY_H */
SignOn::Identity::IdentityError
IdentityError
Definition: identity.h:70
SignOn::Identity::StoreFailedError
Definition: identity.h:86
SignOn::IdentityInfo
Definition: identityinfo.h:64
SignOn::Identity
Definition: identity.h:57
SignOn::Identity::RemoveFailedError
Definition: identity.h:87
SignOn
Definition: async-dbus-proxy.cpp:41
SignOn::Error
Definition: signonerror.h:49
SignOn::Identity::CanceledError
Definition: identity.h:89
SignOn::Identity::SignOutFailedError
Definition: identity.h:88