Merge lp:~pete-woods/indicator-network/keyring-support into lp:indicator-network

Proposed by Pete Woods
Status: Merged
Approved by: Pete Woods
Approved revision: no longer in the source branch.
Merged at revision: 566
Proposed branch: lp:~pete-woods/indicator-network/keyring-support
Merge into: lp:indicator-network
Prerequisite: lp:~pete-woods/indicator-network/pptp-ui
Diff against target: 1247 lines (+631/-129)
22 files modified
CMakeLists.txt (+12/-0)
debian/control (+1/-0)
src/CMakeLists.txt (+2/-0)
src/agent/CMakeLists.txt (+61/-0)
src/agent/CredentialStore.cpp (+29/-0)
src/agent/CredentialStore.h (+44/-0)
src/agent/KeyringCredentialStore.cpp (+154/-0)
src/agent/KeyringCredentialStore.h (+44/-0)
src/agent/SecretAgent.cpp (+162/-13)
src/agent/SecretAgent.h (+43/-13)
src/agent/SecretRequest.cpp (+16/-12)
src/agent/SecretRequest.h (+2/-0)
src/agent/agent-main.cpp (+11/-13)
src/indicator/CMakeLists.txt (+3/-37)
src/indicator/factory.cpp (+0/-7)
src/indicator/factory.h (+0/-2)
src/indicator/nmofono/vpn/vpn-manager.cpp (+1/-1)
src/notify-cpp/CMakeLists.txt (+1/-0)
src/util/CMakeLists.txt (+8/-0)
tests/unit/CMakeLists.txt (+1/-1)
tests/unit/secret-agent/secret-agent-main.cpp (+10/-4)
tests/unit/secret-agent/test-secret-agent.cpp (+26/-26)
To merge this branch: bzr merge lp:~pete-woods/indicator-network/keyring-support
Reviewer Review Type Date Requested Status
Indicator Applet Developers Pending
PS Jenkins bot continuous-integration Pending
Review via email: mp+286029@code.launchpad.net

Commit message

Add keyring support to secret agent (requires libsecret)

Description of the change

Add keyring support to secret agent (requires libsecret)

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2015-08-03 13:27:40 +0000
+++ CMakeLists.txt 2016-02-23 09:05:39 +0000
@@ -60,6 +60,18 @@
60)60)
61include_directories(${OFONO_INCLUDE_DIRS})61include_directories(${OFONO_INCLUDE_DIRS})
6262
63pkg_check_modules(
64 NETWORKMANAGER REQUIRED
65 NetworkManager
66)
67include_directories(${NETWORKMANAGER_INCLUDE_DIRS})
68
69pkg_check_modules(
70 LIBSECRET REQUIRED
71 libsecret-1
72)
73include_directories(${LIBSECRET_INCLUDE_DIRS})
74
63find_package(Qt5Core REQUIRED)75find_package(Qt5Core REQUIRED)
64include_directories(${Qt5Core_INCLUDE_DIRS})76include_directories(${Qt5Core_INCLUDE_DIRS})
6577
6678
=== modified file 'debian/control'
--- debian/control 2016-02-23 09:05:39 +0000
+++ debian/control 2016-02-23 09:05:39 +0000
@@ -17,6 +17,7 @@
17 libqofono-qt5-0,17 libqofono-qt5-0,
18 libqtdbusmock1-dev (>= 0.4),18 libqtdbusmock1-dev (>= 0.4),
19 libqtdbustest1-dev,19 libqtdbustest1-dev,
20 libsecret-1-dev,
20 liburl-dispatcher1-dev,21 liburl-dispatcher1-dev,
21 libunity-api-dev,22 libunity-api-dev,
22 network-manager-dev,23 network-manager-dev,
2324
=== modified file 'src/CMakeLists.txt'
--- src/CMakeLists.txt 2015-07-28 08:26:51 +0000
+++ src/CMakeLists.txt 2016-02-23 09:05:39 +0000
@@ -1,6 +1,7 @@
11
2add_subdirectory(connectivity-api)2add_subdirectory(connectivity-api)
33
4add_subdirectory(agent)
4add_subdirectory(indicator)5add_subdirectory(indicator)
5add_subdirectory(menumodel-cpp)6add_subdirectory(menumodel-cpp)
6add_subdirectory(qdbus-stubs)7add_subdirectory(qdbus-stubs)
@@ -8,3 +9,4 @@
8add_subdirectory(notify-cpp)9add_subdirectory(notify-cpp)
9add_subdirectory(sniffer)10add_subdirectory(sniffer)
10add_subdirectory(url-dispatcher-cpp)11add_subdirectory(url-dispatcher-cpp)
12add_subdirectory(util)
1113
=== renamed directory 'src/indicator/agent' => 'src/agent'
=== added file 'src/agent/CMakeLists.txt'
--- src/agent/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ src/agent/CMakeLists.txt 2016-02-23 09:05:39 +0000
@@ -0,0 +1,61 @@
1
2include_directories("${CMAKE_SOURCE_DIR}/src")
3include_directories("${CMAKE_BINARY_DIR}/src/qdbus-stubs")
4include_directories("${CMAKE_SOURCE_DIR}/src/qdbus-stubs")
5
6set(AGENT_SOURCES
7 CredentialStore.cpp
8 KeyringCredentialStore.cpp
9 SecretAgent.cpp
10 SecretRequest.cpp
11 PasswordMenu.cpp
12)
13
14qt5_add_dbus_adaptor(
15 AGENT_SOURCES
16 "${DATA_DIR}/nm-secret-agent.xml"
17 "agent/SecretAgentInclude.h"
18 "agent::SecretAgent"
19 SecretAgentAdaptor
20)
21
22add_library(
23 agent-static
24 STATIC
25 ${AGENT_SOURCES}
26)
27
28target_link_libraries(
29 agent-static
30 notify_cpp
31 util
32 Qt5::Core
33 Qt5::DBus
34 ${LIBSECRET_LDFLAGS}
35)
36
37###########################
38# Executables
39###########################
40
41add_executable(
42 indicator-network-secret-agent
43 agent-main.cpp
44)
45
46target_link_libraries(
47 indicator-network-secret-agent
48 agent-static
49 Qt5::Core
50 Qt5::DBus
51)
52
53###########################
54# Installation
55###########################
56
57install(
58 TARGETS
59 indicator-network-secret-agent
60 RUNTIME DESTINATION "${CMAKE_INSTALL_LIBEXECDIR}/indicator-network/"
61)
062
=== added file 'src/agent/CredentialStore.cpp'
--- src/agent/CredentialStore.cpp 1970-01-01 00:00:00 +0000
+++ src/agent/CredentialStore.cpp 2016-02-23 09:05:39 +0000
@@ -0,0 +1,29 @@
1/*
2 * Copyright (C) 2016 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Pete Woods <pete.woods@canonical.com>
17 */
18
19#include <agent/CredentialStore.h>
20
21namespace agent {
22
23CredentialStore::CredentialStore() {
24}
25
26CredentialStore::~CredentialStore() {
27}
28
29}
030
=== added file 'src/agent/CredentialStore.h'
--- src/agent/CredentialStore.h 1970-01-01 00:00:00 +0000
+++ src/agent/CredentialStore.h 2016-02-23 09:05:39 +0000
@@ -0,0 +1,44 @@
1/*
2 * Copyright (C) 2016 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Pete Woods <pete.woods@canonical.com>
17 */
18
19#pragma once
20
21#include <unity/util/DefinesPtrs.h>
22
23#include <QMap>
24#include <QString>
25
26namespace agent {
27
28class CredentialStore {
29public:
30 UNITY_DEFINES_PTRS(CredentialStore);
31
32 CredentialStore();
33
34 virtual ~CredentialStore();
35
36 virtual void save(const QString& uuid, const QString& settingName, const QString& settingKey,
37 const QString& displayName, const QString& secret) = 0;
38
39 virtual QMap<QString, QString> get(const QString& uuid, const QString& settingName) = 0;
40
41 virtual void clear(const QString& uuid) = 0;
42};
43
44}
045
=== added file 'src/agent/KeyringCredentialStore.cpp'
--- src/agent/KeyringCredentialStore.cpp 1970-01-01 00:00:00 +0000
+++ src/agent/KeyringCredentialStore.cpp 2016-02-23 09:05:39 +0000
@@ -0,0 +1,154 @@
1/*
2 * Copyright (C) 2016 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Pete Woods <pete.woods@canonical.com>
17 */
18
19#include <agent/KeyringCredentialStore.h>
20
21#include <libsecret/secret.h>
22#include <QDebug>
23
24#define KEYRING_UUID_TAG "connection-uuid"
25#define KEYRING_SN_TAG "setting-name"
26#define KEYRING_SK_TAG "setting-key"
27
28static const SecretSchema network_manager_secret_schema = {
29 "org.freedesktop.NetworkManager.Connection",
30 SECRET_SCHEMA_DONT_MATCH_NAME,
31 {
32 {KEYRING_UUID_TAG, SECRET_SCHEMA_ATTRIBUTE_STRING},
33 {KEYRING_SN_TAG, SECRET_SCHEMA_ATTRIBUTE_STRING},
34 {KEYRING_SK_TAG, SECRET_SCHEMA_ATTRIBUTE_STRING},
35 {NULL, (SecretSchemaAttributeType) 0},
36 },
37 // The below junk prevents compilation warnings for
38 // the uninitialised reserved values
39 0,
40 (gpointer) 0,
41 (gpointer) 0,
42 (gpointer) 0,
43 (gpointer) 0,
44 (gpointer) 0,
45 (gpointer) 0,
46 (gpointer) 0
47};
48
49using namespace std;
50
51namespace agent {
52
53KeyringCredentialStore::KeyringCredentialStore() {
54}
55
56KeyringCredentialStore::~KeyringCredentialStore() {
57}
58
59void KeyringCredentialStore::save(const QString& uuid,
60 const QString& settingName, const QString& settingKey,
61 const QString& displayName, const QString& secret) {
62 shared_ptr<GHashTable> attrs(
63 secret_attributes_build(&network_manager_secret_schema,
64 KEYRING_UUID_TAG, uuid.toUtf8().constData(),
65 KEYRING_SN_TAG, settingName.toUtf8().constData(),
66 KEYRING_SK_TAG, settingKey.toUtf8().constData(),
67 NULL), &g_hash_table_unref);
68
69 GError* error = NULL;
70 if (!secret_password_storev_sync(&network_manager_secret_schema,
71 attrs.get(),
72 NULL,
73 displayName.toUtf8().constData(),
74 secret.toUtf8().constData(),
75 NULL, &error)) {
76 QString message;
77 if (error != NULL) {
78 if (error->message) {
79 message = QString::fromUtf8(error->message);
80 }
81 g_error_free(error);
82 }
83 qCritical() << __PRETTY_FUNCTION__ << message;
84 }
85}
86
87QMap<QString, QString> KeyringCredentialStore::get(const QString& uuid, const QString& settingName) {
88 QMap<QString, QString> result;
89
90 shared_ptr<GHashTable> attrs(secret_attributes_build(
91 &network_manager_secret_schema,
92 KEYRING_UUID_TAG, uuid.toUtf8().constData(),
93 KEYRING_SN_TAG, settingName.toUtf8().constData(),
94 NULL), &g_hash_table_unref);
95
96 GError* error = NULL;
97 shared_ptr<GList> list(secret_service_search_sync(NULL,
98 &network_manager_secret_schema, attrs.get(),
99 (SecretSearchFlags) (SECRET_SEARCH_ALL | SECRET_SEARCH_UNLOCK
100 | SECRET_SEARCH_LOAD_SECRETS), NULL, &error), [](GList* list) {
101 g_list_free_full (list, g_object_unref);
102 });
103
104 if (list == NULL) {
105 if (error != NULL) {
106 string errorMessage;
107 if (error->message) {
108 errorMessage = error->message;
109 }
110 g_error_free(error);
111 throw domain_error(errorMessage);
112 }
113
114 return result;
115 }
116
117 for (GList* iter = list.get(); iter != NULL; iter = g_list_next(iter)) {
118 SecretItem *item = (SecretItem *) iter->data;
119 shared_ptr<SecretValue> secret(secret_item_get_secret(item), &secret_value_unref);
120 if (secret) {
121 shared_ptr<GHashTable> attributes(secret_item_get_attributes(item), &g_hash_table_unref);
122 const char *keyName = (const char *) g_hash_table_lookup(attributes.get(),
123 KEYRING_SK_TAG);
124 if (!keyName) {
125 continue;
126 }
127
128 QString keyString = QString::fromUtf8(keyName);
129 QString secretString = QString::fromUtf8(secret_value_get(secret.get(), NULL));
130
131 result[keyString] = secretString;
132 }
133 }
134
135 return result;
136}
137
138void KeyringCredentialStore::clear(const QString& uuid) {
139 GError *error = NULL;
140 if (!secret_password_clear_sync(&network_manager_secret_schema, NULL, &error,
141 KEYRING_UUID_TAG, uuid.toUtf8().constData(),
142 NULL)) {
143 if (error != NULL) {
144 QString message;
145 if (error->message) {
146 message = QString::fromUtf8(error->message);
147 }
148 g_error_free(error);
149 qCritical() << __PRETTY_FUNCTION__ << message;
150 }
151 }
152}
153
154}
0155
=== added file 'src/agent/KeyringCredentialStore.h'
--- src/agent/KeyringCredentialStore.h 1970-01-01 00:00:00 +0000
+++ src/agent/KeyringCredentialStore.h 2016-02-23 09:05:39 +0000
@@ -0,0 +1,44 @@
1/*
2 * Copyright (C) 2016 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Pete Woods <pete.woods@canonical.com>
17 */
18
19#pragma once
20
21#include <agent/CredentialStore.h>
22
23#include <QList>
24#include <QPair>
25#include <QString>
26
27namespace agent {
28
29class KeyringCredentialStore: public CredentialStore {
30public:
31 KeyringCredentialStore();
32
33 ~KeyringCredentialStore();
34
35 void save(const QString& uuid, const QString& settingName,
36 const QString& settingKey, const QString& displayName,
37 const QString& secret) override;
38
39 QMap<QString, QString> get(const QString& uuid, const QString& settingName) override;
40
41 void clear(const QString& uuid) override;
42};
43
44}
045
=== modified file 'src/agent/SecretAgent.cpp'
--- src/indicator/agent/SecretAgent.cpp 2015-11-20 13:14:50 +0000
+++ src/agent/SecretAgent.cpp 2016-02-23 09:05:39 +0000
@@ -25,6 +25,13 @@
25#include <NetworkManager.h>25#include <NetworkManager.h>
26#include <stdexcept>26#include <stdexcept>
2727
28#define NM_SECRET_AGENT_CAPABILITY_NONE 0
29
30#define NM_SECRET_AGENT_GET_SECRETS_FLAG_NONE 0
31#define NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION 1
32#define NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW 2
33#define NM_SECRET_AGENT_GET_SECRETS_FLAG_USER_REQUESTED 4
34
28using namespace std;35using namespace std;
2936
30namespace agent37namespace agent
@@ -34,16 +41,85 @@
34 Q_OBJECT41 Q_OBJECT
3542
36public:43public:
37 Priv(notify::NotificationManager::SPtr notificationManager, const QDBusConnection &systemConnection,44 Priv(notify::NotificationManager::SPtr notificationManager,
45 agent::CredentialStore::SPtr credentialStore,
46 const QDBusConnection &systemConnection,
38 const QDBusConnection &sessionConnection) :47 const QDBusConnection &sessionConnection) :
39 m_systemConnection(systemConnection),48 m_systemConnection(systemConnection),
40 m_sessionConnection(sessionConnection),49 m_sessionConnection(sessionConnection),
41 m_managerWatcher(NM_DBUS_SERVICE, m_systemConnection),50 m_managerWatcher(NM_DBUS_SERVICE, m_systemConnection),
42 m_agentManager(NM_DBUS_SERVICE, NM_DBUS_PATH_AGENT_MANAGER, m_systemConnection),51 m_agentManager(NM_DBUS_SERVICE, NM_DBUS_PATH_AGENT_MANAGER, m_systemConnection),
43 m_notifications(notificationManager),52 m_notifications(notificationManager),
53 m_credentialStore(credentialStore),
44 m_request(nullptr) {54 m_request(nullptr) {
45 }55 }
4656
57 void saveSecret(const QString& id, const QString& uuid,
58 const QString& settingName, const QString& settingKey,
59 const QString& secret, const QString& inputDisplayName =
60 QString()) {
61
62 // TODO: Don't save always-ask or system-owned secrets
63
64 QString displayName(inputDisplayName);
65 if (displayName.isEmpty()) {
66 static const QString DISPLAY_NAME("Network secret for %s/%s/%s");
67 displayName = DISPLAY_NAME.arg(id, settingName, settingKey);
68 }
69
70 m_credentialStore->save(uuid, settingName, settingKey, displayName, secret);
71 }
72
73 static bool isSecret(const QString& settingName, const QString& key) {
74 static const QMap<QString, QSet<QString>> KNOWN_SECRETS{
75 {QString::fromUtf8(NM_802_1X_SETTING_NAME), {NM_802_1X_PASSWORD, NM_802_1X_PRIVATE_KEY_PASSWORD,
76 NM_802_1X_PHASE2_PRIVATE_KEY_PASSWORD, NM_802_1X_PIN}},
77 {QString::fromUtf8(NM_ADSL_SETTING_NAME), {NM_ADSL_PASSWORD}},
78 {QString::fromUtf8(NM_CDMA_SETTING_NAME), {NM_CDMA_PASSWORD}},
79 {QString::fromUtf8(NM_GSM_SETTING_NAME), {NM_GSM_PASSWORD, NM_GSM_PIN}},
80 {QString::fromUtf8(NM_PPPOE_SETTING_NAME), {NM_PPPOE_PASSWORD}},
81 {QString::fromUtf8(NM_WIRELESS_SECURITY_SETTING_NAME), {NM_WIRELESS_SECURITY_WEP_KEY0,
82 NM_WIRELESS_SECURITY_WEP_KEY1, NM_WIRELESS_SECURITY_WEP_KEY2, NM_WIRELESS_SECURITY_WEP_KEY3,
83 NM_WIRELESS_SECURITY_PSK, NM_WIRELESS_SECURITY_LEAP_PASSWORD}}
84 };
85 auto it = KNOWN_SECRETS.constFind(settingName);
86 if (it != KNOWN_SECRETS.constEnd()) {
87 if (it->contains(key)) {
88 return true;
89 }
90 }
91 return false;
92 }
93
94 void saveSettings(const QString& id, const QString& uuid,
95 const QString& settingName, const QVariantMap& setting) {
96
97 QMapIterator<QString, QVariant> iter(setting);
98 while (iter.hasNext()) {
99 iter.next();
100 if (isSecret(settingName, iter.key())) {
101 saveSecret(id, uuid, settingName, iter.key(),
102 iter.value().toString());
103 }
104 }
105 }
106
107 void saveVpnSettings(const QString& id, const QString& uuid,
108 const QString& settingName, const QVariantMap& setting) {
109 static const QString DISPLAY_NAME{"VPN %1 secret for %2/%3/%4"};
110
111 QString serviceType = setting[NM_VPN_SERVICE_TYPE].toString();
112 QStringMap secrets;
113 auto dbusArgument = qvariant_cast<QDBusArgument>(setting[NM_VPN_SECRETS]);
114 dbusArgument >> secrets;
115 QMapIterator<QString, QString> iter(secrets);
116 while(iter.hasNext()) {
117 iter.next();
118 saveSecret(id, uuid, settingName, iter.key(), iter.value(),
119 DISPLAY_NAME.arg(iter.key(), id, serviceType, NM_VPN_SETTING_NAME));
120 }
121 }
122
47public Q_SLOTS:123public Q_SLOTS:
48 void serviceOwnerChanged(const QString &name, const QString &oldOwner,124 void serviceOwnerChanged(const QString &name, const QString &oldOwner,
49 const QString &newOwner)125 const QString &newOwner)
@@ -53,7 +129,7 @@
53 if (!newOwner.isEmpty()) {129 if (!newOwner.isEmpty()) {
54 auto reply = m_agentManager.RegisterWithCapabilities(130 auto reply = m_agentManager.RegisterWithCapabilities(
55 "com.canonical.indicator.SecretAgent",131 "com.canonical.indicator.SecretAgent",
56 0 /*NM_SECRET_AGENT_CAPABILITY_NONE*/);132 NM_SECRET_AGENT_CAPABILITY_NONE);
57 reply.waitForFinished();133 reply.waitForFinished();
58 if (reply.isError()) {134 if (reply.isError()) {
59 qCritical() << __PRETTY_FUNCTION__ << reply.error().message();135 qCritical() << __PRETTY_FUNCTION__ << reply.error().message();
@@ -72,13 +148,16 @@
72148
73 notify::NotificationManager::SPtr m_notifications;149 notify::NotificationManager::SPtr m_notifications;
74150
151 CredentialStore::SPtr m_credentialStore;
152
75 std::shared_ptr<SecretRequest> m_request;153 std::shared_ptr<SecretRequest> m_request;
76};154};
77155
78SecretAgent::SecretAgent(notify::NotificationManager::SPtr notificationManager,156SecretAgent::SecretAgent(notify::NotificationManager::SPtr notificationManager,
79 const QDBusConnection &systemConnection,157 agent::CredentialStore::SPtr credentialStore,
158 const QDBusConnection &systemConnection,
80 const QDBusConnection &sessionConnection, QObject *parent) :159 const QDBusConnection &sessionConnection, QObject *parent) :
81 QObject(parent), d(new Priv(notificationManager, systemConnection, sessionConnection))160 QObject(parent), d(new Priv(notificationManager, credentialStore, systemConnection, sessionConnection))
82 {161 {
83 // Memory managed by Qt162 // Memory managed by Qt
84 new SecretAgentAdaptor(this);163 new SecretAgentAdaptor(this);
@@ -94,7 +173,7 @@
94173
95 auto reply = d->m_agentManager.RegisterWithCapabilities(174 auto reply = d->m_agentManager.RegisterWithCapabilities(
96 "com.canonical.indicator.SecretAgent",175 "com.canonical.indicator.SecretAgent",
97 0 /*NM_SECRET_AGENT_CAPABILITY_NONE*/);176 NM_SECRET_AGENT_CAPABILITY_NONE);
98 reply.waitForFinished();177 reply.waitForFinished();
99 if (reply.isError()) {178 if (reply.isError()) {
100 qCritical() << __PRETTY_FUNCTION__ << reply.error().message();179 qCritical() << __PRETTY_FUNCTION__ << reply.error().message();
@@ -153,13 +232,66 @@
153232
154 setDelayedReply(true);233 setDelayedReply(true);
155234
156 if (flags != 0 && settingName == "802-11-wireless-security") {235 qDebug() << __PRETTY_FUNCTION__ << connectionPath.path() << settingName << hints << flags;
236
237 // If we want a WiFi secret, and
238 if (settingName == NM_WIRELESS_SECURITY_SETTING_NAME &&
239 ((flags & NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION) > 0) &&
240 (
241 ((flags & NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW) > 0) ||
242 ((flags & NM_SECRET_AGENT_GET_SECRETS_FLAG_USER_REQUESTED) > 0)
243 )) {
244 qDebug() << __PRETTY_FUNCTION__ << "Requesting secret from user";
157 d->m_request.reset(new SecretRequest(*this, connection,245 d->m_request.reset(new SecretRequest(*this, connection,
158 connectionPath, settingName, hints, flags, message()));246 connectionPath, settingName, hints, flags, message()));
247 } else if (((flags == NM_SECRET_AGENT_GET_SECRETS_FLAG_NONE) ||
248 (flags == NM_SECRET_AGENT_GET_SECRETS_FLAG_USER_REQUESTED))) {
249 qDebug() << __PRETTY_FUNCTION__ << "Retrieving secret from keyring";
250
251 bool isVpn = (settingName == NM_VPN_SETTING_NAME);
252
253 QString uuid = connection[NM_CONNECTION_SETTING_NAME][NM_CONNECTION_UUID].toString();
254
255 QStringMap secrets;
256
257 try {
258 secrets = d->m_credentialStore->get(uuid, settingName);
259 } catch (domain_error& e) {
260 d->m_systemConnection.send(
261 message().createErrorReply(
262 "org.freedesktop.NetworkManager.SecretAgent.InternalError",
263 e.what()));
264 return QVariantDictMap();
265 }
266
267 if (secrets.isEmpty()) {
268 d->m_systemConnection.send(
269 message().createErrorReply(
270 "org.freedesktop.NetworkManager.SecretAgent.NoSecrets",
271 "No secrets found for this connection."));
272 return QVariantDictMap();
273 }
274
275 QVariantDictMap newConnection;
276
277 if (isVpn) {
278 newConnection[settingName][NM_VPN_SECRETS] = QVariant::fromValue(
279 secrets);
280 } else {
281 QMapIterator<QString, QString> it(secrets);
282 while (it.hasNext()) {
283 it.next();
284 newConnection[settingName][it.key()] = it.value();
285 }
286 }
287
288 d->m_systemConnection.send(
289 message().createReply(QVariant::fromValue(newConnection)));
159 } else {290 } else {
291 qDebug() << __PRETTY_FUNCTION__ << "Can't get secrets for this connection";
160 d->m_systemConnection.send(292 d->m_systemConnection.send(
161 message().createErrorReply(QDBusError::InternalError,293 message().createErrorReply("org.freedesktop.NetworkManager.SecretAgent.NoSecrets",
162 "No password found for this connection."));294 "No secrets found for this connection."));
163 }295 }
164296
165 return QVariantDictMap();297 return QVariantDictMap();
@@ -168,7 +300,7 @@
168void SecretAgent::FinishGetSecrets(SecretRequest &request, bool error) {300void SecretAgent::FinishGetSecrets(SecretRequest &request, bool error) {
169 if (error) {301 if (error) {
170 d->m_systemConnection.send(302 d->m_systemConnection.send(
171 request.message().createErrorReply(QDBusError::InternalError,303 request.message().createErrorReply("org.freedesktop.NetworkManager.SecretAgent.NoSecrets",
172 "No password found for this connection."));304 "No password found for this connection."));
173 } else {305 } else {
174 d->m_systemConnection.send(306 d->m_systemConnection.send(
@@ -181,21 +313,38 @@
181313
182void SecretAgent::CancelGetSecrets(const QDBusObjectPath &connectionPath,314void SecretAgent::CancelGetSecrets(const QDBusObjectPath &connectionPath,
183 const QString &settingName) {315 const QString &settingName) {
184 Q_UNUSED(connectionPath);
185 Q_UNUSED(settingName);316 Q_UNUSED(settingName);
186 d->m_request.reset();317
318 if (d->m_request && d->m_request->connectionPath() == connectionPath) {
319 d->m_request.reset();
320 }
187}321}
188322
189void SecretAgent::DeleteSecrets(const QVariantDictMap &connection,323void SecretAgent::DeleteSecrets(const QVariantDictMap &connection,
190 const QDBusObjectPath &connectionPath) {324 const QDBusObjectPath &connectionPath) {
191 Q_UNUSED(connection);
192 Q_UNUSED(connectionPath);325 Q_UNUSED(connectionPath);
326
327 QString uuid = connection[NM_CONNECTION_SETTING_NAME][NM_CONNECTION_UUID].toString();
328 d->m_credentialStore->clear(uuid);
193}329}
194330
195void SecretAgent::SaveSecrets(const QVariantDictMap &connection,331void SecretAgent::SaveSecrets(const QVariantDictMap &connection,
196 const QDBusObjectPath &connectionPath) {332 const QDBusObjectPath &connectionPath) {
197 Q_UNUSED(connection);
198 Q_UNUSED(connectionPath);333 Q_UNUSED(connectionPath);
334
335 QString id = connection[NM_CONNECTION_SETTING_NAME][NM_CONNECTION_ID].toString();
336 QString uuid = connection[NM_CONNECTION_SETTING_NAME][NM_CONNECTION_UUID].toString();
337 QString type = connection[NM_CONNECTION_SETTING_NAME][NM_CONNECTION_TYPE].toString();
338
339 if (type == NM_VPN_SETTING_NAME) {
340 d->saveVpnSettings(id, uuid, NM_VPN_SETTING_NAME, connection[NM_VPN_SETTING_NAME]);
341 } else {
342 QMapIterator<QString, QVariantMap> iter(connection);
343 while (iter.hasNext()) {
344 iter.next();
345 d->saveSettings(id, uuid, iter.key(), iter.value());
346 }
347 }
199}348}
200349
201notify::NotificationManager::SPtr SecretAgent::notifications() {350notify::NotificationManager::SPtr SecretAgent::notifications() {
202351
=== modified file 'src/agent/SecretAgent.h'
--- src/indicator/agent/SecretAgent.h 2015-08-03 13:27:40 +0000
+++ src/agent/SecretAgent.h 2016-02-23 09:05:39 +0000
@@ -19,6 +19,7 @@
19#pragma once19#pragma once
2020
21#include <dbus-types.h>21#include <dbus-types.h>
22#include <agent/CredentialStore.h>
2223
23#include <memory>24#include <memory>
2425
@@ -48,21 +49,50 @@
48 typedef std::shared_ptr<SecretAgent> Ptr;49 typedef std::shared_ptr<SecretAgent> Ptr;
49 typedef std::unique_ptr<SecretAgent> UPtr;50 typedef std::unique_ptr<SecretAgent> UPtr;
5051
51 static constexpr char const* CONNECTION_SETTING_NAME = "connection";52 static constexpr char const* NM_CONNECTION_SETTING_NAME = "connection";
52 static constexpr char const* WIRELESS_SECURITY_SETTING_NAME = "802-11-wireless-security";53
5354 static constexpr char const* NM_CONNECTION_ID = "id";
54 static constexpr char const* CONNECTION_ID = "id";55 static constexpr char const* NM_CONNECTION_UUID = "uuid";
5556 static constexpr char const* NM_CONNECTION_TYPE = "type";
56 static constexpr char const* WIRELESS_SECURITY_PSK = "psk";57
57 static constexpr char const* WIRELESS_SECURITY_WEP_KEY0 = "wep-key0";58 static constexpr char const* NM_ADSL_SETTING_NAME = "adsl";
5859 static constexpr char const* NM_ADSL_PASSWORD = "password";
59 static constexpr char const* WIRELESS_SECURITY_KEY_MGMT = "key-mgmt";60
6061 static constexpr char const* NM_GSM_SETTING_NAME = "gsm";
61 static constexpr char const* KEY_MGMT_WPA_NONE = "wpa-none";62 static constexpr char const* NM_GSM_PASSWORD = "password";
62 static constexpr char const* KEY_MGMT_WPA_PSK = "wpa-psk";63 static constexpr char const* NM_GSM_PIN = "pin";
63 static constexpr char const* KEY_MGMT_NONE = "none";64
65 static constexpr char const* NM_802_1X_SETTING_NAME = "802-1x";
66 static constexpr char const* NM_802_1X_PASSWORD = "password";
67 static constexpr char const* NM_802_1X_PRIVATE_KEY_PASSWORD = "private-key-password";
68 static constexpr char const* NM_802_1X_PHASE2_PRIVATE_KEY_PASSWORD = "phase2-private-key-password";
69 static constexpr char const* NM_802_1X_PIN = "pin";
70
71 static constexpr char const* NM_CDMA_SETTING_NAME = "cdma";
72 static constexpr char const* NM_CDMA_PASSWORD = "password";
73
74 static constexpr char const* NM_PPPOE_SETTING_NAME = "pppoe";
75 static constexpr char const* NM_PPPOE_PASSWORD = "password";
76
77 static constexpr char const* NM_VPN_SETTING_NAME = "vpn";
78 static constexpr char const* NM_VPN_SERVICE_TYPE = "service-type";
79 static constexpr char const* NM_VPN_SECRETS = "secrets";
80
81 static constexpr char const* NM_WIRELESS_SECURITY_SETTING_NAME = "802-11-wireless-security";
82 static constexpr char const* NM_WIRELESS_SECURITY_KEY_MGMT = "key-mgmt";
83 static constexpr char const* NM_WIRELESS_SECURITY_WEP_KEY0 = "wep-key0";
84 static constexpr char const* NM_WIRELESS_SECURITY_WEP_KEY1 = "wep-key1";
85 static constexpr char const* NM_WIRELESS_SECURITY_WEP_KEY2 = "wep-key2";
86 static constexpr char const* NM_WIRELESS_SECURITY_WEP_KEY3 = "wep-key3";
87 static constexpr char const* NM_WIRELESS_SECURITY_PSK = "psk";
88 static constexpr char const* NM_WIRELESS_SECURITY_LEAP_PASSWORD = "leap-password";
89
90 static constexpr char const* NM_KEY_MGMT_WPA_NONE = "wpa-none";
91 static constexpr char const* NM_KEY_MGMT_WPA_PSK = "wpa-psk";
92 static constexpr char const* NM_KEY_MGMT_NONE = "none";
6493
65 explicit SecretAgent(std::shared_ptr<notify::NotificationManager> notificationManager,94 explicit SecretAgent(std::shared_ptr<notify::NotificationManager> notificationManager,
95 CredentialStore::SPtr credentialStore,
66 const QDBusConnection &systemConnection,96 const QDBusConnection &systemConnection,
67 const QDBusConnection &sessionConnection, QObject *parent = 0);97 const QDBusConnection &sessionConnection, QObject *parent = 0);
6898
6999
=== modified file 'src/agent/SecretRequest.cpp'
--- src/indicator/agent/SecretRequest.cpp 2015-08-03 13:27:40 +0000
+++ src/agent/SecretRequest.cpp 2016-02-23 09:05:39 +0000
@@ -52,24 +52,24 @@
5252
53 notificationHints["x-canonical-private-menu-model"] = menuModelPaths;53 notificationHints["x-canonical-private-menu-model"] = menuModelPaths;
5454
55 const QVariantMap &conn = m_connection[SecretAgent::CONNECTION_SETTING_NAME];55 const QVariantMap &conn = m_connection[SecretAgent::NM_CONNECTION_SETTING_NAME];
5656
57 auto wirelessSecurity = m_connection.find(m_settingName);57 auto wirelessSecurity = m_connection.find(m_settingName);
58 QString keyMgmt(58 QString keyMgmt(
59 wirelessSecurity->value(SecretAgent::WIRELESS_SECURITY_KEY_MGMT).toString());59 wirelessSecurity->value(SecretAgent::NM_WIRELESS_SECURITY_KEY_MGMT).toString());
6060
61 QString title(_("Connect to “%1”"));61 QString title(_("Connect to “%1”"));
6262
63 QString subject;63 QString subject;
64 if (keyMgmt == SecretAgent::KEY_MGMT_WPA_NONE64 if (keyMgmt == SecretAgent::NM_KEY_MGMT_WPA_NONE
65 || keyMgmt == SecretAgent::KEY_MGMT_WPA_PSK) {65 || keyMgmt == SecretAgent::NM_KEY_MGMT_WPA_PSK) {
66 subject = _("WPA");66 subject = _("WPA");
67 } else if (keyMgmt == SecretAgent::KEY_MGMT_NONE) {67 } else if (keyMgmt == SecretAgent::NM_KEY_MGMT_NONE) {
68 subject = _("WEP");68 subject = _("WEP");
69 }69 }
7070
71 m_notification = m_secretAgent.notifications()->notify(71 m_notification = m_secretAgent.notifications()->notify(
72 title.arg(conn[SecretAgent::CONNECTION_ID].toString()), subject,72 title.arg(conn[SecretAgent::NM_CONNECTION_ID].toString()), subject,
73 "wifi-full-secure",73 "wifi-full-secure",
74 QStringList() << "connect_id" << _("Connect") << "cancel_id"74 QStringList() << "connect_id" << _("Connect") << "cancel_id"
75 << _("Cancel"), notificationHints, 0);75 << _("Cancel"), notificationHints, 0);
@@ -101,13 +101,13 @@
101101
102 auto wirelessSecurity = m_connection.find(m_settingName);102 auto wirelessSecurity = m_connection.find(m_settingName);
103 QString keyMgmt(103 QString keyMgmt(
104 wirelessSecurity->value(SecretAgent::WIRELESS_SECURITY_KEY_MGMT).toString());104 wirelessSecurity->value(SecretAgent::NM_WIRELESS_SECURITY_KEY_MGMT).toString());
105105
106 if (keyMgmt == SecretAgent::KEY_MGMT_WPA_NONE106 if (keyMgmt == SecretAgent::NM_KEY_MGMT_WPA_NONE
107 || keyMgmt == SecretAgent::KEY_MGMT_WPA_PSK) {107 || keyMgmt == SecretAgent::NM_KEY_MGMT_WPA_PSK) {
108 wirelessSecurity->insert(SecretAgent::WIRELESS_SECURITY_PSK, key);108 wirelessSecurity->insert(SecretAgent::NM_WIRELESS_SECURITY_PSK, key);
109 } else if (keyMgmt == SecretAgent::KEY_MGMT_NONE) {109 } else if (keyMgmt == SecretAgent::NM_KEY_MGMT_NONE) {
110 wirelessSecurity->insert(SecretAgent::WIRELESS_SECURITY_WEP_KEY0, key);110 wirelessSecurity->insert(SecretAgent::NM_WIRELESS_SECURITY_WEP_KEY0, key);
111 }111 }
112112
113 m_secretAgent.FinishGetSecrets(*this, false);113 m_secretAgent.FinishGetSecrets(*this, false);
@@ -130,4 +130,8 @@
130 return m_message;130 return m_message;
131}131}
132132
133const QDBusObjectPath & SecretRequest::connectionPath() const {
134 return m_connectionPath;
135}
136
133}137}
134138
=== modified file 'src/agent/SecretRequest.h'
--- src/indicator/agent/SecretRequest.h 2015-08-03 13:27:40 +0000
+++ src/agent/SecretRequest.h 2016-02-23 09:05:39 +0000
@@ -51,6 +51,8 @@
5151
52 const QDBusMessage & message() const;52 const QDBusMessage & message() const;
5353
54 const QDBusObjectPath & connectionPath() const;
55
54protected:56protected:
55 notify::Notification::UPtr m_notification;57 notify::Notification::UPtr m_notification;
5658
5759
=== renamed file 'src/indicator/agent-main.cpp' => 'src/agent/agent-main.cpp'
--- src/indicator/agent-main.cpp 2015-11-20 13:14:50 +0000
+++ src/agent/agent-main.cpp 2016-02-23 09:05:39 +0000
@@ -17,7 +17,9 @@
17 * Antti Kaijanmäki <antti.kaijanmaki@canonical.com>17 * Antti Kaijanmäki <antti.kaijanmaki@canonical.com>
18 */18 */
1919
20#include <factory.h>20#include <notify-cpp/notification-manager.h>
21#include <agent/KeyringCredentialStore.h>
22#include <agent/SecretAgent.h>
21#include <util/unix-signal-handler.h>23#include <util/unix-signal-handler.h>
22#include <dbus-types.h>24#include <dbus-types.h>
2325
@@ -32,7 +34,6 @@
32#include <config.h>34#include <config.h>
3335
34using namespace std;36using namespace std;
35using namespace connectivity_service;
3637
37int38int
38main(int argc, char **argv)39main(int argc, char **argv)
@@ -42,23 +43,20 @@
42 Variant::registerMetaTypes();43 Variant::registerMetaTypes();
43 std::srand(std::time(0));44 std::srand(std::time(0));
4445
45 util::UnixSignalHandler handler([]{
46 QCoreApplication::exit(0);
47 });
48 handler.setupUnixSignalHandlers();
49
50 bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");46 bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
51 setlocale(LC_ALL, "");47 setlocale(LC_ALL, "");
52 bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR);48 bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR);
53 textdomain(GETTEXT_PACKAGE);49 textdomain(GETTEXT_PACKAGE);
5450
55 if (argc == 2 && QString("--print-address") == argv[1])51 util::UnixSignalHandler handler([]{
56 {52 QCoreApplication::exit(0);
57 qDebug() << QDBusConnection::systemBus().baseService();53 });
58 }54 handler.setupUnixSignalHandlers();
5955
60 Factory factory;56 auto agent = make_unique<agent::SecretAgent>(
61 auto secretAgent = factory.newSecretAgent();57 make_shared<notify::NotificationManager>(GETTEXT_PACKAGE),
58 make_shared<agent::KeyringCredentialStore>(),
59 QDBusConnection::systemBus(), QDBusConnection::sessionBus());
6260
63 return app.exec();61 return app.exec();
64}62}
6563
=== modified file 'src/indicator/CMakeLists.txt'
--- src/indicator/CMakeLists.txt 2016-01-14 11:40:59 +0000
+++ src/indicator/CMakeLists.txt 2016-02-23 09:05:39 +0000
@@ -1,11 +1,5 @@
11
2pkg_check_modules(2pkg_check_modules(
3 NETWORKMANAGER REQUIRED
4 NetworkManager
5)
6include_directories(${NETWORKMANAGER_INCLUDE_DIRS})
7
8pkg_check_modules(
9 QOFONO REQUIRED3 QOFONO REQUIRED
10 qofono-qt54 qofono-qt5
11)5)
@@ -43,10 +37,6 @@
43 nmofono/vpn/vpn-connection.cpp37 nmofono/vpn/vpn-connection.cpp
44 nmofono/vpn/vpn-manager.cpp38 nmofono/vpn/vpn-manager.cpp
4539
46 agent/SecretAgent.cpp
47 agent/SecretRequest.cpp
48 agent/PasswordMenu.cpp
49
50 factory.cpp40 factory.cpp
51 indicator-menu.cpp41 indicator-menu.cpp
52 icons.cpp42 icons.cpp
@@ -71,9 +61,6 @@
71 menuitems/wifi-link-item.cpp61 menuitems/wifi-link-item.cpp
72 menuitems/wwan-link-item.cpp62 menuitems/wwan-link-item.cpp
73 menuitems/modem-info-item.cpp63 menuitems/modem-info-item.cpp
74
75 util/dbus-utils.cpp
76 util/unix-signal-handler.cpp
77)64)
7865
79qt5_add_dbus_adaptor(66qt5_add_dbus_adaptor(
@@ -116,14 +103,6 @@
116 PptpAdaptor103 PptpAdaptor
117)104)
118105
119qt5_add_dbus_adaptor(
120 NETWORK_SERVICE_SOURCES
121 "${DATA_DIR}/nm-secret-agent.xml"
122 "agent/SecretAgentInclude.h"
123 "agent::SecretAgent"
124 SecretAgentAdaptor
125)
126
127add_library(106add_library(
128 indicator-network-service-static107 indicator-network-service-static
129 STATIC108 STATIC
@@ -137,9 +116,9 @@
137 url_dispatcher_cpp116 url_dispatcher_cpp
138 qdbus-stubs117 qdbus-stubs
139 qpowerd118 qpowerd
140 ${DBUSCPP_LIBRARIES}119 util
141 ${GLIB_LIBRARIES}120 ${GLIB_LDFLAGS}
142 ${QOFONO_LIBRARIES}121 ${QOFONO_LDFLAGS}
143 Qt5::Core122 Qt5::Core
144 Qt5::DBus123 Qt5::DBus
145)124)
@@ -160,18 +139,6 @@
160 Qt5::DBus139 Qt5::DBus
161)140)
162141
163add_executable(
164 indicator-network-secret-agent
165 agent-main.cpp
166)
167
168target_link_libraries(
169 indicator-network-secret-agent
170 indicator-network-service-static
171 Qt5::Core
172 Qt5::DBus
173)
174
175###########################142###########################
176# Installation143# Installation
177###########################144###########################
@@ -179,6 +146,5 @@
179install(146install(
180 TARGETS147 TARGETS
181 indicator-network-service148 indicator-network-service
182 indicator-network-secret-agent
183 RUNTIME DESTINATION "${CMAKE_INSTALL_LIBEXECDIR}/indicator-network/"149 RUNTIME DESTINATION "${CMAKE_INSTALL_LIBEXECDIR}/indicator-network/"
184)150)
185151
=== modified file 'src/indicator/factory.cpp'
--- src/indicator/factory.cpp 2015-12-11 14:58:11 +0000
+++ src/indicator/factory.cpp 2016-02-23 09:05:39 +0000
@@ -221,13 +221,6 @@
221 return make_unique<BusName>(name, acquired, lost, d->singletonSessionBus());221 return make_unique<BusName>(name, acquired, lost, d->singletonSessionBus());
222}222}
223223
224agent::SecretAgent::UPtr Factory::newSecretAgent()
225{
226 return make_unique<agent::SecretAgent>(d->singletonNotificationManager(),
227 QDBusConnection::systemBus(),
228 QDBusConnection::sessionBus());
229}
230
231VpnStatusNotifier::UPtr Factory::newVpnStatusNotifier()224VpnStatusNotifier::UPtr Factory::newVpnStatusNotifier()
232{225{
233 return make_unique<VpnStatusNotifier>(d->singletonActiveConnectionManager(),226 return make_unique<VpnStatusNotifier>(d->singletonActiveConnectionManager(),
234227
=== modified file 'src/indicator/factory.h'
--- src/indicator/factory.h 2015-12-11 14:58:11 +0000
+++ src/indicator/factory.h 2016-02-23 09:05:39 +0000
@@ -31,7 +31,6 @@
31#include <sections/wifi-section.h>31#include <sections/wifi-section.h>
32#include <sections/wwan-section.h>32#include <sections/wwan-section.h>
33#include <menuitems/switch-item.h>33#include <menuitems/switch-item.h>
34#include <agent/SecretAgent.h>
3534
36#include <memory>35#include <memory>
3736
@@ -77,7 +76,6 @@
77 std::function<void(std::string)> acquired,76 std::function<void(std::string)> acquired,
78 std::function<void(std::string)> lost);77 std::function<void(std::string)> lost);
7978
80 virtual agent::SecretAgent::UPtr newSecretAgent();
8179
82 virtual VpnStatusNotifier::UPtr newVpnStatusNotifier();80 virtual VpnStatusNotifier::UPtr newVpnStatusNotifier();
83};81};
8482
=== modified file 'src/indicator/nmofono/vpn/vpn-manager.cpp'
--- src/indicator/nmofono/vpn/vpn-manager.cpp 2016-01-14 11:40:59 +0000
+++ src/indicator/nmofono/vpn/vpn-manager.cpp 2016-02-23 09:05:39 +0000
@@ -251,7 +251,7 @@
251 {"type", "vpn"},251 {"type", "vpn"},
252 {"id", d->newConnectionName()},252 {"id", d->newConnectionName()},
253 {"uuid", uuid},253 {"uuid", uuid},
254 {"autoconnect", "false"}254 {"autoconnect", false}
255255
256 };256 };
257 connection["vpn"] = QVariantMap257 connection["vpn"] = QVariantMap
258258
=== modified file 'src/notify-cpp/CMakeLists.txt'
--- src/notify-cpp/CMakeLists.txt 2015-08-03 13:27:40 +0000
+++ src/notify-cpp/CMakeLists.txt 2016-02-23 09:05:39 +0000
@@ -11,5 +11,6 @@
11add_library(notify_cpp STATIC ${NOTIFY_CPP_SOURCES})11add_library(notify_cpp STATIC ${NOTIFY_CPP_SOURCES})
12target_link_libraries(12target_link_libraries(
13 notify_cpp13 notify_cpp
14 menumodel_cpp
14 qdbus-stubs15 qdbus-stubs
15)16)
1617
=== renamed directory 'src/indicator/util' => 'src/util'
=== added file 'src/util/CMakeLists.txt'
--- src/util/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ src/util/CMakeLists.txt 2016-02-23 09:05:39 +0000
@@ -0,0 +1,8 @@
1include_directories("${CMAKE_SOURCE_DIR}/src/")
2
3set(UTIL_SOURCES
4 dbus-utils.cpp
5 unix-signal-handler.cpp
6)
7
8add_library(util STATIC ${UTIL_SOURCES})
09
=== modified file 'tests/unit/CMakeLists.txt'
--- tests/unit/CMakeLists.txt 2015-11-20 11:21:59 +0000
+++ tests/unit/CMakeLists.txt 2016-02-23 09:05:39 +0000
@@ -27,7 +27,7 @@
2727
28target_link_libraries(28target_link_libraries(
29 secret-agent-test-bin29 secret-agent-test-bin
30 indicator-network-service-static30 agent-static
31)31)
3232
33###################33###################
3434
=== modified file 'tests/unit/secret-agent/secret-agent-main.cpp'
--- tests/unit/secret-agent/secret-agent-main.cpp 2015-04-21 10:59:52 +0000
+++ tests/unit/secret-agent/secret-agent-main.cpp 2016-02-23 09:05:39 +0000
@@ -19,19 +19,23 @@
19#include <config.h>19#include <config.h>
20#include <libintl.h>20#include <libintl.h>
21#include <config.h>21#include <config.h>
22#include <factory.h>
23#include <dbus-types.h>22#include <dbus-types.h>
23#include <notify-cpp/notification-manager.h>
24#include <agent/KeyringCredentialStore.h>
25#include <agent/SecretAgent.h>
24#include <util/unix-signal-handler.h>26#include <util/unix-signal-handler.h>
2527
26#include <QCoreApplication>28#include <QCoreApplication>
29#include <QDBusConnection>
27#include <iostream>30#include <iostream>
31#include <memory>
2832
29using namespace std;33using namespace std;
3034
31
32int main(int argc, char *argv[]) {35int main(int argc, char *argv[]) {
33 QCoreApplication application(argc, argv);36 QCoreApplication application(argc, argv);
34 DBusTypes::registerMetaTypes();37 DBusTypes::registerMetaTypes();
38 Variant::registerMetaTypes();
3539
36 setlocale(LC_ALL, "");40 setlocale(LC_ALL, "");
37 bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR);41 bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR);
@@ -43,8 +47,10 @@
43 });47 });
44 handler.setupUnixSignalHandlers();48 handler.setupUnixSignalHandlers();
4549
46 Factory factory;50 auto secretAgent = make_unique<agent::SecretAgent>(
47 auto secretAgent = factory.newSecretAgent();51 make_shared<notify::NotificationManager>(GETTEXT_PACKAGE),
52 make_shared<agent::KeyringCredentialStore>(),
53 QDBusConnection::systemBus(), QDBusConnection::sessionBus());
4854
49 if (argc == 2 && QString("--print-address") == argv[1]) {55 if (argc == 2 && QString("--print-address") == argv[1]) {
50 cout << QDBusConnection::systemBus().baseService().toStdString()56 cout << QDBusConnection::systemBus().baseService().toStdString()
5157
=== modified file 'tests/unit/secret-agent/test-secret-agent.cpp'
--- tests/unit/secret-agent/test-secret-agent.cpp 2015-11-20 11:21:59 +0000
+++ tests/unit/secret-agent/test-secret-agent.cpp 2016-02-23 09:05:39 +0000
@@ -78,16 +78,16 @@
7878
79 QVariantDictMap connection(const QString &keyManagement) {79 QVariantDictMap connection(const QString &keyManagement) {
80 QVariantMap wirelessSecurity;80 QVariantMap wirelessSecurity;
81 wirelessSecurity[SecretAgent::WIRELESS_SECURITY_KEY_MGMT] =81 wirelessSecurity[SecretAgent::NM_WIRELESS_SECURITY_KEY_MGMT] =
82 keyManagement;82 keyManagement;
8383
84 QVariantMap conn;84 QVariantMap conn;
85 conn[SecretAgent::CONNECTION_ID] = "the ssid";85 conn[SecretAgent::NM_CONNECTION_ID] = "the ssid";
8686
87 QVariantDictMap connection;87 QVariantDictMap connection;
88 connection[SecretAgent::WIRELESS_SECURITY_SETTING_NAME] =88 connection[SecretAgent::NM_WIRELESS_SECURITY_SETTING_NAME] =
89 wirelessSecurity;89 wirelessSecurity;
90 connection[SecretAgent::CONNECTION_SETTING_NAME] = conn;90 connection[SecretAgent::NM_CONNECTION_SETTING_NAME] = conn;
9191
92 return connection;92 return connection;
93 }93 }
@@ -96,17 +96,17 @@
96 const QString &keyName, const QString &password) {96 const QString &keyName, const QString &password) {
9797
98 QVariantMap wirelessSecurity;98 QVariantMap wirelessSecurity;
99 wirelessSecurity[SecretAgent::WIRELESS_SECURITY_KEY_MGMT] =99 wirelessSecurity[SecretAgent::NM_WIRELESS_SECURITY_KEY_MGMT] =
100 keyManagement;100 keyManagement;
101 wirelessSecurity[keyName] = password;101 wirelessSecurity[keyName] = password;
102102
103 QVariantMap conn;103 QVariantMap conn;
104 conn[SecretAgent::CONNECTION_ID] = "the ssid";104 conn[SecretAgent::NM_CONNECTION_ID] = "the ssid";
105105
106 QVariantDictMap connection;106 QVariantDictMap connection;
107 connection[SecretAgent::WIRELESS_SECURITY_SETTING_NAME] =107 connection[SecretAgent::NM_WIRELESS_SECURITY_SETTING_NAME] =
108 wirelessSecurity;108 wirelessSecurity;
109 connection[SecretAgent::CONNECTION_SETTING_NAME] = conn;109 connection[SecretAgent::NM_CONNECTION_SETTING_NAME] = conn;
110110
111 return connection;111 return connection;
112 }112 }
@@ -166,7 +166,7 @@
166 QDBusPendingReply<QVariantDictMap> reply(166 QDBusPendingReply<QVariantDictMap> reply(
167 agentInterface->GetSecrets(connection(GetParam().keyManagement),167 agentInterface->GetSecrets(connection(GetParam().keyManagement),
168 QDBusObjectPath("/connection/foo"),168 QDBusObjectPath("/connection/foo"),
169 SecretAgent::WIRELESS_SECURITY_SETTING_NAME, QStringList(),169 SecretAgent::NM_WIRELESS_SECURITY_SETTING_NAME, QStringList(),
170 5));170 5));
171171
172 QSignalSpy notificationSpy(notificationsInterface.data(),172 QSignalSpy notificationSpy(notificationsInterface.data(),
@@ -230,21 +230,21 @@
230}230}
231231
232INSTANTIATE_TEST_CASE_P(WpaPsk, TestSecretAgentGetSecrets,232INSTANTIATE_TEST_CASE_P(WpaPsk, TestSecretAgentGetSecrets,
233 Values(TestSecretAgentParams( { SecretAgent::KEY_MGMT_WPA_PSK,233 Values(TestSecretAgentParams( { SecretAgent::NM_KEY_MGMT_WPA_PSK,
234 SecretAgent::WIRELESS_SECURITY_PSK, "hard-coded-password" })));234 SecretAgent::NM_WIRELESS_SECURITY_PSK, "hard-coded-password" })));
235235
236INSTANTIATE_TEST_CASE_P(WpaPskLongPassword, TestSecretAgentGetSecrets,236INSTANTIATE_TEST_CASE_P(WpaPskLongPassword, TestSecretAgentGetSecrets,
237 Values(TestSecretAgentParams( { SecretAgent::KEY_MGMT_WPA_PSK,237 Values(TestSecretAgentParams( { SecretAgent::NM_KEY_MGMT_WPA_PSK,
238 SecretAgent::WIRELESS_SECURITY_PSK, "123456789012345678901234567890123456789012345678901234" })));238 SecretAgent::NM_WIRELESS_SECURITY_PSK, "123456789012345678901234567890123456789012345678901234" })));
239239
240INSTANTIATE_TEST_CASE_P(WpaNone, TestSecretAgentGetSecrets,240INSTANTIATE_TEST_CASE_P(WpaNone, TestSecretAgentGetSecrets,
241 Values(TestSecretAgentParams( { SecretAgent::KEY_MGMT_WPA_NONE,241 Values(TestSecretAgentParams( { SecretAgent::NM_KEY_MGMT_WPA_NONE,
242 SecretAgent::WIRELESS_SECURITY_PSK, "hard-coded-password" })));242 SecretAgent::NM_WIRELESS_SECURITY_PSK, "hard-coded-password" })));
243243
244INSTANTIATE_TEST_CASE_P(None, TestSecretAgentGetSecrets,244INSTANTIATE_TEST_CASE_P(None, TestSecretAgentGetSecrets,
245 Values(245 Values(
246 TestSecretAgentParams( { SecretAgent::KEY_MGMT_NONE,246 TestSecretAgentParams( { SecretAgent::NM_KEY_MGMT_NONE,
247 SecretAgent::WIRELESS_SECURITY_WEP_KEY0,247 SecretAgent::NM_WIRELESS_SECURITY_WEP_KEY0,
248 "hard-coded-password" })));248 "hard-coded-password" })));
249249
250class TestSecretAgent: public TestSecretAgentCommon, public Test {250class TestSecretAgent: public TestSecretAgentCommon, public Test {
@@ -254,9 +254,9 @@
254254
255 QDBusPendingReply<QVariantDictMap> reply(255 QDBusPendingReply<QVariantDictMap> reply(
256 agentInterface->GetSecrets(256 agentInterface->GetSecrets(
257 connection(SecretAgent::KEY_MGMT_WPA_PSK),257 connection(SecretAgent::NM_KEY_MGMT_WPA_PSK),
258 QDBusObjectPath("/connection/foo"),258 QDBusObjectPath("/connection/foo"),
259 SecretAgent::WIRELESS_SECURITY_SETTING_NAME, QStringList(),259 SecretAgent::NM_WIRELESS_SECURITY_SETTING_NAME, QStringList(),
260 0));260 0));
261 reply.waitForFinished();261 reply.waitForFinished();
262262
@@ -272,9 +272,9 @@
272 QSignalSpy notificationSpy(notificationsInterface.data(), SIGNAL(MethodCalled(const QString &, const QVariantList &)));272 QSignalSpy notificationSpy(notificationsInterface.data(), SIGNAL(MethodCalled(const QString &, const QVariantList &)));
273273
274 agentInterface->GetSecrets(274 agentInterface->GetSecrets(
275 connection(SecretAgent::KEY_MGMT_WPA_PSK),275 connection(SecretAgent::NM_KEY_MGMT_WPA_PSK),
276 QDBusObjectPath("/connection/foo"),276 QDBusObjectPath("/connection/foo"),
277 SecretAgent::WIRELESS_SECURITY_SETTING_NAME, QStringList(),277 SecretAgent::NM_WIRELESS_SECURITY_SETTING_NAME, QStringList(),
278 5);278 5);
279279
280 notificationSpy.wait();280 notificationSpy.wait();
@@ -286,7 +286,7 @@
286 notificationSpy.clear();286 notificationSpy.clear();
287287
288 agentInterface->CancelGetSecrets(QDBusObjectPath("/connection/foo"),288 agentInterface->CancelGetSecrets(QDBusObjectPath("/connection/foo"),
289 SecretAgent::WIRELESS_SECURITY_SETTING_NAME);289 SecretAgent::NM_WIRELESS_SECURITY_SETTING_NAME);
290290
291 notificationSpy.wait();291 notificationSpy.wait();
292292
@@ -301,9 +301,9 @@
301 QSignalSpy notificationSpy(notificationsInterface.data(), SIGNAL(MethodCalled(const QString &, const QVariantList &)));301 QSignalSpy notificationSpy(notificationsInterface.data(), SIGNAL(MethodCalled(const QString &, const QVariantList &)));
302302
303 agentInterface->GetSecrets(303 agentInterface->GetSecrets(
304 connection(SecretAgent::KEY_MGMT_WPA_PSK),304 connection(SecretAgent::NM_KEY_MGMT_WPA_PSK),
305 QDBusObjectPath("/connection/foo"),305 QDBusObjectPath("/connection/foo"),
306 SecretAgent::WIRELESS_SECURITY_SETTING_NAME, QStringList(),306 SecretAgent::NM_WIRELESS_SECURITY_SETTING_NAME, QStringList(),
307 5);307 5);
308308
309 notificationSpy.wait();309 notificationSpy.wait();
@@ -315,9 +315,9 @@
315 notificationSpy.clear();315 notificationSpy.clear();
316316
317 agentInterface->GetSecrets(317 agentInterface->GetSecrets(
318 connection(SecretAgent::KEY_MGMT_WPA_PSK),318 connection(SecretAgent::NM_KEY_MGMT_WPA_PSK),
319 QDBusObjectPath("/connection/foo2"),319 QDBusObjectPath("/connection/foo2"),
320 SecretAgent::WIRELESS_SECURITY_SETTING_NAME, QStringList(),320 SecretAgent::NM_WIRELESS_SECURITY_SETTING_NAME, QStringList(),
321 5);321 5);
322322
323 notificationSpy.wait();323 notificationSpy.wait();

Subscribers

People subscribed via source and target branches