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
46namespace SignOn {
47
48typedef QPointer<AuthSession> AuthSessionP;
49
57class SIGNON_EXPORT Identity: public QObject
58{
59 Q_OBJECT
60 Q_DISABLE_COPY(Identity)
61
62 friend class IdentityImpl;
63
64public:
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
93protected:
97 Identity(const quint32 id = SSO_NEW_IDENTITY,
98 QObject *parent = 0);
99
100public:
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
319Q_SIGNALS:
320
331 void error(const SignOn::Error &err);
332
339 void methodsAvailable(const QStringList &methods);
340
346 void credentialsStored(const quint32 id);
347
354
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
390private:
391 class IdentityImpl *impl;
392};
393
394} // namespace SignOn
395
396#endif /* IDENTITY_H */
definition for Signon error handling.
Definition signonerror.h:53
Contains identity information.
Represents a database entry for a single identity.
Definition identity.h:58
void error(const SignOn::Error &err)
Emitted when an error occurs while performing an operation.
void secretVerified(const bool valid)
Emitted when secret verification is completed.
IdentityError
Codes for errors that may be reported by Identity objects.
Definition identity.h:70
void referenceAdded()
Emitted when references are added by addReference() method and change has been successfully stored on...
void info(const SignOn::IdentityInfo &info)
Emitted when credentials passed by queryInfo() method.
void signedOut()
Emitted when the identity is signed out.
void methodsAvailable(const QStringList &methods)
Emitted when the list of available mechanisms has been obtained for identity.
void referenceRemoved()
Emitted when references are removed by removeReference() method and change has been successfully stor...
void credentialsStored(const quint32 id)
Emitted when credentials passed by storeCredentials() method have been successfully stored on the ser...
void removed()
Emitted when the identity is removed.
void userVerified(const bool valid)
Emitted when the user verification is completed.