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 "chromeos/chromeos_switches.h" | 10 #include "chromeos/chromeos_switches.h" |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
407 if (vpn_provider_type == flimflam::kProviderOpenVpn) | 407 if (vpn_provider_type == flimflam::kProviderOpenVpn) |
408 client_cert_type = client_cert::CONFIG_TYPE_OPENVPN; | 408 client_cert_type = client_cert::CONFIG_TYPE_OPENVPN; |
409 else | 409 else |
410 client_cert_type = client_cert::CONFIG_TYPE_IPSEC; | 410 client_cert_type = client_cert::CONFIG_TYPE_IPSEC; |
411 } else if (type == flimflam::kTypeWifi && | 411 } else if (type == flimflam::kTypeWifi && |
412 security == flimflam::kSecurity8021x) { | 412 security == flimflam::kSecurity8021x) { |
413 client_cert_type = client_cert::CONFIG_TYPE_EAP; | 413 client_cert_type = client_cert::CONFIG_TYPE_EAP; |
414 } | 414 } |
415 | 415 |
416 base::DictionaryValue config_properties; | 416 base::DictionaryValue config_properties; |
417 if (client_cert_type != client_cert::CONFIG_TYPE_NONE) { | 417 if (client_cert_type != client_cert::CONFIG_TYPE_NONE) { |
pneubeck (no reviews)
2013/09/04 08:40:00
If this condition holds, we only know that this ne
stevenjb
2013/09/04 17:58:13
I see. I'll change the return value to kErrorConfi
| |
418 // If the client certificate must be configured, this will be set to a | 418 // If the client certificate must be configured, this will be set to a |
419 // non-empty string. | 419 // non-empty string. |
420 std::string pkcs11_id; | 420 std::string pkcs11_id; |
421 | 421 |
422 // Check certificate properties in kUIDataProperty if configured. | 422 // Check certificate properties in kUIDataProperty if configured. |
423 // Note: Wifi/VPNConfigView set these properties explicitly, in which case | 423 // Note: Wifi/VPNConfigView set these properties explicitly, in which case |
424 // only the TPM must be configured. | 424 // only the TPM must be configured. |
425 scoped_ptr<NetworkUIData> ui_data = | 425 scoped_ptr<NetworkUIData> ui_data = |
426 ManagedNetworkConfigurationHandler::GetUIData(service_properties); | 426 ManagedNetworkConfigurationHandler::GetUIData(service_properties); |
427 if (ui_data && ui_data->certificate_type() == CLIENT_CERT_TYPE_PATTERN) { | 427 if (ui_data && ui_data->certificate_type() == CLIENT_CERT_TYPE_PATTERN) { |
pneubeck (no reviews)
2013/09/04 08:40:00
In this branch we know that the policy configured
stevenjb
2013/09/04 17:58:13
Right...
| |
428 // User must be logged in to connect to a network requiring a certificate. | 428 // User must be logged in to connect to a network requiring a certificate. |
429 if (!logged_in_ || !cert_loader_) { | 429 if (!logged_in_ || !cert_loader_) { |
430 ErrorCallbackForPendingRequest(service_path, kErrorCertificateRequired); | 430 ErrorCallbackForPendingRequest(service_path, kErrorCertificateRequired); |
431 return; | 431 return; |
432 } | 432 } |
433 | 433 |
434 // If certificates have not been loaded yet, queue the connect request. | 434 // If certificates have not been loaded yet, queue the connect request. |
435 if (!certificates_loaded_) { | 435 if (!certificates_loaded_) { |
436 ConnectRequest* request = GetPendingRequest(service_path); | 436 ConnectRequest* request = GetPendingRequest(service_path); |
437 if (!request) { | 437 if (!request) { |
438 NET_LOG_ERROR("No pending request to queue", service_path); | 438 NET_LOG_ERROR("No pending request to queue", service_path); |
439 return; | 439 return; |
440 } | 440 } |
441 NET_LOG_EVENT("Connect Request Queued", service_path); | 441 NET_LOG_EVENT("Connect Request Queued", service_path); |
442 queued_connect_.reset(new ConnectRequest( | 442 queued_connect_.reset(new ConnectRequest( |
443 service_path, request->success_callback, request->error_callback)); | 443 service_path, request->success_callback, request->error_callback)); |
444 pending_requests_.erase(service_path); | 444 pending_requests_.erase(service_path); |
445 return; | 445 return; |
446 } | 446 } |
447 | 447 |
448 pkcs11_id = CertificateIsConfigured(ui_data.get()); | 448 pkcs11_id = CertificateIsConfigured(ui_data.get()); |
449 // Ensure the certificate is available and configured. | 449 // Ensure the certificate is available and configured. |
450 if (!cert_loader_->IsHardwareBacked() || pkcs11_id.empty()) { | 450 if (!cert_loader_->IsHardwareBacked() || pkcs11_id.empty()) { |
451 ErrorCallbackForPendingRequest(service_path, kErrorCertificateRequired); | 451 ErrorCallbackForPendingRequest(service_path, kErrorCertificateRequired); |
452 return; | 452 return; |
453 } | 453 } |
454 } else { | |
pneubeck (no reviews)
2013/08/31 05:31:30
NIT: 'else if' and comment inside the clause.
stevenjb
2013/09/03 22:33:05
Done.
pneubeck (no reviews)
2013/09/04 08:40:00
See my new comments above. I think, in this branch
stevenjb
2013/09/04 17:58:13
So it sounds like for OpenVPN we never really know
| |
455 // Certificate is not configured in ui_data, check properties. | |
456 if (!client_cert::IsCertificateConfigured( | |
457 client_cert_type, service_properties)) { | |
458 ErrorCallbackForPendingRequest(service_path, kErrorCertificateRequired); | |
459 return; | |
460 } | |
454 } | 461 } |
455 | 462 |
456 // The network may not be 'Connectable' because the TPM properties are not | 463 // The network may not be 'Connectable' because the TPM properties are not |
457 // set up, so configure tpm slot/pin before connecting. | 464 // set up, so configure tpm slot/pin before connecting. |
458 if (cert_loader_ && cert_loader_->IsHardwareBacked()) { | 465 if (cert_loader_ && cert_loader_->IsHardwareBacked()) { |
459 // Pass NULL if pkcs11_id is empty, so that it doesn't clear any | 466 // Pass NULL if pkcs11_id is empty, so that it doesn't clear any |
460 // previously configured client cert. | 467 // previously configured client cert. |
461 client_cert::SetShillProperties(client_cert_type, | 468 client_cert::SetShillProperties(client_cert_type, |
462 cert_loader_->tpm_token_slot(), | 469 cert_loader_->tpm_token_slot(), |
463 cert_loader_->tpm_user_pin(), | 470 cert_loader_->tpm_user_pin(), |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
675 | 682 |
676 void NetworkConnectionHandler::HandleShillDisconnectSuccess( | 683 void NetworkConnectionHandler::HandleShillDisconnectSuccess( |
677 const std::string& service_path, | 684 const std::string& service_path, |
678 const base::Closure& success_callback) { | 685 const base::Closure& success_callback) { |
679 NET_LOG_EVENT("Disconnect Request Sent", service_path); | 686 NET_LOG_EVENT("Disconnect Request Sent", service_path); |
680 if (!success_callback.is_null()) | 687 if (!success_callback.is_null()) |
681 success_callback.Run(); | 688 success_callback.Run(); |
682 } | 689 } |
683 | 690 |
684 } // namespace chromeos | 691 } // namespace chromeos |
OLD | NEW |