OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/network_connection_handler.h" | 5 #include "chromeos/network/network_connection_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
367 // been recently configured), we need to check Connectable again. | 367 // been recently configured), we need to check Connectable again. |
368 if (connectable && type != shill::kTypeVPN) { | 368 if (connectable && type != shill::kTypeVPN) { |
369 // TODO(stevenjb): Shill needs to properly set Connectable for VPN. | 369 // TODO(stevenjb): Shill needs to properly set Connectable for VPN. |
370 CallShillConnect(service_path); | 370 CallShillConnect(service_path); |
371 return; | 371 return; |
372 } | 372 } |
373 | 373 |
374 // Get VPN provider type and host (required for configuration) and ensure | 374 // Get VPN provider type and host (required for configuration) and ensure |
375 // that required VPN non-cert properties are set. | 375 // that required VPN non-cert properties are set. |
376 const base::DictionaryValue* provider_properties = NULL; | 376 const base::DictionaryValue* provider_properties = NULL; |
377 std::string vpn_provider_type, vpn_provider_host; | 377 std::string vpn_provider_type, vpn_provider_host, vpn_client_cert_id; |
378 if (type == shill::kTypeVPN) { | 378 if (type == shill::kTypeVPN) { |
379 // VPN Provider values are read from the "Provider" dictionary, not the | 379 // VPN Provider values are read from the "Provider" dictionary, not the |
380 // "Provider.Type", etc keys (which are used only to set the values). | 380 // "Provider.Type", etc keys (which are used only to set the values). |
381 if (service_properties.GetDictionaryWithoutPathExpansion( | 381 if (service_properties.GetDictionaryWithoutPathExpansion( |
382 shill::kProviderProperty, &provider_properties)) { | 382 shill::kProviderProperty, &provider_properties)) { |
383 provider_properties->GetStringWithoutPathExpansion( | 383 provider_properties->GetStringWithoutPathExpansion( |
384 shill::kTypeProperty, &vpn_provider_type); | 384 shill::kTypeProperty, &vpn_provider_type); |
385 provider_properties->GetStringWithoutPathExpansion( | 385 provider_properties->GetStringWithoutPathExpansion( |
386 shill::kHostProperty, &vpn_provider_host); | 386 shill::kHostProperty, &vpn_provider_host); |
387 provider_properties->GetStringWithoutPathExpansion( | |
388 shill::kL2tpIpsecClientCertIdProperty, &vpn_client_cert_id); | |
387 } | 389 } |
388 if (vpn_provider_type.empty() || vpn_provider_host.empty()) { | 390 if (vpn_provider_type.empty() || vpn_provider_host.empty()) { |
389 ErrorCallbackForPendingRequest(service_path, kErrorConfigurationRequired); | 391 ErrorCallbackForPendingRequest(service_path, kErrorConfigurationRequired); |
390 return; | 392 return; |
391 } | 393 } |
392 } | 394 } |
393 | 395 |
394 client_cert::ConfigType client_cert_type = client_cert::CONFIG_TYPE_NONE; | 396 client_cert::ConfigType client_cert_type = client_cert::CONFIG_TYPE_NONE; |
395 if (type == shill::kTypeVPN) { | 397 if (type == shill::kTypeVPN) { |
396 if (vpn_provider_type == shill::kProviderOpenVpn) | 398 if (vpn_provider_type == shill::kProviderOpenVpn) |
397 client_cert_type = client_cert::CONFIG_TYPE_OPENVPN; | 399 client_cert_type = client_cert::CONFIG_TYPE_OPENVPN; |
398 else | 400 else if (!vpn_client_cert_id.empty()) { |
pneubeck (no reviews)
2014/02/13 09:53:07
please ignore if my reasoning is incorrect:
this
Ben Chan
2014/02/13 16:36:13
In the UI flow, VpnConfigView::CanLogin() already
| |
401 // If |vpn_client_cert_id| is empty, it's L2TP/IPsec PSK and doesn't | |
402 // require a certificate. | |
403 | |
404 // TODO(benchan): Modify shill to include the authentication type, | |
405 // pre-shared key or certificate, in the VPN provider properties, so that | |
406 // Chrome doesn't need to deduce the authentication type based on the | |
407 // kL2tpIpsecClientCertIdProperty here (and also in VPNConfigView). | |
399 client_cert_type = client_cert::CONFIG_TYPE_IPSEC; | 408 client_cert_type = client_cert::CONFIG_TYPE_IPSEC; |
409 } | |
400 } else if (type == shill::kTypeWifi && security == shill::kSecurity8021x) { | 410 } else if (type == shill::kTypeWifi && security == shill::kSecurity8021x) { |
401 client_cert_type = client_cert::CONFIG_TYPE_EAP; | 411 client_cert_type = client_cert::CONFIG_TYPE_EAP; |
402 } | 412 } |
403 | 413 |
404 base::DictionaryValue config_properties; | 414 base::DictionaryValue config_properties; |
405 if (client_cert_type != client_cert::CONFIG_TYPE_NONE) { | 415 if (client_cert_type != client_cert::CONFIG_TYPE_NONE) { |
406 // If the client certificate must be configured, this will be set to a | 416 // If the client certificate must be configured, this will be set to a |
407 // non-empty string. | 417 // non-empty string. |
408 std::string pkcs11_id; | 418 std::string pkcs11_id; |
409 | 419 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
466 if (type == shill::kTypeVPN) { | 476 if (type == shill::kTypeVPN) { |
467 // VPN may require a username, and/or passphrase to be set. (Check after | 477 // VPN may require a username, and/or passphrase to be set. (Check after |
468 // ensuring that any required certificates are configured). | 478 // ensuring that any required certificates are configured). |
469 DCHECK(provider_properties); | 479 DCHECK(provider_properties); |
470 if (VPNRequiresCredentials( | 480 if (VPNRequiresCredentials( |
471 service_path, vpn_provider_type, *provider_properties)) { | 481 service_path, vpn_provider_type, *provider_properties)) { |
472 NET_LOG_USER("VPN Requires Credentials", service_path); | 482 NET_LOG_USER("VPN Requires Credentials", service_path); |
473 ErrorCallbackForPendingRequest(service_path, kErrorConfigurationRequired); | 483 ErrorCallbackForPendingRequest(service_path, kErrorConfigurationRequired); |
474 return; | 484 return; |
475 } | 485 } |
486 | |
487 // If it's L2TP/IPsec PSK, there is no properties to configure, so proceed | |
488 // to connect. | |
pneubeck (no reviews)
2014/02/13 09:53:07
this should be removed once the connectable proper
| |
489 if (client_cert_type == client_cert::CONFIG_TYPE_NONE) { | |
490 CallShillConnect(service_path); | |
491 return; | |
492 } | |
476 } | 493 } |
477 | 494 |
478 if (!config_properties.empty()) { | 495 if (!config_properties.empty()) { |
479 NET_LOG_EVENT("Configuring Network", service_path); | 496 NET_LOG_EVENT("Configuring Network", service_path); |
480 network_configuration_handler_->SetProperties( | 497 network_configuration_handler_->SetProperties( |
481 service_path, | 498 service_path, |
482 config_properties, | 499 config_properties, |
483 base::Bind(&NetworkConnectionHandler::CallShillConnect, | 500 base::Bind(&NetworkConnectionHandler::CallShillConnect, |
484 AsWeakPtr(), | 501 AsWeakPtr(), |
485 service_path), | 502 service_path), |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
676 | 693 |
677 void NetworkConnectionHandler::HandleShillDisconnectSuccess( | 694 void NetworkConnectionHandler::HandleShillDisconnectSuccess( |
678 const std::string& service_path, | 695 const std::string& service_path, |
679 const base::Closure& success_callback) { | 696 const base::Closure& success_callback) { |
680 NET_LOG_EVENT("Disconnect Request Sent", service_path); | 697 NET_LOG_EVENT("Disconnect Request Sent", service_path); |
681 if (!success_callback.is_null()) | 698 if (!success_callback.is_null()) |
682 success_callback.Run(); | 699 success_callback.Run(); |
683 } | 700 } |
684 | 701 |
685 } // namespace chromeos | 702 } // namespace chromeos |
OLD | NEW |