My Project: identity.cpp Source File

My Project

identity.cpp
1/*
2 * This file is part of signon
3 *
4 * Copyright (C) 2009-2010 Nokia Corporation.
5 * Copyright (C) 2011-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 */
23
24#include <QDBusMetaType>
25
26#include "debug.h"
27#include "identityimpl.h"
28#include "identity.h"
29#include "securitycontext.h"
30#include "securitycontextpriv.h"
31
32namespace SignOn {
33
34Identity::Identity(const quint32 id, QObject *parent):
35 QObject(parent)
36{
37 initDebug();
38
39 qRegisterMetaType<Error>("SignOn::Error");
40 qRegisterMetaType<Error>("Error");
41 qDBusRegisterMetaType<SecurityContext>();
42
43 if (qMetaTypeId<Error>() < QMetaType::User)
44 BLAME() << "Identity::Identity() - "
45 "SignOn::Error meta type not registered.";
46
47 impl = new IdentityImpl(this, id);
48}
49
50 Identity *Identity::newIdentity(const IdentityInfo &info, QObject *parent)
51{
52 Identity *identity = new Identity(SSO_NEW_IDENTITY, parent);
53 identity->impl->copyInfo(info);
54 return identity;
55}
56
57 Identity *Identity::existingIdentity(const quint32 id, QObject *parent)
58{
59 if (id == 0)
60 return NULL;
61 return new Identity(id, parent);
62}
63
64Identity::~Identity()
65{
66}
67
68quint32 Identity::id() const
69{
70 return impl->id();
71}
72
73 void Identity::queryAvailableMethods()
74{
75 impl->queryAvailableMethods();
76}
77
78AuthSessionP Identity::createSession(const QString &methodName)
79{
80 if (methodName.isEmpty())
81 return NULL;
82
83 return AuthSessionP(impl->createSession(methodName, this));
84}
85
86 void Identity::destroySession(const AuthSessionP &session)
87{
88 if (session.isNull())
89 return;
90
91 impl->destroySession(session.data());
92}
93
94 void Identity::requestCredentialsUpdate(const QString &message)
95{
96 impl->requestCredentialsUpdate(message);
97}
98
99 void Identity::storeCredentials(const IdentityInfo &info)
100{
101 impl->storeCredentials(info);
102}
103
104 void Identity::remove()
105{
106 impl->remove();
107}
108
109 void Identity::addReference(const QString &reference)
110{
111 impl->addReference(reference);
112}
113
114 void Identity::removeReference(const QString &reference)
115{
116 impl->removeReference(reference);
117}
118
119 void Identity::queryInfo()
120{
121 impl->queryInfo();
122}
123
124 void Identity::verifyUser(const QString &message)
125{
126 impl->verifyUser(message);
127}
128
129 void Identity::verifyUser(const QVariantMap &params)
130{
131 impl->verifyUser(params);
132}
133
134 void Identity::verifySecret(const QString &secret)
135{
136 impl->verifySecret(secret);
137}
138
139 void Identity::signOut()
140{
141 impl->signOut();
142}
143
144} //namespace SignOn
SignOn::IdentityInfo
Contains identity information.
Definition identityinfo.h:65
SignOn::Identity
Represents a database entry for a single identity.
Definition identity.h:58
SignOn::Identity::destroySession
void destroySession(const AuthSessionP &session)
Destroys an authentication session.
Definition identity.cpp:86
SignOn::Identity::newIdentity
static Identity * newIdentity(const IdentityInfo &info=IdentityInfo(), QObject *parent=0)
Constructs a new identity object.
Definition identity.cpp:50
SignOn::Identity::addReference
void addReference(const QString &reference=QString())
Adds the named reference to identity into the database.
Definition identity.cpp:109
SignOn::Identity::removeReference
void removeReference(const QString &reference=QString())
Removes a named reference to identity from the database.
Definition identity.cpp:114
SignOn::Identity::queryInfo
void queryInfo()
Query stored credential parameters for this authentication identity.
Definition identity.cpp:119
SignOn::Identity::requestCredentialsUpdate
void requestCredentialsUpdate(const QString &message=QString())
Requests the user to give a new secret into database.
Definition identity.cpp:94
SignOn::Identity::createSession
AuthSessionP createSession(const QString &methodName)
Creates a new session for authentication.
Definition identity.cpp:78
SignOn::Identity::verifySecret
void verifySecret(const QString &secret)
Verifies if the given secret match the stored secret.
Definition identity.cpp:134
SignOn::Identity::verifyUser
void verifyUser(const QString &message=QString())
Gets a secret verification from the user and compares it to the stored secret.
Definition identity.cpp:124
SignOn::Identity::id
quint32 id() const
Unique id of given identity.
Definition identity.cpp:68
SignOn::Identity::info
void info(const SignOn::IdentityInfo &info)
Emitted when credentials passed by queryInfo() method.
SignOn::Identity::signOut
void signOut()
Signs out Identity from all services.
Definition identity.cpp:139
SignOn::Identity::~Identity
virtual ~Identity()
Destructor.
Definition identity.cpp:64
SignOn::Identity::remove
void remove()
Removes this identity from database.
Definition identity.cpp:104
SignOn::Identity::storeCredentials
void storeCredentials(const IdentityInfo &info=IdentityInfo())
Stores credential parameters for this authentication identity.
Definition identity.cpp:99
SignOn::Identity::existingIdentity
static Identity * existingIdentity(const quint32 id, QObject *parent=0)
Constructs an identity object associated with an existing identity record.
Definition identity.cpp:57
SignOn::Identity::queryAvailableMethods
void queryAvailableMethods()
Query list of available authentication methods for given identity.
Definition identity.cpp:73
SignOn::Identity::Identity
Identity(const quint32 id=SSO_NEW_IDENTITY, QObject *parent=0)
Definition identity.cpp:34
SignOn
Definition async-dbus-proxy.cpp:41