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

Side by Side Diff: chrome/browser/chromeos/network_settings/onc_utils.cc

Issue 11415148: Adding error handling to ONC validation. (Closed) Base URL: http://git.chromium.org/chromium/src.git@extract_onc_certificate
Patch Set: Initial patch. Created 8 years 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 unified diff | Download patch
OLDNEW
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/chromeos/network_settings/onc_utils.h" 5 #include "chrome/browser/chromeos/network_settings/onc_utils.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/chromeos/cros/onc_constants.h" 10 #include "chrome/browser/chromeos/cros/onc_constants.h"
11 #include "crypto/encryptor.h" 11 #include "crypto/encryptor.h"
12 #include "crypto/hmac.h" 12 #include "crypto/hmac.h"
13 #include "crypto/symmetric_key.h" 13 #include "crypto/symmetric_key.h"
14 #include "grit/generated_resources.h" 14 #include "grit/generated_resources.h"
15 #include "ui/base/l10n/l10n_util.h" 15 #include "ui/base/l10n/l10n_util.h"
16 16
17 namespace chromeos { 17 namespace chromeos {
18 namespace onc { 18 namespace onc {
19 19
20 const char kEmptyUnencryptedConfiguration[] =
21 "{\"Type\":\"UnencryptedConfiguration\",\"NetworkConfigurations\":[],"
22 "\"Certificates\":[]}";
23
20 scoped_ptr<base::DictionaryValue> ReadDictionaryFromJson( 24 scoped_ptr<base::DictionaryValue> ReadDictionaryFromJson(
21 const std::string& json, 25 const std::string& json,
22 std::string* error) { 26 std::string* error) {
23 base::Value* root = base::JSONReader::ReadAndReturnError( 27 base::Value* root = base::JSONReader::ReadAndReturnError(
24 json, base::JSON_ALLOW_TRAILING_COMMAS, NULL, error); 28 json, base::JSON_ALLOW_TRAILING_COMMAS, NULL, error);
25 29
26 base::DictionaryValue* dict_ptr = NULL; 30 base::DictionaryValue* dict_ptr = NULL;
27 if (root != NULL && !root->GetAsDictionary(&dict_ptr)) { 31 if (root != NULL && !root->GetAsDictionary(&dict_ptr)) {
28 if (error) { 32 if (error) {
29 *error = l10n_util::GetStringUTF8( 33 *error = l10n_util::GetStringUTF8(
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 ReadDictionaryFromJson(plaintext, error); 147 ReadDictionaryFromJson(plaintext, error);
144 if (new_root.get() != NULL && error->empty()) { 148 if (new_root.get() != NULL && error->empty()) {
145 *error = l10n_util::GetStringUTF8( 149 *error = l10n_util::GetStringUTF8(
146 IDS_NETWORK_CONFIG_ERROR_NETWORK_PROP_DICT_MALFORMED); 150 IDS_NETWORK_CONFIG_ERROR_NETWORK_PROP_DICT_MALFORMED);
147 } 151 }
148 return new_root.Pass(); 152 return new_root.Pass();
149 } 153 }
150 154
151 } // chromeos 155 } // chromeos
152 } // onc 156 } // onc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698