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