Chromium Code Reviews| Index: chromeos/network/network_connection_handler.cc |
| diff --git a/chromeos/network/network_connection_handler.cc b/chromeos/network/network_connection_handler.cc |
| index f27ff4f8a1a25e74cc6bb8cbc03744a3d91d7d5f..1b7fc33973e0b4103025d974fdf1f2f50616b948 100644 |
| --- a/chromeos/network/network_connection_handler.cc |
| +++ b/chromeos/network/network_connection_handler.cc |
| @@ -55,6 +55,13 @@ void CopyStringFromDictionary(const base::DictionaryValue& source, |
| dest->SetStringWithoutPathExpansion(key, string_value); |
| } |
| +std::string GetStringFromDictionary(const base::DictionaryValue& dict, |
| + const std::string& key) { |
| + std::string s; |
| + dict.GetStringWithoutPathExpansion(key, &s); |
| + return s; |
| +} |
| + |
| bool NetworkRequiresActivation(const NetworkState* network) { |
| return (network->type() == flimflam::kTypeCellular && |
| ((network->activation_state() != flimflam::kActivationStateActivated && |
| @@ -65,16 +72,14 @@ bool VPNIsConfigured(const std::string& service_path, |
| const std::string& provider_type, |
| const base::DictionaryValue& provider_properties) { |
| if (provider_type == flimflam::kProviderOpenVpn) { |
| - std::string hostname; |
| - provider_properties.GetStringWithoutPathExpansion( |
| - flimflam::kHostProperty, &hostname); |
| + std::string hostname = GetStringFromDictionary( |
| + provider_properties, flimflam::kHostProperty); |
| if (hostname.empty()) { |
| NET_LOG_EVENT("OpenVPN: No hostname", service_path); |
| return false; |
| } |
| - std::string username; |
| - provider_properties.GetStringWithoutPathExpansion( |
| - flimflam::kOpenVPNUserProperty, &username); |
| + std::string username = GetStringFromDictionary( |
| + provider_properties, flimflam::kOpenVPNUserProperty); |
| if (username.empty()) { |
| NET_LOG_EVENT("OpenVPN: No username", service_path); |
| return false; |
| @@ -373,11 +378,10 @@ void NetworkConnectionHandler::VerifyConfiguredAndConnect( |
| return; |
| } |
| - std::string type, security; |
| - service_properties.GetStringWithoutPathExpansion( |
| - flimflam::kTypeProperty, &type); |
| - service_properties.GetStringWithoutPathExpansion( |
| - flimflam::kSecurityProperty, &security); |
| + std::string type = GetStringFromDictionary( |
| + service_properties, flimflam::kTypeProperty); |
| + std::string security = GetStringFromDictionary( |
| + service_properties, flimflam::kSecurityProperty); |
| bool connectable = false; |
| service_properties.GetBooleanWithoutPathExpansion( |
| flimflam::kConnectableProperty, &connectable); |
| @@ -466,6 +470,40 @@ void NetworkConnectionHandler::VerifyConfiguredAndConnect( |
| ErrorCallbackForPendingRequest(service_path, kErrorCertificateRequired); |
| return; |
| } |
| + } else { |
| + // Certificate is not configured in ui_data, check properties. |
| + bool configured = true; |
| + if (client_cert_type == client_cert::CONFIG_TYPE_OPENVPN) { |
|
pneubeck (no reviews)
2013/08/30 11:04:08
How about putting this into a
client_cert::GetSh
stevenjb
2013/08/30 17:01:21
Yeah, I considered doing something like that origi
|
| + std::string cert_id = GetStringFromDictionary( |
| + service_properties, flimflam::kOpenVPNClientCertIdProperty); |
|
pneubeck (no reviews)
2013/08/30 11:04:08
service_properties -> provider_properties
in case
stevenjb
2013/08/30 17:01:21
Bah, you're right, I keep reversing setting vs get
|
| + std::string username = GetStringFromDictionary( |
| + service_properties, flimflam::kOpenVPNUserProperty); |
| + if (cert_id.empty() || username.empty()) |
| + configured = false; |
| + } else if (client_cert_type == client_cert::CONFIG_TYPE_IPSEC) { |
| + std::string cert_id = GetStringFromDictionary( |
| + service_properties, flimflam::kL2tpIpsecClientCertIdProperty); |
| + std::string username = GetStringFromDictionary( |
| + service_properties, flimflam::kL2tpIpsecUserProperty); |
| + if (cert_id.empty() || username.empty()) |
| + configured = false; |
| + } else if (client_cert_type == client_cert::CONFIG_TYPE_EAP) { |
| + std::string cert_id = GetStringFromDictionary( |
| + service_properties, flimflam::kEapCertIdProperty); |
| + std::string key_id = GetStringFromDictionary( |
| + service_properties, flimflam::kEapKeyIdProperty); |
| + std::string identity = GetStringFromDictionary( |
| + service_properties, flimflam::kEapIdentityProperty); |
| + if (cert_id.empty() || key_id.empty() || identity.empty()) |
| + configured = false; |
| + } else { |
| + NOTREACHED(); |
| + } |
| + if (!configured) { |
| + ErrorCallbackForPendingRequest(service_path, |
| + kErrorConfigurationRequired); |
| + return; |
| + } |
| } |
| // The network may not be 'Connectable' because the TPM properties are not |