Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/chromeos/network_settings/onc_validator.h" | |
| 6 | |
| 7 #include <string> | |
|
Mattias Nissler (ping if slow)
2012/09/18 16:29:08
newline
pneubeck (no reviews)
2012/10/02 15:03:02
Done.
| |
| 8 #include "base/values.h" | |
| 9 #include "chrome/browser/chromeos/cros/onc_constants.h" | |
| 10 | |
| 11 namespace { | |
| 12 | |
| 13 void RemoveEntryUnless(base::DictionaryValue* dict, const std::string path, | |
|
Mattias Nissler (ping if slow)
2012/09/18 16:29:08
all parameters on separate lines unless they reall
pneubeck (no reviews)
2012/10/02 15:03:02
Done.
| |
| 14 bool condition) { | |
| 15 if (!condition) | |
| 16 dict->RemoveWithoutPathExpansion(path, NULL); | |
| 17 } | |
| 18 | |
| 19 } // namespace | |
| 20 | |
| 21 namespace chromeos { | |
| 22 namespace onc { | |
| 23 | |
| 24 // static | |
| 25 void ONCValidator::RemoveIgnoredFieldsFromIPsec(base::DictionaryValue* ipsec) { | |
|
Mattias Nissler (ping if slow)
2012/09/18 16:29:08
If we do this, shouldn't we also remove keys that
| |
| 26 using namespace vpn; | |
| 27 | |
| 28 std::string auth_type = ""; | |
| 29 ipsec->GetStringWithoutPathExpansion(kAuthenticationType, &auth_type); | |
| 30 RemoveEntryUnless(ipsec, kClientCertType, auth_type == "Cert"); | |
| 31 RemoveEntryUnless(ipsec, kServerCARef, auth_type == "Cert"); | |
| 32 RemoveEntryUnless(ipsec, kPSK, auth_type == "PSK"); | |
| 33 RemoveEntryUnless(ipsec, kSaveCredentials, auth_type == "PSK"); | |
| 34 | |
| 35 std::string clientcert_type = ""; | |
| 36 ipsec->GetStringWithoutPathExpansion(kClientCertType, &clientcert_type); | |
| 37 RemoveEntryUnless(ipsec, kClientCertPattern, clientcert_type == "Pattern"); | |
| 38 RemoveEntryUnless(ipsec, kClientCertRef, clientcert_type == "Ref"); | |
| 39 | |
| 40 int ike_version = -1; | |
| 41 ipsec->GetIntegerWithoutPathExpansion(kIKEVersion, &ike_version); | |
| 42 RemoveEntryUnless(ipsec, kEAP, ike_version == 2); | |
| 43 RemoveEntryUnless(ipsec, kGroup, ike_version == 1); | |
| 44 RemoveEntryUnless(ipsec, kXAUTH, ike_version == 1); | |
| 45 } | |
| 46 | |
| 47 // static | |
| 48 void ONCValidator::RemoveIgnoredFieldsFromVPN(base::DictionaryValue* vpn) { | |
| 49 using namespace vpn; | |
| 50 std::string type = ""; | |
| 51 vpn->GetStringWithoutPathExpansion(vpn::kType, &type); | |
| 52 RemoveEntryUnless(vpn, kOpenVPN, type == kOpenVPN); | |
| 53 RemoveEntryUnless(vpn, kIPsec, type == kIPsec || | |
| 54 type == "L2TP-IPsec"); | |
| 55 RemoveEntryUnless(vpn, kL2TP, type == "L2TP-IPSec"); | |
| 56 | |
| 57 base::DictionaryValue* ipsec; | |
| 58 if (vpn->GetDictionaryWithoutPathExpansion(kIPsec, &ipsec)) | |
| 59 RemoveIgnoredFieldsFromIPsec(ipsec); | |
| 60 } | |
| 61 | |
| 62 // static | |
| 63 void ONCValidator::RemoveIgnoredFieldsFromNetwork( | |
| 64 base::DictionaryValue* network) { | |
| 65 std::string type = ""; | |
| 66 network->GetStringWithoutPathExpansion(kType, &type); | |
| 67 RemoveEntryUnless(network, kEthernet, type == kEthernet); | |
| 68 RemoveEntryUnless(network, kVPN, type == kVPN); | |
| 69 RemoveEntryUnless(network, kWiFi, type == kWiFi); | |
| 70 | |
| 71 base::DictionaryValue* vpn; | |
| 72 if (network->GetDictionaryWithoutPathExpansion(kVPN, &vpn)) | |
| 73 RemoveIgnoredFieldsFromVPN(vpn); | |
| 74 } | |
| 75 | |
| 76 } // namespace onc | |
| 77 } // namespace chromeos | |
| OLD | NEW |