~online-accounts/signon/rtm-14.09

« back to all changes in this revision

Viewing changes to src/signond/signonidentityinfo.h

  • Committer: Tarmac
  • Author(s): Alberto Mardegan
  • Date: 2013-11-26 16:09:31 UTC
  • mfrom: (605.1.3 packaging)
  • Revision ID: tarmac-20131126160931-xjatums22ndhvirc
Merge from upstream

signond: avoid rewriting password with empty string
Remove signon-keyring-extension from Recommends field
. Fixes: https://bugs.launchpad.net/bugs/1156776, https://bugs.launchpad.net/bugs/1237782.

Approved by Ken VanDine, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#ifndef SIGNONIDENTITYINFO_H
24
24
#define SIGNONIDENTITYINFO_H
25
25
 
26
 
#include <QMap>
27
26
#include <QStringList>
28
 
#include <QVariant>
 
27
#include <QVariantMap>
29
28
 
30
29
#include "signond/signoncommon.h"
31
30
 
40
39
 * Daemon side representation of identity information.
41
40
 * @todo description.
42
41
 */
43
 
struct SignonIdentityInfo
 
42
struct SignonIdentityInfo: protected QVariantMap
44
43
{
45
44
    SignonIdentityInfo();
46
45
    SignonIdentityInfo(const QVariantMap &info);
47
 
    SignonIdentityInfo(const quint32 id,
48
 
                       const QString &userName,
49
 
                       const QString &password,
50
 
                       const bool storePassword,
51
 
                       const QString &caption,
52
 
                       const MethodMap &methods,
53
 
                       const QStringList &realms = QStringList(),
54
 
                       const QStringList &accessControlList = QStringList(),
55
 
                       const QStringList &ownerList = QStringList(),
56
 
                       int type = 0,
57
 
                       int refCount = 0,
58
 
                       bool validated = false);
59
46
 
60
47
    const QVariantMap toMap() const;
61
48
 
62
 
    bool operator== (const SignonIdentityInfo &other) const;
63
 
    SignonIdentityInfo &operator=(const SignonIdentityInfo &other);
64
 
 
65
 
    void setNew() { m_id = SIGNOND_NEW_IDENTITY; }
66
 
    bool isNew() const { return m_id == SIGNOND_NEW_IDENTITY; }
67
 
    void setId(quint32 id) { m_id = id; }
68
 
    quint32 id() const { return m_id; }
69
 
 
70
 
    void setUserName(const QString &userName) { m_userName = userName; }
71
 
    QString userName() const { return m_userName; }
72
 
    void setUserNameSecret(bool secret) { m_isUserNameSecret = secret; }
73
 
    bool isUserNameSecret() const { return m_isUserNameSecret; }
74
 
 
75
 
    void setPassword(const QString &password) { m_password = password; }
76
 
    QString password() const { return m_password; }
 
49
    void setNew() { setId(SIGNOND_NEW_IDENTITY); }
 
50
    bool isNew() const { return id() == SIGNOND_NEW_IDENTITY; }
 
51
    void setId(quint32 id) { insert(SIGNOND_IDENTITY_INFO_ID, id); }
 
52
    quint32 id() const { return value(SIGNOND_IDENTITY_INFO_ID, 0).toUInt(); }
 
53
 
 
54
    void setUserName(const QString &userName) {
 
55
        insert(SIGNOND_IDENTITY_INFO_USERNAME, userName);
 
56
    }
 
57
 
 
58
    QString userName() const {
 
59
        return value(SIGNOND_IDENTITY_INFO_USERNAME).toString();
 
60
    }
 
61
 
 
62
    void setUserNameSecret(bool secret) {
 
63
        insert(SIGNOND_IDENTITY_INFO_USERNAME_IS_SECRET, secret);
 
64
    }
 
65
 
 
66
    bool isUserNameSecret() const {
 
67
        return value(SIGNOND_IDENTITY_INFO_USERNAME_IS_SECRET).toBool();
 
68
    }
 
69
 
 
70
    void setPassword(const QString &password) {
 
71
        insert(SIGNOND_IDENTITY_INFO_SECRET, password);
 
72
    }
 
73
 
 
74
    QString password() const {
 
75
        return value(SIGNOND_IDENTITY_INFO_SECRET).toString();
 
76
    }
 
77
 
 
78
    void removeSecrets() {
 
79
        remove(SIGNOND_IDENTITY_INFO_SECRET);
 
80
        if (isUserNameSecret())
 
81
            remove(SIGNOND_IDENTITY_INFO_USERNAME);
 
82
    }
 
83
 
 
84
    bool hasSecrets() const {
 
85
        return contains(SIGNOND_IDENTITY_INFO_SECRET) ||
 
86
            (isUserNameSecret() && contains(SIGNOND_IDENTITY_INFO_USERNAME));
 
87
    }
 
88
 
77
89
    void setStorePassword(bool storePassword) {
78
 
        m_storePassword = storePassword;
79
 
    }
80
 
    bool storePassword() const { return m_storePassword; }
81
 
 
82
 
    void setCaption(const QString &caption) { m_caption = caption; }
83
 
    QString caption() const { return m_caption; }
84
 
 
85
 
    void setRealms(const QStringList &realms) { m_realms = realms; }
86
 
    QStringList realms() const { return m_realms; }
87
 
 
88
 
    void setMethods(const MethodMap &methods)
89
 
        { m_methods = methods; }
90
 
    MethodMap methods() const { return m_methods; }
91
 
 
92
 
    void setAccessControlList(const QStringList &acl)
93
 
        { m_accessControlList = acl; }
94
 
    QStringList accessControlList() const { return m_accessControlList; }
95
 
 
96
 
    void setValidated(bool validated) { m_validated = validated; }
97
 
    bool validated() const { return m_validated; }
98
 
 
99
 
    void setType(const int type) { m_type = type; }
100
 
    int type() const { return m_type; }
101
 
 
102
 
    void setOwnerList(const QStringList &owner) { m_ownerList = owner; }
103
 
    QStringList ownerList() const { return m_ownerList; }
 
90
        insert(SIGNOND_IDENTITY_INFO_STORESECRET, storePassword);
 
91
    }
 
92
 
 
93
    bool storePassword() const {
 
94
        return value(SIGNOND_IDENTITY_INFO_STORESECRET).toBool();
 
95
    }
 
96
 
 
97
    void setCaption(const QString &caption) {
 
98
        insert(SIGNOND_IDENTITY_INFO_CAPTION, caption);
 
99
    }
 
100
 
 
101
    QString caption() const {
 
102
        return value(SIGNOND_IDENTITY_INFO_CAPTION).toString();
 
103
    }
 
104
 
 
105
    void setRealms(const QStringList &realms) {
 
106
        insert(SIGNOND_IDENTITY_INFO_REALMS, realms);
 
107
    }
 
108
 
 
109
    QStringList realms() const {
 
110
        return value(SIGNOND_IDENTITY_INFO_REALMS).toStringList();
 
111
    }
 
112
 
 
113
    void setMethods(const MethodMap &methods) {
 
114
        insert(SIGNOND_IDENTITY_INFO_AUTHMETHODS, QVariant::fromValue(methods));
 
115
    }
 
116
 
 
117
    MethodMap methods() const {
 
118
        return value(SIGNOND_IDENTITY_INFO_AUTHMETHODS).value<MethodMap>();
 
119
    }
 
120
 
 
121
    void setAccessControlList(const QStringList &accessControlList) {
 
122
        insert(SIGNOND_IDENTITY_INFO_ACL, accessControlList);
 
123
    }
 
124
 
 
125
    QStringList accessControlList() const {
 
126
        return value(SIGNOND_IDENTITY_INFO_ACL).toStringList();
 
127
    }
 
128
 
 
129
    void setValidated(bool validated) {
 
130
        insert(SIGNOND_IDENTITY_INFO_VALIDATED, validated);
 
131
    }
 
132
 
 
133
    bool validated() const {
 
134
        return value(SIGNOND_IDENTITY_INFO_VALIDATED).toBool();
 
135
    }
 
136
 
 
137
    void setType(int type) {
 
138
        insert(SIGNOND_IDENTITY_INFO_TYPE, type);
 
139
    }
 
140
 
 
141
    int type() const {
 
142
        return value(SIGNOND_IDENTITY_INFO_TYPE).toInt();
 
143
    }
 
144
 
 
145
    void setOwnerList(const QStringList &owners) {
 
146
        insert(SIGNOND_IDENTITY_INFO_OWNER, owners);
 
147
    }
 
148
 
 
149
    QStringList ownerList() const {
 
150
        return value(SIGNOND_IDENTITY_INFO_OWNER).toStringList();
 
151
    }
 
152
 
 
153
    void setRefCount(int refCount) {
 
154
        insert(SIGNOND_IDENTITY_INFO_REFCOUNT, refCount);
 
155
    }
 
156
 
 
157
    int refCount() const {
 
158
        return value(SIGNOND_IDENTITY_INFO_REFCOUNT).toInt();
 
159
    }
104
160
 
105
161
    bool checkMethodAndMechanism(const QString &method,
106
162
                                 const QString &mechanism,
107
163
                                 QString &allowedMechanism);
108
 
 
109
 
private:
110
 
    quint32 m_id;
111
 
    QString m_userName;
112
 
    QString m_password;
113
 
    bool m_storePassword;
114
 
    QString m_caption;
115
 
    MethodMap m_methods;
116
 
    QStringList m_realms;
117
 
    QStringList m_accessControlList;
118
 
    QStringList m_ownerList;
119
 
    int m_type;
120
 
    int m_refCount;
121
 
    bool m_validated;
122
 
    bool m_isUserNameSecret;
123
164
}; //struct SignonIdentityInfo
124
165
 
125
166
} //namespace SignonDaemonNS