identityinfo.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 <QVariant>
#include <QString>
#include "debug.h"
#include "libsignoncommon.h"
#include "identityinfo.h"
#include "identityinfoimpl.h"
#include "identity.h"
namespace SignOn {
IdentityInfo::IdentityInfo():
impl(new IdentityInfoImpl)
{
qRegisterMetaType<IdentityInfo>("SignOn::IdentityInfo");
if (qMetaTypeId<IdentityInfo>() < QMetaType::User)
BLAME() << "IdentityInfo::IdentityInfo() - "
"IdentityInfo meta type not registered.";
}
IdentityInfo::IdentityInfo(const IdentityInfo &other):
impl(new IdentityInfoImpl)
{
*impl = *other.impl;
}
IdentityInfo &IdentityInfo::operator=(const IdentityInfo &other)
{
*impl = *other.impl;
return *this;
}
IdentityInfo::IdentityInfo(const QString &caption,
const QString &userName,
const QMap<MethodName, MechanismsList> &methods):
impl(new IdentityInfoImpl)
{
impl->setCaption(caption);
impl->setUserName(userName);
impl->setMethods(methods);
}
IdentityInfo::~IdentityInfo()
{
if (impl) delete impl;
impl = 0;
}
void IdentityInfo::setId(const quint32 id)
{
impl->setId(id);
}
quint32 IdentityInfo::id() const
{
return impl->id();
}
void IdentityInfo::setUserName(const QString &userName)
{
impl->setUserName(userName);
}
const QString IdentityInfo::userName() const
{
return impl->userName();
}
void IdentityInfo::setCaption(const QString &caption)
{
impl->setCaption(caption);
}
const QString IdentityInfo::caption() const
{
return impl->caption();
}
void IdentityInfo::setRealms(const QStringList &realms)
{
impl->setRealms(realms);
}
QStringList IdentityInfo::realms() const
{
return impl->realms();
}
void IdentityInfo::setOwner(const QString &ownerToken)
{
impl->setOwners(QStringList() << ownerToken);
}
QString IdentityInfo::owner() const
{
return impl->owners().value(0);
}
void IdentityInfo::setAccessControlList(const QStringList &accessControlList)
{
SecurityContextList list;
for (const QString &sysCtx: accessControlList) {
list.append(SecurityContext(sysCtx, QLatin1String("*")));
}
impl->setAccessControlList(list);
}
QStringList IdentityInfo::accessControlList() const
{
SecurityContextList accessControlList = impl->accessControlList();
QStringList list;
for (const SecurityContext &secCtx: accessControlList) {
list.append(secCtx.systemContext());
}
return list;
}
void IdentityInfo::setAccessControlList(const SecurityContextList &accessControlList)
{
impl->setAccessControlList(accessControlList);
}
SecurityContextList IdentityInfo::accessControlListFull() const
{
return impl->accessControlList();
}
QString IdentityInfo::secret() const
{
return impl->secret();
}
void IdentityInfo::setSecret(const QString &secret, const bool storeSecret)
{
impl->setSecret(secret);
impl->setStoreSecret(storeSecret);
}
bool IdentityInfo::isStoringSecret() const
{
return impl->storeSecret();
}
void IdentityInfo::setStoreSecret(const bool storeSecret)
{
impl->setStoreSecret(storeSecret);
}
void IdentityInfo::setMethod(const MethodName &method,
const MechanismsList &mechanismsList)
{
impl->updateMethod(method, mechanismsList);
}
void IdentityInfo::removeMethod(const MethodName &method)
{
impl->removeMethod(method);
}
void IdentityInfo::setType(IdentityInfo::CredentialsType type)
{
impl->setType(type);
}
IdentityInfo::CredentialsType IdentityInfo::type() const
{
return impl->type();
}
QList<MethodName> IdentityInfo::methods() const
{
return impl->methods().keys();
}
MechanismsList IdentityInfo::mechanisms(const MethodName &method) const
{
return impl->methods().value(method, QStringList());
}
void IdentityInfo::setRefCount(qint32 refCount)
{
/* This method is a mistake, let's keep it for binary compatibility as a
* no-op. */
Q_UNUSED(refCount);
}
qint32 IdentityInfo::refCount() const
{
return impl->refCount();
}
} //namespace SignOn
SignOn::IdentityInfo
Contains identity information.
Definition: identityinfo.h:65
SignOn::IdentityInfo::setCaption
void setCaption(const QString &caption)
Sets a human readable caption of the identity.
Definition: identityinfo.cpp:93
SignOn::IdentityInfo::realms
QStringList realms() const
Gets the realms, e.g.
Definition: identityinfo.cpp:108
SignOn::IdentityInfo::~IdentityInfo
~IdentityInfo()
Destructor.
Definition: identityinfo.cpp:67
SignOn::IdentityInfo::type
CredentialsType type() const
Retrieves the identity type from identity info.
Definition: identityinfo.cpp:191
SignOn::IdentityInfo::setAccessControlList
void setAccessControlList(const QStringList &accessControlList)
Sets the list of access control system tokens, therefore defining the applications that will be able ...
Definition: identityinfo.cpp:123
SignOn::IdentityInfo::setRefCount
void setRefCount(qint32 refCount)
Sets the refcount into identity info.
Definition: identityinfo.cpp:206
SignOn::IdentityInfo::setType
void setType(CredentialsType type)
Sets the type into identity info.
Definition: identityinfo.cpp:186
SignOn::IdentityInfo::setSecret
void setSecret(const QString &secret, const bool storeSecret=true)
Sets the secret.
Definition: identityinfo.cpp:159
SignOn::IdentityInfo::removeMethod
void removeMethod(const MethodName &method)
Removes a method from identity info.
Definition: identityinfo.cpp:181
SignOn::IdentityInfo::accessControlList
QStringList accessControlList() const
Gets the list of access control system tokens defining the applications that are able to access this ...
Definition: identityinfo.cpp:133
SignOn::IdentityInfo::setId
void setId(const quint32 id)
Sets the numeric identifier for the credentials record.
Definition: identityinfo.cpp:73
SignOn::IdentityInfo::owner
QString owner() const
Gets the owner application token that is defining the applications that are able to modify this speci...
Definition: identityinfo.cpp:118
SignOn::IdentityInfo::refCount
qint32 refCount() const
Retrieves the refcount from identity info.
Definition: identityinfo.cpp:213
SignOn::IdentityInfo::operator=
IdentityInfo & operator=(const IdentityInfo &other)
Assignment operator.
Definition: identityinfo.cpp:51
SignOn::IdentityInfo::accessControlListFull
SecurityContextList accessControlListFull() const
Gets the list of access control application tokens defining the applications that are able to access ...
Definition: identityinfo.cpp:149
SignOn::IdentityInfo::setRealms
void setRealms(const QStringList &realms)
Sets the realms, e.g.
Definition: identityinfo.cpp:103
SignOn::IdentityInfo::setUserName
void setUserName(const QString &userName)
Sets the username.
Definition: identityinfo.cpp:83
SignOn::IdentityInfo::IdentityInfo
IdentityInfo()
Creates a new empty IdentityInfo object.
Definition: identityinfo.cpp:35
SignOn::IdentityInfo::caption
const QString caption() const
Returns a human-readable representation of the identity.
Definition: identityinfo.cpp:98
SignOn::IdentityInfo::setMethod
void setMethod(const MethodName &method, const MechanismsList &mechanismsList)
Sets the method into identity info.
Definition: identityinfo.cpp:175
SignOn::IdentityInfo::secret
QString secret() const
Gets the secret.
Definition: identityinfo.cpp:154
SignOn::IdentityInfo::userName
const QString userName() const
Returns the username.
Definition: identityinfo.cpp:88
SignOn::IdentityInfo::setStoreSecret
void setStoreSecret(const bool storeSecret)
Sets whether the secret is stored or not.
Definition: identityinfo.cpp:170
SignOn::IdentityInfo::id
quint32 id() const
Returns the identity identifier.
Definition: identityinfo.cpp:78
SignOn::IdentityInfo::methods
QList< MethodName > methods() const
Lists all methods in identity info.
Definition: identityinfo.cpp:196
SignOn::IdentityInfo::mechanisms
MechanismsList mechanisms(const MethodName &method) const
Lists the all mechanisms for certain method in identity info.
Definition: identityinfo.cpp:201
SignOn::IdentityInfo::CredentialsType
CredentialsType
Values used to describe the type of the identity.
Definition: identityinfo.h:76
SignOn::IdentityInfo::setOwner
void setOwner(const QString &ownerToken)
Sets application token that owns identity, therefore defining the applications that will be able to m...
Definition: identityinfo.cpp:113
SignOn::IdentityInfo::isStoringSecret
bool isStoringSecret() const
Returns whether secret is to be stored.
Definition: identityinfo.cpp:165
SignOn::SecurityContext
Contains access security context information.
Definition: securitycontext.h:41
SignOn
Definition: async-dbus-proxy.cpp:41
SignOn::MethodName
QString MethodName
Defines a string as an authentication method.
Definition: identityinfo.h:43
SignOn::MechanismsList
QStringList MechanismsList
Defines a string list as a list of mechanisms.
Definition: identityinfo.h:49
SignOn::SecurityContextList
QList< SecurityContext > SecurityContextList
Defines a list of security contexts.
Definition: identityinfo.h:55