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

Side by Side Diff: remoting/host/host_key_pair.cc

Issue 10007048: Cleanup and simplify HostConfig and JsonHostConfig. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « remoting/host/host_key_pair.h ('k') | remoting/host/host_key_pair_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "remoting/host/host_key_pair.h" 5 #include "remoting/host/host_key_pair.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 26 matching lines...) Expand all
37 std::vector<uint8> key_buf(key_str.begin(), key_str.end()); 37 std::vector<uint8> key_buf(key_str.begin(), key_str.end());
38 key_.reset(crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(key_buf)); 38 key_.reset(crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(key_buf));
39 if (key_.get() == NULL) { 39 if (key_.get() == NULL) {
40 LOG(ERROR) << "Invalid private key."; 40 LOG(ERROR) << "Invalid private key.";
41 return false; 41 return false;
42 } 42 }
43 43
44 return true; 44 return true;
45 } 45 }
46 46
47 bool HostKeyPair::Load(HostConfig* host_config) { 47 bool HostKeyPair::Load(const HostConfig& host_config) {
48 std::string key_base64; 48 std::string key_base64;
49 if (!host_config->GetString(kPrivateKeyConfigPath, &key_base64)) { 49 if (!host_config.GetString(kPrivateKeyConfigPath, &key_base64)) {
50 LOG(ERROR) << "Private key wasn't found in the config file."; 50 LOG(ERROR) << "Private key wasn't found in the config file.";
51 return false; 51 return false;
52 } 52 }
53 return LoadFromString(key_base64); 53 return LoadFromString(key_base64);
54 } 54 }
55 55
56 void HostKeyPair::Save(MutableHostConfig* host_config) { 56 void HostKeyPair::Save(MutableHostConfig* host_config) {
57 host_config->SetString(kPrivateKeyConfigPath, GetAsString()); 57 host_config->SetString(kPrivateKeyConfigPath, GetAsString());
58 } 58 }
59 59
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 base::RandInt(1, std::numeric_limits<int>::max()), 106 base::RandInt(1, std::numeric_limits<int>::max()),
107 base::TimeDelta::FromDays(1)); 107 base::TimeDelta::FromDays(1));
108 std::string encoded; 108 std::string encoded;
109 bool result = net::X509Certificate::GetDEREncoded(cert->os_cert_handle(), 109 bool result = net::X509Certificate::GetDEREncoded(cert->os_cert_handle(),
110 &encoded); 110 &encoded);
111 CHECK(result); 111 CHECK(result);
112 return encoded; 112 return encoded;
113 } 113 }
114 114
115 } // namespace remoting 115 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/host_key_pair.h ('k') | remoting/host/host_key_pair_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698