identity.cpp
/*
* This file is part of signon
*
* Copyright (C) 2009-2010 Nokia Corporation.
* Copyright (C) 2011-2016 Canonical Ltd.
*
* Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#include <QDBusMetaType>
#include "debug.h"
#include "identityimpl.h"
#include "identity.h"
#include "securitycontext.h"
#include "securitycontextpriv.h"
namespace SignOn {
Identity::Identity(const quint32 id, QObject *parent):
QObject(parent)
{
initDebug();
qRegisterMetaType<Error>("SignOn::Error");
qRegisterMetaType<Error>("Error");
qDBusRegisterMetaType<SecurityContext>();
if (qMetaTypeId<Error>() < QMetaType::User)
BLAME() << "Identity::Identity() - "
"SignOn::Error meta type not registered.";
impl = new IdentityImpl(this, id);
}
Identity *Identity::newIdentity(const IdentityInfo &info, QObject *parent)
{
Identity *identity = new Identity(SSO_NEW_IDENTITY, parent);
identity->impl->copyInfo(info);
return identity;
}
Identity *Identity::existingIdentity(const quint32 id, QObject *parent)
{
if (id == 0)
return NULL;
return new Identity(id, parent);
}
Identity::~Identity()
{
}
quint32 Identity::id() const
{
return impl->id();
}
void Identity::queryAvailableMethods()
{
impl->queryAvailableMethods();
}
AuthSessionP Identity::createSession(const QString &methodName)
{
if (methodName.isEmpty())
return NULL;
return AuthSessionP(impl->createSession(methodName, this));
}
void Identity::destroySession(const AuthSessionP &session)
{
if (session.isNull())
return;
impl->destroySession(session.data());
}
void Identity::requestCredentialsUpdate(const QString &message)
{
impl->requestCredentialsUpdate(message);
}
void Identity::storeCredentials(const IdentityInfo &info)
{
impl->storeCredentials(info);
}
void Identity::remove()
{
impl->remove();
}
void Identity::addReference(const QString &reference)
{
impl->addReference(reference);
}
void Identity::removeReference(const QString &reference)
{
impl->removeReference(reference);
}
void Identity::queryInfo()
{
impl->queryInfo();
}
void Identity::verifyUser(const QString &message)
{
impl->verifyUser(message);
}
void Identity::verifyUser(const QVariantMap &params)
{
impl->verifyUser(params);
}
void Identity::verifySecret(const QString &secret)
{
impl->verifySecret(secret);
}
void Identity::signOut()
{
impl->signOut();
}
} //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