Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(315)

Side by Side Diff: chromeos/network/client_cert_util.cc

Issue 2828713002: Enable client certificate patterns in device ONC policy (Closed)
Patch Set: Rebase. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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->source_is_device_policy_ =
46 onc_source != onc::ONC_SOURCE_USER_POLICY;
47
44 dict_with_client_cert.GetStringWithoutPathExpansion( 48 dict_with_client_cert.GetStringWithoutPathExpansion(
45 ::onc::eap::kIdentity, &cert_config->policy_identity); 49 ::onc::eap::kIdentity, &cert_config->policy_identity);
46 50
47 using namespace ::onc::client_cert; 51 using namespace ::onc::client_cert;
48 dict_with_client_cert.GetStringWithoutPathExpansion( 52 dict_with_client_cert.GetStringWithoutPathExpansion(
49 kClientCertType, &cert_config->client_cert_type); 53 kClientCertType, &cert_config->client_cert_type);
50 54
51 if (cert_config->client_cert_type == kPattern) { 55 if (cert_config->client_cert_type == kPattern) {
52 const base::DictionaryValue* pattern = NULL; 56 const base::DictionaryValue* pattern = NULL;
53 dict_with_client_cert.GetDictionaryWithoutPathExpansion(kClientCertPattern, 57 dict_with_client_cert.GetDictionaryWithoutPathExpansion(kClientCertPattern,
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 } 263 }
260 } 264 }
261 265
262 ClientCertConfig::ClientCertConfig() 266 ClientCertConfig::ClientCertConfig()
263 : location(CONFIG_TYPE_NONE), 267 : location(CONFIG_TYPE_NONE),
264 client_cert_type(onc::client_cert::kClientCertTypeNone) { 268 client_cert_type(onc::client_cert::kClientCertTypeNone) {
265 } 269 }
266 270
267 ClientCertConfig::ClientCertConfig(const ClientCertConfig& other) = default; 271 ClientCertConfig::ClientCertConfig(const ClientCertConfig& other) = default;
268 272
269 void OncToClientCertConfig(const base::DictionaryValue& network_config, 273 void OncToClientCertConfig(::onc::ONCSource onc_source,
274 const base::DictionaryValue& network_config,
270 ClientCertConfig* cert_config) { 275 ClientCertConfig* cert_config) {
271 using namespace ::onc; 276 using namespace ::onc;
272 277
273 *cert_config = ClientCertConfig(); 278 *cert_config = ClientCertConfig();
274 279
275 const base::DictionaryValue* dict_with_client_cert = NULL; 280 const base::DictionaryValue* dict_with_client_cert = NULL;
276 281
277 const base::DictionaryValue* wifi = NULL; 282 const base::DictionaryValue* wifi = NULL;
278 network_config.GetDictionaryWithoutPathExpansion(network_config::kWiFi, 283 network_config.GetDictionaryWithoutPathExpansion(network_config::kWiFi,
279 &wifi); 284 &wifi);
(...skipping 30 matching lines...) Expand all
310 &ethernet); 315 &ethernet);
311 if (ethernet) { 316 if (ethernet) {
312 const base::DictionaryValue* eap = NULL; 317 const base::DictionaryValue* eap = NULL;
313 ethernet->GetDictionaryWithoutPathExpansion(wifi::kEAP, &eap); 318 ethernet->GetDictionaryWithoutPathExpansion(wifi::kEAP, &eap);
314 if (!eap) 319 if (!eap)
315 return; 320 return;
316 dict_with_client_cert = eap; 321 dict_with_client_cert = eap;
317 cert_config->location = CONFIG_TYPE_EAP; 322 cert_config->location = CONFIG_TYPE_EAP;
318 } 323 }
319 324
320 if (dict_with_client_cert) 325 if (dict_with_client_cert) {
321 GetClientCertTypeAndPattern(*dict_with_client_cert, cert_config); 326 GetClientCertTypeAndPattern(onc_source, *dict_with_client_cert,
327 cert_config);
328 }
322 } 329 }
323 330
324 bool IsCertificateConfigured(const ConfigType cert_config_type, 331 bool IsCertificateConfigured(const ConfigType cert_config_type,
325 const base::DictionaryValue& service_properties) { 332 const base::DictionaryValue& service_properties) {
326 // VPN certificate properties are read from the Provider dictionary. 333 // VPN certificate properties are read from the Provider dictionary.
327 const base::DictionaryValue* provider_properties = NULL; 334 const base::DictionaryValue* provider_properties = NULL;
328 service_properties.GetDictionaryWithoutPathExpansion( 335 service_properties.GetDictionaryWithoutPathExpansion(
329 shill::kProviderProperty, &provider_properties); 336 shill::kProviderProperty, &provider_properties);
330 switch (cert_config_type) { 337 switch (cert_config_type) {
331 case CONFIG_TYPE_NONE: 338 case CONFIG_TYPE_NONE:
(...skipping 21 matching lines...) Expand all
353 return !cert_id.empty() && !key_id.empty() && !identity.empty(); 360 return !cert_id.empty() && !key_id.empty() && !identity.empty();
354 } 361 }
355 } 362 }
356 NOTREACHED(); 363 NOTREACHED();
357 return false; 364 return false;
358 } 365 }
359 366
360 } // namespace client_cert 367 } // namespace client_cert
361 368
362 } // namespace chromeos 369 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698