identityinfo.h
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  */
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 
00112     void setId(const quint32 id);
00113 
00118     quint32 id() const;
00119 
00134     void setSecret(const QString &secret, const bool storeSecret = true);
00135 
00141     QString secret() const;
00142 
00147     bool isStoringSecret() const;
00148 
00153     void setStoreSecret(const bool storeSecret);
00154 
00161     void setUserName(const QString &userName);
00162 
00167     const QString userName() const;
00168 
00173     void setCaption(const QString &caption);
00174 
00179     const QString caption() const;
00180 
00187     void setRealms(const QStringList &realms);
00188 
00195     QStringList realms() const;
00196 
00203     void setOwner(const QString &ownerToken);
00204 
00214     QString owner() const;
00215 
00223     void setAccessControlList(const QStringList &accessControlList);
00224 
00234     QStringList accessControlList() const;
00235 
00246     void setMethod(const MethodName &method,
00247                    const MechanismsList &mechanismsList);
00248 
00253     void removeMethod(const MethodName &method);
00254 
00265     void setType(CredentialsType type);
00266 
00271     CredentialsType type() const;
00272 
00277     QList<MethodName> methods() const;
00278 
00284     MechanismsList mechanisms(const MethodName &method) const;
00285 
00295     void setRefCount(qint32 refCount);
00296 
00301     qint32 refCount() const;
00302 
00303 private:
00304     class IdentityInfoImpl *impl;
00305 };
00306 
00307 }  // namespace SignOn
00308 
00309 Q_DECLARE_METATYPE(SignOn::IdentityInfo)
00310 
00311 #endif /* IDENTITY_INFO_H */