blob: ccba272c3af5810d95dc82f9ab6b1d2b70e1c4c3 [file] [log] [blame]
Paul Stewart75897df2011-04-27 09:05:53 -07001// Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Chris Masoneb2e326b2011-07-12 13:28:51 -07005#include "shill/service.h"
6
Paul Stewart75897df2011-04-27 09:05:53 -07007#include <time.h>
Paul Stewart75897df2011-04-27 09:05:53 -07008#include <stdio.h>
Chris Masoneee929b72011-05-10 10:02:18 -07009
Chris Masone8fe2c7e2011-06-09 15:51:19 -070010#include <map>
Paul Stewart75897df2011-04-27 09:05:53 -070011#include <string>
Chris Masone8fe2c7e2011-06-09 15:51:19 -070012#include <vector>
Paul Stewart75897df2011-04-27 09:05:53 -070013
Chris Masoneee929b72011-05-10 10:02:18 -070014#include <base/logging.h>
Chris Masone3bd3c8c2011-06-13 08:20:26 -070015#include <base/memory/scoped_ptr.h>
mukesh agrawal51a7e932011-07-27 16:18:26 -070016#include <base/string_number_conversions.h>
Chris Masone3bd3c8c2011-06-13 08:20:26 -070017#include <chromeos/dbus/service_constants.h>
Chris Masoneee929b72011-05-10 10:02:18 -070018
Paul Stewart75897df2011-04-27 09:05:53 -070019#include "shill/control_interface.h"
Chris Masone8fe2c7e2011-06-09 15:51:19 -070020#include "shill/error.h"
Chris Masone6791a432011-07-12 13:23:19 -070021#include "shill/manager.h"
Chris Masone7aa5f902011-07-11 11:13:35 -070022#include "shill/profile.h"
Chris Masone3bd3c8c2011-06-13 08:20:26 -070023#include "shill/property_accessor.h"
Chris Masone7aa5f902011-07-11 11:13:35 -070024#include "shill/refptr_types.h"
Chris Masoned7732e42011-05-20 11:08:56 -070025#include "shill/service_dbus_adaptor.h"
Darin Petkovba40dd32011-07-11 20:06:39 -070026#include "shill/store_interface.h"
Paul Stewart75897df2011-04-27 09:05:53 -070027
Chris Masone8fe2c7e2011-06-09 15:51:19 -070028using std::map;
Paul Stewart75897df2011-04-27 09:05:53 -070029using std::string;
Chris Masone8fe2c7e2011-06-09 15:51:19 -070030using std::vector;
Paul Stewart75897df2011-04-27 09:05:53 -070031
32namespace shill {
Darin Petkovba40dd32011-07-11 20:06:39 -070033
34const char Service::kCheckPortalAuto[] = "auto";
35const char Service::kCheckPortalFalse[] = "false";
36const char Service::kCheckPortalTrue[] = "true";
37
Paul Stewartac4ac002011-08-26 12:04:26 -070038const int Service::kPriorityNone = 0;
39
Darin Petkovba40dd32011-07-11 20:06:39 -070040const char Service::kStorageAutoConnect[] = "AutoConnect";
41const char Service::kStorageCheckPortal[] = "CheckPortal";
42const char Service::kStorageEapAnonymousIdentity[] = "EAP.AnonymousIdentity";
43const char Service::kStorageEapCACert[] = "EAP.CACert";
44const char Service::kStorageEapCACertID[] = "EAP.CACertID";
45const char Service::kStorageEapCertID[] = "EAP.CertID";
46const char Service::kStorageEapClientCert[] = "EAP.ClientCert";
47const char Service::kStorageEapEap[] = "EAP.EAP";
48const char Service::kStorageEapIdentity[] = "EAP.Identity";
49const char Service::kStorageEapInnerEap[] = "EAP.InnerEAP";
50const char Service::kStorageEapKeyID[] = "EAP.KeyID";
51const char Service::kStorageEapKeyManagement[] = "EAP.KeyMgmt";
52const char Service::kStorageEapPIN[] = "EAP.PIN";
53const char Service::kStorageEapPassword[] = "EAP.Password";
54const char Service::kStorageEapPrivateKey[] = "EAP.PrivateKey";
55const char Service::kStorageEapPrivateKeyPassword[] = "EAP.PrivateKeyPassword";
56const char Service::kStorageEapUseSystemCAs[] = "EAP.UseSystemCAs";
57const char Service::kStorageFavorite[] = "Favorite";
58const char Service::kStorageName[] = "Name";
59const char Service::kStoragePriority[] = "Priority";
60const char Service::kStorageProxyConfig[] = "ProxyConfig";
61const char Service::kStorageSaveCredentials[] = "SaveCredentials";
62
mukesh agrawal51a7e932011-07-27 16:18:26 -070063// static
64unsigned int Service::serial_number_ = 0;
65
Paul Stewart75897df2011-04-27 09:05:53 -070066Service::Service(ControlInterface *control_interface,
mukesh agrawalb54601c2011-06-07 17:39:22 -070067 EventDispatcher *dispatcher,
mukesh agrawal7a4e4002011-09-06 11:26:05 -070068 Manager *manager,
69 const string &type)
Paul Stewart03dba0b2011-08-22 16:32:45 -070070 : state_(kStateUnknown),
71 failure_(kFailureUnknown),
72 auto_connect_(false),
Darin Petkovba40dd32011-07-11 20:06:39 -070073 check_portal_(kCheckPortalAuto),
Chris Masone3bd3c8c2011-06-13 08:20:26 -070074 connectable_(false),
75 favorite_(false),
Darin Petkovba40dd32011-07-11 20:06:39 -070076 priority_(kPriorityNone),
Paul Stewart1ca3e852011-11-04 07:50:49 -070077 security_level_(0),
Paul Stewart22aa71b2011-09-16 12:15:11 -070078 strength_(0),
Darin Petkovba40dd32011-07-11 20:06:39 -070079 save_credentials_(true),
mukesh agrawal7a4e4002011-09-06 11:26:05 -070080 type_(type),
Chris Masone3bd3c8c2011-06-13 08:20:26 -070081 dispatcher_(dispatcher),
mukesh agrawald835b202011-10-07 15:26:47 -070082 unique_name_(base::UintToString(serial_number_++)),
83 friendly_name_(unique_name_),
Chris Masonea82b7112011-05-25 15:16:29 -070084 available_(false),
85 configured_(false),
Chris Masonea82b7112011-05-25 15:16:29 -070086 configuration_(NULL),
87 connection_(NULL),
Chris Masone6791a432011-07-12 13:23:19 -070088 adaptor_(control_interface->CreateServiceAdaptor(this)),
89 manager_(manager) {
Chris Masone3bd3c8c2011-06-13 08:20:26 -070090
Chris Masone27c4aa52011-07-02 13:10:14 -070091 store_.RegisterBool(flimflam::kAutoConnectProperty, &auto_connect_);
Chris Masone4d42df82011-07-02 17:09:39 -070092
93 // flimflam::kActivationStateProperty: Registered in CellularService
94 // flimflam::kCellularApnProperty: Registered in CellularService
95 // flimflam::kCellularLastGoodApnProperty: Registered in CellularService
96 // flimflam::kNetworkTechnologyProperty: Registered in CellularService
Darin Petkov3335b372011-08-22 11:05:32 -070097 // flimflam::kOperatorNameProperty: DEPRECATED
98 // flimflam::kOperatorCodeProperty: DEPRECATED
Chris Masone4d42df82011-07-02 17:09:39 -070099 // flimflam::kRoamingStateProperty: Registered in CellularService
Darin Petkov3335b372011-08-22 11:05:32 -0700100 // flimflam::kServingOperatorProperty: Registered in CellularService
Chris Masone4d42df82011-07-02 17:09:39 -0700101 // flimflam::kPaymentURLProperty: Registered in CellularService
102
Chris Masone27c4aa52011-07-02 13:10:14 -0700103 store_.RegisterString(flimflam::kCheckPortalProperty, &check_portal_);
104 store_.RegisterConstBool(flimflam::kConnectableProperty, &connectable_);
105 HelpRegisterDerivedString(flimflam::kDeviceProperty,
106 &Service::GetDeviceRpcId,
107 NULL);
Chris Masone3bd3c8c2011-06-13 08:20:26 -0700108
Chris Masoneb2e326b2011-07-12 13:28:51 -0700109 store_.RegisterString(flimflam::kEapIdentityProperty, &eap_.identity);
110 store_.RegisterString(flimflam::kEAPEAPProperty, &eap_.eap);
111 store_.RegisterString(flimflam::kEapPhase2AuthProperty, &eap_.inner_eap);
Chris Masone27c4aa52011-07-02 13:10:14 -0700112 store_.RegisterString(flimflam::kEapAnonymousIdentityProperty,
Chris Masoneb2e326b2011-07-12 13:28:51 -0700113 &eap_.anonymous_identity);
114 store_.RegisterString(flimflam::kEAPClientCertProperty, &eap_.client_cert);
115 store_.RegisterString(flimflam::kEAPCertIDProperty, &eap_.cert_id);
116 store_.RegisterString(flimflam::kEapPrivateKeyProperty, &eap_.private_key);
Chris Masone27c4aa52011-07-02 13:10:14 -0700117 store_.RegisterString(flimflam::kEapPrivateKeyPasswordProperty,
Chris Masoneb2e326b2011-07-12 13:28:51 -0700118 &eap_.private_key_password);
119 store_.RegisterString(flimflam::kEAPKeyIDProperty, &eap_.key_id);
120 store_.RegisterString(flimflam::kEapCaCertProperty, &eap_.ca_cert);
121 store_.RegisterString(flimflam::kEapCaCertIDProperty, &eap_.ca_cert_id);
122 store_.RegisterString(flimflam::kEAPPINProperty, &eap_.pin);
123 store_.RegisterString(flimflam::kEapPasswordProperty, &eap_.password);
124 store_.RegisterString(flimflam::kEapKeyMgmtProperty, &eap_.key_management);
125 store_.RegisterBool(flimflam::kEapUseSystemCAsProperty, &eap_.use_system_cas);
Chris Masone3bd3c8c2011-06-13 08:20:26 -0700126
Chris Masone27c4aa52011-07-02 13:10:14 -0700127 store_.RegisterConstString(flimflam::kErrorProperty, &error_);
128 store_.RegisterConstBool(flimflam::kFavoriteProperty, &favorite_);
129 HelpRegisterDerivedBool(flimflam::kIsActiveProperty,
Chris Masoneb2e326b2011-07-12 13:28:51 -0700130 &Service::IsActive,
131 NULL);
Chris Masone4d42df82011-07-02 17:09:39 -0700132 // flimflam::kModeProperty: Registered in WiFiService
mukesh agrawald835b202011-10-07 15:26:47 -0700133 store_.RegisterConstString(flimflam::kNameProperty, &friendly_name_);
Chris Masone4d42df82011-07-02 17:09:39 -0700134 // flimflam::kPassphraseProperty: Registered in WiFiService
135 // flimflam::kPassphraseRequiredProperty: Registered in WiFiService
Chris Masone27c4aa52011-07-02 13:10:14 -0700136 store_.RegisterInt32(flimflam::kPriorityProperty, &priority_);
137 HelpRegisterDerivedString(flimflam::kProfileProperty,
138 &Service::GetProfileRpcId,
139 NULL);
Chris Masone4d42df82011-07-02 17:09:39 -0700140 store_.RegisterString(flimflam::kProxyConfigProperty, &proxy_config_);
Chris Masone43b48a12011-07-01 13:37:07 -0700141 // TODO(cmasone): Create VPN Service with this property
Chris Masone27c4aa52011-07-02 13:10:14 -0700142 // store_.RegisterConstStringmap(flimflam::kProviderProperty, &provider_);
Chris Masone4d42df82011-07-02 17:09:39 -0700143
Chris Masoneb2e326b2011-07-12 13:28:51 -0700144 store_.RegisterBool(flimflam::kSaveCredentialsProperty, &save_credentials_);
mukesh agrawal7a4e4002011-09-06 11:26:05 -0700145 store_.RegisterConstString(flimflam::kTypeProperty, &type_);
Chris Masone4d42df82011-07-02 17:09:39 -0700146 // flimflam::kSecurityProperty: Registered in WiFiService
Chris Masone27c4aa52011-07-02 13:10:14 -0700147 HelpRegisterDerivedString(flimflam::kStateProperty,
148 &Service::CalculateState,
149 NULL);
Chris Masone4d42df82011-07-02 17:09:39 -0700150 // flimflam::kSignalStrengthProperty: Registered in WiFi/CellularService
151 // flimflam::kTypeProperty: Registered in all derived classes.
152 // flimflam::kWifiAuthMode: Registered in WiFiService
153 // flimflam::kWifiHiddenSsid: Registered in WiFiService
154 // flimflam::kWifiFrequency: Registered in WiFiService
155 // flimflam::kWifiPhyMode: Registered in WiFiService
156 // flimflam::kWifiHexSsid: Registered in WiFiService
Chris Masoneb07006b2011-05-14 16:10:04 -0700157 VLOG(2) << "Service initialized.";
Paul Stewart75897df2011-04-27 09:05:53 -0700158}
159
Paul Stewartba41b992011-05-26 07:02:46 -0700160Service::~Service() {}
Paul Stewart75897df2011-04-27 09:05:53 -0700161
mukesh agrawal1830fa12011-09-26 14:31:40 -0700162void Service::ActivateCellularModem(const std::string &/*carrier*/,
163 Error *error) {
Darin Petkovb100ae72011-08-24 16:19:45 -0700164 const string kMessage = "Service doesn't support cellular modem activation.";
165 LOG(ERROR) << kMessage;
166 CHECK(error);
167 error->Populate(Error::kInvalidArguments, kMessage);
Darin Petkovc408e692011-08-17 13:47:15 -0700168}
169
mukesh agrawal1830fa12011-09-26 14:31:40 -0700170bool Service::TechnologyIs(const Technology::Identifier /*type*/) const {
Paul Stewart22aa71b2011-09-16 12:15:11 -0700171 return false;
172}
173
Paul Stewart03dba0b2011-08-22 16:32:45 -0700174bool Service::IsActive() {
175 return state_ != kStateUnknown &&
176 state_ != kStateIdle &&
177 state_ != kStateFailure;
178}
179
180void Service::SetState(ConnectState state) {
181 if (state == state_) {
182 return;
183 }
184
185 state_ = state;
186 if (state != kStateFailure) {
187 failure_ = kFailureUnknown;
188 }
189 manager_->UpdateService(this);
mukesh agrawalf2f68a52011-09-01 12:15:48 -0700190 adaptor_->EmitStringChanged(flimflam::kStateProperty, CalculateState());
Paul Stewart03dba0b2011-08-22 16:32:45 -0700191}
192
193void Service::SetFailure(ConnectFailure failure) {
194 failure_ = failure;
195 SetState(kStateFailure);
196}
197
Chris Masone6791a432011-07-12 13:23:19 -0700198string Service::GetRpcIdentifier() const {
Chris Masone3c3f6a12011-07-01 10:01:41 -0700199 return adaptor_->GetRpcIdentifier();
200}
201
Paul Stewartbba6a5b2011-11-02 18:45:59 -0700202bool Service::IsLoadableFrom(StoreInterface *storage) const {
203 return storage->ContainsGroup(GetStorageIdentifier());
204}
205
Chris Masone9d779932011-08-25 16:33:41 -0700206bool Service::Load(StoreInterface *storage) {
207 const string id = GetStorageIdentifier();
Chris Masone34af2182011-08-22 11:59:36 -0700208 if (!storage->ContainsGroup(id)) {
209 LOG(WARNING) << "Service is not available in the persistent store: " << id;
210 return false;
211 }
212 storage->GetBool(id, kStorageAutoConnect, &auto_connect_);
213 storage->GetString(id, kStorageCheckPortal, &check_portal_);
214 storage->GetBool(id, kStorageFavorite, &favorite_);
215 storage->GetInt(id, kStoragePriority, &priority_);
216 storage->GetString(id, kStorageProxyConfig, &proxy_config_);
217 storage->GetBool(id, kStorageSaveCredentials, &save_credentials_);
218
219 LoadEapCredentials(storage, id);
220
221 // TODO(petkov): Load these:
222
223 // "Name"
224 // "WiFi.HiddenSSID"
225 // "SSID"
226 // "Failure"
227 // "Modified"
228 // "LastAttempt"
229 // WiFiService: "Passphrase"
230 // "APN"
231 // "LastGoodAPN"
232
233 return true;
Darin Petkovba40dd32011-07-11 20:06:39 -0700234}
235
Chris Masone9d779932011-08-25 16:33:41 -0700236bool Service::Save(StoreInterface *storage) {
237 const string id = GetStorageIdentifier();
Chris Masone34af2182011-08-22 11:59:36 -0700238
239 // TODO(petkov): We could choose to simplify the saving code by removing most
240 // conditionals thus saving even default values.
241 if (favorite_) {
242 storage->SetBool(id, kStorageAutoConnect, auto_connect_);
243 }
244 if (check_portal_ == kCheckPortalAuto) {
245 storage->DeleteKey(id, kStorageCheckPortal);
246 } else {
247 storage->SetString(id, kStorageCheckPortal, check_portal_);
248 }
249 storage->SetBool(id, kStorageFavorite, favorite_);
mukesh agrawald835b202011-10-07 15:26:47 -0700250 storage->SetString(id, kStorageName, friendly_name_);
Chris Masone34af2182011-08-22 11:59:36 -0700251 SaveString(storage, id, kStorageProxyConfig, proxy_config_, false, true);
252 if (priority_ != kPriorityNone) {
253 storage->SetInt(id, kStoragePriority, priority_);
254 } else {
255 storage->DeleteKey(id, kStoragePriority);
256 }
257 if (save_credentials_) {
258 storage->DeleteKey(id, kStorageSaveCredentials);
259 } else {
260 storage->SetBool(id, kStorageSaveCredentials, false);
261 }
262
263 SaveEapCredentials(storage, id);
264
265 // TODO(petkov): Save these:
266
267 // "WiFi.HiddenSSID"
268 // "SSID"
269 // "Failure"
270 // "Modified"
271 // "LastAttempt"
272 // WiFiService: "Passphrase"
273 // "APN"
274 // "LastGoodAPN"
275
276 return true;
277}
278
Paul Stewart22aa71b2011-09-16 12:15:11 -0700279bool Service::DecideBetween(int a, int b, bool *decision) {
280 if (a == b)
281 return false;
282 *decision = (a > b);
283 return true;
284}
285
286bool Service::Compare(ServiceRefPtr a,
287 ServiceRefPtr b,
288 const vector<Technology::Identifier> &tech_order) {
289 bool ret;
290
291 if (a->state() != b->state()) {
292 if (DecideBetween(a->IsConnected(), b->IsConnected(), &ret)) {
293 return ret;
294 }
295
296 // TODO(pstew): Services don't know about portal state yet
297
298 if (DecideBetween(a->IsConnecting(), b->IsConnecting(), &ret)) {
299 return ret;
300 }
301 }
302
303 if (DecideBetween(a->favorite(), b->favorite(), &ret) ||
304 DecideBetween(a->priority(), b->priority(), &ret)) {
305 return ret;
306 }
307
308 // TODO(pstew): Below this point we are making value judgements on
309 // services that are not related to anything intrinsic or
310 // user-specified. These heuristics should be richer (contain
311 // historical information, for example) and be subject to user
312 // customization.
313
314 for (vector<Technology::Identifier>::const_iterator it = tech_order.begin();
315 it != tech_order.end();
316 ++it) {
317 if (DecideBetween(a->TechnologyIs(*it), b->TechnologyIs(*it), &ret))
318 return ret;
319 }
320
Paul Stewart1ca3e852011-11-04 07:50:49 -0700321 if (DecideBetween(a->security_level(), b->security_level(), &ret) ||
Paul Stewart22aa71b2011-09-16 12:15:11 -0700322 DecideBetween(a->strength(), b->strength(), &ret)) {
323 return ret;
324 }
325
326 return a->UniqueName() < b->UniqueName();
327}
328
Chris Masone34af2182011-08-22 11:59:36 -0700329const ProfileRefPtr &Service::profile() const { return profile_; }
330
331void Service::set_profile(const ProfileRefPtr &p) { profile_ = p; }
332
mukesh agrawalf2f68a52011-09-01 12:15:48 -0700333string Service::CalculateState() {
334 switch (state_) {
335 case kStateConnected:
336 return flimflam::kStateReady;
337 default:
338 // TODO(quiche): provide strings for other states
339 return flimflam::kStateIdle;
340 }
341}
342
mukesh agrawalffa3d042011-10-06 15:26:10 -0700343void Service::HelpRegisterDerivedBool(
344 const string &name,
345 bool(Service::*get)(void),
346 void(Service::*set)(const bool&, Error *)) {
Chris Masone27c4aa52011-07-02 13:10:14 -0700347 store_.RegisterDerivedBool(
348 name,
349 BoolAccessor(new CustomAccessor<Service, bool>(this, get, set)));
Chris Masone3bd3c8c2011-06-13 08:20:26 -0700350}
351
mukesh agrawalffa3d042011-10-06 15:26:10 -0700352void Service::HelpRegisterDerivedString(
353 const string &name,
354 string(Service::*get)(void),
355 void(Service::*set)(const string&, Error *)) {
Chris Masone27c4aa52011-07-02 13:10:14 -0700356 store_.RegisterDerivedString(
357 name,
358 StringAccessor(new CustomAccessor<Service, string>(this, get, set)));
Chris Masone3bd3c8c2011-06-13 08:20:26 -0700359}
360
Darin Petkovba40dd32011-07-11 20:06:39 -0700361void Service::SaveString(StoreInterface *storage,
Chris Masone34af2182011-08-22 11:59:36 -0700362 const string &id,
Darin Petkovba40dd32011-07-11 20:06:39 -0700363 const string &key,
364 const string &value,
365 bool crypted,
366 bool save) {
367 if (value.empty() || !save) {
Chris Masone34af2182011-08-22 11:59:36 -0700368 storage->DeleteKey(id, key);
Darin Petkovba40dd32011-07-11 20:06:39 -0700369 return;
370 }
371 if (crypted) {
Chris Masone34af2182011-08-22 11:59:36 -0700372 storage->SetCryptedString(id, key, value);
Darin Petkovba40dd32011-07-11 20:06:39 -0700373 return;
374 }
Chris Masone34af2182011-08-22 11:59:36 -0700375 storage->SetString(id, key, value);
Darin Petkovba40dd32011-07-11 20:06:39 -0700376}
377
Chris Masone34af2182011-08-22 11:59:36 -0700378void Service::LoadEapCredentials(StoreInterface *storage, const string &id) {
Darin Petkovba40dd32011-07-11 20:06:39 -0700379 storage->GetCryptedString(id, kStorageEapIdentity, &eap_.identity);
380 storage->GetString(id, kStorageEapEap, &eap_.eap);
381 storage->GetString(id, kStorageEapInnerEap, &eap_.inner_eap);
382 storage->GetCryptedString(id,
383 kStorageEapAnonymousIdentity,
384 &eap_.anonymous_identity);
385 storage->GetString(id, kStorageEapClientCert, &eap_.client_cert);
386 storage->GetString(id, kStorageEapCertID, &eap_.cert_id);
387 storage->GetString(id, kStorageEapPrivateKey, &eap_.private_key);
388 storage->GetCryptedString(id,
389 kStorageEapPrivateKeyPassword,
390 &eap_.private_key_password);
391 storage->GetString(id, kStorageEapKeyID, &eap_.key_id);
392 storage->GetString(id, kStorageEapCACert, &eap_.ca_cert);
393 storage->GetString(id, kStorageEapCACertID, &eap_.ca_cert_id);
394 storage->GetBool(id, kStorageEapUseSystemCAs, &eap_.use_system_cas);
395 storage->GetString(id, kStorageEapPIN, &eap_.pin);
396 storage->GetCryptedString(id, kStorageEapPassword, &eap_.password);
397 storage->GetString(id, kStorageEapKeyManagement, &eap_.key_management);
398}
399
Chris Masone34af2182011-08-22 11:59:36 -0700400void Service::SaveEapCredentials(StoreInterface *storage, const string &id) {
Darin Petkovba40dd32011-07-11 20:06:39 -0700401 bool save = save_credentials_;
Chris Masone34af2182011-08-22 11:59:36 -0700402 SaveString(storage, id, kStorageEapIdentity, eap_.identity, true, save);
403 SaveString(storage, id, kStorageEapEap, eap_.eap, false, true);
404 SaveString(storage, id, kStorageEapInnerEap, eap_.inner_eap, false, true);
Darin Petkovba40dd32011-07-11 20:06:39 -0700405 SaveString(storage,
Chris Masone34af2182011-08-22 11:59:36 -0700406 id,
Darin Petkovba40dd32011-07-11 20:06:39 -0700407 kStorageEapAnonymousIdentity,
408 eap_.anonymous_identity,
409 true,
410 save);
Chris Masone34af2182011-08-22 11:59:36 -0700411 SaveString(storage, id, kStorageEapClientCert, eap_.client_cert, false, save);
412 SaveString(storage, id, kStorageEapCertID, eap_.cert_id, false, save);
413 SaveString(storage, id, kStorageEapPrivateKey, eap_.private_key, false, save);
Darin Petkovba40dd32011-07-11 20:06:39 -0700414 SaveString(storage,
Chris Masone34af2182011-08-22 11:59:36 -0700415 id,
Darin Petkovba40dd32011-07-11 20:06:39 -0700416 kStorageEapPrivateKeyPassword,
417 eap_.private_key_password,
418 true,
419 save);
Chris Masone34af2182011-08-22 11:59:36 -0700420 SaveString(storage, id, kStorageEapKeyID, eap_.key_id, false, save);
421 SaveString(storage, id, kStorageEapCACert, eap_.ca_cert, false, true);
422 SaveString(storage, id, kStorageEapCACertID, eap_.ca_cert_id, false, true);
423 storage->SetBool(id, kStorageEapUseSystemCAs, eap_.use_system_cas);
424 SaveString(storage, id, kStorageEapPIN, eap_.pin, false, save);
425 SaveString(storage, id, kStorageEapPassword, eap_.password, true, save);
Darin Petkovba40dd32011-07-11 20:06:39 -0700426 SaveString(storage,
Chris Masone34af2182011-08-22 11:59:36 -0700427 id,
Darin Petkovba40dd32011-07-11 20:06:39 -0700428 kStorageEapKeyManagement,
429 eap_.key_management,
430 false,
431 true);
432}
433
Paul Stewartac4ac002011-08-26 12:04:26 -0700434const string &Service::GetEAPKeyManagement() const {
435 return eap_.key_management;
436}
437
438void Service::SetEAPKeyManagement(const string &key_management) {
439 eap_.key_management = key_management;
440}
441
Paul Stewart75897df2011-04-27 09:05:53 -0700442} // namespace shill