OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/policy/configuration_policy_handler_chromeos.h" | 5 #include "chrome/browser/policy/configuration_policy_handler_chromeos.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 network_entry != config_list->end(); | 86 network_entry != config_list->end(); |
87 ++network_entry) { | 87 ++network_entry) { |
88 if ((*network_entry) && | 88 if ((*network_entry) && |
89 (*network_entry)->IsType(base::Value::TYPE_DICTIONARY)) { | 89 (*network_entry)->IsType(base::Value::TYPE_DICTIONARY)) { |
90 StripSensitiveValues(static_cast<DictionaryValue*>(*network_entry)); | 90 StripSensitiveValues(static_cast<DictionaryValue*>(*network_entry)); |
91 } | 91 } |
92 } | 92 } |
93 } | 93 } |
94 | 94 |
95 // Convert back to a string, pretty printing the contents. | 95 // Convert back to a string, pretty printing the contents. |
96 base::JSONWriter::WriteWithOptionalEscape(config_dict, true, false, | 96 base::JSONWriter::WriteWithOptions(config_dict, true, |
97 &json_string); | 97 base::JSONWriter::OPTIONS_DO_NOT_ESCAPE, |
| 98 &json_string); |
98 return Value::CreateStringValue(json_string); | 99 return Value::CreateStringValue(json_string); |
99 } | 100 } |
100 | 101 |
101 // static | 102 // static |
102 void NetworkConfigurationPolicyHandler::StripSensitiveValues( | 103 void NetworkConfigurationPolicyHandler::StripSensitiveValues( |
103 DictionaryValue* network_dict) { | 104 DictionaryValue* network_dict) { |
104 // List of settings we filter from the network dictionary. | 105 // List of settings we filter from the network dictionary. |
105 static const char* kFilteredSettings[] = { | 106 static const char* kFilteredSettings[] = { |
106 "WiFi.Passphrase", | 107 "WiFi.Passphrase", |
107 "IPsec.EAP.Password", | 108 "IPsec.EAP.Password", |
108 "IPsec.EAP.Password", | 109 "IPsec.EAP.Password", |
109 "IPsec.XAUTH.Password", | 110 "IPsec.XAUTH.Password", |
110 "L2TP.Password", | 111 "L2TP.Password", |
111 }; | 112 }; |
112 // Placeholder to insert in place of the filtered setting. | 113 // Placeholder to insert in place of the filtered setting. |
113 static const char kPlaceholder[] = "********"; | 114 static const char kPlaceholder[] = "********"; |
114 | 115 |
115 for (size_t i = 0; i < arraysize(kFilteredSettings); ++i) { | 116 for (size_t i = 0; i < arraysize(kFilteredSettings); ++i) { |
116 if (network_dict->Remove(kFilteredSettings[i], NULL)) { | 117 if (network_dict->Remove(kFilteredSettings[i], NULL)) { |
117 network_dict->Set(kFilteredSettings[i], | 118 network_dict->Set(kFilteredSettings[i], |
118 Value::CreateStringValue(kPlaceholder)); | 119 Value::CreateStringValue(kPlaceholder)); |
119 } | 120 } |
120 } | 121 } |
121 } | 122 } |
122 | 123 |
123 } // namespace policy | 124 } // namespace policy |
OLD | NEW |