identity.cpp
00001 /*
00002  * This file is part of signon
00003  *
00004  * Copyright (C) 2009-2010 Nokia Corporation.
00005  * Copyright (C) 2011-2016 Canonical Ltd.
00006  *
00007  * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
00008  *
00009  * This library is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU Lesser General Public License
00011  * version 2.1 as published by the Free Software Foundation.
00012  *
00013  * This library is distributed in the hope that it will be useful, but
00014  * WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00016  * Lesser General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public
00019  * License along with this library; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
00021  * 02110-1301 USA
00022  */
00023 
00024 #include "debug.h"
00025 #include "identityimpl.h"
00026 #include "identity.h"
00027 
00028 namespace SignOn {
00029 
00030 Identity::Identity(const quint32 id, QObject *parent):
00031     QObject(parent)
00032 {
00033     initDebug();
00034 
00035     qRegisterMetaType<Error>("SignOn::Error");
00036     qRegisterMetaType<Error>("Error");
00037 
00038     if (qMetaTypeId<Error>() < QMetaType::User)
00039         BLAME() << "Identity::Identity() - "
00040             "SignOn::Error meta type not registered.";
00041 
00042     impl = new IdentityImpl(this, id);
00043 }
00044 
00045 Identity *Identity::newIdentity(const IdentityInfo &info, QObject *parent)
00046 {
00047     Identity *identity = new Identity(SSO_NEW_IDENTITY, parent);
00048     identity->impl->copyInfo(info);
00049     return identity;
00050 }
00051 
00052 Identity *Identity::existingIdentity(const quint32 id, QObject *parent)
00053 {
00054     if (id == 0)
00055         return NULL;
00056     return new Identity(id, parent);
00057 }
00058 
00059 Identity::~Identity()
00060 {
00061 }
00062 
00063 quint32 Identity::id() const
00064 {
00065     return impl->id();
00066 }
00067 
00068 void Identity::queryAvailableMethods()
00069 {
00070     impl->queryAvailableMethods();
00071 }
00072 
00073 AuthSessionP Identity::createSession(const QString &methodName)
00074 {
00075     if (methodName.isEmpty())
00076         return NULL;
00077 
00078     return AuthSessionP(impl->createSession(methodName, this));
00079 }
00080 
00081 void Identity::destroySession(const AuthSessionP &session)
00082 {
00083     if (session.isNull())
00084         return;
00085 
00086     impl->destroySession(session.data());
00087 }
00088 
00089 void Identity::requestCredentialsUpdate(const QString &message)
00090 {
00091     impl->requestCredentialsUpdate(message);
00092 }
00093 
00094 void Identity::storeCredentials(const IdentityInfo &info)
00095 {
00096     impl->storeCredentials(info);
00097 }
00098 
00099 void Identity::remove()
00100 {
00101     impl->remove();
00102 }
00103 
00104 void Identity::addReference(const QString &reference)
00105 {
00106     impl->addReference(reference);
00107 }
00108 
00109 void Identity::removeReference(const QString &reference)
00110 {
00111     impl->removeReference(reference);
00112 }
00113 
00114 void Identity::queryInfo()
00115 {
00116     impl->queryInfo();
00117 }
00118 
00119 void Identity::verifyUser(const QString &message)
00120 {
00121     impl->verifyUser(message);
00122 }
00123 
00124 void Identity::verifyUser(const QVariantMap &params)
00125 {
00126     impl->verifyUser(params);
00127 }
00128 
00129 void Identity::verifySecret(const QString &secret)
00130 {
00131     impl->verifySecret(secret);
00132 }
00133 
00134 void Identity::signOut()
00135 {
00136     impl->signOut();
00137 }
00138 
00139 } //namespace SignOn