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
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2015-08-03 13:27:40 +0000
3+++ CMakeLists.txt 2016-02-23 09:05:39 +0000
4@@ -60,6 +60,18 @@
5 )
6 include_directories(${OFONO_INCLUDE_DIRS})
7
8+pkg_check_modules(
9+ NETWORKMANAGER REQUIRED
10+ NetworkManager
11+)
12+include_directories(${NETWORKMANAGER_INCLUDE_DIRS})
13+
14+pkg_check_modules(
15+ LIBSECRET REQUIRED
16+ libsecret-1
17+)
18+include_directories(${LIBSECRET_INCLUDE_DIRS})
19+
20 find_package(Qt5Core REQUIRED)
21 include_directories(${Qt5Core_INCLUDE_DIRS})
22
23
24=== modified file 'debian/control'
25--- debian/control 2016-02-23 09:05:39 +0000
26+++ debian/control 2016-02-23 09:05:39 +0000
27@@ -17,6 +17,7 @@
28 libqofono-qt5-0,
29 libqtdbusmock1-dev (>= 0.4),
30 libqtdbustest1-dev,
31+ libsecret-1-dev,
32 liburl-dispatcher1-dev,
33 libunity-api-dev,
34 network-manager-dev,
35
36=== modified file 'src/CMakeLists.txt'
37--- src/CMakeLists.txt 2015-07-28 08:26:51 +0000
38+++ src/CMakeLists.txt 2016-02-23 09:05:39 +0000
39@@ -1,6 +1,7 @@
40
41 add_subdirectory(connectivity-api)
42
43+add_subdirectory(agent)
44 add_subdirectory(indicator)
45 add_subdirectory(menumodel-cpp)
46 add_subdirectory(qdbus-stubs)
47@@ -8,3 +9,4 @@
48 add_subdirectory(notify-cpp)
49 add_subdirectory(sniffer)
50 add_subdirectory(url-dispatcher-cpp)
51+add_subdirectory(util)
52
53=== renamed directory 'src/indicator/agent' => 'src/agent'
54=== added file 'src/agent/CMakeLists.txt'
55--- src/agent/CMakeLists.txt 1970-01-01 00:00:00 +0000
56+++ src/agent/CMakeLists.txt 2016-02-23 09:05:39 +0000
57@@ -0,0 +1,61 @@
58+
59+include_directories("${CMAKE_SOURCE_DIR}/src")
60+include_directories("${CMAKE_BINARY_DIR}/src/qdbus-stubs")
61+include_directories("${CMAKE_SOURCE_DIR}/src/qdbus-stubs")
62+
63+set(AGENT_SOURCES
64+ CredentialStore.cpp
65+ KeyringCredentialStore.cpp
66+ SecretAgent.cpp
67+ SecretRequest.cpp
68+ PasswordMenu.cpp
69+)
70+
71+qt5_add_dbus_adaptor(
72+ AGENT_SOURCES
73+ "${DATA_DIR}/nm-secret-agent.xml"
74+ "agent/SecretAgentInclude.h"
75+ "agent::SecretAgent"
76+ SecretAgentAdaptor
77+)
78+
79+add_library(
80+ agent-static
81+ STATIC
82+ ${AGENT_SOURCES}
83+)
84+
85+target_link_libraries(
86+ agent-static
87+ notify_cpp
88+ util
89+ Qt5::Core
90+ Qt5::DBus
91+ ${LIBSECRET_LDFLAGS}
92+)
93+
94+###########################
95+# Executables
96+###########################
97+
98+add_executable(
99+ indicator-network-secret-agent
100+ agent-main.cpp
101+)
102+
103+target_link_libraries(
104+ indicator-network-secret-agent
105+ agent-static
106+ Qt5::Core
107+ Qt5::DBus
108+)
109+
110+###########################
111+# Installation
112+###########################
113+
114+install(
115+ TARGETS
116+ indicator-network-secret-agent
117+ RUNTIME DESTINATION "${CMAKE_INSTALL_LIBEXECDIR}/indicator-network/"
118+)
119
120=== added file 'src/agent/CredentialStore.cpp'
121--- src/agent/CredentialStore.cpp 1970-01-01 00:00:00 +0000
122+++ src/agent/CredentialStore.cpp 2016-02-23 09:05:39 +0000
123@@ -0,0 +1,29 @@
124+/*
125+ * Copyright (C) 2016 Canonical, Ltd.
126+ *
127+ * This program is free software: you can redistribute it and/or modify it
128+ * under the terms of the GNU General Public License version 3, as published
129+ * by the Free Software Foundation.
130+ *
131+ * This program is distributed in the hope that it will be useful, but
132+ * WITHOUT ANY WARRANTY; without even the implied warranties of
133+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
134+ * PURPOSE. See the GNU General Public License for more details.
135+ *
136+ * You should have received a copy of the GNU General Public License along
137+ * with this program. If not, see <http://www.gnu.org/licenses/>.
138+ *
139+ * Author: Pete Woods <pete.woods@canonical.com>
140+ */
141+
142+#include <agent/CredentialStore.h>
143+
144+namespace agent {
145+
146+CredentialStore::CredentialStore() {
147+}
148+
149+CredentialStore::~CredentialStore() {
150+}
151+
152+}
153
154=== added file 'src/agent/CredentialStore.h'
155--- src/agent/CredentialStore.h 1970-01-01 00:00:00 +0000
156+++ src/agent/CredentialStore.h 2016-02-23 09:05:39 +0000
157@@ -0,0 +1,44 @@
158+/*
159+ * Copyright (C) 2016 Canonical, Ltd.
160+ *
161+ * This program is free software: you can redistribute it and/or modify it
162+ * under the terms of the GNU General Public License version 3, as published
163+ * by the Free Software Foundation.
164+ *
165+ * This program is distributed in the hope that it will be useful, but
166+ * WITHOUT ANY WARRANTY; without even the implied warranties of
167+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
168+ * PURPOSE. See the GNU General Public License for more details.
169+ *
170+ * You should have received a copy of the GNU General Public License along
171+ * with this program. If not, see <http://www.gnu.org/licenses/>.
172+ *
173+ * Author: Pete Woods <pete.woods@canonical.com>
174+ */
175+
176+#pragma once
177+
178+#include <unity/util/DefinesPtrs.h>
179+
180+#include <QMap>
181+#include <QString>
182+
183+namespace agent {
184+
185+class CredentialStore {
186+public:
187+ UNITY_DEFINES_PTRS(CredentialStore);
188+
189+ CredentialStore();
190+
191+ virtual ~CredentialStore();
192+
193+ virtual void save(const QString& uuid, const QString& settingName, const QString& settingKey,
194+ const QString& displayName, const QString& secret) = 0;
195+
196+ virtual QMap<QString, QString> get(const QString& uuid, const QString& settingName) = 0;
197+
198+ virtual void clear(const QString& uuid) = 0;
199+};
200+
201+}
202
203=== added file 'src/agent/KeyringCredentialStore.cpp'
204--- src/agent/KeyringCredentialStore.cpp 1970-01-01 00:00:00 +0000
205+++ src/agent/KeyringCredentialStore.cpp 2016-02-23 09:05:39 +0000
206@@ -0,0 +1,154 @@
207+/*
208+ * Copyright (C) 2016 Canonical, Ltd.
209+ *
210+ * This program is free software: you can redistribute it and/or modify it
211+ * under the terms of the GNU General Public License version 3, as published
212+ * by the Free Software Foundation.
213+ *
214+ * This program is distributed in the hope that it will be useful, but
215+ * WITHOUT ANY WARRANTY; without even the implied warranties of
216+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
217+ * PURPOSE. See the GNU General Public License for more details.
218+ *
219+ * You should have received a copy of the GNU General Public License along
220+ * with this program. If not, see <http://www.gnu.org/licenses/>.
221+ *
222+ * Author: Pete Woods <pete.woods@canonical.com>
223+ */
224+
225+#include <agent/KeyringCredentialStore.h>
226+
227+#include <libsecret/secret.h>
228+#include <QDebug>
229+
230+#define KEYRING_UUID_TAG "connection-uuid"
231+#define KEYRING_SN_TAG "setting-name"
232+#define KEYRING_SK_TAG "setting-key"
233+
234+static const SecretSchema network_manager_secret_schema = {
235+ "org.freedesktop.NetworkManager.Connection",
236+ SECRET_SCHEMA_DONT_MATCH_NAME,
237+ {
238+ {KEYRING_UUID_TAG, SECRET_SCHEMA_ATTRIBUTE_STRING},
239+ {KEYRING_SN_TAG, SECRET_SCHEMA_ATTRIBUTE_STRING},
240+ {KEYRING_SK_TAG, SECRET_SCHEMA_ATTRIBUTE_STRING},
241+ {NULL, (SecretSchemaAttributeType) 0},
242+ },
243+ // The below junk prevents compilation warnings for
244+ // the uninitialised reserved values
245+ 0,
246+ (gpointer) 0,
247+ (gpointer) 0,
248+ (gpointer) 0,
249+ (gpointer) 0,
250+ (gpointer) 0,
251+ (gpointer) 0,
252+ (gpointer) 0
253+};
254+
255+using namespace std;
256+
257+namespace agent {
258+
259+KeyringCredentialStore::KeyringCredentialStore() {
260+}
261+
262+KeyringCredentialStore::~KeyringCredentialStore() {
263+}
264+
265+void KeyringCredentialStore::save(const QString& uuid,
266+ const QString& settingName, const QString& settingKey,
267+ const QString& displayName, const QString& secret) {
268+ shared_ptr<GHashTable> attrs(
269+ secret_attributes_build(&network_manager_secret_schema,
270+ KEYRING_UUID_TAG, uuid.toUtf8().constData(),
271+ KEYRING_SN_TAG, settingName.toUtf8().constData(),
272+ KEYRING_SK_TAG, settingKey.toUtf8().constData(),
273+ NULL), &g_hash_table_unref);
274+
275+ GError* error = NULL;
276+ if (!secret_password_storev_sync(&network_manager_secret_schema,
277+ attrs.get(),
278+ NULL,
279+ displayName.toUtf8().constData(),
280+ secret.toUtf8().constData(),
281+ NULL, &error)) {
282+ QString message;
283+ if (error != NULL) {
284+ if (error->message) {
285+ message = QString::fromUtf8(error->message);
286+ }
287+ g_error_free(error);
288+ }
289+ qCritical() << __PRETTY_FUNCTION__ << message;
290+ }
291+}
292+
293+QMap<QString, QString> KeyringCredentialStore::get(const QString& uuid, const QString& settingName) {
294+ QMap<QString, QString> result;
295+
296+ shared_ptr<GHashTable> attrs(secret_attributes_build(
297+ &network_manager_secret_schema,
298+ KEYRING_UUID_TAG, uuid.toUtf8().constData(),
299+ KEYRING_SN_TAG, settingName.toUtf8().constData(),
300+ NULL), &g_hash_table_unref);
301+
302+ GError* error = NULL;
303+ shared_ptr<GList> list(secret_service_search_sync(NULL,
304+ &network_manager_secret_schema, attrs.get(),
305+ (SecretSearchFlags) (SECRET_SEARCH_ALL | SECRET_SEARCH_UNLOCK
306+ | SECRET_SEARCH_LOAD_SECRETS), NULL, &error), [](GList* list) {
307+ g_list_free_full (list, g_object_unref);
308+ });
309+
310+ if (list == NULL) {
311+ if (error != NULL) {
312+ string errorMessage;
313+ if (error->message) {
314+ errorMessage = error->message;
315+ }
316+ g_error_free(error);
317+ throw domain_error(errorMessage);
318+ }
319+
320+ return result;
321+ }
322+
323+ for (GList* iter = list.get(); iter != NULL; iter = g_list_next(iter)) {
324+ SecretItem *item = (SecretItem *) iter->data;
325+ shared_ptr<SecretValue> secret(secret_item_get_secret(item), &secret_value_unref);
326+ if (secret) {
327+ shared_ptr<GHashTable> attributes(secret_item_get_attributes(item), &g_hash_table_unref);
328+ const char *keyName = (const char *) g_hash_table_lookup(attributes.get(),
329+ KEYRING_SK_TAG);
330+ if (!keyName) {
331+ continue;
332+ }
333+
334+ QString keyString = QString::fromUtf8(keyName);
335+ QString secretString = QString::fromUtf8(secret_value_get(secret.get(), NULL));
336+
337+ result[keyString] = secretString;
338+ }
339+ }
340+
341+ return result;
342+}
343+
344+void KeyringCredentialStore::clear(const QString& uuid) {
345+ GError *error = NULL;
346+ if (!secret_password_clear_sync(&network_manager_secret_schema, NULL, &error,
347+ KEYRING_UUID_TAG, uuid.toUtf8().constData(),
348+ NULL)) {
349+ if (error != NULL) {
350+ QString message;
351+ if (error->message) {
352+ message = QString::fromUtf8(error->message);
353+ }
354+ g_error_free(error);
355+ qCritical() << __PRETTY_FUNCTION__ << message;
356+ }
357+ }
358+}
359+
360+}
361
362=== added file 'src/agent/KeyringCredentialStore.h'
363--- src/agent/KeyringCredentialStore.h 1970-01-01 00:00:00 +0000
364+++ src/agent/KeyringCredentialStore.h 2016-02-23 09:05:39 +0000
365@@ -0,0 +1,44 @@
366+/*
367+ * Copyright (C) 2016 Canonical, Ltd.
368+ *
369+ * This program is free software: you can redistribute it and/or modify it
370+ * under the terms of the GNU General Public License version 3, as published
371+ * by the Free Software Foundation.
372+ *
373+ * This program is distributed in the hope that it will be useful, but
374+ * WITHOUT ANY WARRANTY; without even the implied warranties of
375+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
376+ * PURPOSE. See the GNU General Public License for more details.
377+ *
378+ * You should have received a copy of the GNU General Public License along
379+ * with this program. If not, see <http://www.gnu.org/licenses/>.
380+ *
381+ * Author: Pete Woods <pete.woods@canonical.com>
382+ */
383+
384+#pragma once
385+
386+#include <agent/CredentialStore.h>
387+
388+#include <QList>
389+#include <QPair>
390+#include <QString>
391+
392+namespace agent {
393+
394+class KeyringCredentialStore: public CredentialStore {
395+public:
396+ KeyringCredentialStore();
397+
398+ ~KeyringCredentialStore();
399+
400+ void save(const QString& uuid, const QString& settingName,
401+ const QString& settingKey, const QString& displayName,
402+ const QString& secret) override;
403+
404+ QMap<QString, QString> get(const QString& uuid, const QString& settingName) override;
405+
406+ void clear(const QString& uuid) override;
407+};
408+
409+}
410
411=== modified file 'src/agent/SecretAgent.cpp'
412--- src/indicator/agent/SecretAgent.cpp 2015-11-20 13:14:50 +0000
413+++ src/agent/SecretAgent.cpp 2016-02-23 09:05:39 +0000
414@@ -25,6 +25,13 @@
415 #include <NetworkManager.h>
416 #include <stdexcept>
417
418+#define NM_SECRET_AGENT_CAPABILITY_NONE 0
419+
420+#define NM_SECRET_AGENT_GET_SECRETS_FLAG_NONE 0
421+#define NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION 1
422+#define NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW 2
423+#define NM_SECRET_AGENT_GET_SECRETS_FLAG_USER_REQUESTED 4
424+
425 using namespace std;
426
427 namespace agent
428@@ -34,16 +41,85 @@
429 Q_OBJECT
430
431 public:
432- Priv(notify::NotificationManager::SPtr notificationManager, const QDBusConnection &systemConnection,
433+ Priv(notify::NotificationManager::SPtr notificationManager,
434+ agent::CredentialStore::SPtr credentialStore,
435+ const QDBusConnection &systemConnection,
436 const QDBusConnection &sessionConnection) :
437 m_systemConnection(systemConnection),
438 m_sessionConnection(sessionConnection),
439 m_managerWatcher(NM_DBUS_SERVICE, m_systemConnection),
440 m_agentManager(NM_DBUS_SERVICE, NM_DBUS_PATH_AGENT_MANAGER, m_systemConnection),
441 m_notifications(notificationManager),
442+ m_credentialStore(credentialStore),
443 m_request(nullptr) {
444 }
445
446+ void saveSecret(const QString& id, const QString& uuid,
447+ const QString& settingName, const QString& settingKey,
448+ const QString& secret, const QString& inputDisplayName =
449+ QString()) {
450+
451+ // TODO: Don't save always-ask or system-owned secrets
452+
453+ QString displayName(inputDisplayName);
454+ if (displayName.isEmpty()) {
455+ static const QString DISPLAY_NAME("Network secret for %s/%s/%s");
456+ displayName = DISPLAY_NAME.arg(id, settingName, settingKey);
457+ }
458+
459+ m_credentialStore->save(uuid, settingName, settingKey, displayName, secret);
460+ }
461+
462+ static bool isSecret(const QString& settingName, const QString& key) {
463+ static const QMap<QString, QSet<QString>> KNOWN_SECRETS{
464+ {QString::fromUtf8(NM_802_1X_SETTING_NAME), {NM_802_1X_PASSWORD, NM_802_1X_PRIVATE_KEY_PASSWORD,
465+ NM_802_1X_PHASE2_PRIVATE_KEY_PASSWORD, NM_802_1X_PIN}},
466+ {QString::fromUtf8(NM_ADSL_SETTING_NAME), {NM_ADSL_PASSWORD}},
467+ {QString::fromUtf8(NM_CDMA_SETTING_NAME), {NM_CDMA_PASSWORD}},
468+ {QString::fromUtf8(NM_GSM_SETTING_NAME), {NM_GSM_PASSWORD, NM_GSM_PIN}},
469+ {QString::fromUtf8(NM_PPPOE_SETTING_NAME), {NM_PPPOE_PASSWORD}},
470+ {QString::fromUtf8(NM_WIRELESS_SECURITY_SETTING_NAME), {NM_WIRELESS_SECURITY_WEP_KEY0,
471+ NM_WIRELESS_SECURITY_WEP_KEY1, NM_WIRELESS_SECURITY_WEP_KEY2, NM_WIRELESS_SECURITY_WEP_KEY3,
472+ NM_WIRELESS_SECURITY_PSK, NM_WIRELESS_SECURITY_LEAP_PASSWORD}}
473+ };
474+ auto it = KNOWN_SECRETS.constFind(settingName);
475+ if (it != KNOWN_SECRETS.constEnd()) {
476+ if (it->contains(key)) {
477+ return true;
478+ }
479+ }
480+ return false;
481+ }
482+
483+ void saveSettings(const QString& id, const QString& uuid,
484+ const QString& settingName, const QVariantMap& setting) {
485+
486+ QMapIterator<QString, QVariant> iter(setting);
487+ while (iter.hasNext()) {
488+ iter.next();
489+ if (isSecret(settingName, iter.key())) {
490+ saveSecret(id, uuid, settingName, iter.key(),
491+ iter.value().toString());
492+ }
493+ }
494+ }
495+
496+ void saveVpnSettings(const QString& id, const QString& uuid,
497+ const QString& settingName, const QVariantMap& setting) {
498+ static const QString DISPLAY_NAME{"VPN %1 secret for %2/%3/%4"};
499+
500+ QString serviceType = setting[NM_VPN_SERVICE_TYPE].toString();
501+ QStringMap secrets;
502+ auto dbusArgument = qvariant_cast<QDBusArgument>(setting[NM_VPN_SECRETS]);
503+ dbusArgument >> secrets;
504+ QMapIterator<QString, QString> iter(secrets);
505+ while(iter.hasNext()) {
506+ iter.next();
507+ saveSecret(id, uuid, settingName, iter.key(), iter.value(),
508+ DISPLAY_NAME.arg(iter.key(), id, serviceType, NM_VPN_SETTING_NAME));
509+ }
510+ }
511+
512 public Q_SLOTS:
513 void serviceOwnerChanged(const QString &name, const QString &oldOwner,
514 const QString &newOwner)
515@@ -53,7 +129,7 @@
516 if (!newOwner.isEmpty()) {
517 auto reply = m_agentManager.RegisterWithCapabilities(
518 "com.canonical.indicator.SecretAgent",
519- 0 /*NM_SECRET_AGENT_CAPABILITY_NONE*/);
520+ NM_SECRET_AGENT_CAPABILITY_NONE);
521 reply.waitForFinished();
522 if (reply.isError()) {
523 qCritical() << __PRETTY_FUNCTION__ << reply.error().message();
524@@ -72,13 +148,16 @@
525
526 notify::NotificationManager::SPtr m_notifications;
527
528+ CredentialStore::SPtr m_credentialStore;
529+
530 std::shared_ptr<SecretRequest> m_request;
531 };
532
533 SecretAgent::SecretAgent(notify::NotificationManager::SPtr notificationManager,
534- const QDBusConnection &systemConnection,
535+ agent::CredentialStore::SPtr credentialStore,
536+ const QDBusConnection &systemConnection,
537 const QDBusConnection &sessionConnection, QObject *parent) :
538- QObject(parent), d(new Priv(notificationManager, systemConnection, sessionConnection))
539+ QObject(parent), d(new Priv(notificationManager, credentialStore, systemConnection, sessionConnection))
540 {
541 // Memory managed by Qt
542 new SecretAgentAdaptor(this);
543@@ -94,7 +173,7 @@
544
545 auto reply = d->m_agentManager.RegisterWithCapabilities(
546 "com.canonical.indicator.SecretAgent",
547- 0 /*NM_SECRET_AGENT_CAPABILITY_NONE*/);
548+ NM_SECRET_AGENT_CAPABILITY_NONE);
549 reply.waitForFinished();
550 if (reply.isError()) {
551 qCritical() << __PRETTY_FUNCTION__ << reply.error().message();
552@@ -153,13 +232,66 @@
553
554 setDelayedReply(true);
555
556- if (flags != 0 && settingName == "802-11-wireless-security") {
557+ qDebug() << __PRETTY_FUNCTION__ << connectionPath.path() << settingName << hints << flags;
558+
559+ // If we want a WiFi secret, and
560+ if (settingName == NM_WIRELESS_SECURITY_SETTING_NAME &&
561+ ((flags & NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION) > 0) &&
562+ (
563+ ((flags & NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW) > 0) ||
564+ ((flags & NM_SECRET_AGENT_GET_SECRETS_FLAG_USER_REQUESTED) > 0)
565+ )) {
566+ qDebug() << __PRETTY_FUNCTION__ << "Requesting secret from user";
567 d->m_request.reset(new SecretRequest(*this, connection,
568 connectionPath, settingName, hints, flags, message()));
569+ } else if (((flags == NM_SECRET_AGENT_GET_SECRETS_FLAG_NONE) ||
570+ (flags == NM_SECRET_AGENT_GET_SECRETS_FLAG_USER_REQUESTED))) {
571+ qDebug() << __PRETTY_FUNCTION__ << "Retrieving secret from keyring";
572+
573+ bool isVpn = (settingName == NM_VPN_SETTING_NAME);
574+
575+ QString uuid = connection[NM_CONNECTION_SETTING_NAME][NM_CONNECTION_UUID].toString();
576+
577+ QStringMap secrets;
578+
579+ try {
580+ secrets = d->m_credentialStore->get(uuid, settingName);
581+ } catch (domain_error& e) {
582+ d->m_systemConnection.send(
583+ message().createErrorReply(
584+ "org.freedesktop.NetworkManager.SecretAgent.InternalError",
585+ e.what()));
586+ return QVariantDictMap();
587+ }
588+
589+ if (secrets.isEmpty()) {
590+ d->m_systemConnection.send(
591+ message().createErrorReply(
592+ "org.freedesktop.NetworkManager.SecretAgent.NoSecrets",
593+ "No secrets found for this connection."));
594+ return QVariantDictMap();
595+ }
596+
597+ QVariantDictMap newConnection;
598+
599+ if (isVpn) {
600+ newConnection[settingName][NM_VPN_SECRETS] = QVariant::fromValue(
601+ secrets);
602+ } else {
603+ QMapIterator<QString, QString> it(secrets);
604+ while (it.hasNext()) {
605+ it.next();
606+ newConnection[settingName][it.key()] = it.value();
607+ }
608+ }
609+
610+ d->m_systemConnection.send(
611+ message().createReply(QVariant::fromValue(newConnection)));
612 } else {
613+ qDebug() << __PRETTY_FUNCTION__ << "Can't get secrets for this connection";
614 d->m_systemConnection.send(
615- message().createErrorReply(QDBusError::InternalError,
616- "No password found for this connection."));
617+ message().createErrorReply("org.freedesktop.NetworkManager.SecretAgent.NoSecrets",
618+ "No secrets found for this connection."));
619 }
620
621 return QVariantDictMap();
622@@ -168,7 +300,7 @@
623 void SecretAgent::FinishGetSecrets(SecretRequest &request, bool error) {
624 if (error) {
625 d->m_systemConnection.send(
626- request.message().createErrorReply(QDBusError::InternalError,
627+ request.message().createErrorReply("org.freedesktop.NetworkManager.SecretAgent.NoSecrets",
628 "No password found for this connection."));
629 } else {
630 d->m_systemConnection.send(
631@@ -181,21 +313,38 @@
632
633 void SecretAgent::CancelGetSecrets(const QDBusObjectPath &connectionPath,
634 const QString &settingName) {
635- Q_UNUSED(connectionPath);
636 Q_UNUSED(settingName);
637- d->m_request.reset();
638+
639+ if (d->m_request && d->m_request->connectionPath() == connectionPath) {
640+ d->m_request.reset();
641+ }
642 }
643
644 void SecretAgent::DeleteSecrets(const QVariantDictMap &connection,
645 const QDBusObjectPath &connectionPath) {
646- Q_UNUSED(connection);
647 Q_UNUSED(connectionPath);
648+
649+ QString uuid = connection[NM_CONNECTION_SETTING_NAME][NM_CONNECTION_UUID].toString();
650+ d->m_credentialStore->clear(uuid);
651 }
652
653 void SecretAgent::SaveSecrets(const QVariantDictMap &connection,
654 const QDBusObjectPath &connectionPath) {
655- Q_UNUSED(connection);
656 Q_UNUSED(connectionPath);
657+
658+ QString id = connection[NM_CONNECTION_SETTING_NAME][NM_CONNECTION_ID].toString();
659+ QString uuid = connection[NM_CONNECTION_SETTING_NAME][NM_CONNECTION_UUID].toString();
660+ QString type = connection[NM_CONNECTION_SETTING_NAME][NM_CONNECTION_TYPE].toString();
661+
662+ if (type == NM_VPN_SETTING_NAME) {
663+ d->saveVpnSettings(id, uuid, NM_VPN_SETTING_NAME, connection[NM_VPN_SETTING_NAME]);
664+ } else {
665+ QMapIterator<QString, QVariantMap> iter(connection);
666+ while (iter.hasNext()) {
667+ iter.next();
668+ d->saveSettings(id, uuid, iter.key(), iter.value());
669+ }
670+ }
671 }
672
673 notify::NotificationManager::SPtr SecretAgent::notifications() {
674
675=== modified file 'src/agent/SecretAgent.h'
676--- src/indicator/agent/SecretAgent.h 2015-08-03 13:27:40 +0000
677+++ src/agent/SecretAgent.h 2016-02-23 09:05:39 +0000
678@@ -19,6 +19,7 @@
679 #pragma once
680
681 #include <dbus-types.h>
682+#include <agent/CredentialStore.h>
683
684 #include <memory>
685
686@@ -48,21 +49,50 @@
687 typedef std::shared_ptr<SecretAgent> Ptr;
688 typedef std::unique_ptr<SecretAgent> UPtr;
689
690- static constexpr char const* CONNECTION_SETTING_NAME = "connection";
691- static constexpr char const* WIRELESS_SECURITY_SETTING_NAME = "802-11-wireless-security";
692-
693- static constexpr char const* CONNECTION_ID = "id";
694-
695- static constexpr char const* WIRELESS_SECURITY_PSK = "psk";
696- static constexpr char const* WIRELESS_SECURITY_WEP_KEY0 = "wep-key0";
697-
698- static constexpr char const* WIRELESS_SECURITY_KEY_MGMT = "key-mgmt";
699-
700- static constexpr char const* KEY_MGMT_WPA_NONE = "wpa-none";
701- static constexpr char const* KEY_MGMT_WPA_PSK = "wpa-psk";
702- static constexpr char const* KEY_MGMT_NONE = "none";
703+ static constexpr char const* NM_CONNECTION_SETTING_NAME = "connection";
704+
705+ static constexpr char const* NM_CONNECTION_ID = "id";
706+ static constexpr char const* NM_CONNECTION_UUID = "uuid";
707+ static constexpr char const* NM_CONNECTION_TYPE = "type";
708+
709+ static constexpr char const* NM_ADSL_SETTING_NAME = "adsl";
710+ static constexpr char const* NM_ADSL_PASSWORD = "password";
711+
712+ static constexpr char const* NM_GSM_SETTING_NAME = "gsm";
713+ static constexpr char const* NM_GSM_PASSWORD = "password";
714+ static constexpr char const* NM_GSM_PIN = "pin";
715+
716+ static constexpr char const* NM_802_1X_SETTING_NAME = "802-1x";
717+ static constexpr char const* NM_802_1X_PASSWORD = "password";
718+ static constexpr char const* NM_802_1X_PRIVATE_KEY_PASSWORD = "private-key-password";
719+ static constexpr char const* NM_802_1X_PHASE2_PRIVATE_KEY_PASSWORD = "phase2-private-key-password";
720+ static constexpr char const* NM_802_1X_PIN = "pin";
721+
722+ static constexpr char const* NM_CDMA_SETTING_NAME = "cdma";
723+ static constexpr char const* NM_CDMA_PASSWORD = "password";
724+
725+ static constexpr char const* NM_PPPOE_SETTING_NAME = "pppoe";
726+ static constexpr char const* NM_PPPOE_PASSWORD = "password";
727+
728+ static constexpr char const* NM_VPN_SETTING_NAME = "vpn";
729+ static constexpr char const* NM_VPN_SERVICE_TYPE = "service-type";
730+ static constexpr char const* NM_VPN_SECRETS = "secrets";
731+
732+ static constexpr char const* NM_WIRELESS_SECURITY_SETTING_NAME = "802-11-wireless-security";
733+ static constexpr char const* NM_WIRELESS_SECURITY_KEY_MGMT = "key-mgmt";
734+ static constexpr char const* NM_WIRELESS_SECURITY_WEP_KEY0 = "wep-key0";
735+ static constexpr char const* NM_WIRELESS_SECURITY_WEP_KEY1 = "wep-key1";
736+ static constexpr char const* NM_WIRELESS_SECURITY_WEP_KEY2 = "wep-key2";
737+ static constexpr char const* NM_WIRELESS_SECURITY_WEP_KEY3 = "wep-key3";
738+ static constexpr char const* NM_WIRELESS_SECURITY_PSK = "psk";
739+ static constexpr char const* NM_WIRELESS_SECURITY_LEAP_PASSWORD = "leap-password";
740+
741+ static constexpr char const* NM_KEY_MGMT_WPA_NONE = "wpa-none";
742+ static constexpr char const* NM_KEY_MGMT_WPA_PSK = "wpa-psk";
743+ static constexpr char const* NM_KEY_MGMT_NONE = "none";
744
745 explicit SecretAgent(std::shared_ptr<notify::NotificationManager> notificationManager,
746+ CredentialStore::SPtr credentialStore,
747 const QDBusConnection &systemConnection,
748 const QDBusConnection &sessionConnection, QObject *parent = 0);
749
750
751=== modified file 'src/agent/SecretRequest.cpp'
752--- src/indicator/agent/SecretRequest.cpp 2015-08-03 13:27:40 +0000
753+++ src/agent/SecretRequest.cpp 2016-02-23 09:05:39 +0000
754@@ -52,24 +52,24 @@
755
756 notificationHints["x-canonical-private-menu-model"] = menuModelPaths;
757
758- const QVariantMap &conn = m_connection[SecretAgent::CONNECTION_SETTING_NAME];
759+ const QVariantMap &conn = m_connection[SecretAgent::NM_CONNECTION_SETTING_NAME];
760
761 auto wirelessSecurity = m_connection.find(m_settingName);
762 QString keyMgmt(
763- wirelessSecurity->value(SecretAgent::WIRELESS_SECURITY_KEY_MGMT).toString());
764+ wirelessSecurity->value(SecretAgent::NM_WIRELESS_SECURITY_KEY_MGMT).toString());
765
766 QString title(_("Connect to “%1”"));
767
768 QString subject;
769- if (keyMgmt == SecretAgent::KEY_MGMT_WPA_NONE
770- || keyMgmt == SecretAgent::KEY_MGMT_WPA_PSK) {
771+ if (keyMgmt == SecretAgent::NM_KEY_MGMT_WPA_NONE
772+ || keyMgmt == SecretAgent::NM_KEY_MGMT_WPA_PSK) {
773 subject = _("WPA");
774- } else if (keyMgmt == SecretAgent::KEY_MGMT_NONE) {
775+ } else if (keyMgmt == SecretAgent::NM_KEY_MGMT_NONE) {
776 subject = _("WEP");
777 }
778
779 m_notification = m_secretAgent.notifications()->notify(
780- title.arg(conn[SecretAgent::CONNECTION_ID].toString()), subject,
781+ title.arg(conn[SecretAgent::NM_CONNECTION_ID].toString()), subject,
782 "wifi-full-secure",
783 QStringList() << "connect_id" << _("Connect") << "cancel_id"
784 << _("Cancel"), notificationHints, 0);
785@@ -101,13 +101,13 @@
786
787 auto wirelessSecurity = m_connection.find(m_settingName);
788 QString keyMgmt(
789- wirelessSecurity->value(SecretAgent::WIRELESS_SECURITY_KEY_MGMT).toString());
790+ wirelessSecurity->value(SecretAgent::NM_WIRELESS_SECURITY_KEY_MGMT).toString());
791
792- if (keyMgmt == SecretAgent::KEY_MGMT_WPA_NONE
793- || keyMgmt == SecretAgent::KEY_MGMT_WPA_PSK) {
794- wirelessSecurity->insert(SecretAgent::WIRELESS_SECURITY_PSK, key);
795- } else if (keyMgmt == SecretAgent::KEY_MGMT_NONE) {
796- wirelessSecurity->insert(SecretAgent::WIRELESS_SECURITY_WEP_KEY0, key);
797+ if (keyMgmt == SecretAgent::NM_KEY_MGMT_WPA_NONE
798+ || keyMgmt == SecretAgent::NM_KEY_MGMT_WPA_PSK) {
799+ wirelessSecurity->insert(SecretAgent::NM_WIRELESS_SECURITY_PSK, key);
800+ } else if (keyMgmt == SecretAgent::NM_KEY_MGMT_NONE) {
801+ wirelessSecurity->insert(SecretAgent::NM_WIRELESS_SECURITY_WEP_KEY0, key);
802 }
803
804 m_secretAgent.FinishGetSecrets(*this, false);
805@@ -130,4 +130,8 @@
806 return m_message;
807 }
808
809+const QDBusObjectPath & SecretRequest::connectionPath() const {
810+ return m_connectionPath;
811+}
812+
813 }
814
815=== modified file 'src/agent/SecretRequest.h'
816--- src/indicator/agent/SecretRequest.h 2015-08-03 13:27:40 +0000
817+++ src/agent/SecretRequest.h 2016-02-23 09:05:39 +0000
818@@ -51,6 +51,8 @@
819
820 const QDBusMessage & message() const;
821
822+ const QDBusObjectPath & connectionPath() const;
823+
824 protected:
825 notify::Notification::UPtr m_notification;
826
827
828=== renamed file 'src/indicator/agent-main.cpp' => 'src/agent/agent-main.cpp'
829--- src/indicator/agent-main.cpp 2015-11-20 13:14:50 +0000
830+++ src/agent/agent-main.cpp 2016-02-23 09:05:39 +0000
831@@ -17,7 +17,9 @@
832 * Antti Kaijanmäki <antti.kaijanmaki@canonical.com>
833 */
834
835-#include <factory.h>
836+#include <notify-cpp/notification-manager.h>
837+#include <agent/KeyringCredentialStore.h>
838+#include <agent/SecretAgent.h>
839 #include <util/unix-signal-handler.h>
840 #include <dbus-types.h>
841
842@@ -32,7 +34,6 @@
843 #include <config.h>
844
845 using namespace std;
846-using namespace connectivity_service;
847
848 int
849 main(int argc, char **argv)
850@@ -42,23 +43,20 @@
851 Variant::registerMetaTypes();
852 std::srand(std::time(0));
853
854- util::UnixSignalHandler handler([]{
855- QCoreApplication::exit(0);
856- });
857- handler.setupUnixSignalHandlers();
858-
859 bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
860 setlocale(LC_ALL, "");
861 bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR);
862 textdomain(GETTEXT_PACKAGE);
863
864- if (argc == 2 && QString("--print-address") == argv[1])
865- {
866- qDebug() << QDBusConnection::systemBus().baseService();
867- }
868+ util::UnixSignalHandler handler([]{
869+ QCoreApplication::exit(0);
870+ });
871+ handler.setupUnixSignalHandlers();
872
873- Factory factory;
874- auto secretAgent = factory.newSecretAgent();
875+ auto agent = make_unique<agent::SecretAgent>(
876+ make_shared<notify::NotificationManager>(GETTEXT_PACKAGE),
877+ make_shared<agent::KeyringCredentialStore>(),
878+ QDBusConnection::systemBus(), QDBusConnection::sessionBus());
879
880 return app.exec();
881 }
882
883=== modified file 'src/indicator/CMakeLists.txt'
884--- src/indicator/CMakeLists.txt 2016-01-14 11:40:59 +0000
885+++ src/indicator/CMakeLists.txt 2016-02-23 09:05:39 +0000
886@@ -1,11 +1,5 @@
887
888 pkg_check_modules(
889- NETWORKMANAGER REQUIRED
890- NetworkManager
891-)
892-include_directories(${NETWORKMANAGER_INCLUDE_DIRS})
893-
894-pkg_check_modules(
895 QOFONO REQUIRED
896 qofono-qt5
897 )
898@@ -43,10 +37,6 @@
899 nmofono/vpn/vpn-connection.cpp
900 nmofono/vpn/vpn-manager.cpp
901
902- agent/SecretAgent.cpp
903- agent/SecretRequest.cpp
904- agent/PasswordMenu.cpp
905-
906 factory.cpp
907 indicator-menu.cpp
908 icons.cpp
909@@ -71,9 +61,6 @@
910 menuitems/wifi-link-item.cpp
911 menuitems/wwan-link-item.cpp
912 menuitems/modem-info-item.cpp
913-
914- util/dbus-utils.cpp
915- util/unix-signal-handler.cpp
916 )
917
918 qt5_add_dbus_adaptor(
919@@ -116,14 +103,6 @@
920 PptpAdaptor
921 )
922
923-qt5_add_dbus_adaptor(
924- NETWORK_SERVICE_SOURCES
925- "${DATA_DIR}/nm-secret-agent.xml"
926- "agent/SecretAgentInclude.h"
927- "agent::SecretAgent"
928- SecretAgentAdaptor
929-)
930-
931 add_library(
932 indicator-network-service-static
933 STATIC
934@@ -137,9 +116,9 @@
935 url_dispatcher_cpp
936 qdbus-stubs
937 qpowerd
938- ${DBUSCPP_LIBRARIES}
939- ${GLIB_LIBRARIES}
940- ${QOFONO_LIBRARIES}
941+ util
942+ ${GLIB_LDFLAGS}
943+ ${QOFONO_LDFLAGS}
944 Qt5::Core
945 Qt5::DBus
946 )
947@@ -160,18 +139,6 @@
948 Qt5::DBus
949 )
950
951-add_executable(
952- indicator-network-secret-agent
953- agent-main.cpp
954-)
955-
956-target_link_libraries(
957- indicator-network-secret-agent
958- indicator-network-service-static
959- Qt5::Core
960- Qt5::DBus
961-)
962-
963 ###########################
964 # Installation
965 ###########################
966@@ -179,6 +146,5 @@
967 install(
968 TARGETS
969 indicator-network-service
970- indicator-network-secret-agent
971 RUNTIME DESTINATION "${CMAKE_INSTALL_LIBEXECDIR}/indicator-network/"
972 )
973
974=== modified file 'src/indicator/factory.cpp'
975--- src/indicator/factory.cpp 2015-12-11 14:58:11 +0000
976+++ src/indicator/factory.cpp 2016-02-23 09:05:39 +0000
977@@ -221,13 +221,6 @@
978 return make_unique<BusName>(name, acquired, lost, d->singletonSessionBus());
979 }
980
981-agent::SecretAgent::UPtr Factory::newSecretAgent()
982-{
983- return make_unique<agent::SecretAgent>(d->singletonNotificationManager(),
984- QDBusConnection::systemBus(),
985- QDBusConnection::sessionBus());
986-}
987-
988 VpnStatusNotifier::UPtr Factory::newVpnStatusNotifier()
989 {
990 return make_unique<VpnStatusNotifier>(d->singletonActiveConnectionManager(),
991
992=== modified file 'src/indicator/factory.h'
993--- src/indicator/factory.h 2015-12-11 14:58:11 +0000
994+++ src/indicator/factory.h 2016-02-23 09:05:39 +0000
995@@ -31,7 +31,6 @@
996 #include <sections/wifi-section.h>
997 #include <sections/wwan-section.h>
998 #include <menuitems/switch-item.h>
999-#include <agent/SecretAgent.h>
1000
1001 #include <memory>
1002
1003@@ -77,7 +76,6 @@
1004 std::function<void(std::string)> acquired,
1005 std::function<void(std::string)> lost);
1006
1007- virtual agent::SecretAgent::UPtr newSecretAgent();
1008
1009 virtual VpnStatusNotifier::UPtr newVpnStatusNotifier();
1010 };
1011
1012=== modified file 'src/indicator/nmofono/vpn/vpn-manager.cpp'
1013--- src/indicator/nmofono/vpn/vpn-manager.cpp 2016-01-14 11:40:59 +0000
1014+++ src/indicator/nmofono/vpn/vpn-manager.cpp 2016-02-23 09:05:39 +0000
1015@@ -251,7 +251,7 @@
1016 {"type", "vpn"},
1017 {"id", d->newConnectionName()},
1018 {"uuid", uuid},
1019- {"autoconnect", "false"}
1020+ {"autoconnect", false}
1021
1022 };
1023 connection["vpn"] = QVariantMap
1024
1025=== modified file 'src/notify-cpp/CMakeLists.txt'
1026--- src/notify-cpp/CMakeLists.txt 2015-08-03 13:27:40 +0000
1027+++ src/notify-cpp/CMakeLists.txt 2016-02-23 09:05:39 +0000
1028@@ -11,5 +11,6 @@
1029 add_library(notify_cpp STATIC ${NOTIFY_CPP_SOURCES})
1030 target_link_libraries(
1031 notify_cpp
1032+ menumodel_cpp
1033 qdbus-stubs
1034 )
1035
1036=== renamed directory 'src/indicator/util' => 'src/util'
1037=== added file 'src/util/CMakeLists.txt'
1038--- src/util/CMakeLists.txt 1970-01-01 00:00:00 +0000
1039+++ src/util/CMakeLists.txt 2016-02-23 09:05:39 +0000
1040@@ -0,0 +1,8 @@
1041+include_directories("${CMAKE_SOURCE_DIR}/src/")
1042+
1043+set(UTIL_SOURCES
1044+ dbus-utils.cpp
1045+ unix-signal-handler.cpp
1046+)
1047+
1048+add_library(util STATIC ${UTIL_SOURCES})
1049
1050=== modified file 'tests/unit/CMakeLists.txt'
1051--- tests/unit/CMakeLists.txt 2015-11-20 11:21:59 +0000
1052+++ tests/unit/CMakeLists.txt 2016-02-23 09:05:39 +0000
1053@@ -27,7 +27,7 @@
1054
1055 target_link_libraries(
1056 secret-agent-test-bin
1057- indicator-network-service-static
1058+ agent-static
1059 )
1060
1061 ###################
1062
1063=== modified file 'tests/unit/secret-agent/secret-agent-main.cpp'
1064--- tests/unit/secret-agent/secret-agent-main.cpp 2015-04-21 10:59:52 +0000
1065+++ tests/unit/secret-agent/secret-agent-main.cpp 2016-02-23 09:05:39 +0000
1066@@ -19,19 +19,23 @@
1067 #include <config.h>
1068 #include <libintl.h>
1069 #include <config.h>
1070-#include <factory.h>
1071 #include <dbus-types.h>
1072+#include <notify-cpp/notification-manager.h>
1073+#include <agent/KeyringCredentialStore.h>
1074+#include <agent/SecretAgent.h>
1075 #include <util/unix-signal-handler.h>
1076
1077 #include <QCoreApplication>
1078+#include <QDBusConnection>
1079 #include <iostream>
1080+#include <memory>
1081
1082 using namespace std;
1083
1084-
1085 int main(int argc, char *argv[]) {
1086 QCoreApplication application(argc, argv);
1087 DBusTypes::registerMetaTypes();
1088+ Variant::registerMetaTypes();
1089
1090 setlocale(LC_ALL, "");
1091 bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR);
1092@@ -43,8 +47,10 @@
1093 });
1094 handler.setupUnixSignalHandlers();
1095
1096- Factory factory;
1097- auto secretAgent = factory.newSecretAgent();
1098+ auto secretAgent = make_unique<agent::SecretAgent>(
1099+ make_shared<notify::NotificationManager>(GETTEXT_PACKAGE),
1100+ make_shared<agent::KeyringCredentialStore>(),
1101+ QDBusConnection::systemBus(), QDBusConnection::sessionBus());
1102
1103 if (argc == 2 && QString("--print-address") == argv[1]) {
1104 cout << QDBusConnection::systemBus().baseService().toStdString()
1105
1106=== modified file 'tests/unit/secret-agent/test-secret-agent.cpp'
1107--- tests/unit/secret-agent/test-secret-agent.cpp 2015-11-20 11:21:59 +0000
1108+++ tests/unit/secret-agent/test-secret-agent.cpp 2016-02-23 09:05:39 +0000
1109@@ -78,16 +78,16 @@
1110
1111 QVariantDictMap connection(const QString &keyManagement) {
1112 QVariantMap wirelessSecurity;
1113- wirelessSecurity[SecretAgent::WIRELESS_SECURITY_KEY_MGMT] =
1114+ wirelessSecurity[SecretAgent::NM_WIRELESS_SECURITY_KEY_MGMT] =
1115 keyManagement;
1116
1117 QVariantMap conn;
1118- conn[SecretAgent::CONNECTION_ID] = "the ssid";
1119+ conn[SecretAgent::NM_CONNECTION_ID] = "the ssid";
1120
1121 QVariantDictMap connection;
1122- connection[SecretAgent::WIRELESS_SECURITY_SETTING_NAME] =
1123+ connection[SecretAgent::NM_WIRELESS_SECURITY_SETTING_NAME] =
1124 wirelessSecurity;
1125- connection[SecretAgent::CONNECTION_SETTING_NAME] = conn;
1126+ connection[SecretAgent::NM_CONNECTION_SETTING_NAME] = conn;
1127
1128 return connection;
1129 }
1130@@ -96,17 +96,17 @@
1131 const QString &keyName, const QString &password) {
1132
1133 QVariantMap wirelessSecurity;
1134- wirelessSecurity[SecretAgent::WIRELESS_SECURITY_KEY_MGMT] =
1135+ wirelessSecurity[SecretAgent::NM_WIRELESS_SECURITY_KEY_MGMT] =
1136 keyManagement;
1137 wirelessSecurity[keyName] = password;
1138
1139 QVariantMap conn;
1140- conn[SecretAgent::CONNECTION_ID] = "the ssid";
1141+ conn[SecretAgent::NM_CONNECTION_ID] = "the ssid";
1142
1143 QVariantDictMap connection;
1144- connection[SecretAgent::WIRELESS_SECURITY_SETTING_NAME] =
1145+ connection[SecretAgent::NM_WIRELESS_SECURITY_SETTING_NAME] =
1146 wirelessSecurity;
1147- connection[SecretAgent::CONNECTION_SETTING_NAME] = conn;
1148+ connection[SecretAgent::NM_CONNECTION_SETTING_NAME] = conn;
1149
1150 return connection;
1151 }
1152@@ -166,7 +166,7 @@
1153 QDBusPendingReply<QVariantDictMap> reply(
1154 agentInterface->GetSecrets(connection(GetParam().keyManagement),
1155 QDBusObjectPath("/connection/foo"),
1156- SecretAgent::WIRELESS_SECURITY_SETTING_NAME, QStringList(),
1157+ SecretAgent::NM_WIRELESS_SECURITY_SETTING_NAME, QStringList(),
1158 5));
1159
1160 QSignalSpy notificationSpy(notificationsInterface.data(),
1161@@ -230,21 +230,21 @@
1162 }
1163
1164 INSTANTIATE_TEST_CASE_P(WpaPsk, TestSecretAgentGetSecrets,
1165- Values(TestSecretAgentParams( { SecretAgent::KEY_MGMT_WPA_PSK,
1166- SecretAgent::WIRELESS_SECURITY_PSK, "hard-coded-password" })));
1167+ Values(TestSecretAgentParams( { SecretAgent::NM_KEY_MGMT_WPA_PSK,
1168+ SecretAgent::NM_WIRELESS_SECURITY_PSK, "hard-coded-password" })));
1169
1170 INSTANTIATE_TEST_CASE_P(WpaPskLongPassword, TestSecretAgentGetSecrets,
1171- Values(TestSecretAgentParams( { SecretAgent::KEY_MGMT_WPA_PSK,
1172- SecretAgent::WIRELESS_SECURITY_PSK, "123456789012345678901234567890123456789012345678901234" })));
1173+ Values(TestSecretAgentParams( { SecretAgent::NM_KEY_MGMT_WPA_PSK,
1174+ SecretAgent::NM_WIRELESS_SECURITY_PSK, "123456789012345678901234567890123456789012345678901234" })));
1175
1176 INSTANTIATE_TEST_CASE_P(WpaNone, TestSecretAgentGetSecrets,
1177- Values(TestSecretAgentParams( { SecretAgent::KEY_MGMT_WPA_NONE,
1178- SecretAgent::WIRELESS_SECURITY_PSK, "hard-coded-password" })));
1179+ Values(TestSecretAgentParams( { SecretAgent::NM_KEY_MGMT_WPA_NONE,
1180+ SecretAgent::NM_WIRELESS_SECURITY_PSK, "hard-coded-password" })));
1181
1182 INSTANTIATE_TEST_CASE_P(None, TestSecretAgentGetSecrets,
1183 Values(
1184- TestSecretAgentParams( { SecretAgent::KEY_MGMT_NONE,
1185- SecretAgent::WIRELESS_SECURITY_WEP_KEY0,
1186+ TestSecretAgentParams( { SecretAgent::NM_KEY_MGMT_NONE,
1187+ SecretAgent::NM_WIRELESS_SECURITY_WEP_KEY0,
1188 "hard-coded-password" })));
1189
1190 class TestSecretAgent: public TestSecretAgentCommon, public Test {
1191@@ -254,9 +254,9 @@
1192
1193 QDBusPendingReply<QVariantDictMap> reply(
1194 agentInterface->GetSecrets(
1195- connection(SecretAgent::KEY_MGMT_WPA_PSK),
1196+ connection(SecretAgent::NM_KEY_MGMT_WPA_PSK),
1197 QDBusObjectPath("/connection/foo"),
1198- SecretAgent::WIRELESS_SECURITY_SETTING_NAME, QStringList(),
1199+ SecretAgent::NM_WIRELESS_SECURITY_SETTING_NAME, QStringList(),
1200 0));
1201 reply.waitForFinished();
1202
1203@@ -272,9 +272,9 @@
1204 QSignalSpy notificationSpy(notificationsInterface.data(), SIGNAL(MethodCalled(const QString &, const QVariantList &)));
1205
1206 agentInterface->GetSecrets(
1207- connection(SecretAgent::KEY_MGMT_WPA_PSK),
1208+ connection(SecretAgent::NM_KEY_MGMT_WPA_PSK),
1209 QDBusObjectPath("/connection/foo"),
1210- SecretAgent::WIRELESS_SECURITY_SETTING_NAME, QStringList(),
1211+ SecretAgent::NM_WIRELESS_SECURITY_SETTING_NAME, QStringList(),
1212 5);
1213
1214 notificationSpy.wait();
1215@@ -286,7 +286,7 @@
1216 notificationSpy.clear();
1217
1218 agentInterface->CancelGetSecrets(QDBusObjectPath("/connection/foo"),
1219- SecretAgent::WIRELESS_SECURITY_SETTING_NAME);
1220+ SecretAgent::NM_WIRELESS_SECURITY_SETTING_NAME);
1221
1222 notificationSpy.wait();
1223
1224@@ -301,9 +301,9 @@
1225 QSignalSpy notificationSpy(notificationsInterface.data(), SIGNAL(MethodCalled(const QString &, const QVariantList &)));
1226
1227 agentInterface->GetSecrets(
1228- connection(SecretAgent::KEY_MGMT_WPA_PSK),
1229+ connection(SecretAgent::NM_KEY_MGMT_WPA_PSK),
1230 QDBusObjectPath("/connection/foo"),
1231- SecretAgent::WIRELESS_SECURITY_SETTING_NAME, QStringList(),
1232+ SecretAgent::NM_WIRELESS_SECURITY_SETTING_NAME, QStringList(),
1233 5);
1234
1235 notificationSpy.wait();
1236@@ -315,9 +315,9 @@
1237 notificationSpy.clear();
1238
1239 agentInterface->GetSecrets(
1240- connection(SecretAgent::KEY_MGMT_WPA_PSK),
1241+ connection(SecretAgent::NM_KEY_MGMT_WPA_PSK),
1242 QDBusObjectPath("/connection/foo2"),
1243- SecretAgent::WIRELESS_SECURITY_SETTING_NAME, QStringList(),
1244+ SecretAgent::NM_WIRELESS_SECURITY_SETTING_NAME, QStringList(),
1245 5);
1246
1247 notificationSpy.wait();

Subscribers

People subscribed via source and target branches