00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <QVariant>
00025
00026 #include "libsignoncommon.h"
00027 #include "identityinfo.h"
00028 #include "identityinfoimpl.h"
00029 #include "identity.h"
00030
00031 namespace SignOn {
00032
00033 IdentityInfo::IdentityInfo()
00034 : impl(new IdentityInfoImpl(this))
00035 {
00036 qRegisterMetaType<IdentityInfo>("SignOn::IdentityInfo");
00037
00038 if (qMetaTypeId<IdentityInfo>() < QMetaType::User)
00039 BLAME() << "IdentityInfo::IdentityInfo() - IdentityInfo meta type not registered.";
00040
00041 impl->m_id = 0;
00042 impl->m_storeSecret = false;
00043 }
00044
00045 IdentityInfo::IdentityInfo(const IdentityInfo &other)
00046 : impl(new IdentityInfoImpl(this))
00047 {
00048 impl->copy(*(other.impl));
00049 }
00050
00051 IdentityInfo &IdentityInfo::operator=(const IdentityInfo &other)
00052 {
00053 impl->copy(*(other.impl));
00054 return *this;
00055 }
00056
00057 IdentityInfo::IdentityInfo(
00058 const QString &caption,
00059 const QString &userName,
00060 const QMap<MethodName, MechanismsList> &methods)
00061 : impl(new IdentityInfoImpl(this))
00062 {
00063 impl->m_caption = caption;
00064 impl->m_userName = userName;
00065 impl->m_isEmpty = false;
00066
00067 QMapIterator<QString, QStringList> it(methods);
00068 while (it.hasNext()) {
00069 it.next();
00070 impl->m_authMethods.insert(it.key(), QVariant(it.value()));
00071 }
00072 }
00073
00074 IdentityInfo::~IdentityInfo()
00075 {
00076 if (impl) delete impl;
00077 impl = 0;
00078 }
00079
00080 void IdentityInfo::setId(const quint32 id)
00081 {
00082 impl->m_id = id;
00083 }
00084
00085 quint32 IdentityInfo::id() const
00086 {
00087 return impl->m_id;
00088 }
00089
00090 void IdentityInfo::setUserName(const QString &userName)
00091 {
00092 impl->m_userName = userName;
00093 impl->m_isEmpty = false;
00094 }
00095
00096 const QString IdentityInfo::userName() const
00097 {
00098 return impl->m_userName;
00099 }
00100
00101 void IdentityInfo::setCaption(const QString &caption)
00102 {
00103 impl->m_caption = caption;
00104 }
00105
00106 const QString IdentityInfo::caption() const
00107 {
00108 return impl->m_caption;
00109 }
00110
00111 void IdentityInfo::setRealms(const QStringList &realms)
00112 {
00113 impl->m_realms = realms;
00114 }
00115
00116 QStringList IdentityInfo::realms() const
00117 {
00118 return impl->m_realms;
00119 }
00120
00121 void IdentityInfo::setOwner(const QString &ownerToken)
00122 {
00123 impl->m_owner = ownerToken;
00124 }
00125
00126 QString IdentityInfo::owner() const
00127 {
00128 return impl->m_owner;
00129 }
00130
00131 void IdentityInfo::setAccessControlList(const QStringList &accessControlList)
00132 {
00133 impl->m_accessControlList = accessControlList;
00134 }
00135
00136 QStringList IdentityInfo::accessControlList() const
00137 {
00138 return impl->m_accessControlList;
00139 }
00140
00141 const QString IdentityInfo::secret() const
00142 {
00143 return impl->m_secret;
00144 }
00145
00146 void IdentityInfo::setSecret(const QString &secret, const bool storeSecret)
00147 {
00148 impl->m_secret = secret;
00149 impl->m_storeSecret = storeSecret;
00150 impl->m_isEmpty = false;
00151 }
00152
00153 bool IdentityInfo::isStoringSecret() const
00154 {
00155 return impl->m_storeSecret;
00156 }
00157
00158 void IdentityInfo::setStoreSecret(const bool storeSecret)
00159 {
00160 impl->m_storeSecret = storeSecret;
00161 }
00162
00163 void IdentityInfo::setMethod(const MethodName &method, const MechanismsList &mechanismsList)
00164 {
00165 if (impl->hasMethod(method))
00166 impl->updateMethod(method, mechanismsList);
00167 else
00168 impl->addMethod(method, mechanismsList);
00169 }
00170
00171 void IdentityInfo::removeMethod(const MethodName &method)
00172 {
00173 impl->removeMethod(method);
00174 }
00175
00176 void IdentityInfo::setType(IdentityInfo::CredentialsType type)
00177 {
00178 impl->setType(type);
00179 }
00180
00181 IdentityInfo::CredentialsType IdentityInfo::type() const
00182 {
00183 return impl->type();
00184 }
00185
00186 QList<MethodName> IdentityInfo::methods() const
00187 {
00188 return impl->m_authMethods.keys();
00189 }
00190
00191 MechanismsList IdentityInfo::mechanisms(const MethodName &method) const
00192 {
00193 return impl->m_authMethods.value(method, QVariant(QStringList())).toStringList();
00194 }
00195
00196 void IdentityInfo::setRefCount(qint32 refCount)
00197 {
00198 impl->setRefCount(refCount);
00199 }
00200
00201 qint32 IdentityInfo::refCount() const
00202 {
00203 return impl->refCount();
00204 }
00205
00206 }