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

Unified Diff: chromeos/network/client_cert_util.cc

Issue 370623002: Remove most of NetworkUIData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed yet-another unused function. Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeos/network/client_cert_util.h ('k') | chromeos/network/network_connection_handler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/network/client_cert_util.cc
diff --git a/chromeos/network/client_cert_util.cc b/chromeos/network/client_cert_util.cc
index 536d5787b43430bd24d5f174f2b2b9ae9cfd4cc3..57eb4fda1de14cf3679185df5fd83f1fd98150bb 100644
--- a/chromeos/network/client_cert_util.cc
+++ b/chromeos/network/client_cert_util.cc
@@ -14,6 +14,7 @@
#include "base/values.h"
#include "chromeos/network/certificate_pattern.h"
#include "chromeos/network/network_event_log.h"
+#include "components/onc/onc_constants.h"
#include "net/base/net_errors.h"
#include "net/cert/cert_database.h"
#include "net/cert/nss_cert_database.h"
@@ -101,6 +102,24 @@ std::string GetStringFromDictionary(const base::DictionaryValue& dict,
return s;
}
+void GetClientCertTypeAndPattern(
+ const base::DictionaryValue& dict_with_client_cert,
+ ClientCertConfig* cert_config) {
+ using namespace ::onc::client_cert;
+ dict_with_client_cert.GetStringWithoutPathExpansion(
+ kClientCertType, &cert_config->client_cert_type);
+
+ if (cert_config->client_cert_type == kPattern) {
+ const base::DictionaryValue* pattern = NULL;
+ dict_with_client_cert.GetDictionaryWithoutPathExpansion(kClientCertPattern,
+ &pattern);
+ if (pattern) {
+ bool success = cert_config->pattern.ReadFromONCDictionary(*pattern);
+ DCHECK(success);
+ }
+ }
+}
+
} // namespace
// Returns true only if any fields set in this pattern match exactly with
@@ -199,7 +218,7 @@ scoped_refptr<net::X509Certificate> GetCertificateMatch(
return latest;
}
-void SetShillProperties(const client_cert::ConfigType cert_config_type,
+void SetShillProperties(const ConfigType cert_config_type,
const std::string& tpm_slot,
const std::string& tpm_pin,
const std::string* pkcs11_id,
@@ -258,7 +277,67 @@ void SetShillProperties(const client_cert::ConfigType cert_config_type,
properties->SetStringWithoutPathExpansion(tpm_pin_property, tpm_pin);
}
-bool IsCertificateConfigured(const client_cert::ConfigType cert_config_type,
+ClientCertConfig::ClientCertConfig()
+ : location(CONFIG_TYPE_NONE),
+ client_cert_type(onc::client_cert::kClientCertTypeNone) {
+}
+
+void OncToClientCertConfig(const base::DictionaryValue& network_config,
+ ClientCertConfig* cert_config) {
+ using namespace ::onc;
+
+ *cert_config = ClientCertConfig();
+
+ const base::DictionaryValue* dict_with_client_cert = NULL;
+
+ const base::DictionaryValue* wifi = NULL;
+ network_config.GetDictionaryWithoutPathExpansion(network_config::kWiFi,
+ &wifi);
+ if (wifi) {
+ const base::DictionaryValue* eap = NULL;
+ wifi->GetDictionaryWithoutPathExpansion(wifi::kEAP, &eap);
+ if (!eap)
+ return;
+
+ dict_with_client_cert = eap;
+ cert_config->location = CONFIG_TYPE_EAP;
+ }
+
+ const base::DictionaryValue* vpn = NULL;
+ network_config.GetDictionaryWithoutPathExpansion(network_config::kVPN, &vpn);
+ if (vpn) {
+ const base::DictionaryValue* openvpn = NULL;
+ vpn->GetDictionaryWithoutPathExpansion(vpn::kOpenVPN, &openvpn);
+ const base::DictionaryValue* ipsec = NULL;
+ vpn->GetDictionaryWithoutPathExpansion(vpn::kIPsec, &ipsec);
+ if (openvpn) {
+ dict_with_client_cert = openvpn;
+ cert_config->location = CONFIG_TYPE_OPENVPN;
+ } else if (ipsec) {
+ dict_with_client_cert = ipsec;
+ cert_config->location = CONFIG_TYPE_IPSEC;
+ } else {
+ return;
+ }
+ }
+
+ const base::DictionaryValue* ethernet = NULL;
+ network_config.GetDictionaryWithoutPathExpansion(network_config::kEthernet,
+ &ethernet);
+ if (ethernet) {
+ const base::DictionaryValue* eap = NULL;
+ ethernet->GetDictionaryWithoutPathExpansion(wifi::kEAP, &eap);
+ if (!eap)
+ return;
+ dict_with_client_cert = eap;
+ cert_config->location = CONFIG_TYPE_EAP;
+ }
+
+ if (dict_with_client_cert)
+ GetClientCertTypeAndPattern(*dict_with_client_cert, cert_config);
+}
+
+bool IsCertificateConfigured(const ConfigType cert_config_type,
const base::DictionaryValue& service_properties) {
// VPN certificate properties are read from the Provider dictionary.
const base::DictionaryValue* provider_properties = NULL;
« no previous file with comments | « chromeos/network/client_cert_util.h ('k') | chromeos/network/network_connection_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698