| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chromeos/network/client_cert_util.h" | 5 #include "chromeos/network/client_cert_util.h" |
| 6 | 6 |
| 7 #include <cert.h> | 7 #include <cert.h> |
| 8 #include <pk11pub.h> | 8 #include <pk11pub.h> |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 | 10 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 const char kDefaultTPMPin[] = "111111"; | 32 const char kDefaultTPMPin[] = "111111"; |
| 33 | 33 |
| 34 std::string GetStringFromDictionary(const base::DictionaryValue& dict, | 34 std::string GetStringFromDictionary(const base::DictionaryValue& dict, |
| 35 const std::string& key) { | 35 const std::string& key) { |
| 36 std::string s; | 36 std::string s; |
| 37 dict.GetStringWithoutPathExpansion(key, &s); | 37 dict.GetStringWithoutPathExpansion(key, &s); |
| 38 return s; | 38 return s; |
| 39 } | 39 } |
| 40 | 40 |
| 41 void GetClientCertTypeAndPattern( | 41 void GetClientCertTypeAndPattern( |
| 42 onc::ONCSource onc_source, |
| 42 const base::DictionaryValue& dict_with_client_cert, | 43 const base::DictionaryValue& dict_with_client_cert, |
| 43 ClientCertConfig* cert_config) { | 44 ClientCertConfig* cert_config) { |
| 45 cert_config->onc_source = onc_source; |
| 46 |
| 44 dict_with_client_cert.GetStringWithoutPathExpansion( | 47 dict_with_client_cert.GetStringWithoutPathExpansion( |
| 45 ::onc::eap::kIdentity, &cert_config->policy_identity); | 48 ::onc::eap::kIdentity, &cert_config->policy_identity); |
| 46 | 49 |
| 47 using namespace ::onc::client_cert; | 50 using namespace ::onc::client_cert; |
| 48 dict_with_client_cert.GetStringWithoutPathExpansion( | 51 dict_with_client_cert.GetStringWithoutPathExpansion( |
| 49 kClientCertType, &cert_config->client_cert_type); | 52 kClientCertType, &cert_config->client_cert_type); |
| 50 | 53 |
| 51 if (cert_config->client_cert_type == kPattern) { | 54 if (cert_config->client_cert_type == kPattern) { |
| 52 const base::DictionaryValue* pattern = NULL; | 55 const base::DictionaryValue* pattern = NULL; |
| 53 dict_with_client_cert.GetDictionaryWithoutPathExpansion(kClientCertPattern, | 56 dict_with_client_cert.GetDictionaryWithoutPathExpansion(kClientCertPattern, |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 } | 262 } |
| 260 } | 263 } |
| 261 | 264 |
| 262 ClientCertConfig::ClientCertConfig() | 265 ClientCertConfig::ClientCertConfig() |
| 263 : location(CONFIG_TYPE_NONE), | 266 : location(CONFIG_TYPE_NONE), |
| 264 client_cert_type(onc::client_cert::kClientCertTypeNone) { | 267 client_cert_type(onc::client_cert::kClientCertTypeNone) { |
| 265 } | 268 } |
| 266 | 269 |
| 267 ClientCertConfig::ClientCertConfig(const ClientCertConfig& other) = default; | 270 ClientCertConfig::ClientCertConfig(const ClientCertConfig& other) = default; |
| 268 | 271 |
| 269 void OncToClientCertConfig(const base::DictionaryValue& network_config, | 272 void OncToClientCertConfig(::onc::ONCSource onc_source, |
| 273 const base::DictionaryValue& network_config, |
| 270 ClientCertConfig* cert_config) { | 274 ClientCertConfig* cert_config) { |
| 271 using namespace ::onc; | 275 using namespace ::onc; |
| 272 | 276 |
| 273 *cert_config = ClientCertConfig(); | 277 *cert_config = ClientCertConfig(); |
| 274 | 278 |
| 275 const base::DictionaryValue* dict_with_client_cert = NULL; | 279 const base::DictionaryValue* dict_with_client_cert = NULL; |
| 276 | 280 |
| 277 const base::DictionaryValue* wifi = NULL; | 281 const base::DictionaryValue* wifi = NULL; |
| 278 network_config.GetDictionaryWithoutPathExpansion(network_config::kWiFi, | 282 network_config.GetDictionaryWithoutPathExpansion(network_config::kWiFi, |
| 279 &wifi); | 283 &wifi); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 310 ðernet); | 314 ðernet); |
| 311 if (ethernet) { | 315 if (ethernet) { |
| 312 const base::DictionaryValue* eap = NULL; | 316 const base::DictionaryValue* eap = NULL; |
| 313 ethernet->GetDictionaryWithoutPathExpansion(wifi::kEAP, &eap); | 317 ethernet->GetDictionaryWithoutPathExpansion(wifi::kEAP, &eap); |
| 314 if (!eap) | 318 if (!eap) |
| 315 return; | 319 return; |
| 316 dict_with_client_cert = eap; | 320 dict_with_client_cert = eap; |
| 317 cert_config->location = CONFIG_TYPE_EAP; | 321 cert_config->location = CONFIG_TYPE_EAP; |
| 318 } | 322 } |
| 319 | 323 |
| 320 if (dict_with_client_cert) | 324 if (dict_with_client_cert) { |
| 321 GetClientCertTypeAndPattern(*dict_with_client_cert, cert_config); | 325 GetClientCertTypeAndPattern(onc_source, *dict_with_client_cert, |
| 326 cert_config); |
| 327 } |
| 322 } | 328 } |
| 323 | 329 |
| 324 bool IsCertificateConfigured(const ConfigType cert_config_type, | 330 bool IsCertificateConfigured(const ConfigType cert_config_type, |
| 325 const base::DictionaryValue& service_properties) { | 331 const base::DictionaryValue& service_properties) { |
| 326 // VPN certificate properties are read from the Provider dictionary. | 332 // VPN certificate properties are read from the Provider dictionary. |
| 327 const base::DictionaryValue* provider_properties = NULL; | 333 const base::DictionaryValue* provider_properties = NULL; |
| 328 service_properties.GetDictionaryWithoutPathExpansion( | 334 service_properties.GetDictionaryWithoutPathExpansion( |
| 329 shill::kProviderProperty, &provider_properties); | 335 shill::kProviderProperty, &provider_properties); |
| 330 switch (cert_config_type) { | 336 switch (cert_config_type) { |
| 331 case CONFIG_TYPE_NONE: | 337 case CONFIG_TYPE_NONE: |
| (...skipping 21 matching lines...) Expand all Loading... |
| 353 return !cert_id.empty() && !key_id.empty() && !identity.empty(); | 359 return !cert_id.empty() && !key_id.empty() && !identity.empty(); |
| 354 } | 360 } |
| 355 } | 361 } |
| 356 NOTREACHED(); | 362 NOTREACHED(); |
| 357 return false; | 363 return false; |
| 358 } | 364 } |
| 359 | 365 |
| 360 } // namespace client_cert | 366 } // namespace client_cert |
| 361 | 367 |
| 362 } // namespace chromeos | 368 } // namespace chromeos |
| OLD | NEW |