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

Side by Side Diff: chrome/browser/chromeos/login/supervised/supervised_user_authentication.cc

Issue 925783002: Split ValueSerializer into separate Serializer and Deserializer classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed cpplint warnings. Created 5 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/login/supervised/supervised_user_authenticatio n.h" 5 #include "chrome/browser/chromeos/login/supervised/supervised_user_authenticatio n.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/json/json_file_value_serializer.h" 8 #include "base/json/json_file_value_serializer.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 std::string BuildRawHMACKey() { 48 std::string BuildRawHMACKey() {
49 scoped_ptr<crypto::SymmetricKey> key(crypto::SymmetricKey::GenerateRandomKey( 49 scoped_ptr<crypto::SymmetricKey> key(crypto::SymmetricKey::GenerateRandomKey(
50 crypto::SymmetricKey::AES, kHMACKeySizeInBits)); 50 crypto::SymmetricKey::AES, kHMACKeySizeInBits));
51 std::string raw_result, result; 51 std::string raw_result, result;
52 key->GetRawKey(&raw_result); 52 key->GetRawKey(&raw_result);
53 base::Base64Encode(raw_result, &result); 53 base::Base64Encode(raw_result, &result);
54 return result; 54 return result;
55 } 55 }
56 56
57 base::DictionaryValue* LoadPasswordData(base::FilePath profile_dir) { 57 base::DictionaryValue* LoadPasswordData(base::FilePath profile_dir) {
58 JSONFileValueSerializer serializer(profile_dir.Append(kPasswordUpdateFile)); 58 JSONFileValueDeserializer deserializer(
59 profile_dir.Append(kPasswordUpdateFile));
59 std::string error_message; 60 std::string error_message;
60 int error_code = JSONFileValueSerializer::JSON_NO_ERROR; 61 int error_code = JSONFileValueDeserializer::JSON_NO_ERROR;
61 scoped_ptr<base::Value> value( 62 scoped_ptr<base::Value> value(
62 serializer.Deserialize(&error_code, &error_message)); 63 deserializer.Deserialize(&error_code, &error_message));
63 if (JSONFileValueSerializer::JSON_NO_ERROR != error_code) { 64 if (JSONFileValueDeserializer::JSON_NO_ERROR != error_code) {
64 LOG(ERROR) << "Could not deserialize password data, error = " << error_code 65 LOG(ERROR) << "Could not deserialize password data, error = " << error_code
65 << " / " << error_message; 66 << " / " << error_message;
66 return NULL; 67 return NULL;
67 } 68 }
68 base::DictionaryValue* result; 69 base::DictionaryValue* result;
69 if (!value->GetAsDictionary(&result)) { 70 if (!value->GetAsDictionary(&result)) {
70 LOG(ERROR) << "Stored password data is not a dictionary"; 71 LOG(ERROR) << "Stored password data is not a dictionary";
71 return NULL; 72 return NULL;
72 } 73 }
73 ignore_result(value.release()); 74 ignore_result(value.release());
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 LOG(FATAL) << "HMAC::Sign failed"; 315 LOG(FATAL) << "HMAC::Sign failed";
315 316
316 std::string raw_result(out_bytes, out_bytes + sizeof(out_bytes)); 317 std::string raw_result(out_bytes, out_bytes + sizeof(out_bytes));
317 318
318 std::string result; 319 std::string result;
319 base::Base64Encode(raw_result, &result); 320 base::Base64Encode(raw_result, &result);
320 return result; 321 return result;
321 } 322 }
322 323
323 } // namespace chromeos 324 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698