identityinfo.h
00001 /*
00002  * This file is part of signon
00003  *
00004  * Copyright (C) 2009-2010 Nokia Corporation.
00005  *
00006  * Contact: Aurel Popirtac <ext-aurel.popirtac@nokia.com>
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  */
00028 #ifndef IDENTITY_INFO_H
00029 #define IDENTITY_INFO_H
00030 
00031 #include <QStringList>
00032 #include <QMetaType>
00033 
00034 #include "libsignoncommon.h"
00035 
00036 namespace SignOn {
00037 
00042 typedef QString MethodName;
00043 
00048 typedef QStringList MechanismsList;
00049 
00057 class SIGNON_EXPORT IdentityInfo
00058 {
00059     friend class AuthServiceImpl;
00060     friend class IdentityImpl;
00061 
00062 public:
00069     enum CredentialsType {
00070         Other = 0,
00071         Application = 1 << 0,
00072         Web = 1 << 1,
00073         Network = 1 << 2
00074     };
00075 
00076 public:
00080     IdentityInfo();
00081 
00085     IdentityInfo(const IdentityInfo &other);
00086 
00090     IdentityInfo &operator=(const IdentityInfo &other);
00091 
00098     IdentityInfo(const QString &caption, const QString &userName,
00099                  const QMap<MethodName,MechanismsList> &methods);
00100 
00104     ~IdentityInfo();
00105 
00110     quint32 id() const;
00111 
00126     void setSecret(const QString &secret, const bool storeSecret = true);
00127 
00132     bool isStoringSecret() const;
00133 
00138     void setStoreSecret(const bool storeSecret);
00139 
00146     void setUserName(const QString &userName);
00147 
00152     const QString userName() const;
00153 
00158     void setCaption(const QString &caption);
00159 
00164     const QString caption() const;
00165 
00172     void setRealms(const QStringList &realms);
00173 
00180     QStringList realms() const;
00181 
00188     void setOwner(const QString &ownerToken);
00189 
00199     QString owner() const;
00200 
00208     void setAccessControlList(const QStringList &accessControlList);
00209 
00219     QStringList accessControlList() const;
00220 
00231     void setMethod(const MethodName &method,
00232                    const MechanismsList &mechanismsList);
00233 
00238     void removeMethod(const MethodName &method);
00239 
00250     void setType(CredentialsType type);
00251 
00256     CredentialsType type() const;
00257 
00262     QList<MethodName> methods() const;
00263 
00269     MechanismsList mechanisms(const MethodName &method) const;
00270 
00280     void setRefCount(qint32 refCount);
00281 
00286     qint32 refCount() const;
00287 
00288 private:
00289     void setId(const quint32 id);
00290     const QString secret() const;
00291 
00292 private:
00293     class IdentityInfoImpl *impl;
00294 };
00295 
00296 }  // namespace SignOn
00297 
00298 Q_DECLARE_METATYPE(SignOn::IdentityInfo)
00299 
00300 #endif /* IDENTITY_INFO_H */